use of com.woorea.openstack.nova.model.InterfaceAttachment 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)
*/
@SuppressWarnings("nls")
@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) {
ExceptionMapper.mapException(e);
}
return list;
}
use of com.woorea.openstack.nova.model.InterfaceAttachment 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.woorea.openstack.nova.model.InterfaceAttachment 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;
}
Aggregations