use of com.att.cdp.openstack.model.OpenStackPort 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.att.cdp.openstack.model.OpenStackPort 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.openstack.model.OpenStackPort in project AJSC by att.
the class OpenStackNetworkService method getPort.
/**
* @see com.att.cdp.zones.NetworkService#getPort(java.lang.String)
*/
@Override
public Port getPort(String id) throws ZoneException {
connect();
Context context = getContext();
trackRequest();
RequestState.put(RequestState.SERVICE, "Network");
RequestState.put(RequestState.SERVICE_URL, quantumConnector.getEndpoint());
RequestState.put(RequestState.PORT, id);
com.woorea.openstack.quantum.model.Port p = null;
try {
Quantum client = quantumConnector.getClient();
PortsResource resource = client.ports();
p = resource.show(id).execute();
} catch (OpenStackBaseException e) {
ExceptionMapper.mapException(e);
}
return new OpenStackPort(context, p);
}
use of com.att.cdp.openstack.model.OpenStackPort 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);
}
use of com.att.cdp.openstack.model.OpenStackPort in project AJSC by att.
the class OpenStackNetworkService method getPorts.
/**
* @see com.att.cdp.zones.NetworkService#getPorts()
*/
@SuppressWarnings("nls")
@Override
public List<com.att.cdp.zones.model.Port> getPorts() throws ZoneException {
connect();
Context context = getContext();
trackRequest();
RequestState.put(RequestState.SERVICE, "Network");
RequestState.put(RequestState.SERVICE_URL, quantumConnector.getEndpoint());
List<com.att.cdp.zones.model.Port> list = new ArrayList<>();
try {
Quantum client = quantumConnector.getClient();
PortsResource resource = client.ports();
for (com.woorea.openstack.quantum.model.Port p : resource.list().execute()) {
list.add(new OpenStackPort(context, p));
}
} catch (OpenStackBaseException e) {
ExceptionMapper.mapException(e);
}
return list;
}
Aggregations