当前位置: 首页>>代码示例>>Python>>正文


Python network_helper.NetworkHelper类代码示例

本文整理汇总了Python中f5_openstack_agent.lbaasv2.drivers.bigip.network_helper.NetworkHelper的典型用法代码示例。如果您正苦于以下问题:Python NetworkHelper类的具体用法?Python NetworkHelper怎么用?Python NetworkHelper使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了NetworkHelper类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_network_helper_delete_fdb_entries

    def test_network_helper_delete_fdb_entries(
            self, l2_service, service, bigips):
        # delete member fdb entry
        loadbalancer = None
        members = list()
        member = service['members'][1]
        network_id = member['network_id']
        member['network'] = service['networks'][network_id]
        members.append(member)

        tunnel_records = l2_service.create_fdb_records(loadbalancer, members)

        network_helper = NetworkHelper()
        tunnel = mock.MagicMock()
        tunnel.exists = mock.MagicMock(return_value=True)

        tunnel_record = mock.MagicMock()
        tunnel.records_s.records.load = mock.MagicMock(
            return_value=tunnel_record)
        tunnel.records_s.records.exist = mock.MagicMock(return_value=True)

        bigip = bigips[0]
        bigip.tm.net.fdb.tunnels.tunnel.load = mock.MagicMock(
            return_value=tunnel)
        network_helper.delete_fdb_entries(bigip, fdb_entries=tunnel_records)

        # expect to delete
        tunnel_record.delete.assert_called()
开发者ID:jputrino,项目名称:f5-openstack-agent,代码行数:28,代码来源:test_l2_service.py

示例2: __init__

 def __init__(self, conf, driver):  # XXX maybe we need a better name: conf
     """Create a BigipTenantManager."""
     self.conf = conf
     self.driver = driver
     self.system_helper = SystemHelper()
     self.network_helper = NetworkHelper()
     self.service_adapter = self.driver.service_adapter
开发者ID:F5Networks,项目名称:f5-openstack-agent,代码行数:7,代码来源:tenants.py

示例3: __init__

    def __init__(self, conf, f5_global_routed_mode):
        self.conf = conf
        self.f5_global_routed_mode = f5_global_routed_mode
        self.vlan_binding = None
        self.fdb_connector = None
        self.vcmp_manager = None
        self.interface_mapping = {}
        self.tagging_mapping = {}
        self.system_helper = SystemHelper()
        self.network_helper = NetworkHelper()
        self.service_adapter = ServiceModelAdapter(conf)

        if not f5_global_routed_mode:
            self.fdb_connector = FDBConnectorML2(conf)

        if self.conf.vlan_binding_driver:
            try:
                self.vlan_binding = importutils.import_object(
                    self.conf.vlan_binding_driver, self.conf, self)
            except ImportError:
                LOG.error('Failed to import VLAN binding driver: %s'
                          % self.conf.vlan_binding_driver)

        # map format is   phynet:interface:tagged
        for maps in self.conf.f5_external_physical_mappings:
            intmap = maps.split(':')
            net_key = str(intmap[0]).strip()
            if len(intmap) > 3:
                net_key = net_key + ':' + str(intmap[3]).strip()
            self.interface_mapping[net_key] = str(intmap[1]).strip()
            self.tagging_mapping[net_key] = str(intmap[2]).strip()
            LOG.debug('physical_network %s = interface %s, tagged %s'
                      % (net_key, intmap[1], intmap[2]))
开发者ID:jlongstaf,项目名称:f5-openstack-agent,代码行数:33,代码来源:l2_service.py

示例4: DisconnectedService

