Search in sources :

Example 16 with ScopedLabel

use of com.emc.storageos.db.client.model.ScopedLabel in project coprhd-controller by CoprHD.

the class XIVRestOperationsHelper method setTag.

private void setTag(DataObject object, String scope, String label) {
    if (label == null) {
        // shouldn't happen
        label = "";
    }
    ScopedLabel newScopedLabel = new ScopedLabel(scope, label);
    ScopedLabelSet tagSet = object.getTag();
    if (tagSet == null) {
        tagSet = new ScopedLabelSet();
        tagSet.add(newScopedLabel);
        object.setTag(tagSet);
    } else if (tagSet.contains(newScopedLabel)) {
        return;
    } else {
        removeLabel(tagSet, scope);
        tagSet.add(newScopedLabel);
    }
    _dbClient.persistObject(object);
}
Also used : ScopedLabel(com.emc.storageos.db.client.model.ScopedLabel) ScopedLabelSet(com.emc.storageos.db.client.model.ScopedLabelSet)

Example 17 with ScopedLabel

use of com.emc.storageos.db.client.model.ScopedLabel in project coprhd-controller by CoprHD.

the class XIVRestOperationsHelper method removeLabel.

private void removeLabel(ScopedLabelSet tagSet, String scope) {
    ScopedLabel oldScopedLabel = null;
    Iterator<ScopedLabel> itr = tagSet.iterator();
    while (itr.hasNext()) {
        ScopedLabel scopedLabel = itr.next();
        if (scope.equals(scopedLabel.getScope())) {
            oldScopedLabel = scopedLabel;
            break;
        }
    }
    if (oldScopedLabel != null) {
        tagSet.remove(oldScopedLabel);
    }
}
Also used : ScopedLabel(com.emc.storageos.db.client.model.ScopedLabel)

Example 18 with ScopedLabel

use of com.emc.storageos.db.client.model.ScopedLabel in project coprhd-controller by CoprHD.

the class TagUtils method getTagValue.

private static String getTagValue(DataObject dataObject, String tagName) {
    if (dataObject == null || (dataObject.getTag() == null)) {
        return null;
    }
    List<String> tags = new ArrayList<>();
    for (ScopedLabel sl : dataObject.getTag()) {
        tags.add("" + sl.getLabel());
    }
    Map<String, String> currentMachineTags = parseTags(tags);
    return currentMachineTags.get(tagName);
}
Also used : ScopedLabel(com.emc.storageos.db.client.model.ScopedLabel) ArrayList(java.util.ArrayList)

Example 19 with ScopedLabel

use of com.emc.storageos.db.client.model.ScopedLabel in project coprhd-controller by CoprHD.

the class VolumeBootVolumeMigration method tagBootVolumes.

/**
 * For all volumes, fill in the boot volume tag, if certain loose criteria is met
 */
private void tagBootVolumes() {
    log.info("Updating volumes to contain boot tag.");
    DbClient dbClient = this.getDbClient();
    List<URI> hostURIs = dbClient.queryByType(Host.class, false);
    Iterator<Host> hosts = dbClient.queryIterativeObjects(Host.class, hostURIs);
    while (hosts.hasNext()) {
        Host host = hosts.next();
        log.info("Examining Host (id={}) for boot volume upgrade", host.getId().toString());
        // If there's no boot volume, there's nothing to upgrade.
        if (NullColumnValueGetter.isNullURI(host.getBootVolumeId())) {
            continue;
        }
        Volume volume = dbClient.queryObject(Volume.class, host.getBootVolumeId());
        // if it's not in the DB, set it back to "null" on the host
        if (volume == null) {
            host.setBootVolumeId(NullColumnValueGetter.getNullURI());
            dbClient.updateObject(host);
            continue;
        }
        // If it's already a boot volume, move on
        if (isVolumeBootVolume(volume)) {
            continue;
        }
        // Add the tag.
        ScopedLabelSet tagSet = volume.getTag();
        if (tagSet == null) {
            tagSet = new ScopedLabelSet();
            volume.setTag(tagSet);
        }
        // Drop the new tag in the tag list
        ScopedLabel tagLabel = new ScopedLabel(volume.getTenant().getURI().toString(), getBootVolumeTagName() + "=" + host.getId());
        tagSet.add(tagLabel);
        // Update the volume object
        dbClient.updateObject(volume);
    }
}
Also used : DbClient(com.emc.storageos.db.client.DbClient) Volume(com.emc.storageos.db.client.model.Volume) ScopedLabel(com.emc.storageos.db.client.model.ScopedLabel) Host(com.emc.storageos.db.client.model.Host) URI(java.net.URI) ScopedLabelSet(com.emc.storageos.db.client.model.ScopedLabelSet)

Example 20 with ScopedLabel

use of com.emc.storageos.db.client.model.ScopedLabel in project coprhd-controller by CoprHD.

the class XIVSmisCommandHelper method setTag.

public void setTag(DataObject object, String scope, String label) {
    if (label == null) {
        // shouldn't happen
        label = "";
    }
    ScopedLabel newScopedLabel = new ScopedLabel(scope, label);
    ScopedLabelSet tagSet = object.getTag();
    if (tagSet == null) {
        tagSet = new ScopedLabelSet();
        tagSet.add(newScopedLabel);
        object.setTag(tagSet);
    } else if (tagSet.contains(newScopedLabel)) {
        return;
    } else {
        removeLabel(tagSet, scope);
        tagSet.add(newScopedLabel);
    }
    _dbClient.persistObject(object);
}
Also used : ScopedLabel(com.emc.storageos.db.client.model.ScopedLabel) ScopedLabelSet(com.emc.storageos.db.client.model.ScopedLabelSet)

Aggregations

ScopedLabel (com.emc.storageos.db.client.model.ScopedLabel)23 ScopedLabelSet (com.emc.storageos.db.client.model.ScopedLabelSet)14 URI (java.net.URI)9 Volume (com.emc.storageos.db.client.model.Volume)7 NamedURI (com.emc.storageos.db.client.model.NamedURI)6 ArrayList (java.util.ArrayList)5 Host (com.emc.storageos.db.client.model.Host)4 Project (com.emc.storageos.db.client.model.Project)4 VirtualPool (com.emc.storageos.db.client.model.VirtualPool)4 Consumes (javax.ws.rs.Consumes)4 POST (javax.ws.rs.POST)4 Produces (javax.ws.rs.Produces)4 BlockServiceApi (com.emc.storageos.api.service.impl.resource.BlockServiceApi)3 BlockConsistencyGroup (com.emc.storageos.db.client.model.BlockConsistencyGroup)3 BlockSnapshot (com.emc.storageos.db.client.model.BlockSnapshot)3 StringMap (com.emc.storageos.db.client.model.StringMap)3 TaskList (com.emc.storageos.model.TaskList)3 TaskResourceRep (com.emc.storageos.model.TaskResourceRep)3 BlockFullCopyManager (com.emc.storageos.api.service.impl.resource.fullcopy.BlockFullCopyManager)2 DbClient (com.emc.storageos.db.client.DbClient)2