Search in sources :

Example 1 with InternalNetworkClient

use of com.emc.storageos.api.service.impl.resource.utils.InternalNetworkClient in project coprhd-controller by CoprHD.

the class InternalApiTest method setup.

@Before
public void setup() throws Exception {
    _requestHelper = new ClientRequestHelper(_coordinatorClient);
    _client = _requestHelper.createClient();
    _internalFileClient = new InternalFileServiceClient();
    _internalFileClient.setCoordinatorClient(_coordinatorClient);
    _internalFileClient.setServer(_server);
    _internalNetworkClient = new InternalNetworkClient();
    _internalNetworkClient.setCoordinatorClient(_coordinatorClient);
    _internalNetworkClient.setServer(_server);
    List<String> urls = new ArrayList<String>();
    urls.add(_apiServer);
    rSys = createHttpsClient(SYSADMIN, SYSADMIN_PASS_WORD, urls);
    TenantResponse tenantResp = rSys.path("/tenant").get(TenantResponse.class);
    _rootTenantId = tenantResp.getTenant();
    _rootToken = (String) _savedTokens.get("root");
    // find a CoS to use
    Resources results = rSys.path("/file/vpools/search").queryParam("name", "cosisi").get(Resources.class);
    Assert.assertTrue(results.resource.iterator().hasNext());
    _cosId = results.resource.iterator().next().getId();
    String cosAclUrl = "/file/vpools/" + _cosId.toString() + "/acl";
    ACLAssignmentChanges changes = new ACLAssignmentChanges();
    ACLEntry entry1 = new ACLEntry();
    entry1.setTenant(_rootTenantId.toString());
    entry1.getAces().add("USE");
    changes.getAdd().add(entry1);
    ClientResponse resp = rSys.path(cosAclUrl).put(ClientResponse.class, changes);
    Assert.assertEquals(200, resp.getStatus());
    // find a nh to use
    results = rSys.path("/vdc/varrays/search").queryParam("name", "nh").get(Resources.class);
    Assert.assertTrue(results.resource.iterator().hasNext());
    _nhId = results.resource.iterator().next().getId();
    String nhAclUrl = "/vdc/varrays/" + _nhId.toString() + "/acl";
    resp = rSys.path(nhAclUrl).put(ClientResponse.class, changes);
    Assert.assertEquals(200, resp.getStatus());
    // find a network to use
    results = rSys.path("/vdc/networks/search").queryParam("name", "iptz").get(Resources.class);
    Assert.assertTrue(results.resource.iterator().hasNext());
    _networkId = results.resource.iterator().next().getId();
}
Also used : InternalNetworkClient(com.emc.storageos.api.service.impl.resource.utils.InternalNetworkClient) ClientResponse(com.sun.jersey.api.client.ClientResponse) ArrayList(java.util.ArrayList) InternalFileServiceClient(com.emc.storageos.api.service.impl.resource.utils.InternalFileServiceClient) TenantResponse(com.emc.storageos.model.tenant.TenantResponse) ClientRequestHelper(com.emc.storageos.security.helpers.ClientRequestHelper) Before(org.junit.Before)

Aggregations

InternalFileServiceClient (com.emc.storageos.api.service.impl.resource.utils.InternalFileServiceClient)1 InternalNetworkClient (com.emc.storageos.api.service.impl.resource.utils.InternalNetworkClient)1 TenantResponse (com.emc.storageos.model.tenant.TenantResponse)1 ClientRequestHelper (com.emc.storageos.security.helpers.ClientRequestHelper)1 ClientResponse (com.sun.jersey.api.client.ClientResponse)1 ArrayList (java.util.ArrayList)1 Before (org.junit.Before)1