class DisconnectedService(object):
    network_name = "disconnected_network"

    def __init__(self):
        self.network_name = DisconnectedService.network_name
        self.network_helper = NetworkHelper()

    # The following method presumes that the plugin driver is aware that we're
    # running in hierarchical mode or not and sets segmentation_id correctly.
    def is_service_connected(self, service):
        networks = service["networks"]
        network_id = service["loadbalancer"]["network_id"]
        network = networks.get(network_id, {})

        if network.get("provider:network_type", "") == "flat":
            return True

        segmentation_id = network.get("provider:segmentation_id", 0)

        return segmentation_id

    def is_virtual_connected(self, virtual, bigips):
        # check if virtual_server is connected on any of our bigips
        connected = True
        for bigip in bigips:
            vsf = bigip.tm.ltm.virtuals.virtual
            if vsf.exists(name=virtual["name"], partition=virtual["partition"]):
                vs = vsf.load(name=virtual["name"], partition=virtual["partition"])
                if getattr(vs, "vlansDisabled", False) or not getattr(vs, "vlansEnabled", True):
                    # accommodate quirk of how big-ip returns virtual server
                    # if vlans are disabled OR vlans are not enabled, then
                    # we're connected
                    continue
                network_path = "/%s/%s" % (virtual["partition"], self.network_name)
                if network_path in getattr(vs, "vlans", []):
                    connected = False
                    break
        return connected

    def network_exists(self, bigip, partition):
        t = bigip.tm.net.tunnels.tunnels.tunnel
        return t.exists(name=self.network_name, partition=partition)

    @log_helpers.log_method_call
    def create_network(self, bigip, partition):
        model = {
            "name": self.network_name,
            "partition": partition,
            "profile": "ppp",
            "description": "Tenant disconnected network",
        }
        t = self.network_helper.create_tunnel(bigip, model)
        return t

    @log_helpers.log_method_call
    def delete_network(self, bigip, partition):
        tf = bigip.tm.net.tunnels.tunnels.tunnel
        if tf.exists(name=self.network_name, partition=partition):
            tf.load(name=self.network_name, partition=partition).delete()
开发者ID:F5Networks,项目名称:f5-openstack-agent,代码行数:59,代码来源:disconnected_service.py

示例5: __init__

 def __init__(self, driver, l2_service, l3_binding):
     self.driver = driver
     self.l2_service = l2_service
     self.l3_binding = l3_binding
     self.snatpool_manager = BigIPResourceHelper(ResourceType.snatpool)
     self.snat_translation_manager = BigIPResourceHelper(
         ResourceType.snat_translation)
     self.network_helper = NetworkHelper()
开发者ID:jlongstaf,项目名称:f5-openstack-agent,代码行数:8,代码来源:snats.py

示例6: purge_folder_contents

    def purge_folder_contents(self, bigip, folder):
        network_helper = NetworkHelper()

        if folder not in self.exempt_folders:

            # First remove all LTM resources.
            ltm_types = [
                ResourceType.virtual,
                ResourceType.virtual_address,
                ResourceType.pool,
                ResourceType.http_monitor,
                ResourceType.https_monitor,
                ResourceType.tcp_monitor,
                ResourceType.ping_monitor,
                ResourceType.node,
                ResourceType.snat,
                ResourceType.snatpool,
                ResourceType.snat_translation,
                ResourceType.universal_persistence,
                ResourceType.rule,
                ResourceType.l7policy
            ]
            for ltm_type in ltm_types:
                resource = BigIPResourceHelper(ltm_type)
                [r.delete() for r in resource.get_resources(bigip, folder)]

            # Remove all net resources
            net_types = [
                ResourceType.arp,
                ResourceType.selfip,
                ResourceType.vlan,
                ResourceType.route_domain
            ]
            for net_type in net_types:
                resource = BigIPResourceHelper(net_type)
                [r.delete() for r in resource.get_resources(bigip, folder)]

            # Tunnels and fdb's require some special attention.
            resource = BigIPResourceHelper(ResourceType.tunnel)
            tunnels = resource.get_resources(bigip, folder)
            for tunnel in tunnels:
                network_helper.delete_all_fdb_entries(
                    bigip, tunnel.name, folder)
                network_helper.delete_tunnel(
                    bigip, tunnel.name, folder)
开发者ID:jputrino,项目名称:f5-openstack-agent,代码行数:45,代码来源:system_helper.py

示例7: DisconnectedService

