use of com.emc.storageos.db.client.model.TenantOrg in project coprhd-controller by CoprHD.
the class BasePermissionsHelper method checkForActiveTenantRoleAssignmentsUsingUserGroup.
/**
* Checks whether the given the user group is present the any of the
* tenants role-assignments or not
*
* @param label to check if any tenants role-assignments uses user group or not.
* @return set of URI's tenants that uses the user group.
*/
public Set<URI> checkForActiveTenantRoleAssignmentsUsingUserGroup(String label) {
Set<URI> tenantsUsingUserGroup = null;
// Find all the configured tenant IDs based on the type.
List<URI> tenantURIList = _dbClient.queryByType(TenantOrg.class, true);
if (tenantURIList == null || !tenantURIList.iterator().hasNext()) {
_log.error("There are no tenants configured.");
return tenantsUsingUserGroup;
}
// Find all the configured tenant objects based on the given list of IDs.
List<TenantOrg> tenants = _dbClient.queryObject(TenantOrg.class, tenantURIList);
if (CollectionUtils.isEmpty(tenants)) {
_log.error("Could not find the tenant objects for the Ids {}", tenantURIList.toString());
return tenantsUsingUserGroup;
}
tenantsUsingUserGroup = new HashSet<URI>();
for (TenantOrg tenant : tenants) {
if (tenant == null) {
_log.debug("Invalid tenant");
continue;
}
if (CollectionUtils.isEmpty(tenant.getRoleAssignments())) {
_log.debug("Role assignments are not configured for tenant {}", tenant.getLabel());
continue;
}
Set<String> roleAssignmentKeys = tenant.getRoleAssignments().keySet();
if (checkUserGroupWithPermissionKeys(label, roleAssignmentKeys)) {
tenantsUsingUserGroup.add(tenant.getId());
}
}
return tenantsUsingUserGroup;
}
use of com.emc.storageos.db.client.model.TenantOrg in project coprhd-controller by CoprHD.
the class VNXUnityBlockStorageDevice method doCreateVolumes.
@Override
public void doCreateVolumes(StorageSystem storage, StoragePool storagePool, String opId, List<Volume> volumes, VirtualPoolCapabilityValuesWrapper capabilities, TaskCompleter taskCompleter) throws DeviceControllerException {
logger.info("creating volumes, array: {}, pool : {}", storage.getSerialNumber(), storagePool.getNativeId());
VNXeApiClient apiClient = getVnxUnityClient(storage);
List<String> jobs = new ArrayList<String>();
boolean opFailed = false;
try {
boolean isCG = false;
Volume vol = volumes.get(0);
String cgName = vol.getReplicationGroupInstance();
if (vol.getConsistencyGroup() != null && NullColumnValueGetter.isNotNullValue(cgName)) {
isCG = true;
}
List<String> volNames = new ArrayList<String>();
String autoTierPolicyName = null;
InvokeTestFailure.internalOnlyInvokeTestFailure(InvokeTestFailure.ARTIFICIAL_FAILURE_022);
for (Volume volume : volumes) {
String tenantName = "";
try {
TenantOrg tenant = dbClient.queryObject(TenantOrg.class, volume.getTenant().getURI());
tenantName = tenant.getLabel();
} catch (DatabaseException e) {
logger.error("Error lookup TenantOrb object", e);
}
String label = nameGenerator.generate(tenantName, volume.getLabel(), volume.getId().toString(), '-', VNXeConstants.MAX_NAME_LENGTH);
autoTierPolicyName = ControllerUtils.getAutoTieringPolicyName(volume.getId(), dbClient);
if (autoTierPolicyName.equals(Constants.NONE)) {
autoTierPolicyName = null;
}
volume.setNativeGuid(label);
dbClient.updateObject(volume);
if (!isCG) {
VNXeCommandJob job = apiClient.createLun(label, storagePool.getNativeId(), volume.getCapacity(), volume.getThinlyProvisioned(), autoTierPolicyName);
jobs.add(job.getId());
} else {
volNames.add(label);
}
}
if (isCG) {
logger.info(String.format("cg %s for the volume", cgName));
String cgId = apiClient.getConsistencyGroupIdByName(cgName);
VNXeUtils.getCGLock(workflowService, storage, cgName, opId);
VNXeCommandJob job = apiClient.createLunsInConsistencyGroup(volNames, storagePool.getNativeId(), vol.getCapacity(), vol.getThinlyProvisioned(), autoTierPolicyName, cgId);
jobs.add(job.getId());
}
VNXeCreateVolumesJob createVolumesJob = new VNXeCreateVolumesJob(jobs, storage.getId(), taskCompleter, storagePool.getId(), isCG);
ControllerServiceImpl.enqueueJob(new QueueJob(createVolumesJob));
InvokeTestFailure.internalOnlyInvokeTestFailure(InvokeTestFailure.ARTIFICIAL_FAILURE_023);
} catch (VNXeException e) {
logger.error("Create volumes got the exception", e);
opFailed = true;
taskCompleter.error(dbClient, e);
} catch (Exception ex) {
logger.error("Create volumes got the exception", ex);
opFailed = true;
ServiceError error = DeviceControllerErrors.vnxe.jobFailed("CreateVolumes", ex.getMessage());
taskCompleter.error(dbClient, error);
}
if (opFailed) {
for (Volume vol : volumes) {
vol.setInactive(true);
dbClient.updateObject(vol);
}
}
}
use of com.emc.storageos.db.client.model.TenantOrg in project coprhd-controller by CoprHD.
the class VolumeBootVolumeMigrationTest method prepareVolumeData.
/**
* Prepares the data for RP volume tests.
*
* @throws Exception When an error occurs preparing the RP volume data.
*/
private void prepareVolumeData() throws Exception {
log.info("Preparing Volumes for VolumeAccessStateLinkStatusMigration");
TenantOrg tenantOrg = new TenantOrg();
URI tenantOrgURI = URIUtil.createId(TenantOrg.class);
tenantOrg.setId(tenantOrgURI);
_dbClient.createObject(tenantOrg);
Project proj = new Project();
URI projectURI = URIUtil.createId(Project.class);
String projectLabel = "project";
proj.setId(projectURI);
proj.setLabel(projectLabel);
proj.setTenantOrg(new NamedURI(tenantOrgURI, projectLabel));
_dbClient.createObject(proj);
// Create a boot volume for a host with no tags
Volume vol1 = new Volume();
URI vol1URI = URIUtil.createId(Volume.class);
vol1.setId(vol1URI);
vol1.setLabel("VOL1-ABOOTVOLUME");
vol1.setTenant(new NamedURI(tenantOrgURI, "provider"));
_dbClient.createObject(vol1);
// Create a host object with a boot volume
Host host1 = new Host();
URI host1URI = URIUtil.createId(Host.class);
host1.setId(host1URI);
host1.setHostName("Host1WithBootVol");
host1.setBootVolumeId(vol1URI);
volumeToHostIds.put(vol1URI, host1URI);
_dbClient.createObject(host1);
// Create a boot volume for a host with existing tags
Volume vol2 = new Volume();
URI vol2URI = URIUtil.createId(Volume.class);
vol2.setId(vol2URI);
vol2.setLabel("VOL2-ABOOTVOLUME");
vol2.setTenant(new NamedURI(tenantOrgURI, "provider"));
ScopedLabel label = new ScopedLabel();
label.setScope(tenantOrg.getId().toASCIIString());
label.setLabel("vipr:someothertag=" + vol2URI.toASCIIString());
ScopedLabelSet labelSet = new ScopedLabelSet();
labelSet.add(label);
vol2.setTag(labelSet);
_dbClient.createObject(vol2);
// Create a host object with a boot volume
Host host2 = new Host();
URI host2URI = URIUtil.createId(Host.class);
host2.setId(host2URI);
host2.setHostName("Host2WithBootVol");
host2.setBootVolumeId(vol2URI);
volumeToHostIds.put(vol2URI, host2URI);
_dbClient.createObject(host2);
// Create a volume with no host association
Volume vol3 = new Volume();
URI vol3URI = URIUtil.createId(Volume.class);
vol3.setId(vol3URI);
vol3.setLabel("VOL3-NOTABOOTVOLUME");
vol3.setTenant(new NamedURI(tenantOrgURI, "provider"));
volumeToHostIds.put(vol3URI, null);
_dbClient.createObject(vol3);
}
use of com.emc.storageos.db.client.model.TenantOrg in project coprhd-controller by CoprHD.
the class ECSCommunicationInterface method discoverNamespaces.
/**
* Discover ECS Namespaces with details
* @param storageSystem
* @return existing and new marked namespace list
* @throws ECSCollectionException
*/
private Map<String, List<ObjectNamespace>> discoverNamespaces(StorageSystem storageSystem) throws Exception {
URI storageSystemId = storageSystem.getId();
List<String> namespaceIdList = new ArrayList<String>();
Map<String, List<ObjectNamespace>> bothNamespaces = new HashMap<String, List<ObjectNamespace>>();
List<ObjectNamespace> newNamespaces = new ArrayList<ObjectNamespace>();
List<ObjectNamespace> existingNamespaces = new ArrayList<ObjectNamespace>();
try {
_logger.info("discover namespace information for storage system {} - start", storageSystemId);
ECSApi ecsApi = getECSDevice(storageSystem);
ObjectNamespace ecsNamespace = null;
// Discover list of all namespaces
namespaceIdList = ecsApi.getNamespaces();
for (String nsId : namespaceIdList) {
// Check if this namespace was already discovered
ecsNamespace = null;
String nsNativeGuid = NativeGUIDGenerator.generateNativeGuidForNamespace(storageSystem, nsId, NativeGUIDGenerator.NAMESPACE);
URIQueryResultList uriQueryList = new URIQueryResultList();
_dbClient.queryByConstraint(AlternateIdConstraint.Factory.getObjectNamespaceByNativeGuidConstraint(nsNativeGuid), uriQueryList);
// Even if the namespace GUID is duplicated, URI-storageSystemId is unique
Iterator<ObjectNamespace> nsItr = _dbClient.queryIterativeObjects(ObjectNamespace.class, uriQueryList);
while (nsItr.hasNext()) {
ObjectNamespace ns = nsItr.next();
if (ns.getStorageDevice().equals(storageSystemId)) {
ecsNamespace = ns;
break;
}
}
if (ecsNamespace == null) {
// New namespace, not discovered
ecsNamespace = new ObjectNamespace();
ecsNamespace.setId(URIUtil.createId(ObjectNamespace.class));
ecsNamespace.setNativeId(nsId);
ecsNamespace.setNativeGuid(nsNativeGuid);
ecsNamespace.setLabel(nsNativeGuid);
ecsNamespace.setStorageDevice(storageSystemId);
// Now obtain the complete namespace details
ECSNamespaceRepGroup nsGroup = ecsApi.getNamespaceDetails(nsId);
ecsNamespace.setPoolType(nsGroup.getRgType());
StringSet repGroups = new StringSet();
for (String rg : nsGroup.getReplicationGroups()) {
repGroups.add(rg);
}
ecsNamespace.setStoragePools(repGroups);
ecsNamespace.setNsName(nsGroup.getNamespaceName());
ecsNamespace.setDiscoveryStatus(DiscoveryStatus.VISIBLE.name());
// Check if this newly discovered namespace is already mapped with a tenant
// Upgrade from 2.4 to 2.5
ecsNamespace.setMapped(false);
List<URI> allTenantURI = _dbClient.queryByType(TenantOrg.class, true);
Iterator<TenantOrg> tnItr = _dbClient.queryIterativeObjects(TenantOrg.class, allTenantURI);
while (tnItr.hasNext()) {
TenantOrg ten = tnItr.next();
if (ten.getNamespace() != null && !ten.getNamespace().isEmpty() && ten.getNamespace().equalsIgnoreCase(nsId)) {
ecsNamespace.setTenant(ten.getId());
ecsNamespace.setMapped(true);
break;
}
}
_logger.info("Creating new namespace with NativeGuid : {}", nsNativeGuid);
newNamespaces.add(ecsNamespace);
} else {
existingNamespaces.add(ecsNamespace);
}
}
bothNamespaces.put(NEW, newNamespaces);
bothNamespaces.put(EXISTING, existingNamespaces);
_logger.info("discoverNamespaces for storage system {} - complete", storageSystemId);
return bothNamespaces;
} catch (Exception e) {
_logger.error("discoverNamespaces failed. Storage system: {}", storageSystemId, e);
throw e;
}
}
use of com.emc.storageos.db.client.model.TenantOrg in project coprhd-controller by CoprHD.
the class VmaxSnapshotOperations method createGroupSnapshotSession.
/**
* {@inheritDoc}
*/
@Override
public void createGroupSnapshotSession(StorageSystem system, URI snapSessionURI, String groupName, TaskCompleter completer) throws DeviceControllerException {
if (system.checkIfVmax3()) {
_log.info("Create snapshot session group operation START");
BlockSnapshotSession snapSession = _dbClient.queryObject(BlockSnapshotSession.class, snapSessionURI);
BlockConsistencyGroup consistencyGroup = _dbClient.queryObject(BlockConsistencyGroup.class, snapSession.getConsistencyGroup());
TenantOrg tenant = _dbClient.queryObject(TenantOrg.class, consistencyGroup.getTenant().getURI());
String tenantName = tenant.getLabel();
final String label = _nameGenerator.generate(tenantName, snapSession.getSessionLabel(), snapSessionURI.toString(), '-', SmisConstants.MAX_SMI80_SNAPSHOT_NAME_LENGTH);
CIMObjectPath groupPath = _cimPath.getReplicationGroupPath(system, groupName);
try {
CIMObjectPath replicationSvcPath = _cimPath.getControllerReplicationSvcPath(system);
CIMArgument[] outArgs = new CIMArgument[5];
CIMArgument[] inArgs = _helper.getCreateSynchronizationAspectForGroupInput(groupPath, false, label, new Integer(SmisConstants.MODE_SYNCHRONOUS));
_helper.invokeMethod(system, replicationSvcPath, SmisConstants.CREATE_SYNCHRONIZATION_ASPECT, inArgs, outArgs);
CIMObjectPath jobPath = _cimPath.getCimObjectPathFromOutputArgs(outArgs, SmisConstants.JOB);
ControllerServiceImpl.enqueueJob(new QueueJob(new SmisBlockSnapshotSessionCGCreateJob(jobPath, system.getId(), completer)));
} catch (Exception e) {
_log.error("Exception creating group snapshot session ", e);
ServiceError error = DeviceControllerErrors.smis.unableToCallStorageProvider(e.getMessage());
completer.error(_dbClient, error);
}
_log.info("Create snapshot session group operation FINISH");
} else {
throw DeviceControllerException.exceptions.blockDeviceOperationNotSupported();
}
}
Aggregations