use of com.emc.storageos.db.client.model.Network in project coprhd-controller by CoprHD.
the class NetworkService method getInitiators.
/**
* This call returns a list of all Initiators associated
* with the Network end points.
*
* @param id the URN of a ViPR network
* @brief List initiators
* @return InitiatorList
*/
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.SYSTEM_MONITOR })
@Path("/{id}/initiators")
public InitiatorList getInitiators(@PathParam("id") URI id) {
InitiatorList registeredInitiators = new InitiatorList();
ArgValidator.checkFieldUriType(id, Network.class, "id");
Network tzone = queryResource(id);
StringSet endpts = tzone.retrieveEndpoints();
Iterator<String> endptsIter = endpts.iterator();
URIQueryResultList resultsList = new URIQueryResultList();
while (endptsIter.hasNext()) {
String endpt = endptsIter.next();
_dbClient.queryByConstraint(AlternateIdConstraint.Factory.getInitiatorPortInitiatorConstraint(endpt), resultsList);
Iterator<URI> resultsIter = resultsList.iterator();
while (resultsIter.hasNext()) {
Initiator initiator = _dbClient.queryObject(Initiator.class, resultsIter.next());
if (initiator != null) {
registeredInitiators.getInitiators().add(toNamedRelatedResource(initiator, initiator.getLabel()));
}
}
}
return registeredInitiators;
}
use of com.emc.storageos.db.client.model.Network in project coprhd-controller by CoprHD.
the class NetworkService method deregisterNetwork.
/**
* Allows the user to deregister a registered network so that it is no
* longer used by the system. This simply sets the registration_status of
* the network to UNREGISTERED.
*
* @param id the URN of a ViPR network.
*
* @brief Unregister network
* @return Status response indicating success or failure
*/
@POST
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/deregister")
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.RESTRICTED_SYSTEM_ADMIN })
public NetworkRestRep deregisterNetwork(@PathParam("id") URI id) {
Network network = queryResource(id);
ArgValidator.checkEntity(network, id, isIdEmbeddedInURL(id));
if (RegistrationStatus.REGISTERED.toString().equalsIgnoreCase(network.getRegistrationStatus())) {
network.setRegistrationStatus(RegistrationStatus.UNREGISTERED.toString());
_dbClient.persistObject(network);
auditOp(OperationTypeEnum.DEREGISTER_NETWORK, true, null, network.getLabel(), network.getId().toString());
}
return MapNetwork.toNetworkRestRep(network, _dbClient);
}
use of com.emc.storageos.db.client.model.Network in project coprhd-controller by CoprHD.
the class NetworkService method registerNetwork.
/**
* Manually register the network with the passed id.
*
* @param id the URN of a ViPR network.
*
* @brief Register network
* @return A reference to a StoragePoolRestRep specifying the data for the
* registered storage pool.
*/
@POST
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.RESTRICTED_SYSTEM_ADMIN })
@Path("/{id}/register")
public NetworkRestRep registerNetwork(@PathParam("id") URI id) {
ArgValidator.checkFieldUriType(id, Network.class, "id");
Network network = _dbClient.queryObject(Network.class, id);
ArgValidator.checkEntity(network, id, isIdEmbeddedInURL(id));
if (RegistrationStatus.UNREGISTERED.toString().equalsIgnoreCase(network.getRegistrationStatus())) {
if (network.getDiscovered()) {
List<URI> registeredNetworkSystems = getRegisteredNetworkSystems(network, _dbClient);
if (registeredNetworkSystems.isEmpty()) {
throw APIException.badRequests.invalidParameterCannotRegisterUnmanagedNetwork(network.getId());
}
}
network.setRegistrationStatus(RegistrationStatus.REGISTERED.toString());
_dbClient.persistObject(network);
auditOp(OperationTypeEnum.REGISTER_NETWORK, true, null, network.getId().toString());
}
return MapNetwork.toNetworkRestRep(network, _dbClient);
}
use of com.emc.storageos.db.client.model.Network in project coprhd-controller by CoprHD.
the class NetworkService method createNetwork.
/**
* Create a network of type FC, IP or Ethernet. The network can optionally
* be added to varrays and populated with endpoints.
* <p>
* When the network has endpoints and the endpoints are matched to storage ports, the storage ports become assigned to the network. When
* the network is also added to virtual arrays, the storage ports' array pools are update to show they are connected to the networks'
* varrays.
*
* @param param object containing the request parameters
* @brief Create network
* @return the details of the created network
*/
@POST
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.RESTRICTED_SYSTEM_ADMIN })
public NetworkRestRep createNetwork(NetworkCreate param) {
_log.info("createNetwork: started for param: name {} and type {}", param.getLabel(), param.getTransportType());
// check for active network with same name
ArgValidator.checkFieldNotEmpty(param.getLabel(), "label");
checkDuplicateLabel(Network.class, param.getLabel());
// check the type is supported
StorageProtocol.Transport type = StorageProtocol.Transport.valueOf(param.getTransportType());
// check VirtualArrays
if (param.getVarrays() != null) {
for (URI uri : param.getVarrays()) {
queryObject(VirtualArray.class, uri, true);
}
}
Network network = new Network();
network.setId(URIUtil.createId(Network.class));
network.setLabel(param.getLabel());
network.setTransportType(type.name());
network.setAssignedVirtualArrays(StringSetUtil.uriListToStringSet(param.getVarrays()));
network.addEndpoints(checkAndFilterAddEndpoints(network, param.getEndpoints()), false);
_dbClient.createObject(network);
recordAndAudit(network, OperationTypeEnum.CREATE_NETWORK);
_log.info("createNetwork: updating ports and pools associations ");
NetworkAssociationHelper.handleNetworkUpdated(network, StringSetUtil.stringSetToUriList(network.getAssignedVirtualArrays()), null, network.getEndpointsMap().keySet(), null, _dbClient, _coordinator);
return MapNetwork.toNetworkRestRep(network, _dbClient);
}
use of com.emc.storageos.db.client.model.Network in project coprhd-controller by CoprHD.
the class NetworkService method getIpInterfaces.
/**
* This call returns a list of all IpInterfaces associated
* with the Network end points.
*
* @param id the URN of a ViPR network
* @brief List IP interfaces
* @return IpInterfaceList
*/
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.SYSTEM_MONITOR })
@Path("/{id}/ip-interfaces")
public IpInterfaceList getIpInterfaces(@PathParam("id") URI id) {
IpInterfaceList registeredIpInterfaces = new IpInterfaceList();
ArgValidator.checkFieldUriType(id, Network.class, "id");
Network tzone = queryResource(id);
if (StorageProtocol.Transport.IP.name().equalsIgnoreCase(tzone.getTransportType())) {
StringSet endpts = tzone.retrieveEndpoints();
Iterator<String> endptsIter = endpts.iterator();
URIQueryResultList resultsList = new URIQueryResultList();
while (endptsIter.hasNext()) {
String endpt = endptsIter.next();
_dbClient.queryByConstraint(AlternateIdConstraint.Factory.getIpInterfaceIpAddressConstraint(endpt.toUpperCase()), resultsList);
Iterator<URI> resultsIter = resultsList.iterator();
while (resultsIter.hasNext()) {
IpInterface ipInterface = _dbClient.queryObject(IpInterface.class, resultsIter.next());
if (ipInterface != null) {
registeredIpInterfaces.getIpInterfaces().add(toNamedRelatedResource(ipInterface, ipInterface.getLabel()));
}
}
}
}
return registeredIpInterfaces;
}
Aggregations