class DisconnectedService(object):
    network_name = 'disconnected_network'

    def __init__(self):
        self.network_name = DisconnectedService.network_name
        self.network_helper = NetworkHelper()

    # The following method presumes that the plugin driver is aware that we're
    # running in hierarchical mode or not and sets segmentation_id correctly.
    def is_service_connected(self, service):
        networks = service['networks']
        network_id = service['loadbalancer']['network_id']
        segmentation_id = networks[network_id]['provider:segmentation_id']
        return (segmentation_id)

    def is_virtual_connected(self, virtual, bigips):
        # check if virtual_server is connected on any of our bigips
        connected = True
        for bigip in bigips:
            vsf = bigip.tm.ltm.virtuals.virtual
            if vsf.exists(name=virtual['name'],
                          partition=virtual['partition']):
                vs = vsf.load(
                    name=virtual['name'], partition=virtual['partition'])
                if (getattr(vs, 'vlansDisabled', False) or
                        not getattr(vs, 'vlansEnabled', True)):
                    # accommodate quirk of how big-ip returns virtual server
                    # if vlans are disabled OR vlans are not enabled, then
                    # we're connected
                    continue
                network_path = "/%s/%s" % (virtual['partition'],
                                           self.network_name)
                if network_path in getattr(vs, 'vlans', []):
                    connected = False
                    break
        return connected

    def network_exists(self, bigip, partition):
        t = bigip.tm.net.tunnels.tunnels.tunnel
        return t.exists(name=self.network_name, partition=partition)

    @log_helpers.log_method_call
    def create_network(self, bigip, partition):
        model = {'name': self.network_name,
                 'partition': partition,
                 'profile': 'ppp',
                 'description': 'Tenant disconnected network'}
        t = self.network_helper.create_tunnel(bigip, model)
        return t

    @log_helpers.log_method_call
    def delete_network(self, bigip, partition):
        tf = bigip.tm.net.tunnels.tunnels.tunnel
        if tf.exists(name=self.network_name, partition=partition):
            tf.load(name=self.network_name, partition=partition).delete()
开发者ID:richbrowne,项目名称:f5-openstack-agent,代码行数:55,代码来源:disconnected_service.py

示例8: test_network_helper_delete_fdb_entries

    def test_network_helper_delete_fdb_entries(
            self, l2_service, service, bigips):
        # delete member fdb entry
        loadbalancer = None
        members = list()
        member = service['members'][1]
        network_id = member['network_id']
        member['network'] = service['networks'][network_id]
        members.append(member)

        tunnel_records = l2_service.create_fdb_records(loadbalancer, members)

        network_helper = NetworkHelper()
        fdb_entry = mock.MagicMock()
        fdb_entry.modify = mock.MagicMock()
        bigip = bigips[0]
        bigip.tm.net.fdb.tunnels.tunnel.load = mock.MagicMock(
            return_value=fdb_entry)
        network_helper.delete_fdb_entries(bigip, fdb_entries=tunnel_records)

        # expect to modify with no records (i.e, removing entry)
        fdb_entry.modify.assert_called_with(records=None)
开发者ID:pjbreaux,项目名称:f5-openstack-agent,代码行数:22,代码来源:test_l2_service.py

示例9: test_network_helper_add_fdb_entries

    def test_network_helper_add_fdb_entries(self, l2_service, service, bigips):
        # add first member fdb entry
        loadbalancer = None
        members = list()
        member = service['members'][0]
        network_id = member['network_id']
        member['network'] = service['networks'][network_id]
        members.append(member)

        tunnel_records = l2_service.create_fdb_records(loadbalancer, members)

        network_helper = NetworkHelper()
        fdb_entry = mock.MagicMock()
        fdb_entry.modify = mock.MagicMock()
        bigip = bigips[0]
        bigip.tm.net.fdb.tunnels.tunnel.load = mock.MagicMock(
            return_value=fdb_entry)
        network_helper.add_fdb_entries(bigip, fdb_entries=tunnel_records)

        # expect to modify with first member's VTEP and MAC addr
        fdb_entry.modify.assert_called_with(
            records=[{'endpoint': '192.168.130.59',
                      'name': 'fa:16:3e:0d:fa:c8'}])

        # add second member fdb entry
        members = list()
        member = service['members'][1]
        network_id = member['network_id']
        member['network'] = service['networks'][network_id]
        members.append(member)

        tunnel_records = l2_service.create_fdb_records(loadbalancer, members)
        network_helper.add_fdb_entries(bigip, fdb_entries=tunnel_records)

        # expect to modify with second member's VTEP and MAC addr
        fdb_entry.modify.assert_called_with(
            records=[{'endpoint': '192.168.130.60',
                      'name': 'fa:16:3e:0d:fa:c6'}])
