use of com.vmware.vim25.VirtualDeviceConfigSpecOperation in project CloudStack-archive by CloudStack-extras.
the class VirtualMachineMO method configureVm.
public boolean configureVm(Ternary<VirtualDevice, VirtualDeviceConfigSpecOperation, VirtualDeviceConfigSpecFileOperation>[] devices) throws Exception {
assert (devices != null);
VirtualMachineConfigSpec configSpec = new VirtualMachineConfigSpec();
VirtualDeviceConfigSpec[] deviceConfigSpecArray = new VirtualDeviceConfigSpec[devices.length];
int i = 0;
for (Ternary<VirtualDevice, VirtualDeviceConfigSpecOperation, VirtualDeviceConfigSpecFileOperation> deviceTernary : devices) {
VirtualDeviceConfigSpec deviceConfigSpec = new VirtualDeviceConfigSpec();
deviceConfigSpec.setDevice(deviceTernary.first());
deviceConfigSpec.setOperation(deviceTernary.second());
deviceConfigSpec.setFileOperation(deviceTernary.third());
deviceConfigSpecArray[i++] = deviceConfigSpec;
}
configSpec.setDeviceChange(deviceConfigSpecArray);
ManagedObjectReference morTask = _context.getService().reconfigVM_Task(_mor, configSpec);
String result = _context.getServiceUtil().waitForTask(morTask);
if (result.equals("sucess")) {
_context.waitForTaskProgressDone(morTask);
return true;
} else {
s_logger.error("VMware reconfigVM_Task failed due to " + TaskMO.getTaskFailureInfo(_context, morTask));
}
return false;
}
use of com.vmware.vim25.VirtualDeviceConfigSpecOperation in project cloudstack by apache.
the class VirtualMachineMO method configureVm.
public boolean configureVm(Ternary<VirtualDevice, VirtualDeviceConfigSpecOperation, VirtualDeviceConfigSpecFileOperation>[] devices) throws Exception {
assert (devices != null);
VirtualMachineConfigSpec configSpec = new VirtualMachineConfigSpec();
VirtualDeviceConfigSpec[] deviceConfigSpecArray = new VirtualDeviceConfigSpec[devices.length];
int i = 0;
for (Ternary<VirtualDevice, VirtualDeviceConfigSpecOperation, VirtualDeviceConfigSpecFileOperation> deviceTernary : devices) {
VirtualDeviceConfigSpec deviceConfigSpec = new VirtualDeviceConfigSpec();
deviceConfigSpec.setDevice(deviceTernary.first());
deviceConfigSpec.setOperation(deviceTernary.second());
deviceConfigSpec.setFileOperation(deviceTernary.third());
deviceConfigSpecArray[i++] = deviceConfigSpec;
}
configSpec.getDeviceChange().addAll(Arrays.asList(deviceConfigSpecArray));
ManagedObjectReference morTask = _context.getService().reconfigVMTask(_mor, configSpec);
boolean result = _context.getVimClient().waitForTask(morTask);
if (result) {
_context.waitForTaskProgressDone(morTask);
return true;
} else {
s_logger.error("VMware reconfigVM_Task failed due to " + TaskMO.getTaskFailureInfo(_context, morTask));
}
return false;
}
Aggregations