def test_start_external_resource(self): """ start with external resource, as success status used retry """ fake_ctx = self.generate_node_context( properties={ 'use_external_resource': True, 'vcloud_config': { 'vdc': 'vdc_name' }, 'management_network': '_management_network' } ) fake_client = self.generate_client([{ 'is_connected': True, 'network_name': 'network_name', 'ip': '1.1.1.1' }]) with mock.patch( 'vcloud_plugin_common.VcloudAirClient.get', mock.MagicMock(return_value=fake_client) ): with self.assertRaises(cfy_exc.OperationRetry): server.start(ctx=fake_ctx)
def test_start(self): fake_ctx = self.generate_node_context() fake_client = self.generate_client([{ 'is_connected': True, 'network_name': 'network_name', 'ip': '1.1.1.1' }]) with mock.patch( 'vcloud_plugin_common.VcloudAirClient.get', mock.MagicMock(return_value=fake_client) ): # poweroff with error equal to None fake_client._vapp.me.get_status = mock.MagicMock( return_value=vcloud_plugin_common.STATUS_POWERED_OFF ) fake_client._vapp.poweron = mock.MagicMock( return_value=None ) with self.assertRaises(cfy_exc.NonRecoverableError): server.start(ctx=fake_ctx) fake_client._vapp.poweron.assert_called_with() self.check_get_vapp(fake_client, 'vapp_name') # poweroff with error in task fake_client._vapp.me.get_status = mock.MagicMock( return_value=vcloud_plugin_common.STATUS_POWERED_OFF ) fake_task = self.generate_task( vcloud_plugin_common.TASK_STATUS_ERROR ) fake_client._vapp.poweron = mock.MagicMock( return_value=fake_task ) with self.assertRaises(cfy_exc.NonRecoverableError): server.start(ctx=fake_ctx) # poweroff with success in task but not connected fake_client._vapp.me.get_status = mock.MagicMock( return_value=vcloud_plugin_common.STATUS_POWERED_OFF ) fake_task = self.generate_task( vcloud_plugin_common.TASK_STATUS_SUCCESS ) fake_client._vapp.poweron = mock.MagicMock( return_value=fake_task ) with self.assertRaises(cfy_exc.OperationRetry): server.start(ctx=fake_ctx) # poweron with success in task but not connected fake_client._vapp.me.get_status = mock.MagicMock( return_value=vcloud_plugin_common.STATUS_POWERED_OFF ) with self.assertRaises(cfy_exc.OperationRetry): server.start(ctx=fake_ctx) fake_client = self.generate_client([{ 'is_connected': True, 'network_name': '_management_network', 'ip': '1.1.1.1' }]) with mock.patch( 'vcloud_plugin_common.VcloudAirClient.get', mock.MagicMock(return_value=fake_client) ): # poweron with success in task and connected fake_client._vapp.me.get_status = mock.MagicMock( return_value=vcloud_plugin_common.STATUS_POWERED_ON ) with self.assertRaises(cfy_exc.OperationRetry): server.start(ctx=fake_ctx)
def test_start(self): fake_ctx = self.generate_node_context() fake_client = self.generate_client([{ 'is_connected': True, 'is_primary': True, 'network_name': 'network_name', 'ip': '1.1.1.1' }]) with mock.patch('vcloud_plugin_common.VcloudAirClient.get', mock.MagicMock(return_value=fake_client)): # poweroff with error equal to None fake_client._vapp.me.get_status = mock.MagicMock( return_value=vcloud_plugin_common.STATUS_POWERED_OFF) fake_client._vapp.poweron = mock.MagicMock(return_value=None) with self.assertRaises(cfy_exc.NonRecoverableError): server.start(ctx=fake_ctx) fake_client._vapp.poweron.assert_called_with() self.check_get_vapp(fake_client, 'vapp_name') # poweroff with error in task fake_client._vapp.me.get_status = mock.MagicMock( return_value=vcloud_plugin_common.STATUS_POWERED_OFF) fake_task = self.generate_task( vcloud_plugin_common.TASK_STATUS_ERROR) fake_client._vapp.poweron = mock.MagicMock(return_value=fake_task) with self.assertRaises(cfy_exc.NonRecoverableError): server.start(ctx=fake_ctx) fake_client = self.generate_client([{ 'is_connected': False, 'is_primary': False, 'network_name': 'network_name', 'ip': '1.1.1.1' }]) with mock.patch('vcloud_plugin_common.VcloudAirClient.get', mock.MagicMock(return_value=fake_client)): # poweroff with success in task but not connected fake_client._vapp.me.get_status = mock.MagicMock( return_value=vcloud_plugin_common.STATUS_POWERED_OFF) fake_task = self.generate_task( vcloud_plugin_common.TASK_STATUS_SUCCESS) fake_client._vapp.poweron = mock.MagicMock(return_value=fake_task) self.assertEquals(server.start(ctx=fake_ctx), None) # poweron with success in task but not connected fake_client._vapp.me.get_status = mock.MagicMock( return_value=vcloud_plugin_common.STATUS_POWERED_OFF) self.assertEquals(server.start(ctx=fake_ctx), None) fake_client = self.generate_client([{ 'is_connected': True, 'is_primary': True, 'network_name': '_management_network', 'ip': '1.1.1.1' }]) with mock.patch('vcloud_plugin_common.VcloudAirClient.get', mock.MagicMock(return_value=fake_client)): # poweron with success in task and connected fake_client._vapp.me.get_status = mock.MagicMock( return_value=vcloud_plugin_common.STATUS_POWERED_ON) self.assertEquals(server.start(ctx=fake_ctx), None)