@attr(tags=['advanced', 'eip', 'advancedns', 'basic', 'sg'])
def test_05_deploy_startvm_false_change_so(self):
    'Test Deploy Virtual Machine with startVM=false and change service offering\n        '
    self.debug(('Deploying instance in the account: %s' % self.account.name))
    self.virtual_machine = VirtualMachine.create(self.apiclient, self.services['virtual_machine'], accountid=self.account.name, domainid=self.account.domainid, serviceofferingid=self.service_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.id)
    self.debug(('Verify listVirtualMachines response for virtual machine: %s' % self.virtual_machine.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 with startvm=false')
    medium_service_off = ServiceOffering.create(self.apiclient, self.services['service_offering'])
    self.cleanup.append(medium_service_off)
    self.debug(('Changing service offering for instance: %s' % self.virtual_machine.name))
    try:
        self.virtual_machine.change_service_offering(self.apiclient, medium_service_off.id)
    except Exception as e:
        self.fail(('Change service offering failed: %s' % e))
    self.debug(('Starting the instance: %s' % self.virtual_machine.name))
    self.virtual_machine.start(self.apiclient)
    self.debug(('Instance: %s started' % self.virtual_machine.name))
    listedvm = VirtualMachine.list(self.apiclient, id=self.virtual_machine.id)
    self.assert_(isinstance(listedvm, list))
    self.assert_((len(listedvm) > 0))
    self.assertEqual(listedvm[0].serviceofferingid, medium_service_off.id, msg='VM did not change service offering')
    return
Test Deploy Virtual Machine with startVM=false and change service offering
@attr(tags=['advanced', 'eip', 'advancedns', 'basic', 'sg'])
def test_05_deploy_startvm_false_change_so(self):
    '\n        '
    self.debug(('Deploying instance in the account: %s' % self.account.name))
    self.virtual_machine = VirtualMachine.create(self.apiclient, self.services['virtual_machine'], accountid=self.account.name, domainid=self.account.domainid, serviceofferingid=self.service_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.id)
    self.debug(('Verify listVirtualMachines response for virtual machine: %s' % self.virtual_machine.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 with startvm=false')
    medium_service_off = ServiceOffering.create(self.apiclient, self.services['service_offering'])
    self.cleanup.append(medium_service_off)
    self.debug(('Changing service offering for instance: %s' % self.virtual_machine.name))
    try:
        self.virtual_machine.change_service_offering(self.apiclient, medium_service_off.id)
    except Exception as e:
        self.fail(('Change service offering failed: %s' % e))
    self.debug(('Starting the instance: %s' % self.virtual_machine.name))
    self.virtual_machine.start(self.apiclient)
    self.debug(('Instance: %s started' % self.virtual_machine.name))
    listedvm = VirtualMachine.list(self.apiclient, id=self.virtual_machine.id)
    self.assert_(isinstance(listedvm, list))
    self.assert_((len(listedvm) > 0))
    self.assertEqual(listedvm[0].serviceofferingid, medium_service_off.id, msg='VM did not change service offering')
    return