use of com.att.cdp.zones.Context in project AJSC by att.
the class OpenStackNetworkService method updateLoadBalancerListener.
/**
* @see com.att.cdp.zones.NetworkService#updateLoadBalancerListener(com.att.cdp.zones.model.LoadBalancerListener)
*/
@Override
public LoadBalancerListener updateLoadBalancerListener(LoadBalancerListener loadBalancerVIP) throws ZoneException {
connect();
Context context = getContext();
trackRequest();
RequestState.put(RequestState.LOADBALANCERLISTENER, loadBalancerVIP.getName());
RequestState.put(RequestState.SERVICE, "Network");
RequestState.put(RequestState.SERVICE_URL, quantumConnector.getEndpoint());
try {
Quantum client = quantumConnector.getClient();
com.woorea.openstack.quantum.model.LoadBalancerVIP loadBalancerVIPToCreate = new com.woorea.openstack.quantum.model.LoadBalancerVIP();
loadBalancerVIPToCreate.setName(loadBalancerVIP.getName());
// TODO Description
loadBalancerVIPToCreate.setSubnetId(loadBalancerVIP.getSubnetId());
loadBalancerVIPToCreate.setAddress(loadBalancerVIP.getIpAddress());
if (loadBalancerVIP.getProtocol() != null) {
loadBalancerVIPToCreate.setProtocol(loadBalancerVIP.getProtocol().name());
}
loadBalancerVIPToCreate.setPort(loadBalancerVIP.getProtocolPort());
loadBalancerVIPToCreate.setPoolId(loadBalancerVIP.getPoolId());
// TODO session persistence
loadBalancerVIPToCreate.setConnectionLimit(loadBalancerVIP.getConnectionLimit());
loadBalancerVIPToCreate.setState(loadBalancerVIP.isAdminStateUp());
com.woorea.openstack.quantum.model.LoadBalancerVIP openstackLbVip = client.lbaas().VIP().update(loadBalancerVIPToCreate).execute();
return new OpenStackLoadBalancerVIP(context, openstackLbVip);
} catch (OpenStackBaseException e) {
ExceptionMapper.mapException(e);
}
return null;
}
use of com.att.cdp.zones.Context in project AJSC by att.
the class OpenStackNetworkService method assignIpAddress.
/**
* @see com.att.cdp.zones.NetworkService#assignIpAddress(java.lang.String, java.lang.String)
*/
@SuppressWarnings("nls")
@Override
public void assignIpAddress(String serverId, String address) throws ZoneException {
checkArg(serverId, "serverId");
checkArg(address, "address");
connect();
Context context = getContext();
trackRequest();
RequestState.put(RequestState.SERVER, serverId);
RequestState.put(RequestState.IPADDRESS, address);
RequestState.put(RequestState.SERVICE, "Compute");
RequestState.put(RequestState.SERVICE_URL, novaConnector.getEndpoint());
ComputeService compute = context.getComputeService();
compute.assignIpAddress(serverId, address);
}
use of com.att.cdp.zones.Context in project AJSC by att.
the class OpenStackNetworkService method createSubnet.
@Override
public Subnet createSubnet(Subnet subnet) throws ZoneException {
connect();
Context context = getContext();
trackRequest();
RequestState.put(RequestState.SUBNET, subnet.getName());
RequestState.put(RequestState.SERVICE, "Network");
RequestState.put(RequestState.SERVICE_URL, quantumConnector.getEndpoint());
try {
Quantum client = quantumConnector.getClient();
com.woorea.openstack.quantum.model.Subnet subnetToCreate = new com.woorea.openstack.quantum.model.Subnet();
subnetToCreate.setName(subnet.getName());
subnetToCreate.setNetworkId(subnet.getNetwork());
subnetToCreate.setCidr(subnet.getRouting());
subnetToCreate.setGw(subnet.getGatewayIp());
subnetToCreate.setEnableDHCP(subnet.isDhcp());
subnetToCreate.setDnsNames(subnet.getDns());
if (subnet.isIpv4()) {
subnetToCreate.setIpversion(IpVersion.IPV4);
} else {
subnetToCreate.setIpversion(IpVersion.IPV6);
}
if (!subnet.getHostRoutes().isEmpty()) {
List<com.woorea.openstack.quantum.model.Route> routesToCreate = new ArrayList<>();
List<Route> routes = subnet.getHostRoutes();
for (Route route : routes) {
com.woorea.openstack.quantum.model.Route newRoute = new com.woorea.openstack.quantum.model.Route();
newRoute.setDestination(route.getDestination());
newRoute.setNexthop(route.getNexthop());
routesToCreate.add(newRoute);
}
subnetToCreate.setHostRoutes(routesToCreate);
}
com.woorea.openstack.quantum.model.Subnet openstackSubnet = client.subnets().create(subnetToCreate).execute();
return new OpenStackSubnet(context, openstackSubnet);
} catch (OpenStackBaseException e) {
ExceptionMapper.mapException(e);
}
return null;
}
use of com.att.cdp.zones.Context in project AJSC by att.
the class OpenStackSnapshotService method destroySnapshot.
/**
* This method can be called to destroy a snapshot.
*
* @param id
* The id of the snapshot to be destroyed.
* @throws ZoneException
* - If the snapshot cannot be destroyed.
* @see com.att.cdp.zones.SnapshotService#destroySnapshot(java.lang.String)
*/
@SuppressWarnings("nls")
@Override
public void destroySnapshot(String id) throws ZoneException {
checkArg(id, "id");
connect();
Context context = getContext();
trackRequest();
RequestState.put(RequestState.SNAPSHOT, id);
RequestState.put(RequestState.SERVICE, "Volume");
RequestState.put(RequestState.SERVICE_URL, cinder.getEndpoint());
try {
cinder.getClient().snapshots().delete(id).execute();
} catch (OpenStackBaseException ex) {
ExceptionMapper.mapException(ex);
}
}
use of com.att.cdp.zones.Context in project AJSC by att.
the class OpenStackSnapshotService method createSnapshot.
/**
* This method is used to create a new snapshot using the Snapshot object (disconnected) as the model. When the
* method returns, a connected model object is returned that should be used for any model navigation desired.
*
* @param template
* The template of the snapshot to create. This must contain at least a name and volumeId. Other
* information will be supplied if not present. Any ID is ignored, and the ID of the created snapshot is
* returned in the connected snapshot object returned to the caller.
* @return A Snapshot object that is connected to the service context and can be used to navigate the model.
* @throws ZoneException
* - If the snapshot cannot be created for some reason.
* @see com.att.cdp.zones.SnapshotService#createSnapshot(com.att.cdp.zones.model.Snapshot)
*/
@SuppressWarnings("nls")
@Override
public Snapshot createSnapshot(Snapshot template) throws ZoneException {
checkArg(template, "template");
connect();
Context context = getContext();
trackRequest();
RequestState.put(RequestState.SNAPSHOT, template.getName());
RequestState.put(RequestState.VOLUME, template.getVolumeId());
RequestState.put(RequestState.SERVICE, "Volume");
RequestState.put(RequestState.SERVICE_URL, cinder.getEndpoint());
try {
com.woorea.openstack.cinder.model.SnapshotForCreate newSnapshot = new com.woorea.openstack.cinder.model.SnapshotForCreate();
HashMap<String, String> dictionary = new HashMap<>();
dictionary.put("name", "name");
dictionary.put("description", "description");
dictionary.put("size", "size");
dictionary.put("volumeId", "volumeId");
ObjectMapper.map(template, newSnapshot, dictionary);
OpenStackSnapshot snapshot = new OpenStackSnapshot(context, cinder.getClient().snapshots().create(newSnapshot).execute());
return snapshot;
} catch (OpenStackBaseException ex) {
ExceptionMapper.mapException(ex);
}
// for the compiler
return null;
}
Aggregations