Search in sources :

Example 1 with KeyValue

use of io.opentelemetry.proto.common.v1.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;
}
Also used : KeyValue(com.vmware.vim25.KeyValue) KeyAnyValue(com.vmware.vim25.KeyAnyValue)

Example 2 with KeyValue

use of io.opentelemetry.proto.common.v1.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);
}
Also used : KeyValue(com.vmware.vim25.KeyValue) OvfNetworkMapping(com.vmware.vim25.OvfNetworkMapping) VmUtils(io.cloudslang.content.vmware.services.utils.VmUtils) OvfCreateImportSpecResult(com.vmware.vim25.OvfCreateImportSpecResult) MorObjectHandler(io.cloudslang.content.vmware.services.helpers.MorObjectHandler) ManagedObjectReference(com.vmware.vim25.ManagedObjectReference)

Example 3 with KeyValue

use of io.opentelemetry.proto.common.v1.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;
}
Also used : KeyValue(com.vmware.vim25.KeyValue) ArrayList(java.util.ArrayList) Map(java.util.Map)

Example 4 with KeyValue

use of io.opentelemetry.proto.common.v1.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;
}
Also used : KeyValue(io.opentelemetry.proto.common.v1.KeyValue) ArrayList(java.util.ArrayList) ByteString(com.google.protobuf.ByteString) Annotation(wavefront.report.Annotation) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 5 with KeyValue

use of io.opentelemetry.proto.common.v1.KeyValue in project wavefront-proxy by wavefrontHQ.

the class OtlpProtobufUtilsTest method transformSpanSetsSourceFromResourceAttributesNotSpanAttributes.

@Test
public void transformSpanSetsSourceFromResourceAttributesNotSpanAttributes() {
    List<KeyValue> resourceAttrs = Collections.singletonList(otlpAttribute("source", "a-src"));
    Span otlpSpan = OtlpTestHelpers.otlpSpanGenerator().addAttributes(otlpAttribute("source", "span-level")).build();
    actualSpan = OtlpProtobufUtils.transformSpan(otlpSpan, resourceAttrs, null, null, "ignored");
    assertEquals("a-src", actualSpan.getSource());
    assertThat(actualSpan.getAnnotations(), not(hasItem(new Annotation("source", "a-src"))));
    assertThat(actualSpan.getAnnotations(), hasItem(new Annotation("_source", "span-level")));
}
Also used : KeyValue(io.opentelemetry.proto.common.v1.KeyValue) Span(io.opentelemetry.proto.trace.v1.Span) Annotation(wavefront.report.Annotation) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Aggregations

KeyValue (io.opentelemetry.proto.common.v1.KeyValue)15 Test (org.junit.Test)11 ByteString (com.google.protobuf.ByteString)10 Annotation (wavefront.report.Annotation)8 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)6 Span (io.opentelemetry.proto.trace.v1.Span)5 KeyValue (com.vmware.vim25.KeyValue)3 AnyValue (io.opentelemetry.proto.common.v1.AnyValue)3 ArrayList (java.util.ArrayList)3 VisibleForTesting (com.google.common.annotations.VisibleForTesting)2 ArrayValue (io.opentelemetry.proto.common.v1.ArrayValue)2 KeyAnyValue (com.vmware.vim25.KeyAnyValue)1 ManagedObjectReference (com.vmware.vim25.ManagedObjectReference)1 OvfCreateImportSpecResult (com.vmware.vim25.OvfCreateImportSpecResult)1 OvfNetworkMapping (com.vmware.vim25.OvfNetworkMapping)1 MorObjectHandler (io.cloudslang.content.vmware.services.helpers.MorObjectHandler)1 VmUtils (io.cloudslang.content.vmware.services.utils.VmUtils)1 AttributesBuilder (io.opentelemetry.api.common.AttributesBuilder)1 List (java.util.List)1 Map (java.util.Map)1