Search in sources :

Example 1 with OptionValue

use of com.vmware.vim25.OptionValue in project CloudStack-archive by CloudStack-extras.

the class HostMO method getVmVncPortsOnHost.

public HashMap<String, Integer> getVmVncPortsOnHost() 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) {
            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;
}
Also used : ObjectContent(com.vmware.vim25.ObjectContent) DynamicProperty(com.vmware.vim25.DynamicProperty) HashMap(java.util.HashMap) OptionValue(com.vmware.vim25.OptionValue)

Example 2 with OptionValue

use of com.vmware.vim25.OptionValue in project CloudStack-archive by CloudStack-extras.

the class VirtualMachineMO method getVncPort.

public Pair<String, Integer> getVncPort(String hostNetworkName) throws Exception {
    HostMO hostMo = getRunningHost();
    VmwareHypervisorHostNetworkSummary summary = hostMo.getHyperHostNetworkSummary(hostNetworkName);
    VirtualMachineConfigInfo configInfo = getConfigInfo();
    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);
}
Also used : OptionValue(com.vmware.vim25.OptionValue) VirtualMachineConfigInfo(com.vmware.vim25.VirtualMachineConfigInfo) Pair(com.cloud.utils.Pair)

Example 3 with OptionValue

use of com.vmware.vim25.OptionValue in project cloudstack by apache.

the class VmwareResource method setNuageVspVrIpInExtraConfig.

private static void setNuageVspVrIpInExtraConfig(List<OptionValue> extraOptions, NicTO nicTo, String dvSwitchUuid) {
    if (nicTo.getBroadcastType() != BroadcastDomainType.Vsp) {
        return;
    }
    OptionValue newVal;
    if (nicTo.getType().equals(TrafficType.Guest) && dvSwitchUuid != null && nicTo.getGateway() != null && nicTo.getNetmask() != null) {
        String vrIp = nicTo.getBroadcastUri().getPath().substring(1);
        newVal = new OptionValue();
        newVal.setKey("vsp.vr-ip." + nicTo.getMac());
        newVal.setValue(vrIp);
        extraOptions.add(newVal);
        newVal = new OptionValue();
        newVal.setKey("vsp.dvswitch." + nicTo.getMac());
        newVal.setValue(dvSwitchUuid);
        extraOptions.add(newVal);
        if (s_logger.isDebugEnabled()) {
            s_logger.debug("NIC with MAC " + nicTo.getMac() + " and BroadcastDomainType " + nicTo.getBroadcastType() + " in network(" + nicTo.getGateway() + "/" + nicTo.getNetmask() + ") is " + nicTo.getType() + " traffic type. So, vsp-vr-ip is set in the extraconfig");
        }
    }
}
Also used : OptionValue(com.vmware.vim25.OptionValue)

Example 4 with OptionValue

use of com.vmware.vim25.OptionValue in project photon-model by vmware.

the class InstanceClient method populateSnapshotLimitValue.

private OptionValue populateSnapshotLimitValue(String snapshotLimitValue) {
    OptionValue ov = new OptionValue();
    ov.setKey(SNAPSHOT_LIMIT_CONFIG_STRING);
    ov.setValue(snapshotLimitValue);
    return ov;
}
Also used : OptionValue(com.vmware.vim25.OptionValue)

Example 5 with OptionValue

use of com.vmware.vim25.OptionValue in project cloudstack by apache.

the class VmwareResource method configCustomExtraOption.

private static void configCustomExtraOption(List<OptionValue> extraOptions, VirtualMachineTO vmSpec) {
    // we no longer to validation anymore
    for (Map.Entry<String, String> entry : vmSpec.getDetails().entrySet()) {
        if (entry.getKey().equalsIgnoreCase(VmDetailConstants.BOOT_MODE)) {
            continue;
        }
        OptionValue newVal = new OptionValue();
        newVal.setKey(entry.getKey());
        newVal.setValue(entry.getValue());
        extraOptions.add(newVal);
    }
}
Also used : OptionValue(com.vmware.vim25.OptionValue) Map(java.util.Map) EnumMap(java.util.EnumMap) HashMap(java.util.HashMap)

Aggregations

OptionValue (com.vmware.vim25.OptionValue)20 HashMap (java.util.HashMap)6 DynamicProperty (com.vmware.vim25.DynamicProperty)4 ManagedObjectReference (com.vmware.vim25.ManagedObjectReference)4 ObjectContent (com.vmware.vim25.ObjectContent)4 VirtualMachineConfigSpec (com.vmware.vim25.VirtualMachineConfigSpec)4 Pair (com.cloud.utils.Pair)3 Map (java.util.Map)3 NicTO (com.cloud.agent.api.to.NicTO)2 CloudException (com.cloud.exception.CloudException)2 InternalErrorException (com.cloud.exception.InternalErrorException)2 VmwareManager (com.cloud.hypervisor.vmware.manager.VmwareManager)2 VirtualMachineMO (com.cloud.hypervisor.vmware.mo.VirtualMachineMO)2 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)2 ArrayOfManagedObjectReference (com.vmware.vim25.ArrayOfManagedObjectReference)2 VirtualMachineConfigInfo (com.vmware.vim25.VirtualMachineConfigInfo)2 IOException (java.io.IOException)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)2 ConnectException (java.net.ConnectException)2 RemoteException (java.rmi.RemoteException)2