Search in sources :

Example 46 with Context

use of com.att.cdp.zones.Context in project AJSC by att.

the class OpenStackNetworkService method getNetworks.

/**
 * @see com.att.cdp.zones.NetworkService#getNetworks()
 */
@SuppressWarnings("nls")
@Override
public List<Network> getNetworks() throws ZoneException {
    connect();
    Context context = getContext();
    trackRequest();
    RequestState.put(RequestState.SERVICE, "Network");
    RequestState.put(RequestState.SERVICE_URL, quantumConnector.getEndpoint());
    ArrayList<Network> list = new ArrayList<>();
    try {
        Quantum client = quantumConnector.getClient();
        NetworksResource resource = client.networks();
        for (com.woorea.openstack.quantum.model.Network net : resource.list().execute()) {
            list.add(new OpenStackNetwork(context, net));
        }
    } catch (OpenStackBaseException e) {
        ExceptionMapper.mapException(e);
    }
    return list;
}
Also used : Context(com.att.cdp.zones.Context) OpenStackContext(com.att.cdp.openstack.OpenStackContext) Quantum(com.woorea.openstack.quantum.Quantum) OpenStackBaseException(com.woorea.openstack.base.client.OpenStackBaseException) Network(com.att.cdp.zones.model.Network) AbstractNetwork(com.att.cdp.zones.spi.AbstractNetwork) OpenStackNetwork(com.att.cdp.openstack.model.OpenStackNetwork) ArrayList(java.util.ArrayList) OpenStackNetwork(com.att.cdp.openstack.model.OpenStackNetwork) NetworksResource(com.woorea.openstack.quantum.api.NetworksResource)

Example 47 with Context

use of com.att.cdp.zones.Context in project AJSC by att.

the class OpenStackNetworkService method deletePort.

/**
 * @see com.att.cdp.zones.NetworkService#deletePort(com.att.cdp.zones.model.Port)
 */
@Override
public void deletePort(Port port) throws ZoneException {
    this.checkArg(port, "port");
    connect();
    Context context = getContext();
    trackRequest();
    RequestState.put(RequestState.PORT, port.getId());
    RequestState.put(RequestState.SERVICE, "Network");
    RequestState.put(RequestState.SERVICE_URL, quantumConnector.getEndpoint());
    try {
        Quantum client = quantumConnector.getClient();
        client.ports().delete(port.getId()).execute();
    } catch (OpenStackBaseException e) {
        ExceptionMapper.mapException(e);
    }
}
Also used : Context(com.att.cdp.zones.Context) OpenStackContext(com.att.cdp.openstack.OpenStackContext) Quantum(com.woorea.openstack.quantum.Quantum) OpenStackBaseException(com.woorea.openstack.base.client.OpenStackBaseException)

Example 48 with Context

use of com.att.cdp.zones.Context in project AJSC by att.

the class OpenStackNetworkService method getSubnetById.

/**
 * @see com.att.cdp.zones.NetworkService#getSubnetById(java.lang.String)
 */
@SuppressWarnings("nls")
@Override
public Subnet getSubnetById(String id) throws ZoneException {
    connect();
    Context context = getContext();
    trackRequest();
    RequestState.put(RequestState.SUBNET, id);
    RequestState.put(RequestState.SERVICE, "Network");
    RequestState.put(RequestState.SERVICE_URL, quantumConnector.getEndpoint());
    try {
        Quantum client = quantumConnector.getClient();
        SubnetsResource resource = client.subnets();
        for (com.woorea.openstack.quantum.model.Subnet net : resource.list().execute()) {
            if (net.getId().equals(id)) {
                return new OpenStackSubnet(context, net);
            }
        }
    } catch (OpenStackBaseException e) {
        ExceptionMapper.mapException(e);
    }
    return null;
}
Also used : Context(com.att.cdp.zones.Context) OpenStackContext(com.att.cdp.openstack.OpenStackContext) Quantum(com.woorea.openstack.quantum.Quantum) OpenStackBaseException(com.woorea.openstack.base.client.OpenStackBaseException) SubnetsResource(com.woorea.openstack.quantum.api.SubnetsResource) OpenStackSubnet(com.att.cdp.openstack.model.OpenStackSubnet)

Example 49 with Context

use of com.att.cdp.zones.Context in project AJSC by att.

the class OpenStackNetworkService method associateLoadBalancerHealthMonitorWithPool.

