Search in sources :

Example 71 with Network

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;
}
Also used : Initiator(com.emc.storageos.db.client.model.Initiator) Network(com.emc.storageos.db.client.model.Network) MapNetwork(com.emc.storageos.api.mapper.functions.MapNetwork) StringSet(com.emc.storageos.db.client.model.StringSet) InitiatorList(com.emc.storageos.model.host.InitiatorList) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 72 with Network

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);
}
Also used : Network(com.emc.storageos.db.client.model.Network) MapNetwork(com.emc.storageos.api.mapper.functions.MapNetwork) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Produces(javax.ws.rs.Produces) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 73 with Network

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);
}
Also used : Network(com.emc.storageos.db.client.model.Network) MapNetwork(com.emc.storageos.api.mapper.functions.MapNetwork) URI(java.net.URI) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 74 with Network

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);
}
Also used : StorageProtocol(com.emc.storageos.db.client.model.StorageProtocol) Network(com.emc.storageos.db.client.model.Network) MapNetwork(com.emc.storageos.api.mapper.functions.MapNetwork) URI(java.net.URI) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 75 with Network

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;
}
Also used : IpInterface(com.emc.storageos.db.client.model.IpInterface) IpInterfaceList(com.emc.storageos.model.host.IpInterfaceList) Network(com.emc.storageos.db.client.model.Network) MapNetwork(com.emc.storageos.api.mapper.functions.MapNetwork) StringSet(com.emc.storageos.db.client.model.StringSet) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Aggregations

Network (com.emc.storageos.db.client.model.Network)88 URI (java.net.URI)42 ArrayList (java.util.ArrayList)38 StringSet (com.emc.storageos.db.client.model.StringSet)31 VirtualArray (com.emc.storageos.db.client.model.VirtualArray)28 StoragePort (com.emc.storageos.db.client.model.StoragePort)25 StringMap (com.emc.storageos.db.client.model.StringMap)23 List (java.util.List)23 StoragePool (com.emc.storageos.db.client.model.StoragePool)22 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)22 Test (org.junit.Test)20 NamedURI (com.emc.storageos.db.client.model.NamedURI)19 Project (com.emc.storageos.db.client.model.Project)19 VirtualPool (com.emc.storageos.db.client.model.VirtualPool)19 VirtualPoolCapabilityValuesWrapper (com.emc.storageos.volumecontroller.impl.utils.VirtualPoolCapabilityValuesWrapper)19 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)17 TenantOrg (com.emc.storageos.db.client.model.TenantOrg)17 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)16 Produces (javax.ws.rs.Produces)16 RPProtectionRecommendation (com.emc.storageos.volumecontroller.RPProtectionRecommendation)15