use of com.emc.storageos.networkcontroller.impl.mds.ZoneWwnAliasUpdate in project coprhd-controller by CoprHD.
the class NetworkSystemService method updateAliases.
/**
* Changes the WWN member of one or more aliases on the specified network system. For Brocade
* the fabric of the aliases will be removed must be specified.
* For MDS, this input is ignored if provided.
* <p>
* Current address WWN is optional; however, if provided, it must match the one in system before update. If not, exception will be
* thrown.
* <p>
* This is an asynchronous call.
*
* @param aliases A parameter structure listing the aliases to be updated
* @param id the URN of a ViPR network system.
* @param fabricId The name of the VSAN or fabric. This parameter is ignored
* if network system is an MDS
* @prereq none
* @brief Update aliases in network system
* @return A task description structure.
* @throws InternalException
*/
@PUT
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/san-aliases")
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.RESTRICTED_SYSTEM_ADMIN })
public TaskResourceRep updateAliases(WwnAliasUpdateParams updateAliasParam, @PathParam("id") URI id) throws InternalException {
String task = UUID.randomUUID().toString();
ArgValidator.checkFieldUriType(id, NetworkSystem.class, "id");
ArgValidator.checkFieldNotEmpty(updateAliasParam.getUpdateAliases(), "aliases");
NetworkSystem device = queryResource(id);
String fabricId = updateAliasParam.getFabricId();
if (Type.brocade.toString().equals(device.getSystemType())) {
ArgValidator.checkFieldNotEmpty(fabricId, "fabric-id");
}
String fabricWwn = null;
if (WWNUtility.isValidWWN(fabricId)) {
fabricWwn = fabricId;
fabricId = fabricId.replaceAll(":", "");
}
Operation op = _dbClient.createTaskOpStatus(NetworkSystem.class, device.getId(), task, ResourceOperationTypeEnum.UPDATE_ALIAS);
List<ZoneWwnAliasUpdate> zoneAliasesUpdate = new ArrayList<ZoneWwnAliasUpdate>();
for (WwnAliasUpdateParam updateAlias : updateAliasParam.getUpdateAliases()) {
validateAlias(updateAlias, false);
// validate new address
if (!StringUtils.isEmpty(updateAlias.getNewAddress())) {
validateWWN(updateAlias.getNewAddress());
}
// validate new name
if (!StringUtils.isEmpty(updateAlias.getNewName())) {
validateWWNAlias(updateAlias.getNewName());
}
zoneAliasesUpdate.add(new ZoneWwnAliasUpdate(updateAlias.getName(), updateAlias.getNewName(), updateAlias.getNewAddress(), updateAlias.getAddress()));
auditOp(OperationTypeEnum.UPDATE_ALIAS, true, AuditLogManager.AUDITOP_BEGIN, updateAlias.getName(), device.getId().toString(), device.getLabel(), device.getPortNumber(), device.getUsername(), device.getSmisProviderIP(), device.getSmisPortNumber(), device.getSmisUserName(), device.getSmisUseSSL(), device.getVersion(), device.getUptime());
}
NetworkController controller = getNetworkController(device.getSystemType());
controller.updateAliases(device.getId(), fabricId, fabricWwn, zoneAliasesUpdate, task);
return toTask(device, task, op);
}
use of com.emc.storageos.networkcontroller.impl.mds.ZoneWwnAliasUpdate in project coprhd-controller by CoprHD.
the class BrocadeNetworkSystemDevice method checkAndUpdateAlias.
/**
* Check if an alias exists before removing it. If the alias does not exist
* then nothing will be done.
*
* @param client an instance of WBEMClient
* @param zoneServiceIns the zone service holding the zoning session
* @param fabricId the fabric name
* @param fabricWwn the fabric WWN
* @param updateAlias the alias to be created
* @return true if an alias was indeed created
* @throws WBEMException
*/
public boolean checkAndUpdateAlias(WBEMClient client, CIMInstance zoneServiceIns, String fabricId, String fabricWwn, ZoneWwnAlias alias) throws WBEMException {
boolean success = false;
ZoneWwnAliasUpdate updateAlias = (ZoneWwnAliasUpdate) alias;
_log.info("Starting update alias {}", updateAlias.getName());
// check if the alias exists
ZoneWwnAlias existingAlias = _smisHelper.getAlias(client, updateAlias.getName(), fabricWwn, true);
if (existingAlias != null) {
_log.info("Found alias {}", updateAlias.getName());
// check if the alias is how we expect it to be
if (!StringUtils.isEmpty(updateAlias.getNewName())) {
_log.warn("Rename alias is request and is not supported for Brocade.", existingAlias.getName());
if (StringUtils.equals(existingAlias.getName(), updateAlias.getNewName())) {
_log.info("The existing alias already has the requested name {}. Ignoring.", existingAlias.getName());
} else {
_log.error("A request is made to update alias name from {} to {}. Rename is not supported for Brocade", existingAlias.getName(), updateAlias.getNewName());
throw NetworkDeviceControllerException.exceptions.renameAliasNotSupported(alias.getName());
}
}
// check if the alias is how we expect it to be
if (!StringUtils.isEmpty(updateAlias.getAddress()) && !StringUtils.equalsIgnoreCase(existingAlias.getAddress(), updateAlias.getAddress())) {
_log.info("The existing alias has a WWN other than the expected {}. It will not be updated.", updateAlias.getAddress());
throw NetworkDeviceControllerException.exceptions.aliasWithDifferentWwnExists(alias.getName(), existingAlias.getAddress(), updateAlias.getAddress());
}
if (!StringUtils.isEmpty(updateAlias.getNewAddress())) {
if (StringUtils.equalsIgnoreCase(existingAlias.getAddress(), updateAlias.getNewAddress())) {
_log.info("The existing alias already has the requested WWN {}. WWN will not change.", existingAlias.getAddress());
} else {
_log.info("Updating alias member from {} to {}", existingAlias.getAddress(), updateAlias.getNewAddress());
_smisHelper.removeZoneOrAliasMember(client, (CIMObjectPath) existingAlias.getCimMemberPath(), (CIMObjectPath) existingAlias.getCimObjectPath(), false);
success = _smisHelper.addZoneOrAliasMember(client, zoneServiceIns, fabricWwn, (CIMObjectPath) existingAlias.getCimObjectPath(), updateAlias.getNewAddress());
// If member change fails, exit this function
if (!success) {
return success;
}
}
}
} else {
throw NetworkDeviceControllerException.exceptions.aliasNotFound(updateAlias.getName());
}
return success;
}
Aggregations