use of com.emc.storageos.db.client.model.NetworkSystem in project coprhd-controller by CoprHD.
the class NetworkSystemService method doDiscoverNetworkSystem.
/**
* Common code for submitting a request for discovery. The request may not be performed
* by the discovery framework if a discovery was recently performed or is ongoing for
* the network system.
*
* @param device the network system to be discovered to re-discovered.
* provided, a new taskId is generated.
* @return the task used to track the discovery job
*/
private TaskResourceRep doDiscoverNetworkSystem(NetworkSystem device) {
NetworkController controller = getNetworkController(device.getSystemType());
DiscoveredObjectTaskScheduler scheduler = new DiscoveredObjectTaskScheduler(_dbClient, new NetworkJobExec(controller));
String taskId = UUID.randomUUID().toString();
ArrayList<AsyncTask> tasks = new ArrayList<AsyncTask>(1);
tasks.add(new AsyncTask(NetworkSystem.class, device.getId(), taskId));
TaskList taskList = scheduler.scheduleAsyncTasks(tasks);
return taskList.getTaskList().iterator().next();
}
use of com.emc.storageos.db.client.model.NetworkSystem in project coprhd-controller by CoprHD.
the class NetworkSystemService method getNetworkSystemList.
/**
* Returns list of all network systems. Each item in the list contains
* an id, name, and link.
*
* @prereq none
* @brief List network systems
* @return NetworkSystemList for each NetworkSystem, each containing an id, name, and link.
*/
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.SYSTEM_MONITOR })
public NetworkSystemList getNetworkSystemList() {
NetworkSystem system;
List<URI> ids;
ids = _dbClient.queryByType(NetworkSystem.class, true);
NetworkSystemList list = new NetworkSystemList();
for (URI id : ids) {
system = _dbClient.queryObject(NetworkSystem.class, id);
if (system != null) {
list.getSystems().add(toNamedRelatedResource(system));
}
}
return list;
}
use of com.emc.storageos.db.client.model.NetworkSystem 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);
}
use of com.emc.storageos.db.client.model.NetworkSystem in project coprhd-controller by CoprHD.
the class VirtualArrayService method getComputeSystems.
/**
* Fetches all Compute Systems that are visible in the vArray
*
* First determine physical connectivity to any switches in the vArrray.
* 1. From the vArray, determine the networks. (Call this Network Set)
* 2. From the networks, get the physical switches that are attached.
* 3. For each physical switch, iterate through the networks and get the FC endpoints.
* 4. Look for any of the FIC ports in any of the FC endpoints on any of the
* networks on the physical switch. When a FIC port matches, call this FIC
* Port.
* 5. If found, then there is physical connectivity.
*
* With physical connectivity Established:
* 1. Given the FIC Port from step (4), pull the VSAN or VSANs assigned to
* it on UCS.
* 2. If the set contains one of the networks from the Network
* Set in (1), we have connectivity to that vArray.
*
* @param id
* the URN of a ViPR VirtualArray.
* @brief List all Compute Systems that are visible in the vArray
* @return List of Compute Systems
*/
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/compute-systems")
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.SYSTEM_MONITOR }, acls = { ACL.USE })
public ComputeSystemBulkRep getComputeSystems(@PathParam("id") URI id) {
_log.info("get connected CS for vArray: {}", id);
// Get and validate the varray with the passed id.
ArgValidator.checkFieldUriType(id, VirtualArray.class, "id");
VirtualArray varray = _dbClient.queryObject(VirtualArray.class, id);
ArgValidator.checkEntityNotNull(varray, id, isIdEmbeddedInURL(id));
BulkIdParam matchingCsIds = new BulkIdParam();
// get varray networks
List<Network> networks = CustomQueryUtility.queryActiveResourcesByRelation(_dbClient, id, Network.class, "connectedVirtualArrays");
// collect network vsanIds and switch ids
Set<String> networkVsanIds = new HashSet<>();
Set<String> nsIds = new HashSet<>();
for (Network network : networks) {
if (StorageProtocol.Transport.FC.name().equalsIgnoreCase(network.getTransportType()) && DiscoveredSystemObject.RegistrationStatus.REGISTERED.name().equals(network.getRegistrationStatus())) {
networkVsanIds.add(network.getNativeId());
if (network.getNetworkSystems() != null) {
nsIds.addAll(network.getNetworkSystems());
}
}
}
_log.info("vArray has these networks: {}", networkVsanIds);
// use only registered network systems
Set<URI> nsUris = new HashSet<>();
for (String nsUri : nsIds) {
nsUris.add(URI.create(nsUri));
}
List<NetworkSystem> nsList = _dbClient.queryObject(NetworkSystem.class, nsUris);
for (NetworkSystem ns : nsList) {
if (!DiscoveredSystemObject.RegistrationStatus.REGISTERED.name().equals(ns.getRegistrationStatus())) {
nsIds.remove(ns.getId().toString());
}
}
_log.info("the networks run on these network systems: {}", nsIds);
if (networkVsanIds.isEmpty() || nsIds.isEmpty()) {
// no networks in the array - exit early
return new ComputeSystemBulkRep();
}
// for every switch get FCEndpoint.remotePortName(s)
Set<String> connectedEndpoints = new HashSet<String>();
for (String nsId : nsIds) {
URIQueryResultList uriList = new URIQueryResultList();
_dbClient.queryByConstraint(ContainmentConstraint.Factory.getNetworkSystemFCPortConnectionConstraint(URI.create(nsId)), uriList);
List<URI> epIds = new ArrayList<URI>();
Iterator<URI> iter = uriList.iterator();
while (iter.hasNext()) {
epIds.add(iter.next());
}
List<FCEndpoint> eps = _dbClient.queryObjectField(FCEndpoint.class, "remotePortName", epIds);
for (FCEndpoint ep : eps) {
connectedEndpoints.add(ep.getRemotePortName());
}
}
_log.debug("all connected endpoints: {}", connectedEndpoints);
// get all CS
List<URI> csIds = _dbClient.queryByType(ComputeSystem.class, true);
List<ComputeSystem> csList = _dbClient.queryObject(ComputeSystem.class, csIds);
for (ComputeSystem cs : csList) {
if (!DiscoveredSystemObject.RegistrationStatus.REGISTERED.name().equals(cs.getRegistrationStatus())) {
// skip not registered CS
continue;
}
boolean connected = false;
_log.info("evaluating uplinks of cs: {}", cs.getLabel());
// loop thru UplinkPorts to find matches
URIQueryResultList uris = new URIQueryResultList();
_dbClient.queryByConstraint(ContainmentConstraint.Factory.getComputeSystemComputeFabricUplinkPortConstraint(cs.getId()), uris);
List<ComputeFabricUplinkPort> uplinkPorts = _dbClient.queryObject(ComputeFabricUplinkPort.class, uris, true);
for (ComputeFabricUplinkPort port : uplinkPorts) {
if (connectedEndpoints.contains(port.getWwpn())) {
_log.info("found matching endpoint: {}", port.getWwpn());
if (!Collections.disjoint(port.getVsans(), networkVsanIds)) {
_log.info("and networks overlap: {}", port.getVsans());
matchingCsIds.getIds().add(cs.getId());
connected = true;
break;
}
}
}
if (connected) {
// skip uplink port channel matching as we are already connected
continue;
}
// now loop thru UplinkPortChannels to find matches
uris = new URIQueryResultList();
_dbClient.queryByConstraint(ContainmentConstraint.Factory.getComputeSystemComputeUplinkPortChannelConstraint(cs.getId()), uris);
List<ComputeFabricUplinkPortChannel> uplinkPortChannels = _dbClient.queryObject(ComputeFabricUplinkPortChannel.class, uris, true);
for (ComputeFabricUplinkPortChannel port : uplinkPortChannels) {
if (connectedEndpoints.contains(port.getWwpn())) {
_log.info("found matching endpoint: {}", port.getWwpn());
if (!Collections.disjoint(port.getVsans(), networkVsanIds)) {
_log.info("and networks overlap: {}", port.getVsans());
matchingCsIds.getIds().add(cs.getId());
connected = true;
break;
}
}
}
}
_log.info("these CS are connected to the vArray: {}", matchingCsIds.getIds());
if (matchingCsIds.getIds().isEmpty()) {
return new ComputeSystemBulkRep();
}
ComputeSystemBulkRep computeSystemReps = computeSystemService.getBulkResources(matchingCsIds);
return mapValidServiceProfileTemplatesToComputeSystem(computeSystemReps, varray.getId());
}
Aggregations