use of com.att.cdp.zones.model.Port in project AJSC by att.
the class TestNetworkService method testCreateAndDeletePort.
/**
* Tests that we can create and delete a port
*
* @throws ZoneException
* If the test cannot connect to the provider
*/
@Test
@Ignore
public void testCreateAndDeletePort() throws ZoneException {
Context context = connect();
NetworkService service = context.getNetworkService();
List<Subnet> subnets = service.getSubnets();
assertNotNull(subnets);
assertFalse(subnets.isEmpty());
Subnet subnet = subnets.get(0);
Port port = service.createPort(subnet);
assertNotNull(port);
assertEquals(port.getSubnetId(), subnet.getId());
assertNotNull(port.getMacAddr());
assertNotNull(port.getId());
assertNotNull(port.getNetwork());
service.deletePort(port);
}
use of com.att.cdp.zones.model.Port in project AJSC by att.
the class TestNetworkService method testGetPorts.
/**
* Verifies that we can get ports
*
* @throws ZoneException
* If the connection fails, user is not authorized, or the provider cannot perform the operation.
*/
@Test
@Ignore
public void testGetPorts() throws ZoneException {
Context context = connect();
NetworkService service = context.getNetworkService();
List<Port> ports = service.getPorts();
assertNotNull(ports);
assertFalse(ports.isEmpty());
}
use of com.att.cdp.zones.model.Port in project AJSC by att.
the class OpenStackComputeService method getPorts.
/**
* Gets the ports connected to a specific server
*
* @throws ZoneException
* If the server is null or invalid, if the context is closed, or if the context has not been
* authenticated, or if the authentication has expired
* @see com.att.cdp.zones.ComputeService#getPorts(com.att.cdp.zones.model.Server)
*/
@Override
public List<Port> getPorts(Server server) throws ZoneException {
checkArg(server, "server");
connect();
trackRequest();
RequestState.put(RequestState.SERVER, server.getId());
RequestState.put(RequestState.SERVICE, "Compute");
RequestState.put(RequestState.SERVICE_URL, nova.getEndpoint());
List<Port> list = new ArrayList<>();
try {
InterfaceAttachments attachments = nova.getClient().servers().listInterfaceAttachments(server.getId()).execute();
for (InterfaceAttachment attachment : attachments.getList()) {
OpenStackPort port = new OpenStackPort(getContext(), attachment);
list.add(port);
}
} catch (OpenStackConnectException | OpenStackResponseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return list;
}
use of com.att.cdp.zones.model.Port in project AJSC by att.
the class OpenStackComputeService method deleteServer.
/**
* Delete the specified server using it's id.
*
* @param serverId
* The server to be deleted.
* @throws ZoneException
* If the server does not exist or cannot be deleted for some reason.
* @see com.att.cdp.zones.ComputeService#deleteServer(java.lang.String)
*/
@SuppressWarnings("nls")
@Override
public void deleteServer(String serverId) throws ZoneException {
checkArg(serverId, "serverId");
connect();
trackRequest();
RequestState.put(RequestState.SERVER, serverId);
RequestState.put(RequestState.SERVICE, "Compute");
RequestState.put(RequestState.SERVICE_URL, nova.getEndpoint());
try {
Server server = getServer(serverId);
Server.Status status = server.getStatus();
RequestState.put(RequestState.STATUS, status.toString());
if (status.equals(Server.Status.RUNNING) || status.equals(Server.Status.READY) || status.equals(Server.Status.ERROR)) {
List<Port> ports = server.getPorts();
for (Port port : ports) {
port.delete();
}
nova.getClient().servers().delete(serverId).execute();
} else {
throw new ZoneException(EELFResourceManager.format(OSMsg.PAL_OS_INVALID_SERVER_STATE, server.getName(), server.getId().toString(), status.toString(), StringHelper.asList(Arrays.asList(Server.Status.READY.toString(), Server.Status.RUNNING.toString(), Server.Status.ERROR.toString()))));
}
} catch (OpenStackBaseException ex) {
ExceptionMapper.mapException(ex);
}
}
use of com.att.cdp.zones.model.Port in project AJSC by att.
the class OpenStackNetworkService method createPort.
/**
* @see com.att.cdp.zones.NetworkService#createPort(com.att.cdp.zones.model.Subnet)
*/
@Override
public Port createPort(Subnet subnet) throws ZoneException {
this.checkArg(subnet, "subnet");
connect();
Context context = getContext();
trackRequest();
RequestState.put(RequestState.PORT, subnet.getName());
RequestState.put(RequestState.SERVICE, "Network");
RequestState.put(RequestState.SERVICE_URL, quantumConnector.getEndpoint());
com.woorea.openstack.quantum.model.Port port = new com.woorea.openstack.quantum.model.Port();
try {
Quantum client = quantumConnector.getClient();
port.setNetworkId(subnet.getNetwork());
// List<com.woorea.openstack.quantum.model.Port.Ip> ips = new ArrayList<>();
// com.woorea.openstack.quantum.model.Port.Ip ip = new com.woorea.openstack.quantum.model.Port.Ip();
// ip.setSubnetId(subnet.getId());
// ips.add(ip);
// port.setList(ips);
port = client.ports().create(port).execute();
} catch (OpenStackBaseException e) {
ExceptionMapper.mapException(e);
}
return new OpenStackPort(context, port);
}
Aggregations