Beispiel #1
0
 def lsn_port_metadata_setup(self, context, lsn_id, subnet):
     """Connect subnet to specified LSN."""
     data = {
         "mac_address": const.METADATA_MAC,
         "ip_address": subnet['cidr'],
         "subnet_id": subnet['id']
     }
     network_id = subnet['network_id']
     tenant_id = subnet['tenant_id']
     lswitch_port_id = None
     try:
         lswitch_port_id = nsxlib.create_lport(
             self.cluster, network_id, tenant_id,
             const.METADATA_PORT_ID, const.METADATA_PORT_NAME,
             const.METADATA_DEVICE_ID, True)['uuid']
         lsn_port_id = self.lsn_port_create(self.cluster, lsn_id, data)
     except (n_exc.NotFound, p_exc.NvpPluginException,
             nsxlib.NvpApiClient.NvpApiException):
         raise p_exc.PortConfigurationError(
             net_id=network_id, lsn_id=lsn_id, port_id=lswitch_port_id)
     else:
         try:
             lsn_api.lsn_port_plug_network(
                 self.cluster, lsn_id, lsn_port_id, lswitch_port_id)
         except p_exc.LsnConfigurationConflict:
             self.lsn_port_delete(self.cluster, lsn_id, lsn_port_id)
             nsxlib.delete_port(self.cluster, network_id, lswitch_port_id)
             raise p_exc.PortConfigurationError(
                 net_id=network_id, lsn_id=lsn_id, port_id=lsn_port_id)
Beispiel #2
0
 def lsn_port_metadata_setup(self, context, lsn_id, subnet):
     """Connect subnet to specified LSN."""
     data = {
         "mac_address": const.METADATA_MAC,
         "ip_address": subnet['cidr'],
         "subnet_id": subnet['id']
     }
     network_id = subnet['network_id']
     tenant_id = subnet['tenant_id']
     lswitch_port_id = None
     try:
         lswitch_port_id = nsxlib.create_lport(self.cluster, network_id,
                                               tenant_id,
                                               const.METADATA_PORT_ID,
                                               const.METADATA_PORT_NAME,
                                               const.METADATA_DEVICE_ID,
                                               True)['uuid']
         lsn_port_id = self.lsn_port_create(self.cluster, lsn_id, data)
     except (n_exc.NotFound, p_exc.NvpPluginException,
             nsxlib.NvpApiClient.NvpApiException):
         raise p_exc.PortConfigurationError(net_id=network_id,
                                            lsn_id=lsn_id,
                                            port_id=lswitch_port_id)
     else:
         try:
             lsn_api.lsn_port_plug_network(self.cluster, lsn_id,
                                           lsn_port_id, lswitch_port_id)
         except p_exc.LsnConfigurationConflict:
             self.lsn_port_delete(self.cluster, lsn_id, lsn_port_id)
             nsxlib.delete_port(self.cluster, network_id, lswitch_port_id)
             raise p_exc.PortConfigurationError(net_id=network_id,
                                                lsn_id=lsn_id,
                                                port_id=lsn_port_id)
Beispiel #3
0
 def lsn_port_dispose(self, context, network_id, mac_address):
     """Delete a LSN port given the network and the mac address."""
     # NOTE(armando-migliaccio): dispose and delete are functionally
     # equivalent, but they use different paraments to identify LSN
     # and LSN port resources.
     lsn_id, lsn_port_id = self.lsn_port_get_by_mac(
         context, network_id, mac_address, raise_on_err=False)
     if lsn_port_id:
         self.lsn_port_delete(context, lsn_id, lsn_port_id)
         if mac_address == METADATA_MAC:
             try:
                 lswitch_port = nvplib.get_port_by_neutron_tag(
                     self.cluster, network_id, METADATA_PORT_ID)
                 if lswitch_port:
                     lswitch_port_id = lswitch_port['uuid']
                     nvplib.delete_port(
                         self.cluster, network_id, lswitch_port_id)
                 else:
                     LOG.warn(_("Metadata port not found while attempting "
                                "to delete it from network %s"), network_id)
             except (n_exc.PortNotFoundOnNetwork,
                     nvplib.NvpApiClient.NvpApiException):
                 LOG.warn(_("Metadata port not found while attempting "
                            "to delete it from network %s"), network_id)
     else:
         LOG.warn(_("Unable to find Logical Services Node "
                    "Port with MAC %s"), mac_address)
