Package net.juniper.contrail.api

Examples of net.juniper.contrail.api.ApiConnector


            }
        }
    }

    public <T extends ApiPropertyBase> void deleteChildren(List<ObjectReference<T>> childs, Class<?> childCls, StringBuffer syncLogMesg) throws Exception {
        final ApiConnector api = _manager.getApiConnector();
        if (childs == null) {
            syncLogMesg.append("no children of type: " + childCls.getName() + "\n");
            return;
        }

        syncLogMesg.append("delete children of type : " + DBSyncGeneric.getClassName(childCls) + "\n");
        String deleteChildMethod = "delete" + DBSyncGeneric.getClassName(childCls);
        Method method = null;
        Method methods[] = this.getClass().getMethods();
        for (int i = 0; i < methods.length; i++) {
            if (methods[i].getName().equalsIgnoreCase(deleteChildMethod)) {
                method = methods[i];
                break;
            }
        }
        int count = 0;
        for (ObjectReference<T> childRef : childs) {
            @SuppressWarnings("unchecked")
            ApiObjectBase child = api.findById((Class<? extends ApiObjectBase>)childCls, childRef.getUuid());
            if (method != null) {
                method.invoke(this, child, syncLogMesg);
            } else {
                deleteDefault(child, childCls, syncLogMesg);
            }
View Full Code Here


        }
        syncLogMesg.append("deleted children count : " + count + "\n");
    }

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

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

        }
    }

    @Override
    public void createDomain(DomainVO db, StringBuffer syncLogMesg) throws IOException {
        final ApiConnector api = _manager.getApiConnector();
        net.juniper.contrail.api.types.Domain vnc = new net.juniper.contrail.api.types.Domain();
        vnc.setName(db.getName());
        vnc.setUuid(db.getUuid());
        if (!api.create(vnc)) {
            s_logger.error("Unable to create domain " + vnc.getName());
            syncLogMesg.append("Error: Virtual domain# VNC : Unable to create domain: " + vnc.getName() + "\n");
            return;
        }
        syncLogMesg.append("Domain# VNC: " + vnc.getName() + " created \n");
View Full Code Here

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

    public void deleteDomain(net.juniper.contrail.api.types.Domain vnc, StringBuffer syncLogMesg) throws IOException {
        final ApiConnector api = _manager.getApiConnector();
        api.read(vnc);
        syncLogMesg.append("Domain# DB: none; VNC: " + vnc.getName() + "(" + vnc.getUuid() + "); action: delete\n");

        /* delete all projects under this domain */
        try {
            deleteChildren(vnc.getProjects(), net.juniper.contrail.api.types.Project.class, syncLogMesg);
        } catch (Exception ex) {
            s_logger.warn("deleteDomain", ex);
        }

        api.delete(vnc);
        syncLogMesg.append("Domain# VNC: " + vnc.getName() + " deleted\n");
    }
View Full Code Here

    /*
     *  Project Synchronization methods
     */
    @SuppressWarnings("unchecked")
    public boolean syncProject() throws Exception {
        final ApiConnector api = _manager.getApiConnector();
        try {
            List<?> dbList = _projectDao.listAll();
            List<?> vncList = api.list(net.juniper.contrail.api.types.Project.class, null);
            return _dbSync.syncGeneric(net.juniper.contrail.api.types.Project.class, dbList, vncList);
        } catch (Exception ex) {
            s_logger.warn("syncProject", ex);
            throw ex;
        }
View Full Code Here

        }
    }

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

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

    public void deleteProject(net.juniper.contrail.api.types.Project vnc, StringBuffer syncLogMesg) throws IOException {
        final ApiConnector api = _manager.getApiConnector();
        api.read(vnc);
        syncLogMesg.append("Project# DB: none; VNC: " + vnc.getName() + "(" + vnc.getUuid() + "); action: delete\n");

        try {
            deleteChildren(vnc.getVirtualNetworks(), VirtualNetwork.class, syncLogMesg);
            deleteChildren(vnc.getSecurityGroups(), net.juniper.contrail.api.types.SecurityGroup.class, syncLogMesg);
            deleteChildren(vnc.getNetworkIpams(), net.juniper.contrail.api.types.NetworkIpam.class, syncLogMesg);
            deleteChildren(vnc.getNetworkPolicys(), net.juniper.contrail.api.types.NetworkPolicy.class, syncLogMesg);
        } catch (Exception ex) {
            s_logger.warn("deleteProject", ex);
        }

        api.delete(vnc);
        syncLogMesg.append("Project# VNC: " + vnc.getName() + " deleted\n");
    }
View Full Code Here

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

    /*
     *  Virtual Network Synchronization methods
     */
    @SuppressWarnings({"unchecked"})
    public boolean syncVirtualNetwork() throws Exception {
        final ApiConnector api = _manager.getApiConnector();
        try {

            List<TrafficType> types = new ArrayList<TrafficType>();
            types.add(TrafficType.Public);
            types.add(TrafficType.Guest);
            List<NetworkVO> dbNets = _manager.findManagedNetworks(types);

            List<VirtualNetwork> vList = (List<VirtualNetwork>)api.list(VirtualNetwork.class, null);
            List<VirtualNetwork> vncList = new ArrayList<VirtualNetwork>();
            for (VirtualNetwork vn : vList) {
                if (!_manager.isSystemDefaultNetwork(vn)) {
                    vncList.add(vn);
                }
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.