com.vmware.vim25.OptionValue Java Examples
The following examples show how to use
com.vmware.vim25.OptionValue.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FakeModel.java From teamcity-vmware-plugin with Apache License 2.0 | 6 votes |
public FakeVirtualMachine addVM(String name, boolean isRunning, VirtualMachineCloneSpec spec){ final FakeVirtualMachine vm = new FakeVirtualMachine(name, name.contains("template"), isRunning); putVM(name, vm); if (spec != null && spec.getLocation()!= null && VirtualMachineRelocateDiskMoveOptions.createNewChildDiskBacking.name().equals(spec.getLocation().getDiskMoveType())){ //((FakeVirtualMachine)vm).set } if (spec != null && spec.getConfig() != null) { final OptionValue[] extraConfig = spec.getConfig().getExtraConfig(); if (extraConfig != null) { for (OptionValue optionValue : extraConfig) { vm.addCustomParam(optionValue.getKey(), String.valueOf(optionValue.getValue())); } } } return vm; }
Example #2
Source File: VirtualMachineMO.java From cloudstack with Apache License 2.0 | 6 votes |
public Pair<String, Integer> getVncPort(String hostNetworkName) throws Exception { HostMO hostMo = getRunningHost(); VmwareHypervisorHostNetworkSummary summary = hostMo.getHyperHostNetworkSummary(hostNetworkName); VirtualMachineConfigInfo configInfo = getConfigInfo(); List<OptionValue> values = configInfo.getExtraConfig(); if (values != null) { for (OptionValue option : values) { if (option.getKey().equals("RemoteDisplay.vnc.port")) { String value = (String)option.getValue(); if (value != null) { return new Pair<String, Integer>(summary.getHostIp(), Integer.parseInt(value)); } } } } return new Pair<String, Integer>(summary.getHostIp(), 0); }
Example #3
Source File: HypervisorHostHelper.java From cloudstack with Apache License 2.0 | 5 votes |
public static String getOVFParamValue(VirtualMachineConfigSpec config) { String paramVal = ""; List<OptionValue> options = config.getExtraConfig(); for (OptionValue option : options) { if (OVA_OPTION_KEY_BOOTDISK.equalsIgnoreCase(option.getKey())) { paramVal = (String)option.getValue(); break; } } return paramVal; }
Example #4
Source File: VirtualMachineMO.java From cloudstack with Apache License 2.0 | 5 votes |
public boolean setVncConfigInfo(boolean enableVnc, String vncPassword, int vncPort, String keyboard) throws Exception { VirtualMachineConfigSpec vmConfigSpec = new VirtualMachineConfigSpec(); OptionValue[] vncOptions = VmwareHelper.composeVncOptions(null, enableVnc, vncPassword, vncPort, keyboard); vmConfigSpec.getExtraConfig().addAll(Arrays.asList(vncOptions)); ManagedObjectReference morTask = _context.getService().reconfigVMTask(_mor, vmConfigSpec); 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; }
Example #5
Source File: ClusterMO.java From cloudstack with Apache License 2.0 | 5 votes |
public HashMap<String, Integer> getVmVncPortsOnCluster() throws Exception { ObjectContent[] ocs = getVmPropertiesOnHyperHost(new String[] {"name", "config.extraConfig[\"RemoteDisplay.vnc.port\"]"}); HashMap<String, Integer> portInfo = new HashMap<String, Integer>(); if (ocs != null && ocs.length > 0) { for (ObjectContent oc : ocs) { List<DynamicProperty> objProps = oc.getPropSet(); if (objProps != null) { String name = null; String value = null; for (DynamicProperty objProp : objProps) { if (objProp.getName().equals("name")) { name = (String)objProp.getVal(); } else { OptionValue optValue = (OptionValue)objProp.getVal(); value = (String)optValue.getValue(); } } if (name != null && value != null) { portInfo.put(name, Integer.parseInt(value)); } } } } return portInfo; }
Example #6
Source File: VmwareHelper.java From cloudstack with Apache License 2.0 | 5 votes |
public static OptionValue[] composeVncOptions(OptionValue[] optionsToMerge, boolean enableVnc, String vncPassword, int vncPort, String keyboardLayout) { int numOptions = 3; boolean needKeyboardSetup = false; if (keyboardLayout != null && !keyboardLayout.isEmpty()) { numOptions++; needKeyboardSetup = true; } if (optionsToMerge != null) numOptions += optionsToMerge.length; OptionValue[] options = new OptionValue[numOptions]; int i = 0; if (optionsToMerge != null) { for (int j = 0; j < optionsToMerge.length; j++) options[i++] = optionsToMerge[j]; } options[i] = new OptionValue(); options[i].setKey("RemoteDisplay.vnc.enabled"); options[i++].setValue(enableVnc ? "true" : "false"); options[i] = new OptionValue(); options[i].setKey("RemoteDisplay.vnc.password"); options[i++].setValue(vncPassword); options[i] = new OptionValue(); options[i].setKey("RemoteDisplay.vnc.port"); options[i++].setValue("" + vncPort); if (needKeyboardSetup) { options[i] = new OptionValue(); options[i].setKey("RemoteDisplay.vnc.keymap"); options[i++].setValue(keyboardLayout); } return options; }
Example #7
Source File: HostMO.java From cloudstack with Apache License 2.0 | 4 votes |
public HashMap<String, Integer> getVmVncPortsOnHost() throws Exception { int key = getCustomFieldKey("VirtualMachine", CustomFieldConstants.CLOUD_VM_INTERNAL_NAME); if (key == 0) { s_logger.warn("Custom field " + CustomFieldConstants.CLOUD_VM_INTERNAL_NAME + " is not registered ?!"); } ObjectContent[] ocs = getVmPropertiesOnHyperHost(new String[] {"name", "config.extraConfig[\"RemoteDisplay.vnc.port\"]", "value[" + key + "]"}); HashMap<String, Integer> portInfo = new HashMap<String, Integer>(); if (ocs != null && ocs.length > 0) { for (ObjectContent oc : ocs) { List<DynamicProperty> objProps = oc.getPropSet(); if (objProps != null) { String vmName = null; String value = null; String vmInternalCSName = null; for (DynamicProperty objProp : objProps) { if (objProp.getName().equals("name")) { vmName = (String)objProp.getVal(); } else if (objProp.getName().startsWith("value[")) { if (objProp.getVal() != null) vmInternalCSName = ((CustomFieldStringValue)objProp.getVal()).getValue(); } else { OptionValue optValue = (OptionValue)objProp.getVal(); value = (String)optValue.getValue(); } } if (vmInternalCSName != null && isUserVMInternalCSName(vmInternalCSName)) vmName = vmInternalCSName; if (vmName != null && value != null) { portInfo.put(vmName, Integer.parseInt(value)); } } } } return portInfo; }