Package net.juniper.contrail.api

Examples of net.juniper.contrail.api.ApiConnector


        }
        if (_vnModel == null) {
            throw new InternalErrorException("virtual-network not set on VMI: " + _uuid);
        }
        ContrailManager manager = controller.getManager();
        ApiConnector api = controller.getApiAccessor();

        VirtualMachineInterface vmi = (VirtualMachineInterface) api.findById(VirtualMachineInterface.class, _uuid);
        boolean create = false;
        if (vmi == null) {
            create = true;
            vmi = new VirtualMachineInterface();
            vmi.setParent(_vmModel.getVirtualMachine());
            vmi.setName(manager.getVifNameByVmName(_vmModel.getInstanceName(), _deviceId));
            vmi.setUuid(_uuid);
            vmi.setVirtualNetwork(_vnModel.getVirtualNetwork());
        } else {
            // Do not try to update VMI to routing-instance references. These are managed by schema-transformer.
            vmi.clearRoutingInstance();
        }
        _vmi = vmi;
        if (_macAddress != null) {
            MacAddressesType mac = new MacAddressesType();
            mac.addMacAddress(_macAddress);
            vmi.setMacAddresses(mac);
        }
       
        if (_serviceTag != null) {
            vmi.setProperties(new VirtualMachineInterfacePropertiesType(_serviceTag, null));
        }

        if (create) {
            if (!api.create(vmi)) {
                throw new InternalErrorException("Unable to create virtual-machine-interface " +  _uuid);
            }
        } else {
            if (!api.update(vmi)) {
                throw new InternalErrorException("Unable to update virtual-machine-interface " +  _uuid);
            }
        }

        api.read(vmi);
       
        int ipCount = 0;
        for (ModelObject successor: successors()) {
            if (successor.getClass() == InstanceIpModel.class) {
                ipCount++;
View Full Code Here


    public void setUp() throws Exception {

        if (_apiTest != null ) return;

        initDefaultConfig();
        ApiConnector api = new ApiConnectorMock(null, 0);
        ((ApiConnectorMock)api).dumpConfig(VirtualNetwork.class);
        _apiTest = new ApiTestCommon(api);

    }
View Full Code Here

    public void initDefaultConfig() throws Exception {
        int  port = ApiTestCommon.findFreePort();
        ApiTestCommon.launchContrailServer(port);
        s_logger.debug("initDefaultConfig: test api server launched <localhost" + ", " + port + ">");
        ApiConnector api = ApiConnectorFactory.build("localhost", port);

        Class<?extends ApiObjectBase>[] vncClasses =  new Class[] {
                Domain.class,
                VirtualNetwork.class,
                VirtualMachine.class,
                NetworkIpam.class,
                InstanceIp.class,
                ServiceInstance.class,
                FloatingIp.class,
                NetworkPolicy.class,
                Project.class
        };

        HashMap<Class<?extends ApiObjectBase>, List<HashMap<String, ApiObjectBase>>> map = new HashMap<Class<?extends ApiObjectBase>, List<HashMap<String, ApiObjectBase>>>();
        for (Class<?extends ApiObjectBase> cls: vncClasses) {
            List<?extends ApiObjectBase> vncList = (List<?extends ApiObjectBase>)api.list(cls, null);
            List<HashMap<String, ApiObjectBase>> objList = new ArrayList<HashMap<String, ApiObjectBase>>();
            HashMap<String, ApiObjectBase> uuidMap = new HashMap<String, ApiObjectBase>();
            HashMap<String, ApiObjectBase> fqnMap = new HashMap<String, ApiObjectBase>();
            objList.add(uuidMap);
            objList.add(fqnMap);
            for (ApiObjectBase obj:vncList) {
               api.read(obj);
               uuidMap.put(obj.getUuid(), obj);
               fqnMap.put(StringUtils.join(obj.getQualifiedName(), ':'), obj);
            }
            map.put(cls, objList);
        }
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.