Search in sources :

Example 41 with ApiConnector

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

the class ServerDBSyncImpl method syncServiceInstance.

/**
     * The service-instance model list is build as a result of synchronizing virtual-machines.
     * @return
     */
public boolean syncServiceInstance() {
    final ApiConnector api = _manager.getApiConnector();
    boolean inSync;
    try {
        @SuppressWarnings("unchecked") List<ServiceInstance> siList = (List<ServiceInstance>) api.list(ServiceInstance.class, null);
        java.util.Collections.sort(siList, new ServiceInstanceComparator());
        DBSyncGeneric.SyncStats stats = new DBSyncGeneric.SyncStats();
        _dbSync.syncCollections(ServiceInstance.class, _manager.getDatabase().getServiceInstances(), siList, _rwMode, stats);
        inSync = stats.create == 0 && stats.delete == 0;
    } catch (Exception ex) {
        s_logger.warn("synchronize service-instances", ex);
        return false;
    }
    return inSync;
}
Also used : ApiConnector(net.juniper.contrail.api.ApiConnector) ServiceInstance(net.juniper.contrail.api.types.ServiceInstance) List(java.util.List) ArrayList(java.util.ArrayList) InternalErrorException(com.cloud.exception.InternalErrorException) IOException(java.io.IOException)

Example 42 with ApiConnector

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

the class ServerDBSyncImpl method deleteDefault.

public void deleteDefault(ApiObjectBase vnc, Class<?> cls, StringBuffer syncLogMesg) throws IOException {
    final ApiConnector api = _manager.getApiConnector();
    api.delete(vnc);
    syncLogMesg.append(cls.getCanonicalName() + "# VNC: " + vnc.getName() + " deleted\n");
}
Also used : ApiConnector(net.juniper.contrail.api.ApiConnector)

Example 43 with ApiConnector

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

the class ServerDBSyncImpl method syncNetworkPolicy.

/*
     *  Network Policy Synchronization methods
     */
@SuppressWarnings({ "unchecked" })
public boolean syncNetworkPolicy() throws Exception {
    final ApiConnector api = _manager.getApiConnector();
    try {
        List<NetworkACLVO> dbAcls = _manager.findManagedACLs();
        if (dbAcls == null) {
            dbAcls = new ArrayList<NetworkACLVO>();
        }
        List<NetworkPolicy> pList = (List<NetworkPolicy>) api.list(NetworkPolicy.class, null);
        List<NetworkPolicy> vncList = new ArrayList<NetworkPolicy>();
        for (NetworkPolicy policy : pList) {
            if (!_manager.isSystemDefaultNetworkPolicy(policy)) {
                vncList.add(policy);
            }
        }
        s_logger.debug("sync Network Policy - DB size: " + dbAcls.size() + " VNC Size: " + vncList.size());
        return _dbSync.syncGeneric(NetworkPolicy.class, dbAcls, vncList);
    } catch (Exception ex) {
        s_logger.warn("sync network-policys", ex);
        throw ex;
    }
}
Also used : NetworkACLVO(com.cloud.network.vpc.NetworkACLVO) NetworkPolicy(net.juniper.contrail.api.types.NetworkPolicy) ApiConnector(net.juniper.contrail.api.ApiConnector) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) InternalErrorException(com.cloud.exception.InternalErrorException) IOException(java.io.IOException)

Example 44 with ApiConnector

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

the class ServerDBSyncImpl method createProject.

@Override
public void createProject(ProjectVO db, StringBuffer syncLogMesg) throws IOException {
    final ApiConnector api = _manager.getApiConnector();
    net.juniper.contrail.api.types.Project vnc = new net.juniper.contrail.api.types.Project();
    vnc.setName(db.getName());
    vnc.setUuid(db.getUuid());
    if (!api.create(vnc)) {
        s_logger.error("Unable to create project: " + vnc.getName());
        syncLogMesg.append("Error: Virtual project# VNC : Unable to create project: " + vnc.getName() + "\n");
        return;
    }
    syncLogMesg.append("Project# VNC: " + vnc.getName() + " created \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