Package net.juniper.contrail.api

Examples of net.juniper.contrail.api.ApiConnector


    private void deleteInstanceIps(List<ObjectReference<ApiPropertyBase>> list, StringBuffer syncLogMesg) throws IOException {
        if (list == null) {
            return;
        }
        final ApiConnector api = _manager.getApiConnector();
        for (ObjectReference<ApiPropertyBase> instIp: list) {
            api.delete(InstanceIp.class, instIp.getUuid());
            syncLogMesg.append("VNC instance ip: " + instIp.getUuid() + " deleted\n");
        }
       
    }
View Full Code Here


   
    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");
        }
    }
View Full Code Here

            syncLogMesg.append("VNC instance ip: " + floatingIp.getUuid() + " deleted\n");
        }
    }

    public void deleteVirtualMachine(VirtualMachine vncVm, StringBuffer syncLogMesg) {
        final ApiConnector api = _manager.getApiConnector();
        syncLogMesg.append("VM# DB:none; VNC: " + vncVm.getName() + "/" + vncVm.getUuid() + "; action: delete\n");
        if (!_rw_mode) {
            return;
        }
        try {
            if (!api.read(vncVm)) {
                 return;
            }
            deleteVirtualMachineInterfaces(vncVm.getVirtualMachineInterfaces(), syncLogMesg);
            api.delete(VirtualMachine.class, vncVm.getUuid());
        } catch (IOException ex) {
            s_logger.warn("delete virtual-machine", ex);
            return;
        }
        syncLogMesg.append("VM# VNC: " + vncVm.getName() + " deleted\n");
View Full Code Here

        }
        syncLogMesg.append("fip# VNC: " + dbIp.getUuid() + " created\n");
    }
   
    public void deleteFloatingIp(FloatingIp vnc, StringBuffer syncLogMesg) throws IOException {
        final ApiConnector api = _manager.getApiConnector();
        syncLogMesg.append("fip# DB: none; VNC: " + vnc.getAddress() + "(" +
                vnc.getUuid() + "); action: delete\n");
        api.delete(vnc);
        syncLogMesg.append("fip# VNC: " + vnc.getUuid() + " deleted\n");
    }
View Full Code Here

    public void createServiceInstance(ServiceInstanceModel siModel, StringBuffer logMsg) {
        assert false;
    }
   
    public void deleteServiceInstance(ServiceInstance siObj, StringBuffer logMsg) {
        final ApiConnector api = _manager.getApiConnector();
        s_logger.debug("delete " + siObj.getQualifiedName());
        if (!_rw_mode) {
            return;
        }
        try {
            api.delete(siObj);
        } catch (IOException ex) {
            s_logger.warn("service-instance delete", ex);
        }
    }
View Full Code Here

    /**
     * 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,
                    _rw_mode, stats);
            inSync = stats.create == 0 && stats.delete == 0;
View Full Code Here

    /*
     *  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);
View Full Code Here

            syncLogMesg.append("Policy# VNC: " + policyModel.getName() + " created \n");
        }
    }

    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");
    }
View Full Code Here

        return _uuid.compareTo(other._uuid);
    }
   
    @Override
    public void delete(ModelController controller) throws IOException {
        ApiConnector api = controller.getApiAccessor();
        if (_policy != null) {
            api.delete(_policy);
            _policy = null;
        }
    }
View Full Code Here

        return _uuid;
    }
   
    @Override
    public void update(ModelController controller) throws InternalErrorException, IOException {
        ApiConnector api = controller.getApiAccessor();
        if (_project == null) {
            s_logger.debug("Project is null for the policy: " + _name);
            throw new IOException("Project is null for the policy: " + _name);
        }

        NetworkPolicy policy = _policy;

        if (policy == null) {
            try {
                String policyId = api.findByName(NetworkPolicy.class, _project, _name);
                if (policyId != null) {
                    policy = _policy = (NetworkPolicy) api.findById(NetworkPolicy.class, policyId);
                }
                if (policy == null) {
                    policy = new NetworkPolicy();
                    policy.setUuid(_uuid);
                    policy.setName(_name);
                    policy.setParent(_project);
                }
            } catch (IOException ex) {
                s_logger.warn("network-policy read", ex);
                return;
            }
        }
       
        policy.setEntries(_policyMap);
        if (_policy == null) {
            try {
                api.create(policy);
            } catch (Exception ex) {
                s_logger.debug("network policy create", ex);
                throw new CloudRuntimeException("Failed to create network policy", ex);
            }
            _policy = policy;
        } else {
            try {
                api.update(policy);
            } catch (IOException ex) {
                s_logger.warn("network policy update", ex);
                throw new CloudRuntimeException("Unable to update network policy", ex);
            }           
        }
View Full Code Here

TOP

Related Classes of net.juniper.contrail.api.ApiConnector

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.