Search in sources :

Example 16 with Network

use of com.emc.storageos.db.client.model.Network in project coprhd-controller by CoprHD.

the class NetworkService method doUpdateEndpoints.

/**
 * Adds/removes endpoints to/from networks and handles all the related
 * updates needed for:
 * <ul>
 * <li>The storage ports corresponding to the endpoints if they exist</li>
 * <li>The networks, the one the endpoints are added into, and the old one when an endpoint is moving from one network to another</li>
 * <li>The storage pools when this operation results in the pools being implicitly associated with the new network's varray and
 * disassociated from the old ones.</li>
 * </ul>
 * When a port is added:
 * <ul>
 * <li>the port's endpoint is added to the network</li>
 * <li>The port's network is set to the new network</li>
 * <li>The pool-to-varray associations are updated if needed.</li>
 * <li>If the ports exists in another network, its endpoint is removed from the old network and the pool-to-varray associations are also
 * updated</li>
 * </ul>
 * When a port is removed:
 * <ul>
 * <li>the port's endpoint is removed from the network</li>
 * <li>The port network is set null</li>
 * <li>The pool-to-varray associations are updated if needed.</li>
 * </ul>
 *
 * @param id the URN of a ViPR network
 * @param param the request object containing the endpoint to be added or removed
 *            as well as the operation type (add/remove).
 * @return the target networke
 */
public Network doUpdateEndpoints(URI id, NetworkEndpointParam param) {
    // This I am not sure about -
    _log.info("doUpdateEndpoints START...");
    ArgValidator.checkUri(id);
    Network network = _dbClient.queryObject(Network.class, id);
    ArgValidator.checkEntity(network, id, isIdEmbeddedInURL(id));
    NetworkEndpointParam.EndpointOp op = NetworkEndpointParam.EndpointOp.valueOf(param.getOp());
    List<String> updatedEndoints = null;
    // create an update parameter
    if (op.equals(NetworkEndpointParam.EndpointOp.add)) {
        _log.info("doUpdateEndpoints: adding endpoints {} to network {}", param.getEndpoints(), network);
        updatedEndoints = checkAndFilterAddEndpoints(network, param.getEndpoints());
        network.addEndpoints(updatedEndoints, false);
    } else {
        _log.info("doUpdateEndpoints: removing endpoints {} from network {}", param.getEndpoints(), network);
        updatedEndoints = checkAndFilterRemoveEndPoints(network, param.getEndpoints());
        network.removeEndpoints(updatedEndoints);
    }
    _dbClient.updateAndReindexObject(network);
    _log.info("doUpdateEndpoints: update the port and pools associations following {} endpoints operation", op.name());
    updateEndpointsAssociation(network, updatedEndoints, op);
    return network;
}
Also used : NetworkEndpointParam(com.emc.storageos.model.varray.NetworkEndpointParam) Network(com.emc.storageos.db.client.model.Network) MapNetwork(com.emc.storageos.api.mapper.functions.MapNetwork)

Example 17 with Network

use of com.emc.storageos.db.client.model.Network in project coprhd-controller by CoprHD.

the class NetworkService method updateNetworkEndpoints.

/**
 * Add or remove end-point(s) to network.
 * <p>
 * For fiber channel, some Networks may be automatically created by discovering Network Systems. These Networks will have endpoints that
 * were discovered by a Network System, including endpoints that represent host initiator port WWNs as well as end points that represent
 * storage array port WWNs.
 * <p>
 * Discovered endpoints may not be deleted by the user. They will be updated periodically as the Network System refreshes its
 * information on the topology of the VSANs or Fabrics.
 * <p>
 * The user may still manually add endpoints to a discovered Network. The user is able to delete endpoints that were manually added. If
 * a manually entered endpoint is subsequently discovered by a a Network System, it becomes managed as if it were discovered originally,
 * and then may no longer be deleted.
 * <p>
 * This API is maintained for backward compatibility. Since the method is deprecated use /vdc/networks/{id} instead.
 *
 * @see #updateNetwork(URI, NetworkUpdate)
 * @param id the URN of a ViPR Network
 * @param param Network endpoint parameters
 * @deprecated use {@link #updateNetwork(URI, NetworkUpdate)}
 * @brief Add or remove network end points
 * @return Network details
 */
