Search in sources :

Example 1 with StackTags

use of com.sequenceiq.cloudbreak.cloud.model.StackTags in project cloudbreak by hortonworks.

the class StackToStackResponseConverter method convertTags.

private void convertTags(StackResponse stackJson, Json tag) {
    try {
        if (tag != null) {
            if (tag.getValue() != null) {
                StackTags stackTag = tag.get(StackTags.class);
                stackJson.setApplicationTags(stackTag.getApplicationTags());
                stackJson.setDefaultTags(stackTag.getDefaultTags());
                stackJson.setUserDefinedTags(stackTag.getUserDefinedTags());
            } else {
                stackJson.setApplicationTags(new HashMap<>());
                stackJson.setDefaultTags(new HashMap<>());
                stackJson.setUserDefinedTags(new HashMap<>());
            }
        } else {
            stackJson.setApplicationTags(new HashMap<>());
            stackJson.setDefaultTags(new HashMap<>());
            stackJson.setUserDefinedTags(new HashMap<>());
        }
    } catch (Exception e) {
        LOGGER.error("Failed to convert dynamic tags.", e);
    }
}
Also used : StackTags(com.sequenceiq.cloudbreak.cloud.model.StackTags) CloudbreakImageNotFoundException(com.sequenceiq.cloudbreak.core.CloudbreakImageNotFoundException)

Example 2 with StackTags

use of com.sequenceiq.cloudbreak.cloud.model.StackTags in project cloudbreak by hortonworks.

the class StackToStackV2RequestConverter method prepareTags.

private void prepareTags(Stack source, StackV2Request stackV2Request) {
    try {
        StackTags stackTags = source.getTags().get(StackTags.class);
        if (stackTags.getUserDefinedTags() != null) {
            Tags tags = new Tags();
            tags.setApplicationTags(null);
            tags.setDefaultTags(null);
            tags.setUserDefinedTags(stackTags.getUserDefinedTags());
            stackV2Request.setTags(tags);
        }
    } catch (IOException e) {
        stackV2Request.setTags(null);
    }
}
Also used : StackTags(com.sequenceiq.cloudbreak.cloud.model.StackTags) IOException(java.io.IOException) Tags(com.sequenceiq.cloudbreak.api.model.v2.Tags) StackTags(com.sequenceiq.cloudbreak.cloud.model.StackTags)

Example 3 with StackTags

use of com.sequenceiq.cloudbreak.cloud.model.StackTags in project cloudbreak by hortonworks.

the class StackToCloudStackConverter method getUserDefinedTags.

public Map<String, String> getUserDefinedTags(Stack stack) {
    Map<String, String> result = Maps.newHashMap();
    try {
        if (stack.getTags() != null) {
            StackTags stackTag = stack.getTags().get(StackTags.class);
            Map<String, String> userDefined = stackTag.getUserDefinedTags();
            Map<String, String> defaultTags = stackTag.getDefaultTags();
            if (userDefined != null) {
                result.putAll(userDefined);
            }
            if (defaultTags != null) {
                result.putAll(defaultTags);
            }
        }
    } catch (IOException e) {
        LOGGER.warn("Exception during converting user defined tags.", e);
    }
    return result;
}
Also used : StackTags(com.sequenceiq.cloudbreak.cloud.model.StackTags) IOException(java.io.IOException)

Aggregations

StackTags (com.sequenceiq.cloudbreak.cloud.model.StackTags)3 IOException (java.io.IOException)2 Tags (com.sequenceiq.cloudbreak.api.model.v2.Tags)1 CloudbreakImageNotFoundException (com.sequenceiq.cloudbreak.core.CloudbreakImageNotFoundException)1