Example #1
0
    def test_crt_trunk_with_free_vlan(
            self, mock_get_partitions, mock_find_or_create_vswitch,
            mock_find_free_vlan, mock_cna_bld):
        """Tests the crt_trunk_with_free_vlan on mgmt based VIOS."""
        # Mock out the data
        mock_vswitch = mock.Mock(related_href='vswitch_href')
        mock_find_or_create_vswitch.return_value = mock_vswitch
        mock_find_free_vlan.return_value = 2050

        # Mock the get of the VIOSes.
        mock_vio1 = mock.Mock(uuid='vios_uuid1')
        mock_get_partitions.return_value = [mock_vio1]

        mock_trunk1 = mock.MagicMock(pvid=2050)
        mock_trunk1.create.return_value = mock_trunk1
        mock_cna_bld.return_value = mock_trunk1

        # Invoke the create
        mock_ext_id = {'test1': 'value1', 'test2': 'value2'}
        trunk_adpts = cna.crt_trunk_with_free_vlan(
            self.adpt, None, ['vios_uuid1'],
            mock_vswitch, crt_vswitch=True, dev_name='tap-12345',
            ovs_bridge='br-int', ovs_ext_ids=mock_ext_id, configured_mtu=1450)

        # Make sure the client and trunk were 'built'
        mock_cna_bld.assert_any_call(
            self.adpt, 2050, 'vswitch_href', trunk_pri=1, dev_name='tap-12345',
            ovs_bridge='br-int', ovs_ext_ids=mock_ext_id, configured_mtu=1450)

        # Make sure that the trunk was created
        self.assertEqual(1, len(trunk_adpts))
        mock_trunk1.create.assert_called_once_with(parent=mock_vio1)
Example #2
0
    def pre_live_migrate_at_destination(self, vif, vea_vlan_mappings):
        """Performs the pre live migrate on the destination host.

        This method will create the trunk adapter on the destination host,
        set its link state up, and attach it to the integration OVS switch.
        It also updates the vea_vlan_mappings to indicate which unique
        hypervisor VLAN should be used for this VIF for the migration operation
        to complete properly.

        :param vif: The virtual interface that will be migrated.  This may be
                    called network_info in other portions of the code.
        :param vea_vlan_mappings: The VEA VLAN mappings.  Key is the vif
                                  mac address, value is the destination's
                                  target hypervisor VLAN.
        """
        self._cleanup_orphan_adapters(vif,
                                      CONF.powervm.pvm_vswitch_for_novalink_io)
        mgmt_wrap = pvm_par.get_this_partition(self.adapter)
        dev = self.get_trunk_dev_name(vif)

        # Find a specific free VLAN and create the Trunk in a single atomic
        # action.
        cna_w = pvm_cna.crt_trunk_with_free_vlan(
            self.adapter,
            self.host_uuid, [mgmt_wrap.uuid],
            CONF.powervm.pvm_vswitch_for_novalink_io,
            dev_name=dev)[0]

        # Bring the vif up.  This signals to neutron that its ready for vif
        # plugging
        utils.execute('ip', 'link', 'set', dev, 'up', run_as_root=True)
        linux_net.create_ovs_vif_port(vif['network']['bridge'], dev,
                                      self.get_ovs_interfaceid(vif),
                                      vif['address'], self.instance.uuid)

        # Save this data for the migration command.
        vea_vlan_mappings[vif['address']] = cna_w.pvid
        LOG.info(
            "VIF with mac %(mac)s is going on trunk %(dev)s with PVID "
            "%(pvid)s", {
                'mac': vif['address'],
                'dev': dev,
                'pvid': cna_w.pvid
            },
            instance=self.instance)
Example #3
0
    def pre_live_migrate_at_destination(self, vif, vea_vlan_mappings):
        """Performs the pre live migrate on the destination host.

        This method will create the trunk adapter on the destination host,
        set its link state up, and attach it to the integration OVS switch.
        It also updates the vea_vlan_mappings to indicate which unique
        hypervisor VLAN should be used for this VIF for the migration operation
        to complete properly.

        :param vif: The virtual interface that will be migrated.  This may be
                    called network_info in other portions of the code.
        :param vea_vlan_mappings: The VEA VLAN mappings.  Key is the vif
                                  mac address, value is the destination's
                                  target hypervisor VLAN.
        """
        self._cleanup_orphan_adapters(vif,
                                      CONF.powervm.pvm_vswitch_for_novalink_io)
        mgmt_wrap = pvm_par.get_mgmt_partition(self.adapter)
        dev = _get_trunk_dev_name(vif)

        meta_attrs = PvmMetaAttrs(vif, self.instance)

        mtu = vif['network'].get_meta('mtu')

        # Find a specific free VLAN and create the Trunk in a single atomic
        # action.
        cna_w = pvm_cna.crt_trunk_with_free_vlan(
            self.adapter,
            self.host_uuid, [mgmt_wrap.uuid],
            CONF.powervm.pvm_vswitch_for_novalink_io,
            dev_name=dev,
            ovs_bridge=vif['network']['bridge'],
            ovs_ext_ids=str(meta_attrs),
            configured_mtu=mtu)[0]

        # Save this data for the migration command.
        vea_vlan_mappings[vif['address']] = cna_w.pvid
        LOG.info(
            "VIF with mac %(mac)s is going on trunk %(dev)s with PVID "
            "%(pvid)s", {
                'mac': vif['address'],
                'dev': dev,
                'pvid': cna_w.pvid
            },
            instance=self.instance)