use of com.vmware.vim25.KeyValue in project cloudstack by apache.
the class LicenseAssignmentManagerMO method isFeatureSupported.
public boolean isFeatureSupported(String featureKey, ManagedObjectReference hostMor) throws Exception {
boolean featureSupported = false;
// Retrieve host license properties
List<KeyAnyValue> props = getHostLicenseProperties(hostMor);
// Check host license properties to see if specified feature is supported by the license.
for (KeyAnyValue prop : props) {
String key = prop.getKey();
if (key.equalsIgnoreCase(LICENSE_INFO_FEATURE)) {
KeyValue propValue = (KeyValue) prop.getValue();
if (propValue.getKey().equalsIgnoreCase(featureKey)) {
featureSupported = true;
break;
}
}
}
return featureSupported;
}
use of com.vmware.vim25.KeyValue in project photon-model by vmware.
the class OvfDeployer method deployOvf.
public ManagedObjectReference deployOvf(URI ovfUri, ManagedObjectReference host, ManagedObjectReference vmFolder, String vmName, List<OvfNetworkMapping> networks, ManagedObjectReference datastore, Collection<KeyValue> ovfProps, String deploymentConfig, ManagedObjectReference resourcePool) throws Exception {
String ovfDescriptor = getRetriever().retrieveAsString(ovfUri);
OvfCreateImportSpecParams params = new OvfCreateImportSpecParams();
params.setHostSystem(host);
params.setLocale("US");
params.setEntityName(vmName);
if (deploymentConfig == null) {
deploymentConfig = "";
}
params.setDeploymentOption(deploymentConfig);
params.getNetworkMapping().addAll(networks);
params.setDiskProvisioning(OvfCreateImportSpecParamsDiskProvisioningType.THIN.name());
if (ovfProps != null) {
params.getPropertyMapping().addAll(ovfProps);
}
ManagedObjectReference ovfManager = this.connection.getServiceContent().getOvfManager();
OvfCreateImportSpecResult importSpecResult = getVimPort().createImportSpec(ovfManager, ovfDescriptor, resourcePool, datastore, params);
if (!importSpecResult.getError().isEmpty()) {
return VimUtils.rethrow(importSpecResult.getError().get(0));
}
long totalBytes = getImportSizeBytes(importSpecResult);
ManagedObjectReference lease = getVimPort().importVApp(resourcePool, importSpecResult.getImportSpec(), vmFolder, host);
LeaseProgressUpdater leaseUpdater = new LeaseProgressUpdater(this.connection, lease, totalBytes);
GetMoRef get = new GetMoRef(this.connection);
HttpNfcLeaseInfo httpNfcLeaseInfo;
ScheduledExecutorService executorService = Executors.newScheduledThreadPool(1);
try {
leaseUpdater.awaitReady();
logger.info("Lease ready");
// start updating the lease
leaseUpdater.start(executorService);
httpNfcLeaseInfo = get.entityProp(lease, PROP_INFO);
List<HttpNfcLeaseDeviceUrl> deviceUrls = httpNfcLeaseInfo.getDeviceUrl();
String ip = this.connection.getURI().getHost();
String basePath = extractBasePath(ovfUri);
for (HttpNfcLeaseDeviceUrl deviceUrl : deviceUrls) {
String deviceKey = deviceUrl.getImportKey();
for (OvfFileItem ovfFileItem : importSpecResult.getFileItem()) {
if (deviceKey.equals(ovfFileItem.getDeviceId())) {
logger.debug("Importing device id: {}", deviceKey);
String sourceUri = computeDiskSourceUri(basePath, ovfFileItem);
String uploadUri = makUploadUri(ip, deviceUrl);
uploadVmdkFile(ovfFileItem, sourceUri, uploadUri, leaseUpdater, this.ovfRetriever.getClient());
logger.info("Completed uploading VMDK file {}", sourceUri);
}
}
}
// complete lease
leaseUpdater.complete();
} catch (Exception e) {
leaseUpdater.abort(VimUtils.convertExceptionToFault(e));
logger.info("Error importing ovf", e);
throw e;
} finally {
executorService.shutdown();
}
httpNfcLeaseInfo = get.entityProp(lease, PROP_INFO);
ManagedObjectReference entity = httpNfcLeaseInfo.getEntity();
// as this is an OVF it makes sense to enable the OVF transport
// only the guestInfo is enabled by default
VmConfigSpec spec = new VmConfigSpec();
spec.getOvfEnvironmentTransport().add(TRANSPORT_GUESTINFO);
spec.getOvfEnvironmentTransport().add(TRANSPORT_ISO);
VirtualMachineConfigSpec reconfig = new VirtualMachineConfigSpec();
reconfig.setVAppConfig(spec);
ManagedObjectReference reconfigTask = getVimPort().reconfigVMTask(entity, reconfig);
VimUtils.waitTaskEnd(this.connection, reconfigTask);
return entity;
}
use of com.vmware.vim25.KeyValue in project cs-actions by CloudSlang.
the class DeployOvfTemplateService method createLeaseSetup.
protected ImmutablePair<ManagedObjectReference, OvfCreateImportSpecResult> createLeaseSetup(final ConnectionResources connectionResources, final VmInputs vmInputs, final String templatePath, final Map<String, String> ovfNetworkMap, final Map<String, String> ovfPropertyMap) throws Exception {
final ManagedObjectReference ovfManager = getOvfManager(connectionResources);
final VmUtils vmUtils = new VmUtils();
final ManagedObjectReference resourcePool;
if (StringUtilities.isBlank(vmInputs.getClusterName())) {
resourcePool = vmUtils.getMorResourcePool(vmInputs.getResourcePool(), connectionResources);
} else {
ManagedObjectReference clusterMor = new MorObjectHandler().getSpecificMor(connectionResources, connectionResources.getMorRootFolder(), ClusterParameter.CLUSTER_COMPUTE_RESOURCE.getValue(), vmInputs.getClusterName());
resourcePool = vmUtils.getMorResourcePoolFromCluster(connectionResources, clusterMor, vmInputs.getResourcePool());
}
final ManagedObjectReference hostMor = vmUtils.getMorHost(vmInputs.getHostname(), connectionResources, null);
final ManagedObjectReference datastoreMor = vmUtils.getMorDataStore(vmInputs.getDataStore(), connectionResources, null, vmInputs);
final ManagedObjectReference folderMor = vmUtils.getMorFolder(vmInputs.getFolderName(), connectionResources);
final List<OvfNetworkMapping> ovfNetworkMappings = getOvfNetworkMappings(ovfNetworkMap, connectionResources);
final List<KeyValue> ovfPropertyMappings = getOvfPropertyMappings(ovfPropertyMap);
final OvfCreateImportSpecResult importSpecResult = connectionResources.getVimPortType().createImportSpec(ovfManager, getOvfTemplateAsString(templatePath), resourcePool, datastoreMor, getOvfCreateImportSpecParams(vmInputs, hostMor, ovfNetworkMappings, ovfPropertyMappings));
checkImportSpecResultForErrors(importSpecResult);
final ManagedObjectReference httpNfcLease = OvfUtils.getHttpNfcLease(connectionResources, importSpecResult.getImportSpec(), resourcePool, hostMor, folderMor);
return ImmutablePair.of(httpNfcLease, importSpecResult);
}
use of com.vmware.vim25.KeyValue in project cs-actions by CloudSlang.
the class DeployOvfTemplateService method getOvfPropertyMappings.
private List<KeyValue> getOvfPropertyMappings(final Map<String, String> ovfPropertyMap) {
final List<KeyValue> mappings = new ArrayList<>();
for (Map.Entry<String, String> entry : ovfPropertyMap.entrySet()) {
final KeyValue keyValue = new KeyValue();
keyValue.setKey(entry.getKey());
keyValue.setValue(entry.getValue());
mappings.add(keyValue);
}
return mappings;
}
use of com.vmware.vim25.KeyValue in project wavefront-proxy by wavefrontHQ.
the class OtlpProtobufUtils method annotationsFromAttributes.
@VisibleForTesting
static List<Annotation> annotationsFromAttributes(List<KeyValue> attributesList) {
List<Annotation> annotations = new ArrayList<>();
for (KeyValue attribute : attributesList) {
String key = attribute.getKey().equals(SOURCE_KEY) ? "_source" : attribute.getKey();
Annotation.Builder annotationBuilder = Annotation.newBuilder().setKey(key);
if (!attribute.hasValue()) {
annotationBuilder.setValue("");
} else {
annotationBuilder.setValue(fromAnyValue(attribute.getValue()));
}
annotations.add(annotationBuilder.build());
}
return annotations;
}
Aggregations