开发者ID:pjbreaux,项目名称:f5-openstack-agent,代码行数:38,代码来源:test_l2_service.py

示例10: test_add_remove_fdbs

def test_add_remove_fdbs(bigip, icontrol_driver):
    """ Test simulating L2 pop events to add/remove fdb entries."""

    net_helper = NetworkHelper()
    tunnels = list()
    fdb_entries = list()

    seg_id_start = 167
    seg_id_end = 176
    n_records = 9 

    # create tunnels on BIG-IP, and fake fdb entries
    for seg_id in range(seg_id_start, seg_id_end):
        tunnel_name = 'tunnel-vxlan-{}'.format(seg_id)
        model = {
            'name': tunnel_name,
            'key': seg_id,
            'profile': 'vxlan_ovs',
            'localAddress': '201.0.155.10'}
        net_helper.create_multipoint_tunnel(bigip.bigip, model)
        tunnels.append(tunnel_name)

        # create a set of fdb entries that reference network seg ID
        for _ in range(n_records):
            entry = create_fdb_entry(seg_id)
            fdb_entries.append(entry)

    # add fdb entries
    for fdb_entry in fdb_entries:
        # mimic neutron L2 pop add_fdb_entries
        icontrol_driver.fdb_add(fdb_entry)

    for fdb_entry in fdb_entries:
        # mimic neutron L2 pop add_fdb_entries
        icontrol_driver.fdb_add(fdb_entry)

    # check created
    for tunnel_name in tunnels:
        records = net_helper.get_fdb_entry(bigip.bigip, tunnel_name=tunnel_name)
        assert records

    # remove fdb entries
    for fdb_entry in fdb_entries:
        # mimic neutron L2 pop remove_fdb_entries
        icontrol_driver.fdb_remove(fdb_entry)

    # check removed
    for tunnel_name in tunnels:
        records = net_helper.get_fdb_entry(bigip.bigip, tunnel_name=tunnel_name)
        assert not records
        net_helper.delete_tunnel(bigip.bigip, tunnel_name)
开发者ID:jputrino,项目名称:f5-openstack-agent,代码行数:51,代码来源:test_l2_pop.py

示例11: __init__

    def __init__(self, f5_global_routed_mode, conf, driver, l3_binding=None):
        self.f5_global_routed_mode = f5_global_routed_mode
        self.conf = conf
        self.driver = driver
        self.l3_binding = l3_binding
        self.l2_service = L2ServiceBuilder(driver, f5_global_routed_mode)

        self.bigip_selfip_manager = BigipSelfIpManager(
            self.driver, self.l2_service, self.driver.l3_binding)
        self.bigip_snat_manager = BigipSnatManager(
            self.driver, self.l2_service, self.driver.l3_binding)

        self.rds_cache = {}
        self.interface_mapping = self.l2_service.interface_mapping
        self.network_helper = NetworkHelper()
        self.service_adapter = self.driver.service_adapter
开发者ID:richbrowne,项目名称:f5-openstack-agent,代码行数:16,代码来源:network_service.py

示例12: L2ServiceBuilder

