use of com.emc.storageos.model.NamedRelatedResourceRep in project coprhd-controller by CoprHD.
the class FileProvider method getFileSystemPolicies.
@Asset("fileSystemPolicies")
@AssetDependencies("fileFilesystemWithPolicies")
public List<AssetOption> getFileSystemPolicies(AssetOptionsContext ctx, URI fsId) {
List<AssetOption> options = Lists.newArrayList();
List<FilePolicyRestRep> fileSystemPolicies = getAllFileSystemLevelPolicies(ctx);
for (FilePolicyRestRep policyRestRep : fileSystemPolicies) {
// workaround to display policy name in oder receipt: if fsId is null then list all the policy
if (fsId == null) {
options.add(new AssetOption(policyRestRep.getId(), policyRestRep.getName()));
} else if (policyRestRep.getAssignedResources() != null && !policyRestRep.getAssignedResources().isEmpty()) {
for (NamedRelatedResourceRep resource : policyRestRep.getAssignedResources()) {
if (resource.getId().equals(fsId)) {
options.add(new AssetOption(policyRestRep.getId(), policyRestRep.getName()));
}
}
}
}
AssetOptionsUtils.sortOptionsByLabel(options);
return options;
}
use of com.emc.storageos.model.NamedRelatedResourceRep in project coprhd-controller by CoprHD.
the class FileProvider method getAllFileSystemLevelPolicies.
private List<FilePolicyRestRep> getAllFileSystemLevelPolicies(AssetOptionsContext ctx) {
ViPRCoreClient client = api(ctx);
List<FilePolicyRestRep> fileSystemPolicies = new ArrayList<FilePolicyRestRep>();
FilePolicyListRestRep policies = client.fileProtectionPolicies().listFilePolicies();
if (policies != null && !policies.getFilePolicies().isEmpty()) {
for (NamedRelatedResourceRep policy : policies.getFilePolicies()) {
FilePolicyRestRep policyRestRep = client.fileProtectionPolicies().get(policy.getId());
if (policyRestRep != null && policyRestRep.getAppliedAt() != null && policyRestRep.getAppliedAt().equalsIgnoreCase("file_system")) {
fileSystemPolicies.add(policyRestRep);
}
}
}
return fileSystemPolicies;
}
use of com.emc.storageos.model.NamedRelatedResourceRep in project coprhd-controller by CoprHD.
the class BlockStorageUtils method getReplicationGroupFullCopies.
public static Table<URI, String, VolumeRestRep> getReplicationGroupFullCopies(List<NamedRelatedResourceRep> volumeUris) {
// Group volumes by storage system and replication group
Table<URI, String, VolumeRestRep> storageRgToVolumes = HashBasedTable.create();
List<URI> parentVolIds = Lists.newArrayList();
for (NamedRelatedResourceRep volumeUri : volumeUris) {
VolumeRestRep volume = execute(new GetBlockVolume(volumeUri.getId()));
if (volume != null && volume.getProtection() != null && volume.getProtection().getFullCopyRep() != null && volume.getProtection().getFullCopyRep().getAssociatedSourceVolume() != null) {
parentVolIds.add(volume.getProtection().getFullCopyRep().getAssociatedSourceVolume().getId());
}
List<VolumeRestRep> parentVolumes = execute(new GetBlockVolumes(parentVolIds));
if (parentVolumes != null && !parentVolumes.isEmpty()) {
for (VolumeRestRep parentVolume : parentVolumes) {
String rgName = stripRPTargetFromReplicationGroup(parentVolume.getReplicationGroupInstance());
URI storage = parentVolume.getStorageController();
if (!storageRgToVolumes.contains(storage, rgName)) {
storageRgToVolumes.put(storage, rgName, volume);
}
}
}
}
return storageRgToVolumes;
}
use of com.emc.storageos.model.NamedRelatedResourceRep in project coprhd-controller by CoprHD.
the class CallHomeServiceImpl method toTask.
private TaskResourceRep toTask(Task task) {
TaskResourceRep taskResourceRep = new TaskResourceRep();
taskResourceRep.setId(task.getId());
NamedURI resource = task.getResource();
NamedRelatedResourceRep namedRelatedResourceRep = new NamedRelatedResourceRep(resource.getURI(), new RestLinkRep("self", URI.create("/" + resource.getURI())), resource.getName());
taskResourceRep.setResource(namedRelatedResourceRep);
if (!StringUtils.isBlank(task.getRequestId())) {
taskResourceRep.setOpId(task.getRequestId());
}
// Operation
taskResourceRep.setState(task.getStatus());
if (task.getServiceCode() != null) {
taskResourceRep.setServiceError(toServiceErrorRestRep(toServiceCode(task.getServiceCode()), task.getMessage()));
} else {
taskResourceRep.setMessage(task.getMessage());
}
taskResourceRep.setDescription(task.getDescription());
taskResourceRep.setStartTime(task.getStartTime());
taskResourceRep.setEndTime(task.getEndTime());
taskResourceRep.setProgress(task.getProgress() != null ? task.getProgress() : 0);
taskResourceRep.setQueuedStartTime(task.getQueuedStartTime());
taskResourceRep.setQueueName(task.getQueueName());
return taskResourceRep;
}
use of com.emc.storageos.model.NamedRelatedResourceRep in project coprhd-controller by CoprHD.
the class GeoMode method setupGeoTenantModeBase.
@BeforeClass
public static void setupGeoTenantModeBase() throws Exception {
VirtualDataCenters vdcs = superUserClient.vdcs();
List<NamedRelatedResourceRep> list = vdcs.list();
for (NamedRelatedResourceRep vdc : list) {
VirtualDataCenterRestRep restRep = superUserClient.vdcs().get(vdc.getId());
vdcList.add(restRep);
}
if (vdcList.size() < 2) {
String errorMsg = "env check fail, only one VDC, Geo test need at least 2 vdcs";
logger.error(errorMsg);
throw new Exception(errorMsg);
}
logger.info("grant " + superUser + " security admin in both VDCs");
ViPRCoreClient vdc1RootClient = new ViPRCoreClient(getVdcEndpointByIndex(0), true).withLogin("root", rootPassword);
ViPRClientHelper vdc1Helper = new ViPRClientHelper(vdc1RootClient);
vdc1Helper.addRoleAssignment(null, superUser, RoleOrAcl.SecurityAdmin.toString());
vdc1Helper.addRoleAssignment(null, superUser, RoleOrAcl.SystemAdmin.toString());
vdc1Helper.addRoleAssignment(null, superUser, RoleOrAcl.SystemMonitor.toString());
vdc1RootClient.auth().logout();
ViPRCoreClient vdc2RootClient = new ViPRCoreClient(getVdcEndpointByIndex(1), true).withLogin("root", rootPassword);
ViPRClientHelper vdc2Helper = new ViPRClientHelper(vdc2RootClient);
vdc2Helper.addRoleAssignment(null, superUser, RoleOrAcl.SecurityAdmin.toString());
vdc2Helper.addRoleAssignment(null, superUser, RoleOrAcl.SystemAdmin.toString());
vdc2Helper.addRoleAssignment(null, superUser, RoleOrAcl.SystemMonitor.toString());
vdc2RootClient.auth().logout();
}
Aggregations