use of com.emc.storageos.networkcontroller.impl.mds.ZoneWwnAlias in project coprhd-controller by CoprHD.
the class BrocadeNetworkSystemDevice method checkAndCreateAlias.
/**
* Check if an alias exists before creating a new one. If the alias exists and for
* the same WWN, then nothing will be done but if the alias name is used for another
* WWN, then this is an error condition.
*
* @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 alias the alias to be created
* @return true if an alias was indeed created
* @throws WBEMException
*/
public boolean checkAndCreateAlias(WBEMClient client, CIMInstance zoneServiceIns, String fabricId, String fabricWwn, ZoneWwnAlias alias) throws WBEMException {
boolean added = false;
_log.info("Starting create alias with name " + alias.getName());
// check if an alias with the same name exists
ZoneWwnAlias existingAlias = _smisHelper.getAlias(client, alias.getName(), fabricWwn, true);
if (existingAlias != null) {
_log.info("Found alias {}", alias.getName());
if (StringUtils.equalsIgnoreCase(existingAlias.getAddress(), alias.getAddress())) {
// alias already exists - this is not an error unless it is for different member
_log.info("The existing alias is for the same WWN {}. Nothing to do.", alias.getAddress());
} else {
throw NetworkDeviceControllerException.exceptions.aliasWithSameNameExists(alias.getName(), existingAlias.getAddress(), alias.getAddress());
}
} else {
// create the new alias
added = _smisHelper.addZoneAlias(client, zoneServiceIns, fabricId, fabricWwn, alias) != null;
}
return added;
}
use of com.emc.storageos.networkcontroller.impl.mds.ZoneWwnAlias in project coprhd-controller by CoprHD.
the class BrocadeNetworkSystemDevice method checkAndRemoveAlias.
/**
* Check if an alias exists before updating 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 alias the alias to be created
* @return true if an alias was indeed created
* @throws WBEMException
*/
public boolean checkAndRemoveAlias(WBEMClient client, CIMInstance zoneServiceIns, String fabricId, String fabricWwn, ZoneWwnAlias alias) throws WBEMException {
boolean removed = false;
_log.info("Starting remove alias with name {}", alias.getName());
// check if an alias with the same name exists
ZoneWwnAlias existingAlias = null;
if (alias.getAddress() != null && alias.getAddress().length() > 0) {
// we need to verify that the alias member matches before removing it
existingAlias = _smisHelper.getAlias(client, alias.getName(), fabricWwn, true);
if (existingAlias != null && !StringUtils.equalsIgnoreCase(existingAlias.getAddress(), alias.getAddress())) {
_log.info("The existing alias has a WWN other than the expected {}. It will not be removed.", alias.getAddress());
throw NetworkDeviceControllerException.exceptions.aliasWithDifferentWwnExists(alias.getName(), existingAlias.getAddress(), alias.getAddress());
}
} else {
existingAlias = _smisHelper.getAlias(client, alias.getName(), fabricWwn, false);
}
if (existingAlias != null) {
_log.info("Found alias {}. The alias will be removed.", alias.getName());
_smisHelper.removeInstance(client, (CIMObjectPath) existingAlias.getCimObjectPath());
removed = true;
} else {
_log.info("Did not find alias {}. Nothing to do.", alias.getName());
}
return removed;
}
use of com.emc.storageos.networkcontroller.impl.mds.ZoneWwnAlias in project coprhd-controller by CoprHD.
the class NetworkSystemService method addAliases.
/**
* Adds one or more aliases to the specified network system. For Brocade the fabric where
* the aliases will be added must be specified. For MDS, this input is ignored if provided.
* <p>
* This is an asynchronous call.
*
* @param aliases A parameter structure listing the aliases to be added
* @param id the URN of a ViPR network system.
* @prereq none
* @brief Add aliases to a network system
* @return A task description structure.
* @throws InternalException
*/
@POST
@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 addAliases(WwnAliasesCreateParam aliases, @PathParam("id") URI id) throws InternalException {
String task = UUID.randomUUID().toString();
ArgValidator.checkFieldUriType(id, NetworkSystem.class, "id");
ArgValidator.checkFieldNotEmpty(aliases.getAliases(), "aliases");
NetworkSystem device = queryResource(id);
String fabricId = aliases.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.ADD_ALIAS);
List<ZoneWwnAlias> zoneAliases = new ArrayList<ZoneWwnAlias>();
for (WwnAliasParam alias : aliases.getAliases()) {
ArgValidator.checkFieldNotEmpty(alias.getAddress(), "address");
validateAlias(alias, true);
zoneAliases.add(new ZoneWwnAlias(alias.getName(), alias.getAddress()));
auditOp(OperationTypeEnum.ADD_ALIAS, true, AuditLogManager.AUDITOP_BEGIN, alias.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.addAliases(device.getId(), fabricId, fabricWwn, zoneAliases, task);
return toTask(device, task, op);
}
use of com.emc.storageos.networkcontroller.impl.mds.ZoneWwnAlias in project coprhd-controller by CoprHD.
the class NetworkSystemService method removeAliases.
/**
* Removes one or more aliases from the specified network system. For Brocade the fabric from where
* the aliases will be removed must be specified. For MDS, this input is ignored if provided.
*
* @param aliases A parameter structure listing the aliases to be removed. The alias member is an
* optional parameter and when provided, the alias membership is checked prior to removing it.
* @param id the URN of a ViPR network system.
* @prereq none
* @brief Remove aliases to network system to VSAN or fabric
* @return A task description structure.
* @throws InternalException
*/
@POST
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/san-aliases/remove")
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.RESTRICTED_SYSTEM_ADMIN })
public TaskResourceRep removeAliases(WwnAliasesDeleteParam aliases, @PathParam("id") URI id) throws InternalException {
String task = UUID.randomUUID().toString();
ArgValidator.checkFieldUriType(id, NetworkSystem.class, "id");
ArgValidator.checkFieldNotEmpty(aliases.getAliases(), "aliases");
NetworkSystem device = queryResource(id);
String fabricId = aliases.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.REMOVE_ALIAS);
List<ZoneWwnAlias> zoneAliases = new ArrayList<ZoneWwnAlias>();
for (WwnAliasParam alias : aliases.getAliases()) {
validateAlias(alias, false);
zoneAliases.add(new ZoneWwnAlias(alias.getName(), alias.getAddress()));
auditOp(OperationTypeEnum.REMOVE_ALIAS, true, AuditLogManager.AUDITOP_BEGIN, alias.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.removeAliases(device.getId(), fabricId, fabricWwn, zoneAliases, task);
return toTask(device, task, op);
}
Aggregations