class L2ServiceBuilder(object):

    def __init__(self, conf, f5_global_routed_mode):
        self.conf = conf
        self.f5_global_routed_mode = f5_global_routed_mode
        self.vlan_binding = None
        self.fdb_connector = None
        self.vcmp_manager = None
        self.interface_mapping = {}
        self.tagging_mapping = {}
        self.system_helper = SystemHelper()
        self.network_helper = NetworkHelper()
        self.service_adapter = ServiceModelAdapter(conf)

        if not f5_global_routed_mode:
            self.fdb_connector = FDBConnectorML2(conf)

        if self.conf.vlan_binding_driver:
            try:
                self.vlan_binding = importutils.import_object(
                    self.conf.vlan_binding_driver, self.conf, self)
            except ImportError:
                LOG.error('Failed to import VLAN binding driver: %s'
                          % self.conf.vlan_binding_driver)

        # map format is   phynet:interface:tagged
        for maps in self.conf.f5_external_physical_mappings:
            intmap = maps.split(':')
            net_key = str(intmap[0]).strip()
            if len(intmap) > 3:
                net_key = net_key + ':' + str(intmap[3]).strip()
            self.interface_mapping[net_key] = str(intmap[1]).strip()
            self.tagging_mapping[net_key] = str(intmap[2]).strip()
            LOG.debug('physical_network %s = interface %s, tagged %s'
                      % (net_key, intmap[1], intmap[2]))

    def post_init(self):
        if self.vlan_binding:
            LOG.debug(
                'Getting BIG-IP device interface for VLAN Binding')
            self.vlan_binding.register_bigip_interfaces()

    def tunnel_sync(self, tunnel_ips):
        if self.fdb_connector:
            self.fdb_connector.advertise_tunnel_ips(tunnel_ips)

    def set_tunnel_rpc(self, tunnel_rpc):
        # Provide FDB Connector with ML2 RPC access
        if self.fdb_connector:
            self.fdb_connector.set_tunnel_rpc(tunnel_rpc)

    def set_l2pop_rpc(self, l2pop_rpc):
        # Provide FDB Connector with ML2 RPC access
        if self.fdb_connector:
            self.fdb_connector.set_l2pop_rpc(l2pop_rpc)

    def set_context(self, context):
        if self.fdb_connector:
            self.fdb_connector.set_context(context)

    def is_common_network(self, network):
        # Does this network belong in the /Common folder?
        return network['shared'] or \
            (network['id'] in self.conf.common_network_ids) or \
            ('router:external' in network and
             network['router:external'] and
             self.conf.f5_common_external_networks)

    def get_vlan_name(self, network, hostname):
        # Construct a consistent vlan name
        net_key = network['provider:physical_network']
        # look for host specific interface mapping
        if net_key + ':' + hostname in self.interface_mapping:
            interface = self.interface_mapping[net_key + ':' + hostname]
            tagged = self.tagging_mapping[net_key + ':' + hostname]
        # look for specific interface mapping
        elif net_key in self.interface_mapping:
            interface = self.interface_mapping[net_key]
            tagged = self.tagging_mapping[net_key]
        # use default mapping
        else:
            interface = self.interface_mapping['default']
            tagged = self.tagging_mapping['default']

        if tagged:
            vlanid = network['provider:segmentation_id']
        else:
            vlanid = 0

        vlan_name = "vlan-" + \
                    str(interface).replace(".", "-") + \
                    "-" + str(vlanid)
        if len(vlan_name) > 15:
            vlan_name = 'vlan-tr-' + str(vlanid)
        return vlan_name

    def assure_bigip_network(self, bigip, network):
        # Ensure bigip has configured network object
        if not network:
            LOG.error('    assure_bigip_network: '
#.........这里部分代码省略.........
开发者ID:jlongstaf,项目名称:f5-openstack-agent,代码行数:101,代码来源:l2_service.py

示例13: BigipSnatManager

class BigipSnatManager(object):
    def __init__(self, driver, l2_service, l3_binding):
        self.driver = driver
        self.l2_service = l2_service
        self.l3_binding = l3_binding
        self.snatpool_manager = BigIPResourceHelper(ResourceType.snatpool)
        self.snat_translation_manager = BigIPResourceHelper(
            ResourceType.snat_translation)
        self.network_helper = NetworkHelper()

    def _get_snat_name(self, subnet, tenant_id):
        # Get the snat name based on HA type
        if self.driver.conf.f5_ha_type == 'standalone':
            return 'snat-traffic-group-local-only-' + subnet['id']
        elif self.driver.conf.f5_ha_type == 'pair':
            # REVISIT(RJB): should this name have a hyphen before subnetid
            return 'snat-traffic-group-1' + subnet['id']
        elif self.driver.conf.f5_ha_type == 'scalen':
            traffic_group = self.driver.tenant_to_traffic_group(tenant_id)
            base_traffic_group = os.path.basename(traffic_group)
            return 'snat-' + base_traffic_group + '-' + subnet['id']
        LOG.error('Invalid f5_ha_type:%s' % self.driver.conf.f5_ha_type)
        return ''

    def _get_snat_traffic_group(self, tenant_id):
        # Get the snat name based on HA type """
        if self.driver.conf.f5_ha_type == 'standalone':
            return 'traffic-group-local-only'
        elif self.driver.conf.f5_ha_type == 'pair':
            return 'traffic-group-1'
        elif self.driver.conf.f5_ha_type == 'scalen':
            traffic_group = self.driver.tenant_to_traffic_group(tenant_id)
            return os.path.basename(traffic_group)
        # If this is an error shouldn't we raise?
        LOG.error('Invalid f5_ha_type:%s' % self.driver.conf.f5_ha_type)
        return ''

    def get_snat_addrs(self, subnetinfo, tenant_id):
        # Get the ip addresses for snat """
        subnet = subnetinfo['subnet']
        snat_addrs = []

        snat_name = self._get_snat_name(subnet, tenant_id)
        for i in range(self.driver.conf.f5_snat_addresses_per_subnet):
            index_snat_name = snat_name + "_" + str(i)
            ports = self.driver.plugin_rpc.get_port_by_name(
                port_name=index_snat_name)
            if len(ports) > 0:
                first_port = ports[0]
                first_fixed_ip = first_port['fixed_ips'][0]
                ip_address = first_fixed_ip['ip_address']
            else:
                new_port = self.driver.plugin_rpc.create_port_on_subnet(
                    subnet_id=subnet['id'],
                    mac_address=None,
                    name=index_snat_name,
                    fixed_address_count=1)
                ip_address = new_port['fixed_ips'][0]['ip_address']
            snat_addrs.append(ip_address)
        return snat_addrs

    def assure_bigip_snats(self, bigip, subnetinfo, snat_addrs, tenant_id):
        # Ensure Snat Addresses are configured on a bigip.
        # Called for every bigip only in replication mode.
        # otherwise called once and synced.
        network = subnetinfo['network']

        snat_info = {}
        if self.l2_service.is_common_network(network):
            snat_info['network_folder'] = 'Common'
        else:
            snat_info['network_folder'] = (
                self.driver.service_adapter.get_folder_name(tenant_id)
            )

        snat_info['pool_name'] = self.driver.service_adapter.get_folder_name(
            tenant_id
        )
        snat_info['pool_folder'] = self.driver.service_adapter.get_folder_name(
            tenant_id
        )
        snat_info['addrs'] = snat_addrs

        self._assure_bigip_snats(bigip, subnetinfo, snat_info, tenant_id)

    def _assure_bigip_snats(self, bigip, subnetinfo, snat_info, tenant_id):
        # Configure the ip addresses for snat
        network = subnetinfo['network']
        subnet = subnetinfo['subnet']
        LOG.debug("_assure_bigip_snats")
        if tenant_id not in bigip.assured_tenant_snat_subnets:
            bigip.assured_tenant_snat_subnets[tenant_id] = []
        if subnet['id'] in bigip.assured_tenant_snat_subnets[tenant_id]:
            return

        snat_name = self._get_snat_name(subnet, tenant_id)
        for i in range(self.driver.conf.f5_snat_addresses_per_subnet):
            ip_address = snat_info['addrs'][i] + \
                '%' + str(network['route_domain_id'])
            index_snat_name = snat_name + "_" + str(i)
#.........这里部分代码省略.........
开发者ID:jlongstaf,项目名称:f5-openstack-agent,代码行数:101,代码来源:snats.py

示例14: BigipTenantManager

class BigipTenantManager(object):
    """Create network connectivity for a bigip."""

    def __init__(self, conf, driver):  # XXX maybe we need a better name: conf
        """Create a BigipTenantManager."""
        self.conf = conf
        self.driver = driver
        self.system_helper = SystemHelper()
        self.network_helper = NetworkHelper()
        self.service_adapter = self.driver.service_adapter

    def assure_tenant_created(self, service):
        """Create tenant partition.

        This method modifies its argument 'service' in place.
        This method adds a 'traffic_group" key to the service
        dict with a value of traffic_group_string_id.  But aren't
        traffic_groups a bigIP device concept?  And wasn't (until
        this method was called) the service object a configuration
        entirely defined by neutron?  Also for neutron->device
        adaptations shouldn't we be using ServiceModelAdapter...  though I
        suppose this is the other way.
        """
        tenant_id = service['loadbalancer']['tenant_id']
        traffic_group = self.driver.service_to_traffic_group(service)
        traffic_group = '/Common/' + traffic_group
        service["traffic_group"] = traffic_group  # modify the passed dict

        # create tenant folder
        folder_name = self.service_adapter.get_folder_name(tenant_id)
        LOG.debug("Creating tenant folder %s" % folder_name)
        for bigip in self.driver.get_config_bigips():
            if not self.system_helper.folder_exists(bigip, folder_name):
                folder = self.service_adapter.get_folder(service)
                # This folder is a dict config obj, that can be passed to
                # folder.create in the SDK
                try:
                    self.system_helper.create_folder(bigip, folder)
                except Exception as err:
                    # XXX Maybe we can make this more specific?
                    LOG.exception("Error creating folder %s" %
                                  (folder))
                    raise f5ex.SystemCreationException(
                        "Folder creation error for tenant %s" %
                        (tenant_id))

            if not self.driver.disconnected_service.network_exists(
                    bigip, folder_name):
                try:
                    self.driver.disconnected_service.create_network(
                        bigip, folder_name)
                except Exception as err:
                    LOG.exception("Error creating disconnected network %s." %
                                  (folder_name))
                    raise f5ex.SystemCreationException(
                        "Disconnected network create error for tenant %s" %
                        (tenant_id))

        # create tenant route domain
        if self.conf.use_namespaces:
            for bigip in self.driver.get_all_bigips():
                if not self.network_helper.route_domain_exists(bigip,
                                                               folder_name):
                    try:
                        self.network_helper.create_route_domain(
                            bigip,
                            folder_name,
                            self.conf.f5_route_domain_strictness)
                    except Exception as err:
                        LOG.exception(err.message)
                        raise f5ex.RouteDomainCreationException(
                            "Failed to create route domain for "
                            "tenant in %s" % (folder_name))

    def assure_tenant_cleanup(self, service, all_subnet_hints):
        """Delete tenant partition."""
        # Called for every bigip only in replication mode,
        # otherwise called once.
        for bigip in self.driver.get_config_bigips():
            subnet_hints = all_subnet_hints[bigip.device_name]
            self._assure_bigip_tenant_cleanup(bigip, service, subnet_hints)

    # called for every bigip only in replication mode.
    # otherwise called once
    def _assure_bigip_tenant_cleanup(self, bigip, service, subnet_hints):
        tenant_id = service['loadbalancer']['tenant_id']

        self._remove_tenant_replication_mode(bigip, tenant_id)

    def _remove_tenant_replication_mode(self, bigip, tenant_id):
        # Remove tenant in replication sync-mode
        partition = self.service_adapter.get_folder_name(tenant_id)
        domain_names = self.network_helper.get_route_domain_names(bigip,
                                                                  partition)
        for domain_name in domain_names:
            try:
                self.network_helper.delete_route_domain(bigip,
                                                        partition,
                                                        domain_name)
            except Exception as err:
#.........这里部分代码省略.........
开发者ID:F5Networks,项目名称:f5-openstack-agent,代码行数:101,代码来源:tenants.py

示例15: NetworkServiceBuilder

class NetworkServiceBuilder(object):

    def __init__(self, f5_global_routed_mode, conf, driver, l3_binding=None):
        self.f5_global_routed_mode = f5_global_routed_mode
        self.conf = conf
        self.driver = driver
        self.l3_binding = l3_binding
        self.l2_service = L2ServiceBuilder(driver, f5_global_routed_mode)

        self.bigip_selfip_manager = BigipSelfIpManager(
            self.driver, self.l2_service, self.driver.l3_binding)
        self.bigip_snat_manager = BigipSnatManager(
            self.driver, self.l2_service, self.driver.l3_binding)

        self.vlan_manager = resource_helper.BigIPResourceHelper(
            resource_helper.ResourceType.vlan)
        self.rds_cache = {}
        self.interface_mapping = self.l2_service.interface_mapping
        self.network_helper = NetworkHelper()
        self.service_adapter = self.driver.service_adapter

    def post_init(self):
        # Run and Post Initialization Tasks """
        # run any post initialized tasks, now that the agent
        # is fully connected
        self.l2_service.post_init()

    def tunnel_sync(self, tunnel_ips):
        self.l2_service.tunnel_sync(tunnel_ips)

    def set_tunnel_rpc(self, tunnel_rpc):
        # Provide FDB Connector with ML2 RPC access """
        self.l2_service.set_tunnel_rpc(tunnel_rpc)

    def set_l2pop_rpc(self, l2pop_rpc):
        # Provide FDB Connector with ML2 RPC access """
        self.l2_service.set_l2pop_rpc(l2pop_rpc)

    def initialize_vcmp(self):
        self.l2_service.initialize_vcmp_manager()

    def initialize_tunneling(self):
        # setup tunneling
        vtep_folder = self.conf.f5_vtep_folder
        vtep_selfip_name = self.conf.f5_vtep_selfip_name
        local_ips = []

        for bigip in self.driver.get_all_bigips():

            bigip.local_ip = None

            if not vtep_folder or vtep_folder.lower() == 'none':
                vtep_folder = 'Common'

            if vtep_selfip_name and \
               not vtep_selfip_name.lower() == 'none':

                # profiles may already exist
                # create vxlan_multipoint_profile`
                self.network_helper.create_vxlan_multipoint_profile(
                    bigip,
                    'vxlan_ovs',
                    partition='Common')
                # create l2gre_multipoint_profile
                self.network_helper.create_l2gre_multipoint_profile(
                    bigip,
                    'gre_ovs',
                    partition='Common')

                # find the IP address for the selfip for each box
                local_ip = self.bigip_selfip_manager.get_selfip_addr(
                    bigip,
                    vtep_selfip_name,
                    partition=vtep_folder
                )

                if local_ip:
                    bigip.local_ip = local_ip
                    local_ips.append(local_ip)
                else:
                    raise f5_ex.MissingVTEPAddress(
                        'device %s missing vtep selfip %s'
                        % (bigip.device_name,
                           '/' + vtep_folder + '/' +
                           vtep_selfip_name))
        return local_ips

    def prep_service_networking(self, service, traffic_group):
        # Assure network connectivity is established on all bigips
        if self.conf.f5_global_routed_mode or not service['loadbalancer']:
            return

        if self.conf.use_namespaces:
            try:
                LOG.debug("Annotating the service definition networks "
                          "with route domain ID.")
                self._annotate_service_route_domains(service)
            except Exception as err:
                LOG.exception(err)
                raise f5_ex.RouteDomainCreationException(
#.........这里部分代码省略.........
开发者ID:F5Networks,项目名称:f5-openstack-agent,代码行数:101,代码来源:network_service.py


注:本文中的f5_openstack_agent.lbaasv2.drivers.bigip.network_helper.NetworkHelper类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。