Search in sources :

Example 11 with ApiConnector

use of net.juniper.contrail.api.ApiConnector in project cloudstack by apache.

the class ServerDBSyncImpl method deleteFloatingIps.

private void deleteFloatingIps(List<ObjectReference<ApiPropertyBase>> list, StringBuffer syncLogMesg) throws IOException {
    if (list == null) {
        return;
    }
    final ApiConnector api = _manager.getApiConnector();
    for (ObjectReference<?> floatingIp : list) {
        api.delete(FloatingIp.class, floatingIp.getUuid());
        syncLogMesg.append("VNC instance ip: " + floatingIp.getUuid() + " deleted\n");
    }
}
Also used : ApiConnector(net.juniper.contrail.api.ApiConnector)

Example 12 with ApiConnector

use of net.juniper.contrail.api.ApiConnector 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 13 with ApiConnector

use of net.juniper.contrail.api.ApiConnector in project cloudstack by apache.

the class ServerDBSyncImpl method syncDomain.

/*
     *  Domain Synchronization methods
     */
public boolean syncDomain() throws Exception {
    final ApiConnector api = _manager.getApiConnector();
    try {
        List<?> dbList = _domainDao.listAll();
        @SuppressWarnings("unchecked") List<?> vncList = api.list(net.juniper.contrail.api.types.Domain.class, null);
        return _dbSync.syncGeneric(net.juniper.contrail.api.types.Domain.class, dbList, vncList);
    } catch (Exception ex) {
        s_logger.warn("syncDomain", ex);
        throw ex;
    }
}
Also used : ApiConnector(net.juniper.contrail.api.ApiConnector) InternalErrorException(com.cloud.exception.InternalErrorException) IOException(java.io.IOException)

Example 14 with ApiConnector

use of net.juniper.contrail.api.ApiConnector in project cloudstack by apache.

the class ServerDBSyncImpl method deleteSecurityGroup.

/*
     * Security Groups
     */
public void deleteSecurityGroup(net.juniper.contrail.api.types.SecurityGroup vnc, StringBuffer syncLogMesg) throws IOException {
    final ApiConnector api = _manager.getApiConnector();
    api.delete(vnc);
    syncLogMesg.append("SecurityGroup# VNC: " + vnc.getName() + " deleted\n");
}
Also used : ApiConnector(net.juniper.contrail.api.ApiConnector)

Example 15 with ApiConnector

use of net.juniper.contrail.api.ApiConnector in project cloudstack by apache.

the class ServerDBSyncImpl method deleteNetworkPolicy.

public void deleteNetworkPolicy(NetworkPolicy policy, StringBuffer syncLogMesg) throws IOException {
    final ApiConnector api = _manager.getApiConnector();
    if (_manager.isSystemDefaultNetworkPolicy(policy)) {
        syncLogMesg.append("Policy# System default Network Policy# VNC: " + policy.getName() + " can not be deleted\n");
        return;
    }
    syncLogMesg.append("Policy# DB: none; VNC: " + policy.getName() + "(" + policy.getUuid() + "); action: delete\n");
    api.delete(policy);
    syncLogMesg.append("Policy# VNC: " + policy.getName() + " deleted\n");
}
Also used : ApiConnector(net.juniper.contrail.api.ApiConnector)

Aggregations

ApiConnector (net.juniper.contrail.api.ApiConnector)44 IOException (java.io.IOException)26 InternalErrorException (com.cloud.exception.InternalErrorException)15 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)9 ArrayList (java.util.ArrayList)8 NetworkVO (com.cloud.network.dao.NetworkVO)6 List (java.util.List)6 VMInstanceVO (com.cloud.vm.VMInstanceVO)5 ContrailManagerImpl (org.apache.cloudstack.network.contrail.management.ContrailManagerImpl)5 VlanDao (com.cloud.dc.dao.VlanDao)4 ApiConnectorMock (net.juniper.contrail.api.ApiConnectorMock)4 ObjectReference (net.juniper.contrail.api.ObjectReference)4 ServiceInstance (net.juniper.contrail.api.types.ServiceInstance)4 VirtualMachineInterface (net.juniper.contrail.api.types.VirtualMachineInterface)4 VirtualNetwork (net.juniper.contrail.api.types.VirtualNetwork)4 ContrailManager (org.apache.cloudstack.network.contrail.management.ContrailManager)4 Test (org.junit.Test)4 VlanVO (com.cloud.dc.VlanVO)3 NicVO (com.cloud.vm.NicVO)3 UserVmDao (com.cloud.vm.dao.UserVmDao)3