use of com.att.cdp.zones.model.Port in project AJSC by att.
the class OpenStackNetworkService method getInterfaces.
/**
* @throws ZoneException
* @see com.att.cdp.zones.NetworkService#getInterfaces(java.lang.String)
*/
@Override
public List<com.att.cdp.zones.model.Port> getInterfaces(String serverId) throws ZoneException {
InterfaceAttachments list = null;
com.att.cdp.zones.model.Port port = null;
List<com.att.cdp.zones.model.Port> ports = new ArrayList<>();
connect();
trackRequest();
RequestState.put(RequestState.SERVICE, "Compute");
RequestState.put(RequestState.SERVICE_URL, novaConnector.getEndpoint());
try {
list = novaConnector.getClient().servers().listInterfaceAttachments(serverId).execute();
if (list != null && list.getList() != null && list.getList().size() > 0) {
for (InterfaceAttachment intf : list.getList()) {
port = new com.att.cdp.zones.model.Port();
port.setPortState(OpenStackPort.mapState(intf.getPortState()));
port.setMacAddr(intf.getMacAddress());
port.setId(intf.getPortId());
port.setSubnetId(intf.getNetworkId());
List<String> addresses = new ArrayList<>();
for (FixedIp ip : intf.getFixedIps()) {
addresses.add(ip.getIpAddress());
}
port.setAddresses(addresses);
ports.add(port);
}
}
} catch (OpenStackBaseException e) {
ExceptionMapper.mapException(e);
}
return ports;
}
use of com.att.cdp.zones.model.Port 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.model.Port in project AJSC by att.
the class TestComputeService method testListPorts.
/**
* Test that we can list all ports on some server
*
* @throws ZoneException
* if anything fails
*/
@Test
@Ignore
public void testListPorts() throws ZoneException {
Context context = connect();
ComputeService service = context.getComputeService();
List<Server> servers = service.getServers();
assertNotNull(servers);
assertFalse(servers.isEmpty());
for (Server server : servers) {
List<Port> ports = service.getPorts(server);
assertNotNull(ports);
assertFalse(ports.isEmpty());
List<Port> serverPorts = server.getPorts();
assertNotNull(serverPorts);
assertFalse(serverPorts.isEmpty());
assertTrue(ports.containsAll(serverPorts));
// System.out.printf("Server %s has %d ports\n", server.getName(),
// ports.size());
}
}
use of com.att.cdp.zones.model.Port 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.model.Port in project AJSC by att.
the class TestNetworkService method testCreateAndDeletePort.
@Test
@Ignore
public void testCreateAndDeletePort() throws ZoneException {
Context context = connect();
NetworkService service = context.getNetworkService();
String poolName = "TestNewPool";
String tenantId = context.getTenant().getId();
String networkId = "64e612b4-0a2a-4073-b408-66a3ef27aef7";
String subnetId = "b124ab37-a285-4b8f-848b-e485c062594c";
Subnet subnet = service.getSubnetById(subnetId);
assertNotNull(subnet);
Port port = service.createPort(subnet);
assertNotNull(port);
port.delete();
}
Aggregations