use of com.att.cdp.zones.model.Network in project AJSC by att.
the class OpenStackNetworkService method getVLANTransparency.
/**
* @see com.att.cdp.zones.NetworkService#getVLANTransparency()
*/
@SuppressWarnings("nls")
@Override
public List<Network> getVLANTransparency() throws ZoneException {
connect();
Context context = getContext();
trackRequest();
RequestState.put(RequestState.SERVICE, "Network");
RequestState.put(RequestState.SERVICE_URL, quantumConnector.getEndpoint());
ArrayList<Network> list = new ArrayList<>();
try {
Quantum client = quantumConnector.getClient();
VLANResource resource = client.vlans();
for (com.woorea.openstack.quantum.model.Network net : resource.list().execute()) {
list.add(new OpenStackNetwork(context, net));
}
} catch (OpenStackBaseException e) {
ExceptionMapper.mapException(e);
}
return list;
}
use of com.att.cdp.zones.model.Network in project AJSC by att.
the class OpenStackNetworkService method getNetworksByName.
/**
* @see com.att.cdp.zones.NetworkService#getNetworksByName(java.lang.String)
*/
@SuppressWarnings("nls")
@Override
public List<Network> getNetworksByName(String name) throws ZoneException {
connect();
Context context = getContext();
trackRequest();
RequestState.put(RequestState.NETWORK, name);
RequestState.put(RequestState.SERVICE, "Network");
RequestState.put(RequestState.SERVICE_URL, quantumConnector.getEndpoint());
List<Network> list = new ArrayList<>();
try {
Quantum client = quantumConnector.getClient();
NetworksResource resource = client.networks();
for (com.woorea.openstack.quantum.model.Network net : resource.list().execute()) {
if (net.getName().equals(name)) {
list.add(new OpenStackNetwork(context, net));
}
}
} catch (OpenStackBaseException e) {
ExceptionMapper.mapException(e);
}
return list;
}
use of com.att.cdp.zones.model.Network in project AJSC by att.
the class OpenStackNetworkService method createNetwork.
@SuppressWarnings("nls")
@Override
public Network createNetwork(Network network) throws ZoneException {
checkArg(network, "network");
connect();
Context context = getContext();
trackRequest();
RequestState.put(RequestState.NETWORK, network.getName());
RequestState.put(RequestState.SERVICE, "Network");
RequestState.put(RequestState.SERVICE_URL, quantumConnector.getEndpoint());
try {
Quantum client = quantumConnector.getClient();
com.woorea.openstack.quantum.model.Network netcreate = new com.woorea.openstack.quantum.model.Network();
netcreate.setName(network.getName());
netcreate.setAdminStateUp(true);
com.woorea.openstack.quantum.model.Network openstackNetwork = client.networks().create(netcreate).execute();
return new OpenStackNetwork(context, openstackNetwork);
} catch (OpenStackBaseException e) {
ExceptionMapper.mapException(e);
}
return null;
}
use of com.att.cdp.zones.model.Network in project AJSC by att.
the class TestComputeService method testGetServerLazy.
/**
* @throws ZoneException
* If the connection fails or the server cant be found
* @throws IllegalAccessException
* If the fields cant be accessed
* @throws IllegalArgumentException
* If the fields cant be accessed
*/
@Ignore
@Test
public void testGetServerLazy() throws ZoneException, IllegalArgumentException, IllegalAccessException {
Context context = connect();
ComputeService computeService = context.getComputeService();
Server server = computeService.getServer(TEST_SERVER_UUID);
/*
* Make sure that we have not obtained any of the transitive dependencies yet
*/
assertNotNull(server);
AtomicBoolean ab = (AtomicBoolean) volumeAttachmentsProcessedField.get(server);
assertNotNull(ab);
assertFalse(ab.get());
ab = (AtomicBoolean) imagesProcessedField.get(server);
assertNotNull(ab);
assertFalse(ab.get());
ab = (AtomicBoolean) networksProcessedField.get(server);
assertNotNull(ab);
assertFalse(ab.get());
/*
* Now, get the network and ensure that it is correct
*/
List<Network> networks = server.getNetworks();
assertNotNull(networks);
assertFalse(networks.isEmpty());
boolean found = false;
for (Network network : networks) {
if (network.getName().equals(TEST_NETWORK_NAME)) {
found = true;
break;
}
}
assertTrue(found);
ab = (AtomicBoolean) networksProcessedField.get(server);
assertNotNull(ab);
assertTrue(ab.get());
ab = (AtomicBoolean) volumeAttachmentsProcessedField.get(server);
assertNotNull(ab);
assertFalse(ab.get());
ab = (AtomicBoolean) imagesProcessedField.get(server);
assertNotNull(ab);
assertFalse(ab.get());
/*
* Now, determine the boot source and image, this will cause the images to be processed
*/
ServerBootSource bs = server.getBootSource();
assertNotNull(bs);
assertTrue(bs.equals(ServerBootSource.IMAGE) || bs.equals(ServerBootSource.SNAPSHOT));
String image = server.getImage();
assertNotNull(image);
ab = (AtomicBoolean) networksProcessedField.get(server);
assertNotNull(ab);
assertTrue(ab.get());
ab = (AtomicBoolean) imagesProcessedField.get(server);
assertNotNull(ab);
assertTrue(ab.get());
ab = (AtomicBoolean) volumeAttachmentsProcessedField.get(server);
assertNotNull(ab);
assertFalse(ab.get());
/*
* Now, lets see if there are any volume attachments. This will load the volumes transitive relationship
*/
Map<String, Volume> volumes = server.getVolumes();
assertNotNull(volumes);
ab = (AtomicBoolean) networksProcessedField.get(server);
assertNotNull(ab);
assertTrue(ab.get());
ab = (AtomicBoolean) imagesProcessedField.get(server);
assertNotNull(ab);
assertTrue(ab.get());
ab = (AtomicBoolean) volumeAttachmentsProcessedField.get(server);
assertNotNull(ab);
assertTrue(ab.get());
}
use of com.att.cdp.zones.model.Network 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");
}
}
Aggregations