Beispiel #1
0
 def execute(self):
     LOG.info(_LI('Renaming instance to name: %s'),
              self.name,
              instance=self.instance)
     wrap = vm.rename(self.adapter, self.host_uuid, self.instance,
                      self.vm_name)
     return wrap
Beispiel #2
0
    def test_rename(self, mock_get_inst):
        instance = objects.Instance(**powervm.TEST_INSTANCE)

        entry = mock.Mock()
        entry.update.return_value = 'NewEntry'
        new_entry = vm.rename(self.apt, 'mock_host_uuid', instance, 'new_name',
                              entry=entry)
        self.assertEqual('new_name', entry.name)
        entry.update.assert_called_once_with()
        self.assertEqual('NewEntry', new_entry)

        # Test optional entry parameter
        entry.reset_mock()
        mock_get_inst.return_value = entry
        new_entry = vm.rename(self.apt, 'mock_host_uuid', instance, 'new_name')
        mock_get_inst.assert_called_once_with(self.apt, instance,
                                              'mock_host_uuid')
        self.assertEqual('new_name', entry.name)
        entry.update.assert_called_once_with()
        self.assertEqual('NewEntry', new_entry)
Beispiel #3
0
    def test_rename(self, mock_get_inst, mock_entry_transaction):
        instance = objects.Instance(**powervm.TEST_INSTANCE)

        mock_entry_transaction.side_effect = lambda x: x

        entry = mock.Mock()
        entry.update.return_value = 'NewEntry'
        new_entry = vm.rename(self.apt, instance, 'new_name', entry=entry)
        self.assertEqual('new_name', entry.name)
        entry.update.assert_called_once_with()
        mock_entry_transaction.assert_called_once_with(mock.ANY)
        self.assertEqual('NewEntry', new_entry)
        self.san_lpar_name.assert_called_with('new_name')
        self.san_lpar_name.reset_mock()

        # Test optional entry parameter
        entry.reset_mock()
        mock_get_inst.return_value = entry
        new_entry = vm.rename(self.apt, instance, 'new_name')
        mock_get_inst.assert_called_once_with(self.apt, instance)
        self.assertEqual('new_name', entry.name)
        entry.update.assert_called_once_with()
        self.assertEqual('NewEntry', new_entry)
        self.san_lpar_name.assert_called_with('new_name')
Beispiel #4
0
    def test_rename(self, mock_get_inst, mock_entry_transaction):
        instance = objects.Instance(**powervm.TEST_INSTANCE)

        mock_entry_transaction.side_effect = lambda x: x

        entry = mock.Mock()
        entry.update.return_value = 'NewEntry'
        new_entry = vm.rename(self.apt, instance, 'new_name', entry=entry)
        self.assertEqual('new_name', entry.name)
        entry.update.assert_called_once_with()
        mock_entry_transaction.assert_called_once_with(mock.ANY)
        self.assertEqual('NewEntry', new_entry)
        self.san_lpar_name.assert_called_with('new_name')
        self.san_lpar_name.reset_mock()

        # Test optional entry parameter
        entry.reset_mock()
        mock_get_inst.return_value = entry
        new_entry = vm.rename(self.apt, instance, 'new_name')
        mock_get_inst.assert_called_once_with(self.apt, instance)
        self.assertEqual('new_name', entry.name)
        entry.update.assert_called_once_with()
        self.assertEqual('NewEntry', new_entry)
        self.san_lpar_name.assert_called_with('new_name')
Beispiel #5
0
 def execute(self):
     LOG.info('Renaming instance to name: %s',
              self.name,
              instance=self.instance)
     return vm.rename(self.adapter, self.instance, self.vm_name)
Beispiel #6
0
 def execute(self):
     LOG.info(_LI('Renaming instance to name: %s'), self.name,
              instance=self.instance)
     wrap = vm.rename(self.adapter, self.host_uuid, self.instance,
                      self.vm_name)
     return wrap
Beispiel #7
0
 def execute_impl(self):
     LOG.info(_LI('Renaming instance to name: %s'), self.name,
              instance=self.instance)
     return vm.rename(self.adapter, self.instance, self.vm_name)