use of com.emc.sa.machinetags.MachineTagsCollection in project coprhd-controller by CoprHD.
the class VMwareDatastoreTagger method removeDatastoreTagsFromFilesystem.
private void removeDatastoreTagsFromFilesystem(URI filesystemId, Integer index) {
final FileShareRestRep filesystem = client.fileSystems().get(filesystemId);
final MachineTagsCollection tags = getFileSystemTags(filesystem);
final MachineTagsCollection removeTags = tags.findTags(NAMESPACE, index, DATASTORE, MOUNT_POINT, VCENTER, DATACENTER);
client.fileSystems().removeTags(filesystemId, removeTags.generateRawTags());
}
use of com.emc.sa.machinetags.MachineTagsCollection in project coprhd-controller by CoprHD.
the class VMwareDatastoreTagger method getDatastoreTag.
private static MachineTag getDatastoreTag(MachineTagsCollection tags, URI vcenterId, URI datacenterId, String datastoreName) {
final MachineTagsCollection datastoreTags = tags.findAll(NAMESPACE, DATASTORE);
for (MachineTag datastoreTag : datastoreTags) {
final Integer index = datastoreTag.index;
final MachineTag vcenterTag = tags.find(NAMESPACE, VCENTER, index);
final MachineTag datacenterTag = tags.find(NAMESPACE, DATACENTER, index);
final boolean isVcenter = StringUtils.equals(vcenterTag.value, vcenterId.toString());
final boolean isDatacenter = StringUtils.equals(datacenterTag.value, datacenterId.toString());
final boolean isDatastore = StringUtils.equals(datastoreTag.value, datastoreName);
if (isVcenter && isDatacenter && isDatastore) {
return datastoreTag;
}
}
return null;
}
use of com.emc.sa.machinetags.MachineTagsCollection in project coprhd-controller by CoprHD.
the class VMwareDatastoreTagger method addDatastoreTagsToFilesystem.
public Integer addDatastoreTagsToFilesystem(URI filesystemId, URI vcenterId, URI datacenterId, String datastoreName, String nfsMountPoint) {
final FileShareRestRep filesystem = client.fileSystems().get(filesystemId);
final MachineTagsCollection tags = getFileSystemTags(filesystem);
for (int i = 1; i < Integer.MAX_VALUE; i++) {
MachineTag datastoreTag = tags.find(NAMESPACE, DATASTORE, i);
if (datastoreTag == null) {
final Integer index = Integer.valueOf(i);
final DatastoreMachineTag tag = new DatastoreMachineTag(index, vcenterId.toString(), datacenterId.toString(), datastoreName, nfsMountPoint);
addDatastoreTagsToFilesystem(filesystemId, tag);
return Integer.valueOf(i);
}
}
throw new IllegalStateException("Attempt to find a valid index to use for this datastore tag failed. All values from 1 up to Integer.MAX_VALUE are being used.");
}
use of com.emc.sa.machinetags.MachineTagsCollection in project coprhd-controller by CoprHD.
the class VMwareDatastoreTagger method getDatastoreMountPoint.
public static String getDatastoreMountPoint(FileShareRestRep filesystem, URI vcenterId, URI datacenterId, String datastoreName) {
final MachineTagsCollection tags = getFileSystemTags(filesystem);
final MachineTag datastoreTag = getDatastoreTag(tags, vcenterId, datacenterId, datastoreName);
final MachineTag mountPointTag = tags.find(NAMESPACE, MOUNT_POINT, datastoreTag.index);
return mountPointTag.value;
}
use of com.emc.sa.machinetags.MachineTagsCollection in project coprhd-controller by CoprHD.
the class VMwareDatastoreTagger method getDatastoreTagsOnFilesystem.
private List<DatastoreMachineTag> getDatastoreTagsOnFilesystem(FileShareRestRep filesystem) {
final List<DatastoreMachineTag> returnTags = Lists.newArrayList();
final MachineTagsCollection tags = getFileSystemTags(filesystem);
final MachineTagsCollection datastoreTags = tags.findAll(NAMESPACE, DATASTORE);
for (MachineTag datastore : datastoreTags) {
final Integer index = datastore.index;
final MachineTag mountPoint = tags.find(NAMESPACE, MOUNT_POINT, index);
final MachineTag vcenter = tags.find(NAMESPACE, VCENTER, index);
final MachineTag datacenter = tags.find(NAMESPACE, DATACENTER, index);
final DatastoreMachineTag datastoreTag = new DatastoreMachineTag(datastore, vcenter, datacenter, mountPoint);
returnTags.add(datastoreTag);
}
return returnTags;
}
Aggregations