Search in sources :

Example 31 with ZoneException

use of com.att.cdp.exceptions.ZoneException in project AJSC by att.

the class TestNetworkService method getNetworkMetadata.

@Test
@Ignore
public void getNetworkMetadata() throws ZoneException {
    Context context = connect();
    NetworkService service = context.getNetworkService();
    try {
        NetworkMetadata metadata = service.getMetadata();
        assertNotNull(metadata);
    } catch (ZoneException ze) {
        ze.printStackTrace();
        fail();
    }
}
Also used : Context(com.att.cdp.zones.Context) NetworkMetadata(com.att.cdp.zones.NetworkMetadata) ZoneException(com.att.cdp.exceptions.ZoneException) NetworkService(com.att.cdp.zones.NetworkService) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 32 with ZoneException

use of com.att.cdp.exceptions.ZoneException in project AJSC by att.

the class TestNetworkService method createIPV4SubnetWithGateway.

/**
 * Verifies that we can create a subnet with a specified gateway IP address on a provider
 *
 * @throws ZoneException
 *             If the connection fails, user is not authorized, or the provider cannot perform the operation.
 */
@Test
@Ignore
public void createIPV4SubnetWithGateway() throws ZoneException {
    Context context = connect();
    NetworkService service = context.getNetworkService();
    try {
        // verify test network exists
        verifyTestNetworkHelper();
        List<Network> networks = service.getNetworksByName("CDP_Test_Network");
        assertNotNull(networks);
        assertFalse(networks.isEmpty());
        Network testNetwork = networks.get(0);
        Subnet subnetWithGateway = new Subnet();
        subnetWithGateway.setName("CDP_Test_IPV4_Subnet_With_Gateway");
        subnetWithGateway.setNetwork(testNetwork.getId());
        subnetWithGateway.setIpv4(true);
        subnetWithGateway.setRouting("10.10.10.0/24");
        subnetWithGateway.setGatewayIp("10.10.10.1");
        service.createSubnet(subnetWithGateway);
        List<Subnet> subnets = service.getSubnetsByName("CDP_Test_IPV4_Subnet_With_Gateway");
        assertFalse(subnets.isEmpty());
        for (Subnet subnet : subnets) {
            assertTrue(subnet.getRouting().equalsIgnoreCase("10.10.10.0/24"));
            assertTrue(subnet.getGatewayIp().equalsIgnoreCase("10.10.10.1"));
        }
    } catch (ZoneException ze) {
        ze.printStackTrace();
        fail("Failed to create the ipv4 test subnet with gateway IP");
    }
}
Also used : Context(com.att.cdp.zones.Context) ZoneException(com.att.cdp.exceptions.ZoneException) Network(com.att.cdp.zones.model.Network) NetworkService(com.att.cdp.zones.NetworkService) Subnet(com.att.cdp.zones.model.Subnet) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 33 with ZoneException

use of com.att.cdp.exceptions.ZoneException in project AJSC by att.

the class TestNetworkService method testDeleteNetwork.

/**
 * Test the ability to delete a network
 *
 * @throws ZoneException
 *             If the connection fails, user is not authorized, or the provider cannot perform the operation.
 */
@Test
@Ignore
public void testDeleteNetwork() throws ZoneException {
    Context context = connect();
    NetworkService service = context.getNetworkService();
    try {
        // ensure test network exists
        verifyTestNetworkHelper();
        List<Network> networks = service.getNetworksByName("CDP_Test_Network");
        assertNotNull(networks);
        assertFalse(networks.isEmpty());
        // test network deletion
        for (Network network : networks) {
            if (network.getName().equalsIgnoreCase("CDP_Test_Network")) {
                service.deleteNetwork(network);
            }
        }
        networks = service.getNetworksByName("CDP_Test_Network");
        assertTrue(networks.isEmpty());
    } catch (ZoneException ze) {
        ze.printStackTrace();
        fail("Failed to delete the test network");
    }
}
Also used : Context(com.att.cdp.zones.Context) ZoneException(com.att.cdp.exceptions.ZoneException) Network(com.att.cdp.zones.model.Network) NetworkService(com.att.cdp.zones.NetworkService) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 34 with ZoneException

use of com.att.cdp.exceptions.ZoneException in project AJSC by att.

the class TestNetworkService method listNetworks.

/**
 * Verifies that we can list the existing networks on a provider. This test requires that the provider actually has
 * networks installed.
 *
 * @throws ZoneException
 *             If the connection fails, user is not authorized, or the provider cannot perform the operation.
 */
