Search in sources :

Example 1 with FloatingIpPool

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");
}
Also used : FloatingIpPool(net.juniper.contrail.api.types.FloatingIpPool) ObjectReference(net.juniper.contrail.api.ObjectReference) ApiConnector(net.juniper.contrail.api.ApiConnector)

Example 2 with FloatingIpPool

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;
}
Also used : FloatingIpPool(net.juniper.contrail.api.types.FloatingIpPool) ObjectReference(net.juniper.contrail.api.ObjectReference) List(java.util.List) ArrayList(java.util.ArrayList) ImmutableList(com.google.common.collect.ImmutableList) IOException(java.io.IOException) FloatingIp(net.juniper.contrail.api.types.FloatingIp) ConfigurationException(javax.naming.ConfigurationException) IOException(java.io.IOException)

Example 3 with FloatingIpPool

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);
    }
}
Also used : FloatingIpPool(net.juniper.contrail.api.types.FloatingIpPool) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) ApiConnector(net.juniper.contrail.api.ApiConnector) ContrailManager(org.apache.cloudstack.network.contrail.management.ContrailManager) IOException(java.io.IOException) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) InternalErrorException(com.cloud.exception.InternalErrorException) IOException(java.io.IOException)

Aggregations

FloatingIpPool (net.juniper.contrail.api.types.FloatingIpPool)3 IOException (java.io.IOException)2 ApiConnector (net.juniper.contrail.api.ApiConnector)2 ObjectReference (net.juniper.contrail.api.ObjectReference)2 InternalErrorException (com.cloud.exception.InternalErrorException)1 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)1 ImmutableList (com.google.common.collect.ImmutableList)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 ConfigurationException (javax.naming.ConfigurationException)1 FloatingIp (net.juniper.contrail.api.types.FloatingIp)1 ContrailManager (org.apache.cloudstack.network.contrail.management.ContrailManager)1