/**
 * @see com.att.cdp.zones.NetworkService#associateLoadBalancerHealthMonitorWithPool(java.lang.String,
 *      java.lang.String)
 */
@SuppressWarnings("nls")
@Override
public void associateLoadBalancerHealthMonitorWithPool(String poolId, String healthMonitorId) throws ZoneException {
    checkArg(poolId, "poolId");
    checkArg(healthMonitorId, "healthMonitorId");
    connect();
    Context context = getContext();
    trackRequest();
    RequestState.put(RequestState.LOADBALANCERPOOL, poolId);
    RequestState.put(RequestState.LOADBALANCERHEALTHMONITOR, healthMonitorId);
    RequestState.put(RequestState.SERVICE, "Network");
    RequestState.put(RequestState.SERVICE_URL, quantumConnector.getEndpoint());
    try {
        Quantum client = quantumConnector.getClient();
        client.lbaas().Pool().associateMonitor(poolId, healthMonitorId).execute();
    } catch (OpenStackBaseException e) {
        ExceptionMapper.mapException(e);
    }
}
Also used : Context(com.att.cdp.zones.Context) OpenStackContext(com.att.cdp.openstack.OpenStackContext) Quantum(com.woorea.openstack.quantum.Quantum) OpenStackBaseException(com.woorea.openstack.base.client.OpenStackBaseException)

Example 50 with Context

use of com.att.cdp.zones.Context in project AJSC by att.

the class OpenStackNetworkService method getLoadBalancerMembers.

/**
 * @see com.att.cdp.zones.NetworkService#getLoadBalancerMembers()
 */
@Override
public List<LoadBalancerMember> getLoadBalancerMembers() throws ZoneException {
    connect();
    Context context = getContext();
    trackRequest();
    RequestState.put(RequestState.SERVICE, "Network");
    RequestState.put(RequestState.SERVICE_URL, quantumConnector.getEndpoint());
    ArrayList<LoadBalancerMember> list = new ArrayList<>();
    try {
        Quantum client = quantumConnector.getClient();
        LoadBalancerResource.Member resource = client.lbaas().Member();
        for (com.woorea.openstack.quantum.model.LoadBalancerMember loadBalancerMember : resource.list().execute()) {
            list.add(new OpenStackLoadBalancerMember(context, loadBalancerMember));
        }
    } catch (OpenStackBaseException e) {
        ExceptionMapper.mapException(e);
    }
    return list;
}
Also used : Context(com.att.cdp.zones.Context) OpenStackContext(com.att.cdp.openstack.OpenStackContext) OpenStackBaseException(com.woorea.openstack.base.client.OpenStackBaseException) ArrayList(java.util.ArrayList) LoadBalancerResource(com.woorea.openstack.quantum.api.LoadBalancerResource) OpenStackLoadBalancerMember(com.att.cdp.openstack.model.OpenStackLoadBalancerMember) LoadBalancerMember(com.att.cdp.zones.model.LoadBalancerMember) Quantum(com.woorea.openstack.quantum.Quantum) OpenStackLoadBalancerMember(com.att.cdp.openstack.model.OpenStackLoadBalancerMember)

Aggregations

Context (com.att.cdp.zones.Context)248 OpenStackContext (com.att.cdp.openstack.OpenStackContext)167 OpenStackBaseException (com.woorea.openstack.base.client.OpenStackBaseException)140 ArrayList (java.util.ArrayList)55 Ignore (org.junit.Ignore)50 Test (org.junit.Test)47 Quantum (com.woorea.openstack.quantum.Quantum)35 ZoneException (com.att.cdp.exceptions.ZoneException)30 NetworkService (com.att.cdp.zones.NetworkService)24 Server (com.att.cdp.zones.model.Server)22 ComputeService (com.att.cdp.zones.ComputeService)21 Network (com.att.cdp.zones.model.Network)19 OpenStackServer (com.att.cdp.openstack.model.OpenStackServer)18 OpenStackSnapshot (com.att.cdp.openstack.model.OpenStackSnapshot)18 Subnet (com.att.cdp.zones.model.Subnet)15 Port (com.att.cdp.zones.model.Port)14 Snapshot (com.att.cdp.zones.model.Snapshot)12 Volume (com.att.cdp.zones.model.Volume)11 OpenStackResponseException (com.woorea.openstack.base.client.OpenStackResponseException)11 ResourceNotFoundException (com.att.cdp.exceptions.ResourceNotFoundException)10