@attr(tags=['advanced', 'eip', 'advancedns', 'basic', 'sg'])
def test_01_deploy_vm_no_startvm(self):
    'Test Deploy Virtual Machine with no startVM parameter\n        '
    self.debug(('Deploying instance in the account: %s' % self.account.name))
    self.virtual_machine_1 = VirtualMachine.create(self.apiclient, self.services['virtual_machine'], accountid=self.account.name, domainid=self.account.domainid, serviceofferingid=self.service_offering.id, diskofferingid=self.disk_offering.id, startvm=False)
    self.debug(('Deployed instance in account: %s' % self.account.name))
    list_vm_response = list_virtual_machines(self.apiclient, id=self.virtual_machine_1.id)
    self.debug(('Verify listVirtualMachines response for virtual machine: %s' % self.virtual_machine_1.id))
    self.assertEqual(isinstance(list_vm_response, list), True, 'Check list response returns a valid list')
    vm_response = list_vm_response[0]
    self.assertEqual(vm_response.state, 'Stopped', 'VM should be in stopped state after deployment')
    self.debug('Checking the router state after VM deployment')
    routers = Router.list(self.apiclient, account=self.account.name, domainid=self.account.domainid, listall=True)
    self.assertEqual(routers, None, 'List routers should return empty response')
    self.debug(('Deploying another instance (startvm=true) in the account: %s' % self.account.name))
    self.virtual_machine_2 = VirtualMachine.create(self.apiclient, self.services['virtual_machine'], accountid=self.account.name, domainid=self.account.domainid, serviceofferingid=self.service_offering.id, diskofferingid=self.disk_offering.id, startvm=True)
    self.debug(('Deployed instance in account: %s' % self.account.name))
    list_vm_response = list_virtual_machines(self.apiclient, id=self.virtual_machine_2.id)
    self.debug(('Verify listVirtualMachines response for virtual machine: %s' % self.virtual_machine_2.id))
    self.assertEqual(isinstance(list_vm_response, list), True, 'Check list response returns a valid list')
    vm_response = list_vm_response[0]
    self.assertEqual(vm_response.state, 'Running', 'VM should be in Running state after deployment')
    self.debug('Checking the router state after VM deployment')
    routers = Router.list(self.apiclient, account=self.account.name, domainid=self.account.domainid, listall=True)
    self.assertEqual(isinstance(routers, list), True, 'List routers should not return empty response')
    for router in routers:
        self.debug(('Router state: %s' % router.state))
        self.assertEqual(router.state, 'Running', 'Router should be in running state when instance is running in the account')
    self.debug(('Destroying the running VM:%s' % self.virtual_machine_2.name))
    self.virtual_machine_2.delete(self.apiclient)
    self.debug('Instance destroyed..waiting till expunge interval')
    interval = list_configurations(self.apiclient, name='expunge.interval')
    delay = list_configurations(self.apiclient, name='expunge.delay')
    time.sleep(((int(interval[0].value) + int(delay[0].value)) * 2))
    self.debug('Checking the router state after VM deployment')
    routers = Router.list(self.apiclient, account=self.account.name, domainid=self.account.domainid, listall=True)
    self.assertNotEqual(routers, None, 'Router should get deleted after expunge delay+wait')
    return
Test Deploy Virtual Machine with no startVM parameter
@attr(tags=['advanced', 'eip', 'advancedns', 'basic', 'sg'])
def test_01_deploy_vm_no_startvm(self):
    '\n        '
    self.debug(('Deploying instance in the account: %s' % self.account.name))
    self.virtual_machine_1 = VirtualMachine.create(self.apiclient, self.services['virtual_machine'], accountid=self.account.name, domainid=self.account.domainid, serviceofferingid=self.service_offering.id, diskofferingid=self.disk_offering.id, startvm=False)
    self.debug(('Deployed instance in account: %s' % self.account.name))
    list_vm_response = list_virtual_machines(self.apiclient, id=self.virtual_machine_1.id)
    self.debug(('Verify listVirtualMachines response for virtual machine: %s' % self.virtual_machine_1.id))
    self.assertEqual(isinstance(list_vm_response, list), True, 'Check list response returns a valid list')
    vm_response = list_vm_response[0]
    self.assertEqual(vm_response.state, 'Stopped', 'VM should be in stopped state after deployment')
    self.debug('Checking the router state after VM deployment')
    routers = Router.list(self.apiclient, account=self.account.name, domainid=self.account.domainid, listall=True)
    self.assertEqual(routers, None, 'List routers should return empty response')
    self.debug(('Deploying another instance (startvm=true) in the account: %s' % self.account.name))
    self.virtual_machine_2 = VirtualMachine.create(self.apiclient, self.services['virtual_machine'], accountid=self.account.name, domainid=self.account.domainid, serviceofferingid=self.service_offering.id, diskofferingid=self.disk_offering.id, startvm=True)
    self.debug(('Deployed instance in account: %s' % self.account.name))
    list_vm_response = list_virtual_machines(self.apiclient, id=self.virtual_machine_2.id)
    self.debug(('Verify listVirtualMachines response for virtual machine: %s' % self.virtual_machine_2.id))
    self.assertEqual(isinstance(list_vm_response, list), True, 'Check list response returns a valid list')
    vm_response = list_vm_response[0]
    self.assertEqual(vm_response.state, 'Running', 'VM should be in Running state after deployment')
    self.debug('Checking the router state after VM deployment')
    routers = Router.list(self.apiclient, account=self.account.name, domainid=self.account.domainid, listall=True)
    self.assertEqual(isinstance(routers, list), True, 'List routers should not return empty response')
    for router in routers:
        self.debug(('Router state: %s' % router.state))
        self.assertEqual(router.state, 'Running', 'Router should be in running state when instance is running in the account')
    self.debug(('Destroying the running VM:%s' % self.virtual_machine_2.name))
    self.virtual_machine_2.delete(self.apiclient)
    self.debug('Instance destroyed..waiting till expunge interval')
    interval = list_configurations(self.apiclient, name='expunge.interval')
    delay = list_configurations(self.apiclient, name='expunge.delay')
    time.sleep(((int(interval[0].value) + int(delay[0].value)) * 2))
    self.debug('Checking the router state after VM deployment')
    routers = Router.list(self.apiclient, account=self.account.name, domainid=self.account.domainid, listall=True)
    self.assertNotEqual(routers, None, 'Router should get deleted after expunge delay+wait')
    return