Package org.apache.cloudstack.network.contrail.management

Examples of org.apache.cloudstack.network.contrail.management.ContrailManager


            throw new InternalErrorException("virtual-machine not set on VMI: " + _uuid);
        }
        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();
View Full Code Here


     *
     * @param controller
     * @param serviceUuid
     */
    private void buildServiceInstance(ModelController controller, String serviceUuid) {
        ContrailManager manager = controller.getManager();
        ApiConnector api = controller.getApiAccessor();
        _serviceUuid = serviceUuid;

        ServiceInstance siObj;
        try {
            siObj = (ServiceInstance) api.findById(ServiceInstance.class, serviceUuid);
        } catch (IOException ex) {
            s_logger.warn("service-instance read", ex);
            throw new CloudRuntimeException("Unable to read service-instance object", ex);
        }

        ServiceInstanceModel siModel;
        String fqn = StringUtils.join(siObj.getQualifiedName(), ':');
        siModel = manager.getDatabase().lookupServiceInstance(fqn);
        if (siModel == null) {
            siModel = new ServiceInstanceModel(serviceUuid);
            siModel.build(controller, siObj);
            manager.getDatabase().getServiceInstances().add(siModel);
        }
        /*
         * The code that was under the ELSE was never executed and due to that has been removed.
         * Also, in the case siObj was null, it was going pass it as parameter to the build() method in the
         * siModel object.
View Full Code Here

        clearSuccessors();

        if (_serviceModel != null) {
            _serviceModel.removeSuccessor(this);
            _serviceModel.destroy(controller);
            ContrailManager manager = controller.getManager();
            manager.getDatabase().getServiceInstances().remove(_serviceModel);
            _serviceModel = null;
        }
    }
View Full Code Here

    /**
     * Initialize the object properties based on the DB object.
     * Common code between plugin calls and DBSync.
     */
    public void setProperties(ModelController controller, VMInstanceVO instance) {
        ContrailManager manager = controller.getManager();
        _instanceName = instance.getInstanceName();
        _active = isActiveInstance(instance);

        try {
            _projectId = manager.getProjectId(instance.getDomainId(), instance.getAccountId());
        } catch (IOException ex) {
            s_logger.warn("project read", ex);
            throw new CloudRuntimeException(ex);
        }
        _initialized = true;
View Full Code Here

        setServiceInstanceNics(controller, instance);
    }

    private void setServiceInstanceNics(ModelController controller, VMInstanceVO instance) throws IOException {
        NicDao nicDao = controller.getNicDao();
        ContrailManager manager = controller.getManager();
        NetworkDao networkDao = controller.getNetworkDao();

        List<NicVO> nics = nicDao.listByVmId(_instanceId);
        for (NicVO nic : nics) {
            String tag;

            switch (nic.getDeviceId()) {
                case 0:
                    tag = "management";
                    break;
                case 1:
                    tag = "left";
                    break;
                case 2:
                    tag = "right";
                    break;
                default:
                    tag = null;
            }

            VMInterfaceModel vmiModel = getVMInterface(nic.getUuid());
            if (vmiModel == null) {
                vmiModel = new VMInterfaceModel(nic.getUuid());
                vmiModel.addToVirtualMachine(this);
                NetworkVO network = networkDao.findById(nic.getNetworkId());
                VirtualNetworkModel vnModel = manager.getDatabase().lookupVirtualNetwork(network.getUuid(), manager.getCanonicalName(network), network.getTrafficType());
                assert vnModel != null;
                vmiModel.addToVirtualNetwork(vnModel);
            }
            vmiModel.setProperties(controller, instance, nic);
            vmiModel.setServiceTag(tag);
View Full Code Here

    /**
     * Initialize the object properties based on the DB object.
     * Common code between plugin calls and DBSync.
     */
    public void setProperties(ModelController controller, Network network) {
        ContrailManager manager = controller.getManager();
        _name = manager.getCanonicalName(network);
        _prefix = network.getCidr();
        _gateway = network.getGateway();

        // For non-cloudstack managed network, find the uuid at this stage.
        if (!isDynamicNetwork()) {
            try {
                _uuid = manager.findVirtualNetworkId(network);
            } catch (IOException ex) {
                s_logger.warn("Unable to read virtual-network", ex);
            }
        }

        _id = network.getId();

        try {
            _projectId = manager.getProjectId(network.getDomainId(), network.getAccountId());
        } catch (IOException ex) {
            s_logger.warn("project read", ex);
            throw new CloudRuntimeException(ex);
        }

View Full Code Here

    public void update(ModelController controller) throws InternalErrorException, IOException {

        assert _initialized;

        ApiConnector api = controller.getApiAccessor();
        ContrailManager manager = controller.getManager();
        FloatingIp fip = _fip;

        if (_fip == null) {
            _fip = fip = (FloatingIp)controller.getApiAccessor().findById(FloatingIp.class, _uuid);
            if (fip == null) {
                fip = new FloatingIp();
                fip.setUuid(_uuid);
                fip.setAddress(_addr);
                fip.setName(_name);
                fip.setParent(_fipPoolModel.getFloatingIpPool());
            }
        }

        IPAddressVO ipAddrVO = controller.getIPAddressDao().findById(_id);
        assert ipAddrVO != null : "can not find address object in db";
        Long vmId = ipAddrVO.getAssociatedWithVmId();
        Long networkId = ipAddrVO.getAssociatedWithNetworkId();
        if (vmId == null || networkId == null) {
            s_logger.debug("Floating ip is not yet associated to either vm or network");
            return;
        }
        NicVO nic = controller.getNicDao().findByNtwkIdAndInstanceId(networkId, vmId);
        assert nic != null : "can not find nic for the given network and vm in db";

        VMInstanceVO vm = controller.getVmDao().findById(vmId);
        assert vm != null : "can not find vm in db";

        VirtualMachineModel vmModel = manager.getDatabase().lookupVirtualMachine(vm.getUuid());
        assert vmModel != null : "can not find vm model";

        VMInterfaceModel vmiModel = vmModel.getVMInterface(nic.getUuid());
        assert vmiModel != null && vmiModel.getVMInterface() != null : "can not find virtual machine interface";
View Full Code Here

    public void update(ModelController controller) throws InternalErrorException, IOException {

        assert _vnModel != null : "vn model is not set";

        ApiConnector api = controller.getApiAccessor();
        ContrailManager manager = controller.getManager();
        FloatingIpPool fipPool = _fipPool;

        if (fipPool == null) {
            String fipPoolName = manager.getDefaultPublicNetworkFQN() + ":PublicIpPool";
            _fipPool = fipPool = (FloatingIpPool)controller.getApiAccessor().findByFQN(FloatingIpPool.class, fipPoolName);
            if (fipPool == null) {
                fipPool = new FloatingIpPool();
                fipPool.setName(_name);
                fipPool.setParent(_vnModel.getVirtualNetwork());
View Full Code Here

    /**
     * Initialize the object properties based on the DB object.
     * Common code between plugin calls and DBSync.
     */
    public void setProperties(ModelController controller, Network network) {
        ContrailManager manager = controller.getManager();
        _name = manager.getCanonicalName(network);
        _prefix = network.getCidr();
        _gateway = network.getGateway();
       
        // For non-cloudstack managed network, find the uuid at this stage.
        if (!isDynamicNetwork()) {
            try {
                _uuid = manager.findVirtualNetworkId(network);
            } catch (IOException ex) {
                s_logger.warn("Unable to read virtual-network", ex);
            }
        }

        _id = network.getId();
       
        try {
            _projectId = manager.getProjectId(network.getDomainId(), network.getAccountId());
        } catch (IOException ex) {
            s_logger.warn("project read", ex);
            throw new CloudRuntimeException(ex);
        }
     
View Full Code Here

     *
     * @param controller
     * @param serviceUuid
     */
    private void buildServiceInstance(ModelController controller, String serviceUuid) {
        ContrailManager manager = controller.getManager();
        ApiConnector api = controller.getApiAccessor();
        _serviceUuid = serviceUuid;
       
        ServiceInstance siObj;
        try {
            siObj = (ServiceInstance) api.findById(ServiceInstance.class, serviceUuid);
        } catch (IOException ex) {
            s_logger.warn("service-instance read", ex);
            throw new CloudRuntimeException("Unable to read service-instance object", ex);
        }
        ServiceInstanceModel siModel;
        if (siObj == null) {
            siModel = new ServiceInstanceModel(serviceUuid);
            siModel.build(controller, siObj);
            manager.getDatabase().getServiceInstances().add(siModel);
        } else {
            String fqn = StringUtils.join(siObj.getQualifiedName(), ':');
            siModel = manager.getDatabase().lookupServiceInstance(fqn);
            if (siModel == null) {
                if (siObj == null) {
                    siModel = new ServiceInstanceModel(serviceUuid);
                    siModel.build(controller, siObj);
                    manager.getDatabase().getServiceInstances().add(siModel);
                }
            }
        }
        _serviceModel = siModel;
    }
View Full Code Here

TOP

Related Classes of org.apache.cloudstack.network.contrail.management.ContrailManager

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.