def update_port_postcommit(self, context):
        """Call ISM API to set VLAN configuration."""

        port = context.current
        if not fj_util.is_baremetal_deploy(port):
            LOG.warning("This plugin is doing nothing before ironic-neutron\
                      integration will be merged.")
            return

        net_type, seg_id = fj_util.get_network_segments(port.network)
        phy_connections = fj_util.get_physical_connectivity(port)

        for phy_con in phy_connections:
            try:
                ism = FujitsuIsmDriver.create_ism_base(net_type, seg_id)
                current = ism.get_current_config(phy_con)
                req_param = ism.generate_req_param_for_port(current)
                ism.setup_for_port(req_param, phy_con)
            except Exception as er:
                LOG.exception(
                    _LE("failed to setup %(net_type)s. detail=%(er)s"), {
                        'net_type': net_type,
                        'er': er
                    })
                raise ml2_exc.MechanismDriverError(method="%s" % __name__)
        return
    def create_port_postcommit(self, context):
        """Call ISM API to set VLAN configuration."""

        port = context.current
        if not fj_util.is_baremetal_deploy(port):
            LOG.warning("This plugin is doing nothing before ironic-neutron\
                      integration will be merged.")
            return
        net_type, seg_id = fj_util.get_network_segments(port.network)
        phy_connections = fj_util.get_physical_connectivity(port)

        # TODO(yushiro) Call LAG setup function of ISM

        for phy_con in phy_connections:
            try:
                ism = FujitsuIsmDriver.create_ism_base(net_type, seg_id)
                current = ism.get_current_config(phy_con)
                req_param = ism.generate_req_param_for_port(current)
                ism.setup_for_port(req_param, phy_con)
            except Exception as er:
                LOG.exception(
                    _LE("failed to setup %(net_type)s. detail=%(er)s"),
                    {'net_type': net_type, 'er': er})
                raise ml2_exc.MechanismDriverError(method="%s" % __name__)
        return
    def delete_port_postcommit(self, mech_context):
        """Calls cleanup process for C-Fabric.

        Case1: Baremetal deploy
                   Clear VLAN/LAG for specified physical port.
        Case2: Otherwise
                   Dissociate MAC address from the portprofile.
        """

        method = 'delete_port_postcommit'
        if fj_util.is_baremetal_deploy(mech_context.current):
            params = self.validate_physical_net_params(mech_context)
            try:
                self.clear_vlan(params)
            except Exception:
                LOG.exception(_LE("Fujitsu Mechanism: "
                                  "failed to clear vlan%s"), params['vlanid'])
                raise ml2_exc.MechanismDriverError(method=method)
        else:
            port = mech_context.current
            port_id = port['id']
            network_id = port['network_id']
            tenant_id = port['tenant_id']

            segments = mech_context.network.network_segments
            # currently supports only one segment per network
            segment = segments[0]
            fj_util._validate_network(mech_context.network)
            vfab_id = self._get_vfab_id(segment[driver_api.PHYSICAL_NETWORK])
            vlanid = segment[driver_api.SEGMENTATION_ID]
            interface_mac = port['mac_address']

            try:
                self._driver.dissociate_mac_from_network(
                    self._switch['address'],
                    self._switch['username'],
                    self._switch['password'],
                    vfab_id,
                    vlanid,
                    interface_mac)
            except Exception:
                LOG.exception(
                    _LE("Fujitsu Mechanism: failed to dissociate MAC %s") %
                    interface_mac)
                raise ml2_exc.MechanismDriverError(method=method)

            LOG.info(
                _LI("delete port (postcommit): port_id=%(port_id)s "
                    "network_id=%(network_id)s tenant_id=%(tenant_id)s"),
                {'port_id': port_id,
                 'network_id': network_id, 'tenant_id': tenant_id})