@PUT
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/endpoints")
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.RESTRICTED_SYSTEM_ADMIN })
@Deprecated
public NetworkRestRep updateNetworkEndpoints(@PathParam("id") URI id, NetworkEndpointParam param) {
    Network network = doUpdateEndpoints(id, param);
    recordAndAudit(network, OperationTypeEnum.UPDATE_NETWORK);
    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) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) PUT(javax.ws.rs.PUT) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 18 with Network

use of com.emc.storageos.db.client.model.Network in project coprhd-controller by CoprHD.

the class NetworkService method queryResource.

@Override
protected Network queryResource(URI id) {
    ArgValidator.checkFieldUriType(id, Network.class, "id");
    Network tzone = _dbClient.queryObject(Network.class, id);
    ArgValidator.checkEntityNotNull(tzone, id, isIdEmbeddedInURL(id));
    return tzone;
}
Also used : Network(com.emc.storageos.db.client.model.Network) MapNetwork(com.emc.storageos.api.mapper.functions.MapNetwork)

Example 19 with Network

use of com.emc.storageos.db.client.model.Network in project coprhd-controller by CoprHD.

the class NetworkSystemService method deleteNetworkSystem.

/**
 * Delete a network system. The method will delete the
 * network system and all resources associated with it.
 *
 * @prereq The network system must be unregistered
 * @brief Delete network system
 * @return An asynchronous task.
 *
 * @throws DatabaseException
 *             When an error occurs querying the database.
 */
