3.5.14.1 Java

Importing the Assembly

The WsDevClient class contains the following code to handle the assembly import:

final Job importAssemblyJob = api.repositoryImportAssembly(testRepoId, assemblyUrl);
System.out.println("import assembly job id: " + importAssemblyJob.getId());
testAssemblyId = waitForJobComplete(api, importAssemblyJob, Assembly.class); 

The assemblyUrl is defined in the WsDevClient.properties file. The URL must point to a valid assembly package that Oracle VM Manager can access and download.

Importing a Virtual Machine From An Assembly

After the assembly has been imported into Oracle VM Manager you may want to import a virtual machine from within the assembly into your environment. First, you need to obtain the assemblyVm ID for the virtual machine that you want to import. For this, the WsDevClient class includes the following code to loop over the Vm ID's within the assembly. The code is simple and selects the first ID that it detects in the loop.

assemblyVms = api.assemblyVmGetListById(assembly.getAssemblyVmIds());
Id<AssemblyVm> testAssemblyVmId = null;
for (final AssemblyVm assemblyVm : assemblyVms)
{
    if (testAssemblyVmId == null)
    {
        testAssemblyVmId = assemblyVm.getId();
    }

Once an assemblyVmId has been set, the vmCreateFromAssemblyVm method can be called to create the new virtual machine:

if (testAssemblyVmId != null)
{
    final Job importVmFromAssemblyJob = api.vmCreateFromAssemblyVm(testAssemblyVmId);
    System.out.println("import vm from assembly job id: " + importVmFromAssemblyJob.getId());
    importedAssemblyVmId = waitForJobComplete(api, importVmFromAssemblyJob, Vm.class);
}