use of com.att.cdp.zones.Context in project AJSC by att.
the class OpenStackSnapshotService method getSnapshots.
/**
* Returns a list of snapshots that match the supplied name
*
* @param name
* The name pattern of the snapshots to be located. The name is a regular expression that is suitable for
* use in the Java String.matches() method.
* @return A list (potentially empty) of all snapshots that match the specified name pattern
* @throws ZoneException
* - If the snapshot service cannot be accessed.
* @see java.lang.String#matches(String)
* @see com.att.cdp.zones.SnapshotService#getSnapshots(java.lang.String)
*/
@Override
public List<Snapshot> getSnapshots(String name) throws ZoneException {
connect();
Context context = getContext();
trackRequest();
RequestState.put(RequestState.SNAPSHOT, name);
RequestState.put(RequestState.SERVICE, "Compute");
RequestState.put(RequestState.SERVICE_URL, nova.getEndpoint());
ArrayList<Snapshot> list = new ArrayList<>();
try {
com.woorea.openstack.nova.model.Snapshots snapshots = nova.getClient().snapshots().list(true).execute();
for (com.woorea.openstack.nova.model.Snapshot snap : snapshots) {
if (name != null) {
if (snap.getName() != null && snap.getName().matches(name)) {
list.add(new OpenStackSnapshot(context, snap));
}
} else {
list.add(new OpenStackSnapshot(context, snap));
}
}
} catch (OpenStackBaseException ex) {
ExceptionMapper.mapException(ex);
}
return list;
}
use of com.att.cdp.zones.Context in project AJSC by att.
the class OpenStackSnapshotService method connect.
/**
* This is a helper method used to construct the Nova service object and setup the environment to access the
* OpenStack compute service (Nova).
*
* @throws NotLoggedInException
* If the user is not logged in
* @throws ContextClosedException
* If the user attempts an operation after the context is closed
*/
private void connect() throws NotLoggedInException, ContextClosedException {
checkLogin();
checkOpen();
Context context = getContext();
OpenStackContext osContext = (OpenStackContext) context;
nova = osContext.getNovaConnector();
((OpenStackContext) context).refreshIfStale(nova);
}
use of com.att.cdp.zones.Context in project AJSC by att.
the class OpenStackStackService method getStack.
/**
* @see com.att.cdp.zones.StackService#getStack(java.lang.String, java.lang.String)
*/
@Override
public Stack getStack(String name, String id) throws ZoneException {
connect();
Context context = getContext();
trackRequest();
RequestState.put(RequestState.SERVICE, "Orchestration");
RequestState.put(RequestState.SERVICE_URL, connector.getEndpoint());
Heat heat = connector.getClient();
OpenStackStack stack = null;
try {
com.woorea.openstack.heat.model.Stack osStack = heat.getStacks().get(name, id).execute();
stack = new OpenStackStack(context, osStack);
} catch (OpenStackBaseException e) {
ExceptionMapper.mapException(e);
}
return stack;
}
use of com.att.cdp.zones.Context in project AJSC by att.
the class OpenStackNetworkService method deleteLoadBalancerMember.
/**
* @see com.att.cdp.zones.NetworkService#deleteLoadBalancerMember(com.att.cdp.zones.model.LoadBalancerMember)
*/
@SuppressWarnings("nls")
@Override
public void deleteLoadBalancerMember(LoadBalancerMember loadBalancerMember) throws ZoneException {
checkArg(loadBalancerMember, "loadBalancerMember");
connect();
Context context = getContext();
trackRequest();
RequestState.put(RequestState.LOADBALANCERMEMBER, loadBalancerMember.getId());
RequestState.put(RequestState.SERVICE, "Network");
RequestState.put(RequestState.SERVICE_URL, quantumConnector.getEndpoint());
try {
Quantum client = quantumConnector.getClient();
client.lbaas().Member().delete(loadBalancerMember.getId()).execute();
} catch (OpenStackBaseException e) {
ExceptionMapper.mapException(e);
}
}
use of com.att.cdp.zones.Context in project AJSC by att.
the class OpenStackNetworkService method assignIpAddressFromPool.
/**
* @see com.att.cdp.zones.NetworkService#assignIpAddressFromPool(java.lang.String, java.lang.String)
*/
@SuppressWarnings("nls")
@Override
public String assignIpAddressFromPool(String serverId, String pool) throws ZoneException {
checkArg(serverId, "serverId");
checkArg(pool, "pool");
connect();
Context context = getContext();
trackRequest();
RequestState.put(RequestState.SERVER, serverId);
RequestState.put(RequestState.POOL, pool);
RequestState.put(RequestState.SERVICE, "Compute");
RequestState.put(RequestState.SERVICE_URL, novaConnector.getEndpoint());
Nova client = novaConnector.getClient();
FloatingIpsExtension extension = client.floatingIps();
if (extension == null) {
throw new NotSupportedException(EELFResourceManager.format(OSMsg.PAL_OS_UNSUPPORTED_OPERATION, "getAvailableAddresses", context.getProvider().getName()));
}
try {
String ip = reserveFreeFloatingIPAddress(pool);
if (ip != null) {
assignIpAddress(serverId, ip);
return ip;
}
} catch (OpenStackBaseException e) {
ExceptionMapper.mapException(e);
}
throw new NotSupportedException(EELFResourceManager.format(OSMsg.PAL_OS_RESOURCE_UNAVAILABLE, "Floating IP Address", context.getProvider().getName()));
}
Aggregations