Subscribe

Issue with Rapid Cloning VM using VSC 4.2.1 through RCU API on iSCSI Datastores

Hi,

 

My use case is to Rapid clone VM from Template  through VSC 4.2.1 on iSCSI Datastore through RCU Utiliy API.

 

When trying to do this through RCU Utility API, the task is getting stuck at 50% not throwing any error , but for NFS datastore it is working fine.

From vCenter if we Rapid clone the template it is working fine for iSCSI as well as NFS  Datastore.

 

Screen shots attached

1. Task status Message Stucked 

2. Tells you List of Tasks triggered when Rapid Cloning a template thorugh vCenter.

 

List of tasks are not triggered when Rapid Cloning a template through RCU Utility API.(Not all the tasks listed in screen shot 2 are triggered when rapid cloning thorugh RCU Utility API

Following tasks are missing)

 

Reload Virtual machine
Initialize powering On
Power On Virtual Machine
Delete file

 

Running this Task on the following configuration

VSC Plugin : 4.2.1

vCenter Server :5.5.0

ESXi Host : ESXi 5.1.0

Storage Controller : ONTAP Version NetApp Release 8.2.2P1

 

Please help usif any thingwe are missing to set through API or any other issues to fix inorder to run this task work 

 

Here is the code used for this task


RcuUtil.ignoreSSL();

// the create request specification
RequestSpec requestSpec = new RequestSpec();
requestSpec.setVcUser(vUsername);
requestSpec.setVcPassword(vPassword);
requestSpec.setServiceUrl(vUrl);

if (type.equalsIgnoreCase("datacenter"))
{
type = "Datacenter";
} else if (type.equalsIgnoreCase("host"))
{
type = "HostSystem";
} else if (type.equalsIgnoreCase("cluster"))
{
type = "ClusterComputeResource";
} else if (type.equalsIgnoreCase("resourcepool"))
{
type = "ResourcePool";
} else
{
throw new Exception("Invalid container type");
}

// connect
URL wsdlLocation;

try
{
wsdlLocation = new URL(vsclocation + "/kamino/public/api?wsdl");
} catch (Exception e)
{
logger.error("Exception while creating URL " + vsclocation + "/kamino/public/api?wsdl");
throw new Exception("Exception while creating URL " + vsclocation + "/kamino/public/api?wsdl");
}

ApiImplService service = new ApiImplService(wsdlLocation);
Api port = service.getApiImplPort();

String sourceMoref = null;

try
{
sourceMoref = port.getMoref(vmName, "VirtualMachine", requestSpec);
} catch (SOAPFaultException e)
{
logger.error("Exception while getting VM info to clone using VSC. Please check the log." + e.getCause());
throw new Exception("Exception while getting VM info to clone using VSC " + e.getLocalizedMessage());
}

if (sourceMoref == null)
{
throw new Exception("Unable to find vm " + vmName);
}

List<VmFileSpec> files = null;

try
{
files = port.getVmFiles(sourceMoref, requestSpec);
} catch (SOAPFaultException e)
{
logger.error("Exception while getting VM file info to clone using VSC. Please check the log."
+ e.getCause());
throw new Exception("Exception while getting VM file info to clone using VSC " + e.getLocalizedMessage());
}

// the NetApp controller that the destination datastore resides on
ControllerSpec controllerSpec = new ControllerSpec();
controllerSpec.setIpAddress(filerName);
controllerSpec.setUsername(userid);
controllerSpec.setPassword(pwd);
controllerSpec.setSsl(ssl);

// set each datastore spec to the controller we just defined
for (VmFileSpec file : files)
{
file.getDestDatastoreSpec().setController(controllerSpec);
}

// the new VM details (an empty VmSpec causes the cloning engine to use default values)
Clones clones = new Clones();
Entry entry = new Entry();
// Adding list to poweron vm after clone
List<String> vmList = new ArrayList<String>();
for (int i = 0; i < cloneCount; i++)
{
// this one we power on...
String cloneName = vmCloneName /*+ i*/;
entry = new Entry();
entry.setKey(cloneName);
vmList.add(cloneName);
VmSpec vspec = new VmSpec();
GuestCustomizationSpec gspec = new GuestCustomizationSpec();
// gspec.setName(value);
vspec.setCustSpec(gspec);
vspec.setPowerOn(true);
entry.setValue(vspec);
clones.getEntry().add(entry);
}

// the clone specification
CloneSpec cloneSpec = new CloneSpec();
// the source VM or template
cloneSpec.setTemplateMoref(sourceMoref);

// the container in which to create new clones (datacenter, cluster, host, or resource pool)
String containerMoref = null;

try
{
containerMoref = port.getMoref(containerName, type, requestSpec);
} catch (SOAPFaultException e)
{
logger.error("Exception while getting Datacenter info to clone using VSC. Please check the log."
+ e.getCause());
throw new Exception("Exception while getting Datacenter info to clone using VSC " + e.getLocalizedMessage());
}

cloneSpec.setContainerMoref(containerMoref);

// the file info created above
cloneSpec.getFiles().addAll(files);
// the clone info created above
cloneSpec.setClones(clones);

// the complete request specification
requestSpec.setCloneSpec(cloneSpec);

String TaskMOR = null;

try
{
// submit the clone request
TaskMOR = port.createClones(requestSpec);
} catch (SOAPFaultException e)
{
logger.error("Exception while cloning using VSC. Please check the log." + e.getCause());
throw new Exception("Exception while cloning using VSC " + e.getLocalizedMessage());
}

logger.info("RCU API returned " + TaskMOR);

TaskStatus tstat = new TaskStatus();

if (tstat.getTaskStatus(vUsername, vPassword, vUrl, TaskMOR))
{
if(powerOn)
{
ServiceInstance si = new ServiceInstance(new URL(vUrl), vUsername, vPassword);
Folder rootFolder = si.getRootFolder();
for(String clonedvm : vmList)
{
VirtualMachine vm = (VirtualMachine) new InventoryNavigator(rootFolder).searchManagedEntity("VirtualMachine", clonedvm);
if(vm != null)
{
Task task = vm.powerOnVM_Task(null);
TaskMOR = task.getMOR().get_value();
logger.info("TaskMOR: " + TaskMOR);
String status = task.waitForTask();
logger.info("task on VM " + clonedvm + " completed with status " + status);

if (!Task.SUCCESS.equals(status))
{
TaskInfo ti = task.getTaskInfo();

if (ti != null)
{
if (ti.getError() != null)
{
status = status + ": " + ti.getError().getLocalizedMessage();
}
}

logger.error("Powering ON completed on VM " + clonedvm + " with status " + status);
throw new Exception(status);
}
}
else
{
logger.error("Unable to find cloned vm:" + clonedvm);
}
}
}
}


return TaskMOR;

 

Thanks,

Ramji