Beispiel #4
0
 def lsn_port_dispose(self, context, network_id, mac_address):
     """Delete a LSN port given the network and the mac address."""
     # NOTE(armando-migliaccio): dispose and delete are functionally
     # equivalent, but they use different paraments to identify LSN
     # and LSN port resources.
     lsn_id, lsn_port_id = self.lsn_port_get_by_mac(
         context, network_id, mac_address, raise_on_err=False)
     if lsn_port_id:
         self.lsn_port_delete(context, lsn_id, lsn_port_id)
         if mac_address == METADATA_MAC:
             try:
                 lswitch_port = nvplib.get_port_by_neutron_tag(
                     self.cluster, network_id, METADATA_PORT_ID)
                 if lswitch_port:
                     lswitch_port_id = lswitch_port['uuid']
                     nvplib.delete_port(
                         self.cluster, network_id, lswitch_port_id)
                 else:
                     LOG.warn(_("Metadata port not found while attempting "
                                "to delete it from network %s"), network_id)
             except (n_exc.PortNotFoundOnNetwork,
                     nvplib.NvpApiClient.NvpApiException):
                 LOG.warn(_("Metadata port not found while attempting "
                            "to delete it from network %s"), network_id)
     else:
         LOG.warn(_("Unable to find Logical Services Node "
                    "Port with MAC %s"), mac_address)
Beispiel #5
0
 def lsn_port_dispose(self, context, network_id, mac_address):
     """Delete a LSN port given the network and the mac address."""
     lsn_id, lsn_port_id = self.lsn_port_get_by_mac(
         context, network_id, mac_address, raise_on_err=False)
     if lsn_port_id:
         self.lsn_port_delete(context, lsn_id, lsn_port_id)
         if mac_address == const.METADATA_MAC:
             try:
                 lswitch_port_id = nsxlib.get_port_by_neutron_tag(
                     self.cluster, network_id,
                     const.METADATA_PORT_ID)['uuid']
                 nsxlib.delete_port(
                     self.cluster, network_id, lswitch_port_id)
             except (n_exc.PortNotFoundOnNetwork,
                     nsxlib.NvpApiClient.NvpApiException):
                 LOG.warn(_("Metadata port not found while attempting "
                            "to delete it from network %s"), network_id)
     else:
         LOG.warn(_("Unable to find Logical Services Node "
                    "Port with MAC %s"), mac_address)
    def _add_router_integration_interface(self, tenant_id, name,
                                          lrouter, lswitch):
        # create logic switch port
        try:
            ls_port = nvplib.create_lport(
                self.cluster, lswitch['uuid'], tenant_id,
                '', '', lrouter['uuid'], True)
        except NvpApiClient.NvpApiException:
            msg = (_("An exception occured while creating a port "
                     "on lswitch %s") % lswitch['uuid'])
            LOG.exception(msg)
            raise q_exc.NeutronException(message=msg)

        # create logic router port
        try:
            neutron_port_id = ''
            pname = name[:36] + '-lp'
            admin_status_enabled = True
            lr_port = nvplib.create_router_lport(
                self.cluster, lrouter['uuid'], tenant_id,
                neutron_port_id, pname, admin_status_enabled,
                [vcns_const.INTEGRATION_LR_IPADDRESS])
        except NvpApiClient.NvpApiException:
            msg = (_("Unable to create port on NVP logical router %s") % name)
            LOG.exception(msg)
            nvplib.delete_port(self.cluster, lswitch['uuid'], ls_port['uuid'])
            raise q_exc.NeutronException(message=msg)

        # attach logic router port to switch port
        try:
            self._update_router_port_attachment(
                self.cluster, None, lrouter['uuid'], {}, lr_port['uuid'],
                'PatchAttachment', ls_port['uuid'], None)
        except NvpApiClient.NvpApiException as e:
            # lr_port should have been deleted
            nvplib.delete_port(self.cluster, lswitch['uuid'], ls_port['uuid'])
            raise e
Beispiel #7
0
 def lsn_port_dispose(self, context, network_id, mac_address):
     """Delete a LSN port given the network and the mac address."""
     lsn_id, lsn_port_id = self.lsn_port_get_by_mac(context,
                                                    network_id,
                                                    mac_address,
                                                    raise_on_err=False)
     if lsn_port_id:
         self.lsn_port_delete(context, lsn_id, lsn_port_id)
         if mac_address == const.METADATA_MAC:
             try:
                 lswitch_port_id = nsxlib.get_port_by_neutron_tag(
                     self.cluster, network_id,
                     const.METADATA_PORT_ID)['uuid']
                 nsxlib.delete_port(self.cluster, network_id,
                                    lswitch_port_id)
             except (n_exc.PortNotFoundOnNetwork,
                     nsxlib.NvpApiClient.NvpApiException):
                 LOG.warn(
                     _("Metadata port not found while attempting "
                       "to delete it from network %s"), network_id)
     else:
         LOG.warn(
             _("Unable to find Logical Services Node "
               "Port with MAC %s"), mac_address)