@Test public void test() throws ApiSenderException { ImageInventory iminv = deployer.images.get("TestImage"); InstanceOfferingInventory ioinv = deployer.instanceOfferings.get("TestInstanceOffering"); L3NetworkInventory l3inv = deployer.l3Networks.get("TestL3Network2"); APICreateVmInstanceMsg msg = new APICreateVmInstanceMsg(); msg.setImageUuid(iminv.getUuid()); msg.setInstanceOfferingUuid(ioinv.getUuid()); List<String> l3uuids = new ArrayList<String>(); l3uuids.add(l3inv.getUuid()); msg.setL3NetworkUuids(l3uuids); msg.setName("TestVm"); msg.setSession(session); msg.setServiceId(ApiMediatorConstant.SERVICE_ID); msg.setType(VmInstanceConstant.USER_VM_TYPE); ApiSender sender = api.getApiSender(); sender.send(msg, APICreateVmInstanceEvent.class); }
VmInstanceInventory create() throws ApiSenderException { APICreateVmInstanceMsg msg = new APICreateVmInstanceMsg(); msg.setClusterUuid(clusterUUid); msg.setImageUuid(imageUuid); msg.setName(name); msg.setHostUuid(hostUuid); msg.setDataDiskOfferingUuids(diskOfferingUuids); msg.setInstanceOfferingUuid(instanceOfferingUuid); msg.setL3NetworkUuids(l3NetworkUuids); msg.setType(VmInstanceConstant.USER_VM_TYPE); msg.setZoneUuid(zoneUuid); msg.setHostUuid(hostUuid); msg.setServiceId(ApiMediatorConstant.SERVICE_ID); msg.setSession(api.getAdminSession()); ApiSender sender = new ApiSender(); APICreateVmInstanceEvent evt = sender.send(msg, APICreateVmInstanceEvent.class); return evt.getInventory(); }