Пример #1
0
 def delete_bigip_network(self, bigip, network):
     # Delete network on bigip
     if network['id'] in self.conf.common_network_ids:
         LOG.debug('skipping delete of common network %s'
                   % network['id'])
         return
     if self.is_common_network(network):
         network_folder = 'Common'
     else:
         network_folder = self.service_adapter.get_folder_name(
             network['tenant_id'])
     if network['provider:network_type'] == 'vlan':
         self._delete_device_vlan(bigip, network, network_folder)
     elif network['provider:network_type'] == 'flat':
         self._delete_device_flat(bigip, network, network_folder)
     elif network['provider:network_type'] == 'vxlan':
         self._delete_device_vxlan(bigip, network, network_folder)
     elif network['provider:network_type'] == 'gre':
         self._delete_device_gre(bigip, network, network_folder)
     elif network['provider:network_type'] == 'opflex':
         raise f5_ex.NetworkNotReady(
             "Opflex network segment definition required")
     else:
         LOG.error('Unsupported network type %s. Can not delete.'
                   % network['provider:network_type'])
     if network['id'] in bigip.assured_networks:
         del bigip.assured_networks[network['id']]
Пример #2
0
    def prep_service_networking(self, service, traffic_group):
        """Assure network connectivity is established on all bigips."""
        if self.conf.f5_global_routed_mode:
            return

        if not self.is_service_connected(service):
            raise f5_ex.NetworkNotReady(
                "Network segment(s) definition incomplete")

        if self.conf.use_namespaces:
            try:
                LOG.debug("Annotating the service definition networks "
                          "with route domain ID.")
                self._annotate_service_route_domains(service)
            except f5_ex.InvalidNetworkType as exc:
                LOG.warning(exc.msg)
            except Exception as err:
                LOG.exception(err)
                raise f5_ex.RouteDomainCreationException(
                    "Route domain annotation error")

        # Per Device Network Connectivity (VLANs or Tunnels)
        subnetsinfo = self._get_subnets_to_assure(service)
        for (assure_bigip,
             subnetinfo) in (itertools.product(self.driver.get_all_bigips(),
                                               subnetsinfo)):
            LOG.debug("Assuring per device network connectivity "
                      "for %s on subnet %s." %
                      (assure_bigip.hostname, subnetinfo['subnet']))

            # Make sure the L2 network is established
            self.l2_service.assure_bigip_network(assure_bigip,
                                                 subnetinfo['network'])

            # Connect the BigIP device to network, by getting
            # a self-ip address on the subnet.
            self.bigip_selfip_manager.assure_bigip_selfip(
                assure_bigip, service, subnetinfo)

        # L3 Shared Config
        assure_bigips = self.driver.get_config_bigips()
        LOG.debug("Getting subnetinfo for ...")
        LOG.debug(assure_bigips)
        for subnetinfo in subnetsinfo:
            if self.conf.f5_snat_addresses_per_subnet > 0:
                self._assure_subnet_snats(assure_bigips, service, subnetinfo)

            if subnetinfo['is_for_member'] and not self.conf.f5_snat_mode:
                try:
                    self._allocate_gw_addr(subnetinfo)
                except KeyError as err:
                    raise f5_ex.VirtualServerCreationException(err.message)

                for assure_bigip in assure_bigips:
                    # If we are not using SNATS, attempt to become
                    # the subnet's default gateway.
                    self.bigip_selfip_manager.assure_gateway_on_subnet(
                        assure_bigip, subnetinfo, traffic_group)
Пример #3
0
    def assure_bigip_network(self, bigip, network):
        # Ensure bigip has configured network object
        if not network:
            LOG.error('assure_bigip_network: '
                      'Attempted to assure a network with no id..skipping.')
            return

        if network['id'] in bigip.assured_networks:
            return

        if network['id'] in self.conf.common_network_ids:
            LOG.debug('assure_bigip_network: '
                      'Network is a common global network... skipping.')
            return

        LOG.debug("assure_bigip_network network: %s" % str(network))
        start_time = time()
        if self.is_common_network(network):
            network_folder = 'Common'
        else:
            network_folder = self.service_adapter.get_folder_name(
                network['tenant_id']
            )

        # setup all needed L2 network segments
        if network['provider:network_type'] == 'flat':
            network_name = self._assure_device_network_flat(
                network, bigip, network_folder)
        elif network['provider:network_type'] == 'vlan':
            network_name = self._assure_device_network_vlan(
                network, bigip, network_folder)
        elif network['provider:network_type'] == 'vxlan':
            network_name = self._assure_device_network_vxlan(
                network, bigip, network_folder)
        elif network['provider:network_type'] == 'gre':
            network_name = self._assure_device_network_gre(
                network, bigip, network_folder)
        elif network['provider:network_type'] == 'opflex':
            raise f5_ex.NetworkNotReady(
                "Opflex network segment definition required")
        else:
            error_message = 'Unsupported network type %s.' \
                            % network['provider:network_type'] + \
                            ' Cannot setup network.'
            LOG.error(error_message)
            raise f5_ex.InvalidNetworkType(error_message)
        bigip.assured_networks[network['id']] = network_name

        if time() - start_time > .001:
            LOG.debug("        assure bigip network took %.5f secs" %
                      (time() - start_time))