コード例 #1
0
ファイル: test_vif.py プロジェクト: openstack/nova-powervm
    def test_plug_secure_rmc_vif_for_rebuild(self, mock_pvm_uuid, mock_crt):
        # Mock up the data
        mock_pvm_uuid.return_value = 'lpar_uuid'
        mock_crt.return_value = mock.Mock()
        self.slot_mgr.build_map.get_mgmt_vea_slot = mock.Mock(
            return_value=(None, None))
        mock_instance = mock.MagicMock(
            system_metadata={'mgmt_interface_mac': 'old_mac'})

        # Run the method
        vif.plug_secure_rmc_vif(self.adpt, mock_instance, 'host_uuid',
                                self.slot_mgr)

        # Validate responses
        # Validate that as part of rebuild, pvm_cna.crt_cna is called with
        # 'old_mac' stored in instance's syetem_metadata. Also, the slot
        # number is not passed. This is because as part of rebuild, the
        # instance is destroyed and spawned again. When the instance is
        # destroyed, the slot data is removed. When instance is spawned,
        # the required volume and network info is got as part of BDM
        # and network info dicts. The only missing information is mgmt
        # interface mac address.
        mock_crt.assert_called_once_with(self.adpt,
                                         'host_uuid',
                                         'lpar_uuid',
                                         4094,
                                         vswitch='MGMTSWITCH',
                                         crt_vswitch=True,
                                         slot_num=None,
                                         mac_addr='old_mac')
        # Validate that register_cna is called.
        self.slot_mgr.register_cna.assert_called_once_with(
            mock_crt.return_value)
コード例 #2
0
ファイル: network.py プロジェクト: adreznec/nova-powervm
    def execute_impl(self, vm_cnas):
        # If configured to not use RMC mgmt vifs, then return None.  Need to
        # return None because the Config Drive step (which may be used...may
        # not be) required the mgmt vif.
        if not CONF.powervm.use_rmc_mgmt_vif:
            LOG.debug('No management VIF created for instance %s as the conf '
                      'option use_rmc_mgmt_vif is set to False',
                      self.instance.name)
            return None

        LOG.info(_LI('Plugging the Management Network Interface to instance '
                     '%s'), self.instance.name, instance=self.instance)
        # Determine if we need to create the secure RMC VIF.  This should only
        # be needed if there is not a VIF on the secure RMC vSwitch
        vswitch_w = vif.get_secure_rmc_vswitch(self.adapter, self.host_uuid)
        if vswitch_w is None:
            LOG.debug('No management VIF created for instance %s due to '
                      'lack of Management Virtual Switch',
                      self.instance.name)
            return None

        # This next check verifies that there are no existing NICs on the
        # vSwitch, so that the VM does not end up with multiple RMC VIFs.
        for cna_w in vm_cnas:
            if cna_w.vswitch_uri == vswitch_w.href:
                LOG.debug('Management VIF already created for instance %s',
                          self.instance.name)
                return None

        # Return the created management CNA
        return vif.plug_secure_rmc_vif(
            self.adapter, self.instance, self.host_uuid, self.slot_mgr)
コード例 #3
0
ファイル: test_vif.py プロジェクト: andymcc/nova-powervm
    def test_plug_secure_rmc_vif_with_slot(self, mock_pvm_uuid, mock_crt):
        # Mock up the data
        mock_pvm_uuid.return_value = 'lpar_uuid'
        mock_crt.return_value = mock.Mock()
        self.slot_mgr.build_map.get_mgmt_vea_slot = mock.Mock(
            return_value=('mac_addr', 5))

        # Run the method
        vif.plug_secure_rmc_vif(self.adpt, 'instance', 'host_uuid',
                                self.slot_mgr)

        # Validate responses
        mock_crt.assert_called_once_with(
            self.adpt, 'host_uuid', 'lpar_uuid', 4094, vswitch='MGMTSWITCH',
            crt_vswitch=True, slot_num=5, mac_addr='mac_addr')
        self.assertFalse(self.slot_mgr.called)
コード例 #4
0
ファイル: test_vif.py プロジェクト: amojohn/nova-powervm
    def test_plug_secure_rmc_vif(self, mock_pvm_uuid, mock_crt):
        # Mock up the data
        mock_pvm_uuid.return_value = 'lpar_uuid'
        mock_crt.return_value = mock.Mock()
        self.slot_mgr.build_map.get_mgmt_vea_slot = mock.Mock(
            return_value=(None, None))
        mock_instance = mock.MagicMock(system_metadata={})

        # Run the method
        vif.plug_secure_rmc_vif(self.adpt, mock_instance, 'host_uuid',
                                self.slot_mgr)

        # Validate responses
        mock_crt.assert_called_once_with(
            self.adpt, 'host_uuid', 'lpar_uuid', 4094, vswitch='MGMTSWITCH',
            crt_vswitch=True, slot_num=None, mac_addr=None)
        self.slot_mgr.register_cna.assert_called_once_with(
            mock_crt.return_value)
コード例 #5
0
    def execute(self, vm_cnas):
        # If configured to not use RMC mgmt vifs, then return None.  Need to
        # return None because the Config Drive step (which may be used...may
        # not be) required the mgmt vif.
        if not CONF.powervm.use_rmc_mgmt_vif:
            LOG.debug(
                'No management VIF created because '
                'CONF.powervm.use_rmc_mgmt_vif is False',
                instance=self.instance)
            return None

        LOG.info('Plugging the management network interface.',
                 instance=self.instance)
        # Determine if we need to create the secure RMC VIF.  This should only
        # be needed if there is not a VIF on the secure RMC vSwitch
        vswitch = vif.get_secure_rmc_vswitch(self.adapter, self.host_uuid)
        if vswitch is None:
            LOG.warning(
                'No management VIF created due to lack of management '
                'virtual switch',
                instance=self.instance)
            return None

        # This next check verifies that there are no existing NICs on the
        # vSwitch, so that the VM does not end up with multiple RMC VIFs.
        if vm_cnas is None:
            has_mgmt_vif = vm.get_cnas(self.adapter,
                                       self.instance,
                                       vswitch_uri=vswitch.href)
        else:
            has_mgmt_vif = vswitch.href in [cna.vswitch_uri for cna in vm_cnas]

        if has_mgmt_vif:
            LOG.debug('Management VIF already exists.', instance=self.instance)
            return None

        # Return the created management CNA
        return vif.plug_secure_rmc_vif(self.adapter, self.instance,
                                       self.host_uuid, self.slot_mgr)