@POST
@Path("/{id}/deactivate")
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.RESTRICTED_SYSTEM_ADMIN })
public TaskResourceRep deleteNetworkSystem(@PathParam("id") URI id) throws DatabaseException {
    NetworkSystem system = queryObject(NetworkSystem.class, id, true);
    ArgValidator.checkEntity(system, id, isIdEmbeddedInURL(id));
    if (!RegistrationStatus.UNREGISTERED.toString().equals(system.getRegistrationStatus())) {
        throw APIException.badRequests.invalidParameterCannotDeactivateRegisteredNetworkSystem(system.getId());
    }
    if (DiscoveredDataObject.DataCollectionJobStatus.IN_PROGRESS.toString().equals(system.getDiscoveryStatus()) || DiscoveredDataObject.DataCollectionJobStatus.SCHEDULED.toString().equals(system.getDiscoveryStatus())) {
        throw APIException.serviceUnavailable.cannotDeactivateStorageSystemWhileInDiscover(system.getId());
    }
    List<Network> networkList = CustomQueryUtility.queryActiveResourcesByConstraint(_dbClient, Network.class, AlternateIdConstraint.Factory.getConstraint(Network.class, "networkSystems", system.getId().toString()));
    for (Network network : networkList) {
        if (network != null && network.getInactive() != true && network.getConnectedVirtualArrays() != null && !network.getConnectedVirtualArrays().isEmpty() && (network.getNetworkSystems() != null && network.getNetworkSystems().contains(system.getId().toString()) && network.getNetworkSystems().size() == 1)) {
            throw APIException.badRequests.invalidParameterNetworkMustBeUnassignedFromVirtualArray(network.getLabel(), system.getLabel());
        }
    }
    Map<String, List<FCZoneReference>> zonesMap = getNetworkSystemZoneRefs(system);
    List<URI> nsystems = null;
    List<FCZoneReference> zones = null;
    // by the purge process
    for (Network network : networkList) {
        // remove references from ports
        nsystems = StringSetUtil.stringSetToUriList(network.getNetworkSystems());
        nsystems.remove(system.getId());
        if (nsystems.isEmpty()) {
            // This network will be removed - Remove any storage port references
            List<StoragePort> netPorts = NetworkAssociationHelper.getNetworkStoragePorts(network.getId().toString(), null, _dbClient);
            NetworkAssociationHelper.clearPortAssociations(netPorts, _dbClient);
        } else {
            // This network will remain, update any zone references to use another network system
            URI nsUri = nsystems.get(0);
            zones = zonesMap.get(network.getNativeId());
            if (zones != null) {
                for (FCZoneReference zone : zones) {
                    zone.setNetworkSystemUri(nsUri);
                }
                _dbClient.updateObject(zones);
            }
        }
    }
    String taskId = UUID.randomUUID().toString();
    Operation op = _dbClient.createTaskOpStatus(NetworkSystem.class, system.getId(), taskId, ResourceOperationTypeEnum.DELETE_NETWORK_SYSTEM);
    PurgeRunnable.executePurging(_dbClient, _dbPurger, _asynchJobService.getExecutorService(), system, _retry_attempts, taskId, 60);
    auditOp(OperationTypeEnum.DELETE_NETWORK_SYSTEM, true, AuditLogManager.AUDITOP_BEGIN, system.getId().toString(), system.getLabel(), system.getPortNumber(), system.getUsername(), system.getSmisProviderIP(), system.getSmisPortNumber(), system.getSmisUserName(), system.getSmisUseSSL(), system.getVersion(), system.getUptime());
    return toTask(system, taskId, op);
}
Also used : NetworkSystem(com.emc.storageos.db.client.model.NetworkSystem) MapNetworkSystem(com.emc.storageos.api.mapper.functions.MapNetworkSystem) StoragePort(com.emc.storageos.db.client.model.StoragePort) Operation(com.emc.storageos.db.client.model.Operation) URI(java.net.URI) FCZoneReference(com.emc.storageos.db.client.model.FCZoneReference) Network(com.emc.storageos.db.client.model.Network) NetworkSystemList(com.emc.storageos.model.network.NetworkSystemList) List(java.util.List) ArrayList(java.util.ArrayList) TaskList(com.emc.storageos.model.TaskList) BulkList(com.emc.storageos.api.service.impl.response.BulkList) 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 20 with Network

use of com.emc.storageos.db.client.model.Network in project coprhd-controller by CoprHD.

the class PlacementTests method testPlacementRpXIONoVplex.

/**
 * RP placement tests with XIO (no VPLEX)
 */
