use of net.juniper.contrail.api.types.FloatingIpPool in project cloudstack by apache.
the class ServerDBSyncImpl method deleteVirtualNetwork.
public void deleteVirtualNetwork(VirtualNetwork vnet, StringBuffer syncLogMesg) throws IOException {
final ApiConnector api = _manager.getApiConnector();
if (_manager.isSystemDefaultNetwork(vnet)) {
syncLogMesg.append("VN# System default virtual Network# VNC: " + vnet.getName() + " can not be deleted\n");
return;
}
api.read(vnet);
deleteInstanceIps(vnet.getInstanceIpBackRefs(), syncLogMesg);
List<ObjectReference<ApiPropertyBase>> fipPools = vnet.getFloatingIpPools();
if (fipPools != null && !fipPools.isEmpty()) {
FloatingIpPool floatingIpPool = (FloatingIpPool) api.findById(FloatingIpPool.class, fipPools.get(0).getUuid());
if (floatingIpPool != null) {
deleteFloatingIps(floatingIpPool.getFloatingIps(), syncLogMesg);
}
}
deleteVirtualMachineInterfaces(vnet.getVirtualMachineInterfaceBackRefs(), syncLogMesg);
syncLogMesg.append("VN# DB: none; VNC: " + vnet.getName() + "(" + vnet.getUuid() + "); action: delete\n");
api.delete(vnet);
syncLogMesg.append("VN# VNC: " + vnet.getName() + " deleted\n");
}
use of net.juniper.contrail.api.types.FloatingIpPool in project cloudstack by apache.
the class ContrailManagerImpl method getFloatingIps.
@SuppressWarnings("unchecked")
@Override
public List<FloatingIp> getFloatingIps() {
String fipPoolName = getDefaultPublicNetworkFQN() + ":PublicIpPool";
FloatingIpPool fipPool = null;
try {
fipPool = (FloatingIpPool) _api.findByFQN(FloatingIpPool.class, fipPoolName);
} catch (Exception ex) {
s_logger.debug(ex);
}
if (fipPool == null) {
return null;
}
List<ObjectReference<ApiPropertyBase>> ips = fipPool.getFloatingIps();
if (ips != null) {
try {
return (List<FloatingIp>) _api.getObjects(FloatingIp.class, ips);
} catch (IOException ex) {
s_logger.debug(ex);
return null;
}
}
return null;
}
use of net.juniper.contrail.api.types.FloatingIpPool in project cloudstack by apache.
the class FloatingIpPoolModel method update.
@Override
public void update(ModelController controller) throws InternalErrorException, IOException {
assert _vnModel != null : "vn model is not set";
ApiConnector api = controller.getApiAccessor();
ContrailManager manager = controller.getManager();
FloatingIpPool fipPool = _fipPool;
if (fipPool == null) {
String fipPoolName = manager.getDefaultPublicNetworkFQN() + ":PublicIpPool";
_fipPool = fipPool = (FloatingIpPool) controller.getApiAccessor().findByFQN(FloatingIpPool.class, fipPoolName);
if (fipPool == null) {
fipPool = new FloatingIpPool();
fipPool.setName(_name);
fipPool.setParent(_vnModel.getVirtualNetwork());
}
}
if (_fipPool == null) {
try {
api.create(fipPool);
} catch (Exception ex) {
s_logger.debug("floating ip pool create", ex);
throw new CloudRuntimeException("Failed to create floating ip pool", ex);
}
_fipPool = fipPool;
} else {
try {
api.update(fipPool);
} catch (IOException ex) {
s_logger.warn("floating ip pool update", ex);
throw new CloudRuntimeException("Unable to update floating ip ppol object", ex);
}
}
for (ModelObject successor : successors()) {
successor.update(controller);
}
}
Aggregations