Search in sources :

Example 1 with OpenStackPort

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;
}
Also used : OpenStackPort(com.att.cdp.openstack.model.OpenStackPort) InterfaceAttachments(com.woorea.openstack.nova.model.InterfaceAttachments) InterfaceAttachment(com.woorea.openstack.nova.model.InterfaceAttachment) OpenStackResponseException(com.woorea.openstack.base.client.OpenStackResponseException) Port(com.att.cdp.zones.model.Port) OpenStackPort(com.att.cdp.openstack.model.OpenStackPort) ArrayList(java.util.ArrayList) OpenStackConnectException(com.woorea.openstack.base.client.OpenStackConnectException)

Example 2 with OpenStackPort

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;
}
Also used : OpenStackPort(com.att.cdp.openstack.model.OpenStackPort) InterfaceAttachments(com.woorea.openstack.nova.model.InterfaceAttachments) InterfaceAttachment(com.woorea.openstack.nova.model.InterfaceAttachment) OpenStackResponseException(com.woorea.openstack.base.client.OpenStackResponseException) Port(com.att.cdp.zones.model.Port) OpenStackPort(com.att.cdp.openstack.model.OpenStackPort) ArrayList(java.util.ArrayList) OpenStackConnectException(com.woorea.openstack.base.client.OpenStackConnectException)

Example 3 with OpenStackPort

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);
}
Also used : Context(com.att.cdp.zones.Context) OpenStackContext(com.att.cdp.openstack.OpenStackContext) Quantum(com.woorea.openstack.quantum.Quantum) OpenStackPort(com.att.cdp.openstack.model.OpenStackPort) OpenStackBaseException(com.woorea.openstack.base.client.OpenStackBaseException) PortsResource(com.woorea.openstack.quantum.api.PortsResource)

Example 4 with OpenStackPort

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);
}
Also used : Context(com.att.cdp.zones.Context) OpenStackContext(com.att.cdp.openstack.OpenStackContext) Quantum(com.woorea.openstack.quantum.Quantum) OpenStackPort(com.att.cdp.openstack.model.OpenStackPort) OpenStackBaseException(com.woorea.openstack.base.client.OpenStackBaseException) Port(com.att.cdp.zones.model.Port) OpenStackPort(com.att.cdp.openstack.model.OpenStackPort)

Example 5 with OpenStackPort

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;
}
Also used : Context(com.att.cdp.zones.Context) OpenStackContext(com.att.cdp.openstack.OpenStackContext) OpenStackPort(com.att.cdp.openstack.model.OpenStackPort) OpenStackBaseException(com.woorea.openstack.base.client.OpenStackBaseException) Port(com.att.cdp.zones.model.Port) OpenStackPort(com.att.cdp.openstack.model.OpenStackPort) ArrayList(java.util.ArrayList) Quantum(com.woorea.openstack.quantum.Quantum) PortsResource(com.woorea.openstack.quantum.api.PortsResource)

Aggregations

OpenStackPort (com.att.cdp.openstack.model.OpenStackPort)5 Port (com.att.cdp.zones.model.Port)4 OpenStackContext (com.att.cdp.openstack.OpenStackContext)3 Context (com.att.cdp.zones.Context)3 OpenStackBaseException (com.woorea.openstack.base.client.OpenStackBaseException)3 Quantum (com.woorea.openstack.quantum.Quantum)3 ArrayList (java.util.ArrayList)3 OpenStackConnectException (com.woorea.openstack.base.client.OpenStackConnectException)2 OpenStackResponseException (com.woorea.openstack.base.client.OpenStackResponseException)2 InterfaceAttachment (com.woorea.openstack.nova.model.InterfaceAttachment)2 InterfaceAttachments (com.woorea.openstack.nova.model.InterfaceAttachments)2 PortsResource (com.woorea.openstack.quantum.api.PortsResource)2