@Ignore
@Test
public void listNetworks() throws ZoneException {
    Context context = connect();
    NetworkService service = context.getNetworkService();
    try {
        List<Network> networks = service.getNetworks();
        assertNotNull(networks);
        assertFalse(networks.isEmpty());
        for (Network network : networks) {
            System.out.println(network.toString());
        // assertNotNull(service.getNetworksByName(network.getName()));
        // assertNotNull(service.getNetworkById(network.getId()));
        }
    } catch (ZoneException ze) {
        ze.printStackTrace();
        fail();
    }
}
Also used : Context(com.att.cdp.zones.Context) ZoneException(com.att.cdp.exceptions.ZoneException) Network(com.att.cdp.zones.model.Network) NetworkService(com.att.cdp.zones.NetworkService) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 35 with ZoneException

use of com.att.cdp.exceptions.ZoneException in project AJSC by att.

the class TestSecurityGroups method testAll.

@Test
@Ignore
public void testAll() throws ZoneException {
    Context context = connect();
    ComputeService service = context.getComputeService();
    String aclName = "Unit Test ACL";
    try {
        ACL template = new ACL();
        template.setName(aclName);
        template.setDescription(aclName);
        ACL acl = service.createAccessControlList(template);
        assertNotNull(acl);
        assertTrue(acl.getRules().isEmpty());
        Rule rule1 = new Rule(Rule.PROTOCOL.TCP, 80, 80, "0.0.0.0/0");
        Rule rule2 = new Rule(Rule.PROTOCOL.UDP, 60000, 60010, "0.0.0.0/0");
        rule1 = service.addACLRule(acl.getId(), rule1);
        assertNotNull(rule1.getId());
        rule2 = service.addACLRule(acl.getId(), rule2);
        assertNotNull(rule2.getId());
        acl = service.getAccessControlList(acl.getId());
        assertEquals(2, acl.getRules().size());
        assertEquals(Rule.PROTOCOL.TCP, acl.getRules().get(0).getProtocol());
        assertEquals(Rule.PROTOCOL.UDP, acl.getRules().get(1).getProtocol());
        service.deleteACLRule(rule1);
        acl = service.getAccessControlList(acl.getId());
        assertEquals(1, acl.getRules().size());
        assertEquals(Rule.PROTOCOL.UDP, acl.getRules().get(0).getProtocol());
        service.deleteACLRule(rule2);
        acl = service.getAccessControlList(acl.getId());
        assertTrue(acl.getRules().isEmpty());
        service.deleteAccessControlList(acl.getId());
        try {
            service.getAccessControlList(acl.getId());
            fail("Failed to delete the ACL");
        } catch (ZoneException ze) {
        // Successfully deleted the ACL
        }
    } catch (ZoneException ze) {
        ze.printStackTrace();
        fail();
    }
}
Also used : Context(com.att.cdp.zones.Context) ZoneException(com.att.cdp.exceptions.ZoneException) ACL(com.att.cdp.zones.model.ACL) Rule(com.att.cdp.zones.model.Rule) ComputeService(com.att.cdp.zones.ComputeService) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

ZoneException (com.att.cdp.exceptions.ZoneException)40 Context (com.att.cdp.zones.Context)30 OpenStackContext (com.att.cdp.openstack.OpenStackContext)18 NetworkService (com.att.cdp.zones.NetworkService)15 OpenStackBaseException (com.woorea.openstack.base.client.OpenStackBaseException)15 Test (org.junit.Test)15 Network (com.att.cdp.zones.model.Network)13 Ignore (org.junit.Ignore)13 OpenStackConnectException (com.woorea.openstack.base.client.OpenStackConnectException)11 OpenStackResponseException (com.woorea.openstack.base.client.OpenStackResponseException)11 Server (com.att.cdp.zones.model.Server)9 OpenStackServer (com.att.cdp.openstack.model.OpenStackServer)8 Subnet (com.att.cdp.zones.model.Subnet)8 ConnectedServer (com.att.cdp.zones.spi.model.ConnectedServer)8 ContextConnectionException (com.att.cdp.exceptions.ContextConnectionException)7 ArrayList (java.util.ArrayList)7 HashMap (java.util.HashMap)6 InvalidRequestException (com.att.cdp.exceptions.InvalidRequestException)5 ResourceNotFoundException (com.att.cdp.exceptions.ResourceNotFoundException)5 ContextClosedException (com.att.cdp.exceptions.ContextClosedException)4