@Test
public void testPlacementRpXIONoVplex() {
    String[] xio1FE = { "50:FE:FE:FE:FE:FE:FE:00", "50:FE:FE:FE:FE:FE:FE:01" };
    String[] xio2FE = { "51:FE:FE:FE:FE:FE:FE:00", "51:FE:FE:FE:FE:FE:FE:01" };
    String[] xio3FE = { "52:FE:FE:FE:FE:FE:FE:00", "52:FE:FE:FE:FE:FE:FE:01" };
    String[] xio4FE = { "53:FE:FE:FE:FE:FE:FE:00", "53:FE:FE:FE:FE:FE:FE:01" };
    String[] xio5FE = { "54:FE:FE:FE:FE:FE:FE:00", "54:FE:FE:FE:FE:FE:FE:01" };
    String[] xio6FE = { "55:FE:FE:FE:FE:FE:FE:00", "55:FE:FE:FE:FE:FE:FE:01" };
    String[] rp1FE = { "56:FE:FE:FE:FE:FE:FE:00", "56:FE:FE:FE:FE:FE:FE:01" };
    String[] rp2FE = { "57:FE:FE:FE:FE:FE:FE:00", "57:FE:FE:FE:FE:FE:FE:01" };
    // Create 2 Virtual Arrays
    VirtualArray varray1 = PlacementTestUtils.createVirtualArray(_dbClient, "varray1");
    VirtualArray varray2 = PlacementTestUtils.createVirtualArray(_dbClient, "varray2");
    // Create 2 Networks
    StringSet connVA = new StringSet();
    connVA.add(varray1.getId().toString());
    Network network1 = PlacementTestUtils.createNetwork(_dbClient, rp1FE, "VSANSite1", "FC+BROCADE+FE", connVA);
    connVA = new StringSet();
    connVA.add(varray2.getId().toString());
    Network network2 = PlacementTestUtils.createNetwork(_dbClient, rp2FE, "VSANSite2", "FC+CISCO+FE", connVA);
    // Create 6 storage systems
    StorageSystem storageSystem1 = PlacementTestUtils.createStorageSystem(_dbClient, "xtremio", "xtremio1");
    StorageSystem storageSystem2 = PlacementTestUtils.createStorageSystem(_dbClient, "xtremio", "xtremio2");
    StorageSystem storageSystem3 = PlacementTestUtils.createStorageSystem(_dbClient, "xtremio", "xtremio3");
    StorageSystem storageSystem4 = PlacementTestUtils.createStorageSystem(_dbClient, "xtremio", "xtremio4");
    StorageSystem storageSystem5 = PlacementTestUtils.createStorageSystem(_dbClient, "xtremio", "xtremio5");
    StorageSystem storageSystem6 = PlacementTestUtils.createStorageSystem(_dbClient, "xtremio", "xtremio6");
    // Create two front-end storage ports XIO1
    List<StoragePort> xio1Ports = new ArrayList<StoragePort>();
    for (int i = 0; i < xio1FE.length; i++) {
        xio1Ports.add(PlacementTestUtils.createStoragePort(_dbClient, storageSystem1, network1, xio1FE[i], varray1, StoragePort.PortType.frontend.name(), "portGroupSite1xio1" + i, "C0+FC0" + i));
    }
    // Create two front-end storage ports XIO2
    List<StoragePort> xio2Ports = new ArrayList<StoragePort>();
    for (int i = 0; i < xio2FE.length; i++) {
        xio2Ports.add(PlacementTestUtils.createStoragePort(_dbClient, storageSystem2, network1, xio2FE[i], varray1, StoragePort.PortType.frontend.name(), "portGroupSite1xio2" + i, "D0+FC0" + i));
    }
    // Create two front-end storage ports XIO3
    List<StoragePort> xio3Ports = new ArrayList<StoragePort>();
    for (int i = 0; i < xio3FE.length; i++) {
        xio3Ports.add(PlacementTestUtils.createStoragePort(_dbClient, storageSystem3, network1, xio3FE[i], varray1, StoragePort.PortType.frontend.name(), "portGroupSite1xio3" + i, "E0+FC0" + i));
    }
    // Create two front-end storage ports XIO4
    List<StoragePort> xio4Ports = new ArrayList<StoragePort>();
    for (int i = 0; i < xio4FE.length; i++) {
        xio4Ports.add(PlacementTestUtils.createStoragePort(_dbClient, storageSystem4, network2, xio4FE[i], varray2, StoragePort.PortType.frontend.name(), "portGroupSite2xio4" + i, "F0+FC0" + i));
    }
    // Create two front-end storage ports XIO5
    List<StoragePort> xio5Ports = new ArrayList<StoragePort>();
    for (int i = 0; i < xio5FE.length; i++) {
        xio5Ports.add(PlacementTestUtils.createStoragePort(_dbClient, storageSystem5, network2, xio5FE[i], varray2, StoragePort.PortType.frontend.name(), "portGroupSite2xio5" + i, "G0+FC0" + i));
    }
    // Create two front-end storage ports XIO6
    List<StoragePort> xio6Ports = new ArrayList<StoragePort>();
    for (int i = 0; i < xio6FE.length; i++) {
        xio6Ports.add(PlacementTestUtils.createStoragePort(_dbClient, storageSystem6, network2, xio6FE[i], varray2, StoragePort.PortType.frontend.name(), "portGroupSite2xio6" + i, "H0+FC0" + i));
    }
    // Create RP system
    AbstractChangeTrackingSet<String> wwnSite1 = new StringSet();
    for (int i = 0; i < rp1FE.length; i++) {
        wwnSite1.add(rp1FE[i]);
    }
    StringSetMap initiatorsSiteMap = new StringSetMap();
    initiatorsSiteMap.put("site1", wwnSite1);
    AbstractChangeTrackingSet<String> wwnSite2 = new StringSet();
    for (int i = 0; i < rp2FE.length; i++) {
        wwnSite2.add(rp2FE[i]);
    }
    initiatorsSiteMap.put("site2", wwnSite2);
    StringSet storSystems = new StringSet();
    storSystems.add(ProtectionSystem.generateAssociatedStorageSystem("site1", storageSystem1.getSerialNumber()));
    storSystems.add(ProtectionSystem.generateAssociatedStorageSystem("site1", storageSystem2.getSerialNumber()));
    storSystems.add(ProtectionSystem.generateAssociatedStorageSystem("site1", storageSystem3.getSerialNumber()));
    storSystems.add(ProtectionSystem.generateAssociatedStorageSystem("site2", storageSystem4.getSerialNumber()));
    storSystems.add(ProtectionSystem.generateAssociatedStorageSystem("site2", storageSystem5.getSerialNumber()));
    storSystems.add(ProtectionSystem.generateAssociatedStorageSystem("site2", storageSystem6.getSerialNumber()));
    StringMap siteVolCap = new StringMap();
    siteVolCap.put("site1", "3221225472");
    siteVolCap.put("site2", "3221225472");
    StringMap siteVolCnt = new StringMap();
    siteVolCnt.put("site1", "10");
    siteVolCnt.put("site2", "10");
    ProtectionSystem rpSystem = PlacementTestUtils.createProtectionSystem(_dbClient, "rp", "rp1", "site1", "site2", null, "IP", initiatorsSiteMap, storSystems, null, Long.valueOf("3221225472"), Long.valueOf("2"), siteVolCap, siteVolCnt);
    // RP Site Array objects
    RPSiteArray rpSiteArray1 = new RPSiteArray();
    rpSiteArray1.setId(URI.create("rsa1"));
    rpSiteArray1.setStorageSystem(URI.create("xtremio1"));
    rpSiteArray1.setRpInternalSiteName("site1");
    rpSiteArray1.setRpProtectionSystem(rpSystem.getId());
    _dbClient.createObject(rpSiteArray1);
    RPSiteArray rpSiteArray2 = new RPSiteArray();
    rpSiteArray2.setId(URI.create("rsa2"));
    rpSiteArray2.setStorageSystem(URI.create("xtremio2"));
    rpSiteArray2.setRpInternalSiteName("site1");
    rpSiteArray2.setRpProtectionSystem(rpSystem.getId());
    _dbClient.createObject(rpSiteArray2);
    RPSiteArray rpSiteArray3 = new RPSiteArray();
    rpSiteArray3.setId(URI.create("rsa3"));
    rpSiteArray3.setStorageSystem(URI.create("xtremio3"));
    rpSiteArray3.setRpInternalSiteName("site1");
    rpSiteArray3.setRpProtectionSystem(rpSystem.getId());
    _dbClient.createObject(rpSiteArray3);
    RPSiteArray rpSiteArray4 = new RPSiteArray();
    rpSiteArray4.setId(URI.create("rsa4"));
    rpSiteArray4.setStorageSystem(URI.create("xtremio4"));
    rpSiteArray4.setRpInternalSiteName("site2");
    rpSiteArray4.setRpProtectionSystem(rpSystem.getId());
    _dbClient.createObject(rpSiteArray4);
    RPSiteArray rpSiteArray5 = new RPSiteArray();
    rpSiteArray5.setId(URI.create("rsa5"));
    rpSiteArray5.setStorageSystem(URI.create("xtremio5"));
    rpSiteArray5.setRpInternalSiteName("site2");
    rpSiteArray5.setRpProtectionSystem(rpSystem.getId());
    _dbClient.createObject(rpSiteArray5);
    RPSiteArray rpSiteArray6 = new RPSiteArray();
    rpSiteArray6.setId(URI.create("rsa6"));
    rpSiteArray6.setStorageSystem(URI.create("xtremio6"));
    rpSiteArray6.setRpInternalSiteName("site2");
    rpSiteArray6.setRpProtectionSystem(rpSystem.getId());
    _dbClient.createObject(rpSiteArray6);
    // Create a storage pool for xio1
    StoragePool pool1 = PlacementTestUtils.createStoragePool(_dbClient, varray1, storageSystem1, "pool1", "Pool1", Long.valueOf(1024 * 1024 * 10), Long.valueOf(1024 * 1024 * 10), 300, 300, StoragePool.SupportedResourceTypes.THIN_ONLY.toString());
    // Create a storage pool for xio2
    StoragePool pool2 = PlacementTestUtils.createStoragePool(_dbClient, varray1, storageSystem2, "pool2", "Pool2", Long.valueOf(1024 * 1024 * 10), Long.valueOf(1024 * 1024 * 10), 300, 300, StoragePool.SupportedResourceTypes.THIN_ONLY.toString());
    // Create a storage pool for xio3
    StoragePool pool3 = PlacementTestUtils.createStoragePool(_dbClient, varray1, storageSystem3, "pool3", "Pool3", Long.valueOf(1024 * 1024 * 1), Long.valueOf(1024 * 1024 * 1), 100, 100, StoragePool.SupportedResourceTypes.THIN_ONLY.toString());
    // Create a storage pool for xio4
    StoragePool pool4 = PlacementTestUtils.createStoragePool(_dbClient, varray2, storageSystem4, "pool4", "Pool4", Long.valueOf(1024 * 1024 * 10), Long.valueOf(1024 * 1024 * 10), 300, 300, StoragePool.SupportedResourceTypes.THIN_ONLY.toString());
    // Create a storage pool for xio5
    StoragePool pool5 = PlacementTestUtils.createStoragePool(_dbClient, varray2, storageSystem5, "pool5", "Pool5", Long.valueOf(1024 * 1024 * 10), Long.valueOf(1024 * 1024 * 10), 300, 300, StoragePool.SupportedResourceTypes.THIN_ONLY.toString());
    // Create a storage pool for xio6
    StoragePool pool6 = PlacementTestUtils.createStoragePool(_dbClient, varray2, storageSystem6, "pool6", "Pool6", Long.valueOf(1024 * 1024 * 1), Long.valueOf(1024 * 1024 * 1), 100, 100, StoragePool.SupportedResourceTypes.THIN_ONLY.toString());
    // Create a RP virtual pool
    VirtualPool rpVpool = new VirtualPool();
    rpVpool.setId(URI.create("rpVpool"));
    rpVpool.setLabel("rpVpool");
    rpVpool.setSupportedProvisioningType(VirtualPool.ProvisioningType.Thin.name());
    rpVpool.setDriveType(SupportedDriveTypes.FC.name());
    VpoolProtectionVarraySettings protectionSettings = new VpoolProtectionVarraySettings();
    protectionSettings.setVirtualPool(URI.create("vpool"));
    protectionSettings.setId(URI.create("protectionSettings"));
    _dbClient.createObject(protectionSettings);
    List<VpoolProtectionVarraySettings> protectionSettingsList = new ArrayList<VpoolProtectionVarraySettings>();
    protectionSettingsList.add(protectionSettings);
    StringMap protectionVarray = new StringMap();
    protectionVarray.put(varray2.getId().toString(), protectionSettingsList.get(0).getId().toString());
    rpVpool.setProtectionVarraySettings(protectionVarray);
    rpVpool.setRpCopyMode("SYNCHRONOUS");
    rpVpool.setRpRpoType("MINUTES");
    rpVpool.setRpRpoValue(Long.valueOf("5"));
    StringSet matchedPools = new StringSet();
    matchedPools.add(pool1.getId().toString());
    matchedPools.add(pool2.getId().toString());
    matchedPools.add(pool3.getId().toString());
    rpVpool.setMatchedStoragePools(matchedPools);
    rpVpool.setUseMatchedPools(true);
    StringSet virtualArrays1 = new StringSet();
    virtualArrays1.add(varray1.getId().toString());
    rpVpool.setVirtualArrays(virtualArrays1);
    _dbClient.createObject(rpVpool);
    // Create a virtual pool
    VirtualPool vpool = new VirtualPool();
    vpool.setId(URI.create("vpool"));
    vpool.setLabel("vpool");
    vpool.setSupportedProvisioningType(VirtualPool.ProvisioningType.Thin.name());
    vpool.setDriveType(SupportedDriveTypes.FC.name());
    matchedPools = new StringSet();
    matchedPools.add(pool4.getId().toString());
    matchedPools.add(pool5.getId().toString());
    matchedPools.add(pool6.getId().toString());
    vpool.setMatchedStoragePools(matchedPools);
    vpool.setUseMatchedPools(true);
    StringSet virtualArrays2 = new StringSet();
    virtualArrays2.add(varray2.getId().toString());
    vpool.setVirtualArrays(virtualArrays2);
    _dbClient.createObject(vpool);
    // Create Tenant
    TenantOrg tenant = new TenantOrg();
    tenant.setId(URI.create("tenant"));
    _dbClient.createObject(tenant);
    // Create a project object
    Project project = new Project();
    project.setId(URI.create("project"));
    project.setLabel("project");
    project.setTenantOrg(new NamedURI(tenant.getId(), project.getLabel()));
    _dbClient.createObject(project);
    // Create block consistency group
    BlockConsistencyGroup cg = new BlockConsistencyGroup();
    cg.setProject(new NamedURI(project.getId(), project.getLabel()));
    cg.setId(URI.create("blockCG"));
    _dbClient.createObject(cg);
    // Create capabilities
    VirtualPoolCapabilityValuesWrapper capabilities = PlacementTestUtils.createCapabilities("2GB", 1, cg);
    // Run single volume placement: Run 10 times to make sure pool3 never comes up for source and pool6 for target.
    for (int i = 0; i < 10; i++) {
        List recommendations = PlacementTestUtils.invokePlacement(_dbClient, _coordinator, varray1, project, rpVpool, capabilities);
        assertNotNull(recommendations);
        assertTrue(!recommendations.isEmpty());
        assertNotNull(recommendations.get(0));
        RPProtectionRecommendation rec = (RPProtectionRecommendation) recommendations.get(0);
        assertNotNull(rec.getSourceRecommendations());
        assertTrue(!rec.getSourceRecommendations().isEmpty());
        assertNotNull(rec.getProtectionDevice());
        assertNotNull(rec.getPlacementStepsCompleted().name());
        assertTrue("rp1".equals(rec.getProtectionDevice().toString()));
        for (RPRecommendation sourceRec : rec.getSourceRecommendations()) {
            assertNotNull(sourceRec);
            assertNotNull(sourceRec.getInternalSiteName());
            assertNotNull(sourceRec.getSourceStorageSystem());
            assertNotNull(sourceRec.getSourceStoragePool());
            assertTrue(sourceRec.getVirtualArray().toString().equals("varray1"));
            assertTrue("site1".equals(sourceRec.getInternalSiteName()));
            assertTrue("xtremio2".equals(sourceRec.getSourceStorageSystem().toString()));
            assertTrue(("pool2".equals(sourceRec.getSourceStoragePool().toString())) || ("pool1".equals(sourceRec.getSourceStoragePool().toString())));
            assertNotNull(sourceRec.getTargetRecommendations());
            assertTrue(!sourceRec.getTargetRecommendations().isEmpty());
            for (RPRecommendation targetRec : sourceRec.getTargetRecommendations()) {
                assertNotNull(targetRec.getSourceStoragePool());
                assertTrue("xtremio4".equals(targetRec.getSourceStorageSystem().toString()));
                assertTrue("site2".equals(targetRec.getInternalSiteName()));
                assertTrue(targetRec.getVirtualArray().toString().equals("varray2"));
                assertTrue("pool4".equals(targetRec.getSourceStoragePool().toString()) || "pool5".equals(targetRec.getSourceStoragePool().toString()));
            }
        }
        // source journal
        assertNotNull(rec.getSourceJournalRecommendation());
        assertNotNull(rec.getSourceJournalRecommendation().getSourceStoragePool());
        assertTrue(("pool2".equals(rec.getSourceJournalRecommendation().getSourceStoragePool().toString())) || ("pool1".equals(rec.getSourceJournalRecommendation().getSourceStoragePool().toString())));
        // target journal
        assertNotNull(rec.getTargetJournalRecommendations());
        assertTrue(!rec.getTargetJournalRecommendations().isEmpty());
        for (RPRecommendation targetJournalRec : rec.getTargetJournalRecommendations()) {
            assertNotNull(targetJournalRec.getSourceStoragePool());
            assertTrue(targetJournalRec.getVirtualArray().toString().equals("varray2"));
            assertTrue("pool4".equals(targetJournalRec.getSourceStoragePool().toString()) || "pool5".equals(targetJournalRec.getSourceStoragePool().toString()) || "pool6".equals(targetJournalRec.getSourceStoragePool().toString()));
            assertTrue("site2".equals(targetJournalRec.getInternalSiteName()));
            assertTrue("xtremio4".equals(targetJournalRec.getSourceStorageSystem().toString()) || "xtremio5".equals(targetJournalRec.getSourceStorageSystem().toString()) || "xtremio6".equals(targetJournalRec.getSourceStorageSystem().toString()));
        }
        _log.info(rec.toString(_dbClient));
    }
}
Also used : VirtualPoolCapabilityValuesWrapper(com.emc.storageos.volumecontroller.impl.utils.VirtualPoolCapabilityValuesWrapper) RPSiteArray(com.emc.storageos.db.client.model.RPSiteArray) VirtualArray(com.emc.storageos.db.client.model.VirtualArray) StringMap(com.emc.storageos.db.client.model.StringMap) StoragePool(com.emc.storageos.db.client.model.StoragePool) RPProtectionRecommendation(com.emc.storageos.volumecontroller.RPProtectionRecommendation) NamedURI(com.emc.storageos.db.client.model.NamedURI) ArrayList(java.util.ArrayList) ProtectionSystem(com.emc.storageos.db.client.model.ProtectionSystem) RPRecommendation(com.emc.storageos.volumecontroller.RPRecommendation) Network(com.emc.storageos.db.client.model.Network) StringSet(com.emc.storageos.db.client.model.StringSet) List(java.util.List) ArrayList(java.util.ArrayList) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) StringSetMap(com.emc.storageos.db.client.model.StringSetMap) StoragePort(com.emc.storageos.db.client.model.StoragePort) VpoolProtectionVarraySettings(com.emc.storageos.db.client.model.VpoolProtectionVarraySettings) VirtualPool(com.emc.storageos.db.client.model.VirtualPool) BlockConsistencyGroup(com.emc.storageos.db.client.model.BlockConsistencyGroup) Project(com.emc.storageos.db.client.model.Project) TenantOrg(com.emc.storageos.db.client.model.TenantOrg) Test(org.junit.Test)

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