示例#4
0
    def delete_port_postcommit(self, mech_context):
        """Calls cleanup process for C-Fabric.

        Case1: Baremetal deploy
                   Clear VLAN/LAG for specified physical port.
        Case2: Otherwise
                   Dissociate MAC address from the portprofile.
        """

        method = 'delete_port_postcommit'
        if fj_util.is_baremetal_deploy(mech_context.current):
            params = self.validate_physical_net_params(mech_context)
            try:
                self.clear_vlan(params)
            except Exception:
                LOG.exception(
                    _LE("Fujitsu Mechanism: "
                        "failed to clear vlan%s"), params['vlanid'])
                raise ml2_exc.MechanismDriverError(method=method)
        else:
            port = mech_context.current
            port_id = port['id']
            network_id = port['network_id']
            tenant_id = port['tenant_id']

            segments = mech_context.network.network_segments
            # currently supports only one segment per network
            segment = segments[0]
            fj_util._validate_network(mech_context.network)
            vfab_id = self._get_vfab_id(segment[driver_api.PHYSICAL_NETWORK])
            vlanid = segment[driver_api.SEGMENTATION_ID]
            interface_mac = port['mac_address']

            try:
                self._driver.dissociate_mac_from_network(
                    self._switch['address'], self._switch['username'],
                    self._switch['password'], vfab_id, vlanid, interface_mac)
            except Exception:
                LOG.exception(
                    _LE("Fujitsu Mechanism: failed to dissociate MAC %s") %
                    interface_mac)
                raise ml2_exc.MechanismDriverError(method=method)

            LOG.info(
                _LI("delete port (postcommit): port_id=%(port_id)s "
                    "network_id=%(network_id)s tenant_id=%(tenant_id)s"), {
                        'port_id': port_id,
                        'network_id': network_id,
                        'tenant_id': tenant_id
                    })
    def bind_port(self, context):

        port = context.current
        vnic_type = port['binding:vnic_type']

        LOG.debug("Attempting to bind port %(port)s with vnic_type "
                  "%(vnic_type)s on network %(network)s",
                  {'port': port['id'], 'vnic_type': vnic_type,
                   'network': context.network.current['id']})

        if fj_util.is_baremetal_deploy(port):
            segments = context.segments_to_bind
            params = self.validate_physical_net_params(context)
            self.setup_vlan(params)
            context.set_binding(segments[0][driver_api.ID],
                                portbindings.VIF_TYPE_OTHER, {},
                                status=const.PORT_STATUS_ACTIVE)
示例#6
0
    def create_port_postcommit(self, mech_context):
        """Calls setup process for C-Fabric.

        Case1: Baremetal deploy
                   Setup VLAN for specified physical port.
        Case2: Otherwise
                   Associate the assigned MAC address to the portprofile.
        """

        if fj_util.is_baremetal_deploy(mech_context.current):
            return

        method = 'create_port_postcommit'
        port = mech_context.current
        port_id = port['id']
        network_id = port['network_id']
        tenant_id = port['tenant_id']
        segments = mech_context.network.network_segments
        # currently supports only one segment per network
        segment = segments[0]
        fj_util._validate_network(mech_context.network)
        vfab_id = self._get_vfab_id(segment[driver_api.PHYSICAL_NETWORK])
        vlanid = segment[driver_api.SEGMENTATION_ID]

        interface_mac = port['mac_address']

        try:
            self._driver.associate_mac_to_network(self._switch['address'],
                                                  self._switch['username'],
                                                  self._switch['password'],
                                                  vfab_id, vlanid,
                                                  interface_mac)
        except Exception:
            LOG.exception(
                _LE("Fujitsu Mechanism: failed to associate mac %s") %
                interface_mac)
            raise ml2_exc.MechanismDriverError(method=method)

        LOG.info(
            _LI("created port (postcommit): port_id=%(port_id)s "
                "network_id=%(network_id)s tenant_id=%(tenant_id)s"), {
                    'port_id': port_id,
                    'network_id': network_id,
                    'tenant_id': tenant_id
                })
    def create_port_postcommit(self, mech_context):
        """Calls setup process for C-Fabric.

        Case1: Baremetal deploy
                   Setup VLAN for specified physical port.
        Case2: Otherwise
                   Associate the assigned MAC address to the portprofile.
        """

        if fj_util.is_baremetal_deploy(mech_context.current):
            return

        method = 'create_port_postcommit'
        port = mech_context.current
        port_id = port['id']
        network_id = port['network_id']
        tenant_id = port['tenant_id']
        segments = mech_context.network.network_segments
        # currently supports only one segment per network
        segment = segments[0]
        fj_util._validate_network(mech_context.network)
        vfab_id = self._get_vfab_id(segment[driver_api.PHYSICAL_NETWORK])
        vlanid = segment[driver_api.SEGMENTATION_ID]

        interface_mac = port['mac_address']

        try:
            self._driver.associate_mac_to_network(self._switch['address'],
                                                  self._switch['username'],
                                                  self._switch['password'],
                                                  vfab_id,
                                                  vlanid,
                                                  interface_mac)
        except Exception:
            LOG.exception(
                _LE("Fujitsu Mechanism: failed to associate mac %s")
                % interface_mac)
            raise ml2_exc.MechanismDriverError(method=method)

        LOG.info(
            _LI("created port (postcommit): port_id=%(port_id)s "
                "network_id=%(network_id)s tenant_id=%(tenant_id)s"),
            {'port_id': port_id,
             'network_id': network_id, 'tenant_id': tenant_id})
示例#8
0
    def bind_port(self, context):

        port = context.current
        vnic_type = port['binding:vnic_type']

        LOG.debug(
            "Attempting to bind port %(port)s with vnic_type "
            "%(vnic_type)s on network %(network)s", {
                'port': port['id'],
                'vnic_type': vnic_type,
                'network': context.network.current['id']
            })

        if fj_util.is_baremetal_deploy(port):
            segments = context.segments_to_bind
            params = self.validate_physical_net_params(context)
            self.setup_vlan(params)
            context.set_binding(segments[0][driver_api.ID],
                                portbindings.VIF_TYPE_OTHER, {},
                                status=const.PORT_STATUS_ACTIVE)