Package net.juniper.contrail.api

Examples of net.juniper.contrail.api.ApiConnector


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

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


    /*
     *  Virtual Machine Synchronization methods
     */

    public boolean syncVirtualMachine() {
        final ApiConnector api = _manager.getApiConnector();
        try {
            List<VMInstanceVO> vmDbList = _vmInstanceDao.listAll();
            @SuppressWarnings("unchecked")
            List<VirtualMachine> vncVmList = (List<VirtualMachine>)api.list(VirtualMachine.class, null);
            s_logger.debug("sync VM:  CS size: " + vmDbList.size() + " VNC size: " + vncVmList.size());
            return _dbSync.syncGeneric(VirtualMachine.class, vmDbList, vncVmList);
        } catch (Exception ex) {
            s_logger.warn("sync virtual-machines", ex);
        }
View Full Code Here

    private void deleteVirtualMachineInterfaces(List<ObjectReference<ApiPropertyBase>> list, StringBuffer syncLogMesg) throws IOException {
        if (list == null) {
            return;
        }
        final ApiConnector api = _manager.getApiConnector();
        for (ObjectReference<ApiPropertyBase> vmiRef : list) {
            VirtualMachineInterface vmi = (VirtualMachineInterface)api.findById(VirtualMachineInterface.class, vmiRef.getUuid());
            deleteInstanceIps(vmi.getInstanceIpBackRefs(), syncLogMesg);
            deleteFloatingIps(vmi.getFloatingIpBackRefs(), syncLogMesg);
            api.delete(VirtualMachineInterface.class, vmiRef.getUuid());
            syncLogMesg.append("VNC vmi: " + vmi.getUuid() + " deleted\n");
        }
    }
View Full Code Here

    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 (!_rwMode) {
            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

    /*
     *  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

    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 (!_rwMode) {
            return;
        }
        try {
            api.delete(siObj);
        } catch (IOException ex) {
            s_logger.warn("service-instance delete", 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.