Esempio n. 1
0
    def _convert_nl_io_mappings(self, mappings):
        if not mappings:
            return None

        resp = []
        for mac, value in six.iteritems(mappings):
            resp.append("%s/%s" % (util.sanitize_mac_for_api(mac), value))
        return resp
Esempio n. 2
0
 def _vea_build_out(self):
     """Builds the '_build_map' for the veas."""
     for slot, io_dict in six.iteritems(self._slot_store.topology):
         for mac, vswitch in six.iteritems(io_dict.get(IOCLASS.CNA, {})):
             mac = pvm_util.sanitize_mac_for_api(mac)
             if vswitch == 'MGMTSWITCH':
                 self._put_mgmt_vea_slot(mac, slot)
             else:
                 self._put_novios_val(IOCLASS.CNA, mac, slot)
Esempio n. 3
0
    def get_vnet_slot(self, mac):
        """Gets the client slot for the VEA or VNIC, mgmt VEA not included.

        :param mac: MAC address string to look up.
        :return: Integer client slot number on which to create a CNA or VNIC
                 with the specified MAC address.
        """
        # Pull from the build map. Will default to None (indicating to use
        # the next available high slot).
        mac = pvm_util.sanitize_mac_for_api(mac)
        return (self._build_map.get(IOCLASS.CNA, {}).get(mac, None)
                or self._build_map.get(IOCLASS.VNIC, {}).get(mac, None))
Esempio n. 4
0
    def get_vea_slot(self, mac):
        """Gets the client slot for the VEA.

        :param mac: MAC address string to look up.
        :return: Integer client slot number on which to create a CNA with the
                 specified MAC address.
        """
        # Pull from the build map.  Will default to None (indicating to use
        # the next available high slot).
        return self._build_map.get(IOCLASS.CNA,
                                   {}).get(pvm_util.sanitize_mac_for_api(mac),
                                           None)
Esempio n. 5
0
def find_cna_for_mac(mac, client_adpts):
    """Returns the appropriate client adapter for a given mac address.

    :param mac: The mac address of the client adapter.
    :param client_adpts: The Client Adapters from pypowervm.
    :returns: The Client Adapter for the mac.  If one isn't found, then
              None will be returned.
    """
    mac = pvm_util.sanitize_mac_for_api(mac)

    for client_adpt in client_adpts:
        if client_adpt.mac == mac:
            return client_adpt

    # None was found.
    return None
Esempio n. 6
0
def find_cna_for_mac(mac, client_adpts):
    """Returns the appropriate client adapter for a given mac address.

    :param mac: The mac address of the client adapter.
    :param client_adpts: The Client Adapters from pypowervm.
    :returns: The Client Adapter for the mac.  If one isn't found, then
              None will be returned.
    """
    mac = pvm_util.sanitize_mac_for_api(mac)

    for client_adpt in client_adpts:
        if client_adpt.mac == mac:
            return client_adpt

    # None was found.
    return None
Esempio n. 7
0
 def unplug(self, vif, cna_w_list=None):
     mac = pvm_util.sanitize_mac_for_api(vif['address'])
     vnic = vm.get_vnics(self.adapter,
                         self.instance,
                         mac=mac,
                         one_result=True)
     if not vnic:
         LOG.warning(
             'Unable to unplug VIF with mac %(mac)s. No matching '
             'vNIC was found on the instance. VIF: %(vif)s', {
                 'mac': mac,
                 'vif': vif
             },
             instance=self.instance)
         return None
     vnic.delete()
     return vnic
Esempio n. 8
0
    def post_live_migrate_at_destination(self, vif):
        """Performs live migrate cleanup on the destination host.

        This is optional, child classes do not need to implement this.

        :param vif: The virtual interface that was migrated.
        """
        # 1) Find a free vlan to use
        # 2) Update the migrated CNA to use the new vlan that was found
        #    and ensure that the CNA is enabled
        # 3) Create a trunk adapter on the destination of the migration
        #    using the same vlan as the CNA

        mgmt_wrap = pvm_par.get_this_partition(self.adapter)
        dev_name = self.get_trunk_dev_name(vif)
        mac = pvm_util.sanitize_mac_for_api(vif['address'])

        # Get vlan
        vswitch_w = pvm_net.VSwitch.search(
            self.adapter, parent_type=pvm_ms.System.schema_type,
            one_result=True, parent_uuid=self.host_uuid,
            name=CONF.powervm.pvm_vswitch_for_novalink_io)
        cna = pvm_net.CNA.search(
            self.adapter, mac=mac, one_result=True, parent_type=pvm_lpar.LPAR,
            parent_uuid=vm.get_pvm_uuid(self.instance))

        # Assigns a free vlan (which is returned) to the cna_list
        # also enable the cna
        cna = pvm_cna.assign_free_vlan(
            self.adapter, self.host_uuid, vswitch_w, cna)
        # Create a trunk with the vlan_id
        trunk_adpt = pvm_net.CNA.bld(
            self.adapter, cna.pvid, vswitch_w.related_href, trunk_pri=1,
            dev_name=dev_name)
        trunk_adpt.create(parent=mgmt_wrap)

        utils.execute('ip', 'link', 'set', dev_name, 'up', run_as_root=True)
        linux_net.create_ovs_vif_port(vif['network']['bridge'], dev_name,
                                      self.get_ovs_interfaceid(vif),
                                      vif['address'], self.instance.uuid)
