use of com.emc.storageos.networkcontroller.NetworkController in project coprhd-controller by CoprHD.
the class NetworkSystemService method addSanZones.
/**
* Adds one or more SAN zones to the active zoneset of the VSAN or fabric specified on a network system.
* This is an asynchronous call.
*
* @param sanZones A parameter structure listing the zone(s) to be added and their members.
* @param id the URN of a ViPR network system.
* @param fabricId The name of the VSAN or fabric as returned by
* /vdc/network-systems/{id}/san-fabrics or the VSAN or fabric WWN
* @prereq none
* @brief Add SAN zones to network system 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-fabrics/{fabricId}/san-zones")
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.RESTRICTED_SYSTEM_ADMIN })
public TaskResourceRep addSanZones(SanZoneCreateParam sanZones, @PathParam("id") URI id, @PathParam("fabricId") String fabricId) throws InternalException {
String task = UUID.randomUUID().toString();
String fabricWwn = null;
if (WWNUtility.isValidWWN(fabricId)) {
fabricWwn = fabricId;
fabricId = fabricId.replaceAll(":", "");
}
ArgValidator.checkFieldUriType(id, NetworkSystem.class, "id");
NetworkSystem device = queryResource(id);
List<Zone> zones = new ArrayList<Zone>();
for (SanZone sz : sanZones.getZones()) {
Zone zone = new Zone(sz.getName());
validateZoneName(sz.getName(), device.getSystemType());
zones.add(zone);
for (String szm : sz.getMembers()) {
ZoneMember member = createZoneMember(szm);
zone.getMembers().add(member);
}
ArgValidator.checkFieldNotEmpty(zone.getMembers(), "zone members");
auditOp(OperationTypeEnum.ADD_SAN_ZONE, true, AuditLogManager.AUDITOP_BEGIN, zone.getName(), device.getId().toString(), device.getLabel(), device.getPortNumber(), device.getUsername(), device.getSmisProviderIP(), device.getSmisPortNumber(), device.getSmisUserName(), device.getSmisUseSSL(), device.getVersion(), device.getUptime());
}
ArgValidator.checkFieldNotEmpty(zones, "zones");
Operation op = _dbClient.createTaskOpStatus(NetworkSystem.class, device.getId(), task, ResourceOperationTypeEnum.ADD_SAN_ZONE);
NetworkController controller = getNetworkController(device.getSystemType());
controller.addSanZones(device.getId(), fabricId, fabricWwn, zones, false, task);
return toTask(device, task, op);
}
use of com.emc.storageos.networkcontroller.NetworkController in project coprhd-controller by CoprHD.
the class NetworkSystemService method activateSanZones.
/**
* Activate current active zoneset of the given fabric specified on a network system.
* This is an asynchronous call.
*
* @param sanZones A parameter structure listing the zone(s) to be added and their members.
* @param id the URN of a ViPR network system.
* @param fabricId The name of the VSAN or fabric as returned by
* /vdc/network-systems/{id}/san-fabrics or the WWN of the VSAN or fabric
* @prereq none
* @brief Activate all zoning changes made since the last activation
* @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-fabrics/{fabricId}/san-zones/activate")
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.RESTRICTED_SYSTEM_ADMIN })
public TaskResourceRep activateSanZones(@PathParam("id") URI id, @PathParam("fabricId") String fabricId) throws InternalException {
String task = UUID.randomUUID().toString();
String fabricWwn = null;
if (WWNUtility.isValidWWN(fabricId)) {
fabricWwn = fabricId;
fabricId = fabricId.replaceAll(":", "");
}
ArgValidator.checkFieldUriType(id, NetworkSystem.class, "id");
NetworkSystem device = queryResource(id);
Operation op = _dbClient.createTaskOpStatus(NetworkSystem.class, device.getId(), task, ResourceOperationTypeEnum.ACTIVATE_SAN_ZONE);
auditOp(OperationTypeEnum.ACTIVATE_SAN_ZONE, true, AuditLogManager.AUDITOP_BEGIN, 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.activateSanZones(device.getId(), fabricId, fabricWwn, task);
return toTask(device, task, op);
}
use of com.emc.storageos.networkcontroller.NetworkController 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.NetworkController in project coprhd-controller by CoprHD.
the class NetworkSystemService method updateSanZones.
/**
* For given network system's fabric, update zones via add and/or remove their pwwns or aliases.
* This is an asynchronous call.
*
* @param updateSanZones A parameter structure listing the zone(s) to be added and their members.
* @param id the URN of a ViPR network system.
* @param fabricId The name of the VSAN or fabric as returned by /vdc/network-systems/{id}/san-fabrics
* or the VSAN or fabric WWN
* @prereq Updating zones must be exist in network system with given <code>id</code>
* @brief Update SAN zones details for network system VSAN or fabric
* @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-fabrics/{fabricId}/san-zones")
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.RESTRICTED_SYSTEM_ADMIN })
public TaskResourceRep updateSanZones(SanZoneUpdateParams updateSanZones, @PathParam("id") URI id, @PathParam("fabricId") String fabricId) throws InternalException {
String task = UUID.randomUUID().toString();
String fabricWwn = null;
if (WWNUtility.isValidWWN(fabricId)) {
fabricWwn = fabricId;
fabricId = fabricId.replaceAll(":", "");
}
ArgValidator.checkFieldUriType(id, NetworkSystem.class, "id");
NetworkSystem device = queryResource(id);
List<ZoneUpdate> updateZones = new ArrayList<ZoneUpdate>();
for (SanZoneUpdateParam sz : updateSanZones.getUpdateZones()) {
ZoneUpdate updateZone = new ZoneUpdate(sz.getName());
validateZoneName(sz.getName(), device.getSystemType());
for (String szm : sz.getAddMembers()) {
if (StringUtils.isEmpty(szm)) {
continue;
}
ZoneMember member = createZoneMember(szm);
updateZone.getAddZones().add(member);
}
for (String szm : sz.getRemoveMembers()) {
if (StringUtils.isEmpty(szm)) {
continue;
}
ZoneMember member = createZoneMember(szm);
updateZone.getRemoveZones().add(member);
}
updateZones.add(updateZone);
auditOp(OperationTypeEnum.UPDATE_SAN_ZONE, true, AuditLogManager.AUDITOP_BEGIN, updateZone.getName(), device.getId().toString(), device.getLabel(), device.getPortNumber(), device.getUsername(), device.getSmisProviderIP(), device.getSmisPortNumber(), device.getSmisUserName(), device.getSmisUseSSL(), device.getVersion(), device.getUptime());
}
ArgValidator.checkFieldNotEmpty(updateZones, "zones");
Operation op = _dbClient.createTaskOpStatus(NetworkSystem.class, device.getId(), task, ResourceOperationTypeEnum.UPDATE_SAN_ZONE);
NetworkController controller = getNetworkController(device.getSystemType());
controller.updateSanZones(device.getId(), fabricId, fabricWwn, updateZones, false, task);
return toTask(device, task, op);
}
use of com.emc.storageos.networkcontroller.NetworkController in project coprhd-controller by CoprHD.
the class NetworkSystemService method getSanZones.
/**
* Returns a list of the active zones (and their zone members) for the specified
* fabric or VSAN in a network system. E.g., ../san-fabrics/{fabric-id}/san-zones?zone-name="abc-zone"&exclude-members=true
* Note: This is a synchronous call to the device and may take a while to receive a response.
*
* @param id the URN of a ViPR network system.
* @param fabricId The name of the VSAN or fabric as returned by
* @param zoneName - only returns zone with zone name matched the given name. Return all zones, if not specified.
* @param excludeMembers - true, do not include members with zone. Include members, if not specified.
* @param excludeAliases - true, do not include aliases with zone. Include aliases, if not specified.
* @prereq none
* @brief List active zones in a network system fabric or VSAN
* @return A list of the active zones and their members. If zone name is specified, and there is a match, then only one zone is
* returned.
* If excludeMembers is true, then only zone name is present.
* @throws InternalException
*/
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/san-fabrics/{fabricId}/san-zones")
@CheckPermission(roles = { Role.SYSTEM_ADMIN })
public SanZonesRestRep getSanZones(@PathParam("id") URI id, @PathParam("fabricId") String fabricId, @QueryParam("zone-name") String zoneName, @QueryParam("exclude-members") boolean excludeMembers, @QueryParam("exclude-aliases") boolean excludeAliases) throws InternalException {
SanZonesRestRep szones = new SanZonesRestRep();
ArgValidator.checkFieldUriType(id, NetworkSystem.class, "id");
NetworkSystem device = queryResource(id);
String fabricWwn = null;
if (WWNUtility.isValidWWN(fabricId)) {
fabricWwn = fabricId;
fabricId = fabricId.replaceAll(":", "");
}
NetworkController controller = getNetworkController(device.getSystemType());
List<Zoneset> zonesets = controller.getZonesets(device.getId(), fabricId, fabricWwn, zoneName, excludeMembers, excludeAliases);
for (Zoneset zoneset : zonesets) {
for (Zone zone : zoneset.getZones()) {
SanZoneRestRep sz = new SanZoneRestRep();
sz.setName(zone.getName());
for (ZoneMember member : zone.getMembers()) {
// convert zone member to xml aware. Only fill in alias if member is an alias type
sz.getMembers().add(new SanZoneMemberRestRep(member.getAddress(), member.isAliasType() ? member.getAlias() : null));
}
szones.getZones().add(sz);
}
}
return szones;
}
Aggregations