use of com.att.cdp.zones.NetworkService in project AJSC by att.
the class TestComputeService method testDeletePort.
@Ignore
@Test
public void testDeletePort() throws ZoneException {
String[] ids = { "0e1ae02a-f34e-4208-a031-ba251c9d6538", "7235a241-a5d1-473c-97e2-f3115e91d878", "791b9689-7f19-469a-9759-154018315d4b", "958bbf73-7559-439d-bbad-94e67fc07263", "b43449bc-a427-4838-a0ab-4fd544533677", "b94deec4-fdcc-41d9-ae93-8d0f746011d2" };
Context context = connect();
ComputeService compute = context.getComputeService();
NetworkService network = context.getNetworkService();
for (String id : ids) {
Port port = network.getPort(id);
if (port != null) {
port.delete();
}
}
}
use of com.att.cdp.zones.NetworkService in project AJSC by att.
the class TestNetworkService method testListPorts.
/**
* Test that we can list all ports on the network
*
* @throws ZoneException
* If the test cannot connect to the provider
*/
@Test
@Ignore
public void testListPorts() throws ZoneException {
Context context = connect();
NetworkService service = context.getNetworkService();
List<Port> ports = service.getPorts();
assertNotNull(ports);
assertFalse(ports.isEmpty());
Port port = ports.get(0);
assertNotNull(port.getId());
assertNotNull(port.getMacAddr());
}
use of com.att.cdp.zones.NetworkService in project AJSC by att.
the class TestNetworkService method testLoadBalancer.
/**
* Verifies all load balancer apis
*
* @throws ZoneException
* If the connection fails, user is not authorized, or the provider cannot perform the operation.
*/
@Ignore
@Test
public void testLoadBalancer() throws ZoneException {
Context context = connect();
NetworkService service = context.getNetworkService();
String poolName = "TestNewPool";
String tenantId = context.getTenant().getId();
String subnetId = "2de8b5a0-1f7d-4736-8655-874c506e8f1b";
// Step 1: Check if pool exists with this name
LoadBalancerPool loadBalancerPool = null;
try {
List<LoadBalancerPool> loadBalancePools = service.getLoadBalancerPoolByName(poolName);
assertNotNull(loadBalancePools);
if (loadBalancePools.size() == 1) {
loadBalancerPool = loadBalancePools.get(0);
}
} catch (ZoneException ze) {
ze.printStackTrace();
fail("Failed to find the pool with name: " + ze.getMessage());
}
// Step 2: If pool exists delete it
if (loadBalancerPool != null) {
try {
service.deleteLoadBalancerPool(loadBalancerPool);
List<LoadBalancerPool> loadBalancePools = service.getLoadBalancerPoolByName(poolName);
assertNotNull(loadBalancePools);
assertEquals(loadBalancePools.size(), 0);
} catch (ZoneException ze) {
ze.printStackTrace();
fail("Failed to delete the test load balancer pool: " + ze.getMessage());
}
}
// Step 3: Create a new pool
try {
LoadBalancerPool testlbPool = new LoadBalancerPool();
testlbPool.setProtocol(ProtocolType.HTTP);
testlbPool.setName(poolName);
testlbPool.setSubnetId(subnetId);
testlbPool.setLbAlgorithm(AlgorithmType.ROUND_ROBIN);
loadBalancerPool = service.createLoadBalancerPool(testlbPool);
LoadBalancerPool returnedLoadBalancerPool = service.getLoadBalancerPoolById(loadBalancerPool.getId());
assertNotNull(returnedLoadBalancerPool);
assertEquals(returnedLoadBalancerPool.getName(), poolName);
} catch (ZoneException ze) {
ze.printStackTrace();
fail("Failed to create the test load balancer pool: " + ze.getMessage());
}
// Step 4: Create a new load balancer vip and assign to the pool
LoadBalancerListener loadBalancerListener = null;
try {
LoadBalancerListener testlbVIP = new LoadBalancerListener();
testlbVIP.setProtocol(ProtocolType.HTTP);
testlbVIP.setName("TestNewVip");
testlbVIP.setPoolId(loadBalancerPool.getId());
testlbVIP.setSubnetId(subnetId);
loadBalancerListener = service.createLoadBalancerListener(testlbVIP);
LoadBalancerListener returnedloadBalancerVIP = service.getLoadBalancerListenerById(loadBalancerListener.getId());
assertNotNull(returnedloadBalancerVIP);
} catch (ZoneException ze) {
ze.printStackTrace();
fail("Failed to create the test load balancer VIP: " + ze.getMessage());
}
// Step 5: Fetch load balancer vips
try {
List<LoadBalancerListener> loadBalanceVIPs = service.getLoadBalancerListeners();
assertNotNull(loadBalanceVIPs);
for (LoadBalancerListener loadBalanceVIP : loadBalanceVIPs) {
assertNotNull(loadBalanceVIP.getId());
}
} catch (ZoneException ze) {
ze.printStackTrace();
fail("Failed to fetch the test load balancer VIPs: " + ze.getMessage());
}
// Step 7: Create load balancer health monitor
LoadBalancerHealthMonitor loadBalancerHealthMonitor = null;
try {
LoadBalancerHealthMonitor testlbHM = new LoadBalancerHealthMonitor();
testlbHM.setType(ProtocolType.PING);
testlbHM.setMaxRetries(1);
loadBalancerHealthMonitor = service.createLoadBalancerHealthMonitor(testlbHM);
LoadBalancerHealthMonitor returnedloadBalancerHealthMonitor = service.getLoadBalancerHealthMonitorById(loadBalancerHealthMonitor.getId());
assertNotNull(returnedloadBalancerHealthMonitor);
assertNotNull(returnedloadBalancerHealthMonitor.getId());
List<LoadBalancerHealthMonitor> loadBalancerHealthMonitors = service.getLoadBalancerHealthMonitors();
assertNotNull(loadBalancerHealthMonitors);
for (LoadBalancerHealthMonitor monitor : loadBalancerHealthMonitors) {
assertNotNull(monitor.getId());
}
} catch (ZoneException ze) {
ze.printStackTrace();
fail("Failed to create the test load balancer health monitor : " + ze.getMessage());
}
// associate the health monitor to pool
try {
service.associateLoadBalancerHealthMonitorWithPool(loadBalancerPool.getId(), loadBalancerHealthMonitor.getId());
} catch (ZoneException ze) {
ze.printStackTrace();
fail("Failed to associate health monitor to pool: " + ze.getMessage());
}
// Step 9: Create a new load balancer member and assign to the pool
LoadBalancerMember loadBalancerMember = null;
// test load balancer vip creation
try {
LoadBalancerMember testlbMember = new LoadBalancerMember();
testlbMember.setAddress("135.144.122.19");
testlbMember.setPoolId(loadBalancerPool.getId());
loadBalancerMember = service.createLoadBalancerMember(testlbMember);
LoadBalancerMember returnedLoadBalancerMembers = service.getLoadBalancerMemberById(loadBalancerMember.getId());
assertNotNull(returnedLoadBalancerMembers);
List<LoadBalancerMember> loadBalancerMembers = service.getLoadBalancerMembers();
assertNotNull(loadBalancerMembers);
for (LoadBalancerMember loadBalancerMembe : loadBalancerMembers) {
assertNotNull(loadBalancerMembe.getId());
}
} catch (ZoneException ze) {
ze.printStackTrace();
fail("Failed to create the test load balancer member : " + ze.getMessage());
}
// Step 10: Fetch load balancer member
try {
List<LoadBalancerMember> loadBalanceMembers = service.getLoadBalancerMembers();
assertNotNull(loadBalanceMembers);
for (LoadBalancerMember loadBalanceMember : loadBalanceMembers) {
assertNotNull(loadBalanceMember.getId());
}
} catch (ZoneException ze) {
ze.printStackTrace();
fail("Failed to fetch the test load balancer members: " + ze.getMessage());
}
// Step 6: Delete load balancer vip
try {
assertNotNull(loadBalancerListener);
// test network deletion
service.deleteLoadBalancerListener(loadBalancerListener);
} catch (ZoneException ze) {
ze.printStackTrace();
fail("Failed to delete the test load balancer vip: " + ze.getMessage());
}
// disassociate the health monitor to pool
try {
service.disassociateLoadBalancerHealthMonitorWithPool(loadBalancerPool.getId(), loadBalancerHealthMonitor.getId());
} catch (ZoneException ze) {
ze.printStackTrace();
fail("Failed to disassociate health monitor to pool: " + ze.getMessage());
}
// Step 11: Delete load balancer member
try {
assertNotNull(loadBalancerMember);
// test network deletion
service.deleteLoadBalancerMember(loadBalancerMember);
} catch (ZoneException ze) {
ze.printStackTrace();
fail("Failed to delete the test load balancer member: " + ze.getMessage());
}
// Step 12: pool delete
if (loadBalancerPool != null) {
try {
service.deleteLoadBalancerPool(loadBalancerPool);
List<LoadBalancerPool> loadBalancePools = service.getLoadBalancerPoolByName(poolName);
assertNotNull(loadBalancePools);
} catch (ZoneException ze) {
ze.printStackTrace();
fail("Failed to delete the test load balancer pool: " + ze.getMessage());
}
}
// Step 8: Delete load balancer health monitor
try {
LoadBalancerHealthMonitor loadBalancerHM = service.getLoadBalancerHealthMonitorById(loadBalancerHealthMonitor.getId());
assertNotNull(loadBalancerHM);
// test network deletion
service.deleteLoadBalancerHealthMonitor(loadBalancerHM);
} catch (ZoneException ze) {
ze.printStackTrace();
fail("Failed to delete the test load balancer health montor: " + ze.getMessage());
}
}
use of com.att.cdp.zones.NetworkService in project AJSC by att.
the class TestNetworkService method testCreateNetwork.
/**
* Verifies that we can create a network on a provider.
*
* @throws ZoneException
* If the connection fails, user is not authorized, or the provider cannot perform the operation.
*/
@Test
@Ignore
public void testCreateNetwork() throws ZoneException {
Context context = connect();
NetworkService service = context.getNetworkService();
// test network creation
try {
Network testNetwork = new Network("CDP_Test_Network");
service.createNetwork(testNetwork);
List<Network> networks = service.getNetworksByName("CDP_Test_Network");
assertNotNull(networks);
assertFalse(networks.isEmpty());
} catch (ZoneException ze) {
ze.printStackTrace();
fail("Failed to create the test network");
}
}
use of com.att.cdp.zones.NetworkService 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();
}
}
Aggregations