use of com.emc.storageos.db.client.model.AbstractChangeTrackingSet in project coprhd-controller by CoprHD.
the class BasePermissionsHelper method convertToACLEntries.
/**
* Converts StringSetMap of acls into a list of ACLEntry as used by the API
*
* @param acls to be converted into the ACLEntry list.
* @return the converted ACLEntry list.
*/
public static List<ACLEntry> convertToACLEntries(StringSetMap acls) {
List<ACLEntry> assignments = new ArrayList<ACLEntry>();
if (CollectionUtils.isEmpty(acls)) {
return assignments;
}
for (Map.Entry<String, AbstractChangeTrackingSet<String>> ace : acls.entrySet()) {
PermissionsKey rowKey = new PermissionsKey();
rowKey.parseFromString(ace.getKey());
ACLEntry entry = new ACLEntry();
if (rowKey.getType().equals(PermissionsKey.Type.GROUP)) {
entry.setGroup(rowKey.getValue());
} else if (rowKey.getType().equals(PermissionsKey.Type.SID)) {
entry.setSubjectId(rowKey.getValue());
} else if (rowKey.getType().equals(PermissionsKey.Type.TENANT)) {
entry.setTenant(rowKey.getValue());
}
for (String priv : ace.getValue()) {
// skip owner
if (priv.equalsIgnoreCase(ACL.OWN.toString())) {
continue;
}
entry.getAces().add(priv);
}
if (!entry.getAces().isEmpty()) {
assignments.add(entry);
}
}
return assignments;
}
use of com.emc.storageos.db.client.model.AbstractChangeTrackingSet in project coprhd-controller by CoprHD.
the class ExternalDeviceExportOperations method prepareCapabilitiesForAddInitiators.
private void prepareCapabilitiesForAddInitiators(ExportPathParams pathParams, StringSetMap existingZoningMap, URI varrayURI, List<com.emc.storageos.db.client.model.Initiator> initiators, StorageCapabilities capabilities) {
int driverMaxPath;
StringSetMap zoningMap = new StringSetMap();
// Calculate existing paths (without new initiators).
int existingPaths = 0;
List<URI> initiatorUris = URIUtil.toUris(initiators);
for (Map.Entry<String, AbstractChangeTrackingSet<String>> entry : existingZoningMap.entrySet()) {
if (!initiatorUris.contains(URIUtil.uri(entry.getKey()))) {
zoningMap.put(entry.getKey(), entry.getValue());
}
}
Map<com.emc.storageos.db.client.model.Initiator, List<com.emc.storageos.db.client.model.StoragePort>> assignments = blockScheduler.generateInitiatorsToStoragePortsMap(zoningMap, varrayURI);
existingPaths = assignments.values().size();
log.info("Existing path number in the export mask is {}", existingPaths);
// Otherwise we allocate the difference between max paths and existing paths
if (existingPaths + pathParams.getPathsPerInitiator() > pathParams.getMaxPaths()) {
// we always need at least path-per-initiator ports
driverMaxPath = pathParams.getPathsPerInitiator();
} else {
driverMaxPath = pathParams.getMaxPaths() - existingPaths;
}
// We assume that masking view meets min path before new initiators are added. We pass ppi as a minPath
// to driver, so we can zone at least one new initiator.
ExportPathsServiceOption numPath = new ExportPathsServiceOption(pathParams.getPathsPerInitiator(), driverMaxPath);
List<ExportPathsServiceOption> exportPathParams = new ArrayList<>();
exportPathParams.add(numPath);
CommonStorageCapabilities commonCapabilities = new CommonStorageCapabilities();
commonCapabilities.setExportPathParams(exportPathParams);
capabilities.setCommonCapabilitis(commonCapabilities);
}
use of com.emc.storageos.db.client.model.AbstractChangeTrackingSet in project coprhd-controller by CoprHD.
the class VDCRoleMigrationCallback method removeRoleFromRootTenant.
/**
* remove VDC roles from rootTenantOrg
*
* @param vdc
* @param rootTenant
*/
private void removeRoleFromRootTenant(VirtualDataCenter vdc, TenantOrg rootTenant) {
StringSetMap vdcRoles = vdc.getRoleAssignments();
for (Map.Entry<String, AbstractChangeTrackingSet<String>> roleAssignment : vdcRoles.entrySet()) {
String uid = roleAssignment.getKey();
Iterator<String> itr = roleAssignment.getValue().iterator();
while (itr.hasNext()) {
String role = itr.next();
rootTenant.removeRole(uid, role);
}
}
}
use of com.emc.storageos.db.client.model.AbstractChangeTrackingSet in project coprhd-controller by CoprHD.
the class DBClient method rebuildIndex.
public boolean rebuildIndex(URI id, Class clazz) {
boolean runResult = false;
try {
DataObject queryObject = queryObject(id, clazz);
if (queryObject != null) {
DataObject newObject = queryObject.getClass().newInstance();
newObject.trackChanges();
ConvertUtils.register(new CalendarConverter(null), Calendar.class);
ConvertUtils.register(new DateConverter(null), Date.class);
BeanUtilsBean notNull = new NullAwareBeanUtilsBean();
notNull.copyProperties(newObject, queryObject);
// special change tracking for customized types
BeanInfo bInfo;
try {
bInfo = Introspector.getBeanInfo(clazz);
} catch (IntrospectionException ex) {
log.error("Unexpected exception getting bean info", ex);
throw new RuntimeException("Unexpected exception getting bean info", ex);
}
PropertyDescriptor[] pds = bInfo.getPropertyDescriptors();
for (PropertyDescriptor pd : pds) {
Object val = pd.getReadMethod().invoke(newObject);
if (val instanceof AbstractChangeTrackingSet) {
AbstractChangeTrackingSet valueSet = (AbstractChangeTrackingSet) val;
valueSet.markAllForOverwrite();
} else if (val instanceof AbstractChangeTrackingMap) {
AbstractChangeTrackingMap valueMap = (AbstractChangeTrackingMap) val;
valueMap.markAllForOverwrite();
} else if (val instanceof AbstractChangeTrackingSetMap) {
AbstractChangeTrackingSetMap valueMap = (AbstractChangeTrackingSetMap) val;
Set<String> keys = valueMap.keySet();
if (keys != null) {
Iterator<String> it = keys.iterator();
while (it.hasNext()) {
String key = it.next();
AbstractChangeTrackingSet valueSet = valueMap.get(key);
valueSet.markAllForOverwrite();
}
}
}
}
_dbClient.updateObject(newObject);
logMsg(String.format("Successfully rebuild index for %s in cf %s", id, clazz));
runResult = true;
} else {
logMsg(String.format("Could not find data object record for %s in cf %s, no need to rebuild index. Mark as success too.", id, clazz));
runResult = true;
}
} catch (Exception e) {
logMsg(String.format("Error when rebuilding index for %s in cf %s", id, clazz), true, e);
}
return runResult;
}
use of com.emc.storageos.db.client.model.AbstractChangeTrackingSet in project coprhd-controller by CoprHD.
the class NetworkScheduler method getZoningRemoveTargets.
/**
* Generate the NetworkFCZoneInfo structures representing the zone/volume duples
* that are fed to the actual zoning code to remove zones.
* @param zoningParams -- Collection of NetworkZoningParam that contains initiator information
* @param volumeURIs -- Optional Collection of volumes being affected by the zoning operation.
* If null, the zoningParams.getVolumes() is used instead, which comes from the ExportMask volumes keyset.
* @return list of NetworkFCZonInfos representing zones and FCZoneReferences to be removed
*/
public List<NetworkFCZoneInfo> getZoningRemoveTargets(Collection<NetworkZoningParam> zoningParams, Collection<URI> volumeURIs) {
List<NetworkFCZoneInfo> zoningTargets = new ArrayList<NetworkFCZoneInfo>();
// and add them to the zoningTargets result list.
for (NetworkZoningParam zoningParam : zoningParams) {
URI varray = zoningParam.getVirtualArray();
_log.info(String.format("Generating remove zoning targets for ExportMask %s (%s)", zoningParam.getMaskName(), zoningParam.getMaskId()));
// validate the initiators are FC, and calculate the zone information
for (Map.Entry<String, AbstractChangeTrackingSet<String>> entry : zoningParam.getZoningMap().entrySet()) {
String initiatorId = entry.getKey();
Initiator initiator = _dbClient.queryObject(Initiator.class, URI.create(initiatorId));
if (initiator == null || initiator.getInactive()) {
_log.info("Initiator inactive: " + initiatorId);
continue;
}
if (StorageProtocol.block2Transport(initiator.getProtocol()) != Transport.FC) {
_log.info(String.format("Initiator not FC %s %s", initiator.getInitiatorPort(), initiatorId));
continue;
}
Set<String> portSet = entry.getValue();
if (portSet == null || portSet.isEmpty()) {
_log.info(String.format("No ports in zoningMap for initiator %s %s", initiator.getInitiatorPort(), initiatorId));
continue;
}
List<URI> exportGroupURIs = new ArrayList<URI>();
exportGroupURIs.add(zoningParam.getExportGroupId());
if (zoningParam.getAlternateExportGroupIds() != null) {
exportGroupURIs.addAll(zoningParam.getAlternateExportGroupIds());
}
// Calculate the zone information for each initiator/port combination
for (String portId : portSet) {
// Calculate the zone information
List<NetworkFCZoneInfo> zoneInfos = unexportVolumes(varray, (volumeURIs != null ? volumeURIs : zoningParam.getVolumes()), exportGroupURIs, URI.create(portId), formatWWN(initiator.getInitiatorPort()), zoningParam.hasExistingVolumes());
if (zoneInfos != null) {
zoningTargets.addAll(zoneInfos);
}
}
}
}
return zoningTargets;
}
Aggregations