Search in sources :

Example 1 with InterfaceAttachment

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;
}
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 InterfaceAttachment

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;
}
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 InterfaceAttachment

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;
}
Also used : InterfaceAttachment(com.woorea.openstack.nova.model.InterfaceAttachment) 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) FixedIp(com.woorea.openstack.nova.model.FixedIp) Port(com.att.cdp.zones.model.Port) InterfaceAttachments(com.woorea.openstack.nova.model.InterfaceAttachments)

Aggregations

OpenStackPort (com.att.cdp.openstack.model.OpenStackPort)3 Port (com.att.cdp.zones.model.Port)3 InterfaceAttachment (com.woorea.openstack.nova.model.InterfaceAttachment)3 InterfaceAttachments (com.woorea.openstack.nova.model.InterfaceAttachments)3 ArrayList (java.util.ArrayList)3 OpenStackConnectException (com.woorea.openstack.base.client.OpenStackConnectException)2 OpenStackResponseException (com.woorea.openstack.base.client.OpenStackResponseException)2 OpenStackBaseException (com.woorea.openstack.base.client.OpenStackBaseException)1 FixedIp (com.woorea.openstack.nova.model.FixedIp)1