Esempio n. 1
0
 def _cloud_init_vm_definition(self, cloud_init_hostname):
     if cloud_init_hostname:
         return types.Vm(initialization=types.Initialization(
             cloud_init=types.CloudInit(host=types.Host(
                 address=cloud_init_hostname))))
     else:
         return None
Esempio n. 2
0
def vm_run(prefix):
    engine = prefix.virt_env.engine_vm()
    api = engine.get_api_v4()
    host_names = [h.name() for h in prefix.virt_env.host_vms()]

    vms_service = api.system_service().vms_service()
    vm = vms_service.list(search='name=%s' % VM0_NAME)[0]
    vm_service = vms_service.vm_service(vm.id)
    vm_service.start(use_cloud_init=True,
                     vm=types.Vm(placement_policy=types.VmPlacementPolicy(
                         hosts=[types.Host(name=sorted(host_names)[0])], ),
                                 initialization=types.Initialization(
                                     domain='lago.example.com',
                                     cloud_init=types.CloudInit(
                                         host=types.Host(address='VM0'), ),
                                 )))
    testlib.assert_true_within_long(
        lambda: (vms_service.list(search='name=%s' % VM0_NAME)[0]).status ==
        types.VmStatus.UP, )