Esempio n. 9
0
    def pre_live_migrate_at_source(self, vif):
        """Performs the pre live migrate on the source host.

        This is executed directly before the migration is started on the source
        host.

        :param vif: The virtual interface that will be migrated.  This may be
                    called network_info in other portions of the code.
        :return: The list of TrunkAdapter's on the source that are hosting the
                 VM's vif.  Should only return data if those trunks should be
                 deleted after the migration.
        """
        # Right before the migration, we need to find the trunk on the source
        # host.
        mac = pvm_util.sanitize_mac_for_api(vif['address'])
        cna_w = pvm_net.CNA.search(self.adapter,
                                   parent_type=pvm_lpar.LPAR.schema_type,
                                   parent_uuid=vm.get_pvm_uuid(self.instance),
                                   one_result=True,
                                   mac=mac)

        return pvm_cna.find_trunks(self.adapter, cna_w)
Esempio n. 10
0
    def plug(self, vif, slot_num, new_vif=True):
        if not new_vif:
            return None

        physnet = vif.get_physical_network()
        if not physnet:
            # Get physnet from neutron network if not present in vif
            # TODO(svenkat): This section of code will be eliminated in
            # pike release. Design will be in place to fix any vif
            # that has physical_network missing. The fix will be in
            # compute startup code.
            net_id = vif['network']['id']
            admin_context = ctx.get_admin_context()
            napi = net_api.API()
            network = napi.get(admin_context, net_id)
            physnet = network.physical_network

        LOG.debug("Plugging vNIC SR-IOV vif for physical network %(physnet)s.",
                  {'physnet': physnet},
                  instance=self.instance)

        # Get the msys
        msys = pvm_ms.System.get(self.adapter)[0]
        # Physical ports for the given port label
        pports_w = sriovtask.find_pports_for_portlabel(physnet, self.adapter,
                                                       msys)
        pports = [pport.loc_code for pport in pports_w]

        if not pports:
            raise exception.VirtualInterfacePlugException(
                _("Unable to find acceptable Ethernet ports on physical "
                  "network '%(physnet)s' for instance %(inst)s for SRIOV "
                  "based VIF with MAC address %(vif_mac)s.") % {
                      'physnet': physnet,
                      'inst': self.instance.name,
                      'vif_mac': vif['address']
                  })

        # MAC
        mac_address = pvm_util.sanitize_mac_for_api(vif['address'])

        # vlan id
        vlan_id = int(vif['details']['vlan'])

        # Redundancy: plugin sets from binding:profile, then conf, then default
        redundancy = int(vif['details']['redundancy'])

        # Capacity: plugin sets from binding:profile, then conf, then default
        capacity = vif['details']['capacity']

        vnic = pvm_card.VNIC.bld(self.adapter,
                                 vlan_id,
                                 slot_num=slot_num,
                                 mac_addr=mac_address,
                                 allowed_vlans=pvm_util.VLANList.NONE,
                                 allowed_macs=pvm_util.MACList.NONE)

        sriovtask.set_vnic_back_devs(vnic,
                                     pports,
                                     sys_w=msys,
                                     redundancy=redundancy,
                                     capacity=capacity,
                                     check_port_status=True)

        return vnic.create(parent_type=pvm_lpar.LPAR,
                           parent_uuid=vm.get_pvm_uuid(self.instance))
Esempio n. 11
0
 def _vnic_build_out(self):
     """Builds the '_build_map' for the vnics."""
     for slot, io_dict in six.iteritems(self._slot_store.topology):
         for mac in io_dict.get(IOCLASS.VNIC, {}):
             self._put_novios_val(IOCLASS.VNIC,
                                  pvm_util.sanitize_mac_for_api(mac), slot)
Esempio n. 12
0
 def mac(self, new_val):
     new_mac = u.sanitize_mac_for_api(new_val)
     self.set_parm_value(_VADPT_MAC_ADDR, new_mac)
Esempio n. 13
0
 def _mac(self, value):
     self.set_parm_value(_SRIOVLP_MAC, u.sanitize_mac_for_api(value))
Esempio n. 14
0
 def _mac(self, val):
     self.set_parm_value(_VNICD_MAC, u.sanitize_mac_for_api(val))
Esempio n. 15
0
 def mac(self, new_val):
     new_mac = u.sanitize_mac_for_api(new_val)
     self.set_parm_value(_VADPT_MAC_ADDR, new_mac)