Search in sources :

Example 1 with FixedIp

use of com.woorea.openstack.nova.model.FixedIp 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)1 Port (com.att.cdp.zones.model.Port)1 OpenStackBaseException (com.woorea.openstack.base.client.OpenStackBaseException)1 FixedIp (com.woorea.openstack.nova.model.FixedIp)1 InterfaceAttachment (com.woorea.openstack.nova.model.InterfaceAttachment)1 InterfaceAttachments (com.woorea.openstack.nova.model.InterfaceAttachments)1 ArrayList (java.util.ArrayList)1