コード例 #1
0
    def create_network_postcommit(self, mech_context):
        """Create Network on the switch."""

        LOG.debug("create_network_postcommit: called")

        if self.is_flat_network(mech_context.network_segments[0]):
            return

        network = mech_context.current
        # use network_id to get the network attributes
        # ONLY depend on our db for getting back network attributes
        # this is so we can replay postcommit from db
        context = mech_context._plugin_context

        network_id = network['id']
        network = brocade_db.get_network(context, network_id)
        network['network_type']
        network['tenant_id']
        vlan_id = network['vlan']
        segments = mech_context.network_segments
        # currently supports only one segment per network
        segment = segments[0]
        physical_network = segment['physical_network']

        try:
            self._driver.create_network(self._device_dict, physical_network,
                                        vlan_id)
        except Exception:
            LOG.exception(_LE("Brocade NOS driver: failed in create network"))
            brocade_db.delete_network(context, network_id)
            raise Exception(
                _("Brocade Mechanism: create_network_postcommmit failed"))
コード例 #2
0
    def delete_network_precommit(self, mech_context):
        """Delete Network from the plugin specific database table."""

        LOG.debug("delete_network_precommit: called")
        if self.is_flat_network(mech_context.network_segments[0]):
            return

        network = mech_context.current
        network_id = network['id']
        vlan_id = network['provider:segmentation_id']
        tenant_id = network['tenant_id']

        context = mech_context._plugin_context

        try:
            brocade_db.delete_network(context, network_id)
        except Exception:
            LOG.exception(
                _LE("Brocade Mechanism: failed to delete network in db"))
            raise Exception(
                _("Brocade Mechanism: delete_network_precommit failed"))

        LOG.info(
            _LI("delete network (precommit): %(network_id)s"
                " with vlan = %(vlan_id)s"
                " for tenant %(tenant_id)s"), {
                    'network_id': network_id,
                    'vlan_id': vlan_id,
                    'tenant_id': tenant_id
                })
コード例 #3
0
    def delete_network_precommit(self, mech_context):
        """Delete Network from the plugin specific database table."""

        LOG.debug("delete_network_precommit: called")
        if self.is_flat_network(mech_context.network_segments[0]):
            return

        network = mech_context.current
        network_id = network['id']
        vlan_id = network['provider:segmentation_id']
        tenant_id = network['tenant_id']

        context = mech_context._plugin_context

        try:
            brocade_db.delete_network(context, network_id)
        except Exception:
            LOG.exception(
                _LE("Brocade Mechanism: failed to delete network in db"))
            raise Exception(
                _("Brocade Mechanism: delete_network_precommit failed"))

        LOG.info(_LI("delete network (precommit): %(network_id)s"
                     " with vlan = %(vlan_id)s"
                     " for tenant %(tenant_id)s"),
                 {'network_id': network_id,
                  'vlan_id': vlan_id,
                  'tenant_id': tenant_id})
コード例 #4
0
 def delete_network_precommit(self, context):
     network = context.current
     provider_type = network['provider:network_type']
     brocade_network = brocade_db.get_network(context._plugin_context, network['id'])
     segmentation_id = brocade_network.vlan
     vrf_name = self.internal_vrf_name
     if '-pub-' in network['name']:
         vrf_name = self.external_vrf_name
     try:
         self.fabric_driver.delete_network(segmentation_id)
         brocade_db.delete_network(context._plugin_context, network['id'])
     except Exception as ex:
         LOG.exception("Error in create_network_postcommit.")
         raise ex
     return True
コード例 #5
0
    def delete_network_precommit(self, mech_context):
        """Delete Network from the plugin specific database table."""

        LOG.debug("delete_network_precommit: called")
        if self.is_flat_network(mech_context.network_segments[0]):
            return

        network = mech_context.current
        network_id = network['id']
        network['tenant_id']

        context = mech_context._plugin_context

        try:
            brocade_db.delete_network(context, network_id)
        except Exception:
            LOG.exception(
                _LE("Brocade Mechanism: failed to delete network in db"))
            raise Exception(
                _("Brocade Mechanism: delete_network_precommit failed"))
コード例 #6
0
    def create_network_postcommit(self, mech_context):
        """Create Network as a portprofile on the switch."""

        LOG.debug("create_network_postcommit: called")
        if self.is_flat_network(mech_context.network_segments[0]):
            return

        network = mech_context.current
        # use network_id to get the network attributes
        # ONLY depend on our db for getting back network attributes
        # this is so we can replay postcommit from db
        context = mech_context._plugin_context

        network_id = network['id']
        network = brocade_db.get_network(context, network_id)
        network_type = network.network_type
        tenant_id = network['tenant_id']
        vlan_id = network['vlan']

        try:
            self._driver.create_network(self._switch['address'],
                                        self._switch['username'],
                                        self._switch['password'], vlan_id)
        except Exception:
            LOG.exception(_LE("Brocade NOS driver: failed in create network"))
            brocade_db.delete_network(context, network_id)
            raise Exception(
                _("Brocade Mechanism: create_network_postcommmit failed"))

        LOG.info(
            _LI("created network (postcommit): %(network_id)s"
                " of network type = %(network_type)s"
                " with vlan = %(vlan_id)s"
                " for tenant %(tenant_id)s"), {
                    'network_id': network_id,
                    'network_type': network_type,
                    'vlan_id': vlan_id,
                    'tenant_id': tenant_id
                })
コード例 #7
0
    def create_network_postcommit(self, mech_context):
        """Create Network as a portprofile on the switch."""

        LOG.debug("create_network_postcommit: called")
        if self.is_flat_network(mech_context.network_segments[0]):
            return

        network = mech_context.current
        # use network_id to get the network attributes
        # ONLY depend on our db for getting back network attributes
        # this is so we can replay postcommit from db
        context = mech_context._plugin_context

        network_id = network['id']
        network = brocade_db.get_network(context, network_id)
        network_type = network.network_type
        tenant_id = network['tenant_id']
        vlan_id = network['vlan']

        try:
            self._driver.create_network(self._switch['address'],
                                        self._switch['username'],
                                        self._switch['password'],
                                        vlan_id)
        except Exception:
            LOG.exception(_LE("Brocade NOS driver: failed in create network"))
            brocade_db.delete_network(context, network_id)
            raise Exception(
                _("Brocade Mechanism: create_network_postcommmit failed"))

        LOG.info(_LI("created network (postcommit): %(network_id)s"
                     " of network type = %(network_type)s"
                     " with vlan = %(vlan_id)s"
                     " for tenant %(tenant_id)s"),
                 {'network_id': network_id,
                  'network_type': network_type,
                  'vlan_id': vlan_id,
                  'tenant_id': tenant_id})