Package org.apache.cloudstack.network.contrail.model

Examples of org.apache.cloudstack.network.contrail.model.VirtualNetworkModel


        if (right.getTrafficType() == TrafficType.Guest) {
            _networkModel.checkNetworkPermissions(owner, right);
        }
       
        final ApiConnector api = _manager.getApiConnector();
        VirtualNetworkModel leftModel = _manager.getDatabase().lookupVirtualNetwork(left.getUuid(),
                _manager.getCanonicalName(left), left.getTrafficType());
        if (leftModel == null) {
            throw new CloudRuntimeException("Unable to read virtual-network object");
        }
        VirtualNetworkModel rightModel = _manager.getDatabase().lookupVirtualNetwork(right.getUuid(),
                _manager.getCanonicalName(right), right.getTrafficType());
        if (rightModel == null) {
            throw new CloudRuntimeException("Unable to read virtual-network object");
        }
View Full Code Here


    public Network implement(Network network, NetworkOffering offering,
            DeployDestination destination, ReservationContext context)
                    throws InsufficientVirtualNetworkCapcityException {
        s_logger.debug("Implement network: " + network.getName() + ", traffic type: " + network.getTrafficType());

        VirtualNetworkModel vnModel = _manager.getDatabase().lookupVirtualNetwork(
                network.getUuid(), _manager.getCanonicalName(network), network.getTrafficType());
        if (vnModel == null) {
            vnModel = new VirtualNetworkModel(network, network.getUuid(),
                    _manager.getCanonicalName(network), network.getTrafficType());
            vnModel.setProperties(_manager.getModelController(), network);
        }

        try {
            if (!vnModel.verify(_manager.getModelController())) {
                vnModel.update(_manager.getModelController());
            }
        } catch (Exception ex) {
            s_logger.warn("virtual-network update: ", ex);
            return network;
        }
View Full Code Here

        s_logger.debug("deviceId: " + nic.getDeviceId());

        NicVO nicVO = _nicDao.findById(nic.getId());
        assert nicVO != null;

        VirtualNetworkModel vnModel = _manager.getDatabase().lookupVirtualNetwork(
                network.getUuid(), _manager.getCanonicalName(network), network.getTrafficType());
        /* Network must have been implemented */
        assert vnModel != null;
       
        VirtualMachineModel vmModel = _manager.getDatabase().lookupVirtualMachine(vm.getUuid());
View Full Code Here

    }

    @Override
    public void shutdown(NetworkProfile network, NetworkOffering offering)  {
        s_logger.debug("NetworkGuru shutdown");
        VirtualNetworkModel vnModel = _manager.getDatabase().lookupVirtualNetwork(network.getUuid(),
                _manager.getCanonicalName(network), network.getTrafficType());
        if (vnModel == null) {
            return;
        }
        try {
            _manager.getDatabase().getVirtualNetworks().remove(vnModel);
            vnModel.delete(_manager.getModelController());
        } catch (IOException e) {
            s_logger.warn("virtual-network delete", e);
        }
    }
View Full Code Here

    public Boolean equalVirtualNetwork(NetworkVO dbn, VirtualNetwork vnet, StringBuffer syncLogMesg) {
        syncLogMesg.append("VN# DB: " + _manager.getCanonicalName(dbn) +
                "; VNC: " + vnet.getName() + "; action: equal\n");
       
        VirtualNetworkModel current = _manager.getDatabase().lookupVirtualNetwork(vnet.getUuid(),
                _manager.getCanonicalName(dbn), dbn.getTrafficType());

        VirtualNetworkModel vnModel = new VirtualNetworkModel(dbn, vnet.getUuid(),
                _manager.getCanonicalName(dbn), dbn.getTrafficType());

        if (dbn.getTrafficType() == TrafficType.Guest && dbn.getNetworkACLId() != null) {
            NetworkACLVO acl = _networkACLDao.findById(dbn.getNetworkACLId());
            NetworkPolicyModel policyModel = _manager.getDatabase().lookupNetworkPolicy(acl.getUuid());
            if (policyModel == null) {
                s_logger.error("Network(" + dbn.getName() + ") has ACL but policy model not created: " +
                                       acl.getUuid() + ", name: " + acl.getName());     
            } else {
                vnModel.addToNetworkPolicy(policyModel);
            }
        }
        vnModel.build(_manager.getModelController(), dbn);

        if (_rw_mode) {
            if (current != null) {
                FloatingIpPoolModel fipPoolModel = current.getFipPoolModel();
                if (fipPoolModel != null) {
                   vnModel.setFipPoolModel(fipPoolModel)
                   fipPoolModel.addToVirtualNetwork(vnModel);
                }
                _manager.getDatabase().getVirtualNetworks().remove(current);
            }
            s_logger.debug("add model " + vnModel.getName());
            _manager.getDatabase().getVirtualNetworks().add(vnModel);  
            try {
                if (!vnModel.verify(_manager.getModelController())) {
                    vnModel.update(_manager.getModelController());
                }
            } catch (Exception ex) {
                s_logger.warn("update virtual-network", ex);
            }
            if (current != null) {
                NetworkPolicyModel oldPolicyModel = current.getNetworkPolicyModel();
                if (oldPolicyModel != vnModel.getNetworkPolicyModel()) {
                    /*
                     * if no other VNs are associated with the old policy,
                     * we could delete it from the Contrail VNC
                     */
                    if (oldPolicyModel != null && !oldPolicyModel.hasDescendents()) {
View Full Code Here

        for (NicVO nic : nics) {
            VMInterfaceModel vmiModel = vmModel.getVMInterface(nic.getUuid());
            if (vmiModel == null) {
                vmiModel = new VMInterfaceModel(nic.getUuid());
                NetworkVO network = _networksDao.findById(nic.getNetworkId());
                VirtualNetworkModel vnModel = _manager.getDatabase().lookupVirtualNetwork(
                        network.getUuid(), _manager.getCanonicalName(network), network.getTrafficType());
                if (vnModel == null)  {
                    s_logger.warn("Unable to locate virtual-network for network id " + network.getId());
                    continue;
                }
View Full Code Here

            throws IOException {

        syncLogMsg.append("fip# DB: " + db.getAddress().addr() +
                "; VNC: " + vnc.getAddress() + "; action: equal" + "\n");

        VirtualNetworkModel vnModel = _manager.lookupPublicNetworkModel();
        assert vnModel != null : "public network vn model is null";

        FloatingIpPoolModel fipPoolModel = vnModel.getFipPoolModel();
        if (fipPoolModel == null) {
            fipPoolModel = new FloatingIpPoolModel();
            fipPoolModel.addToVirtualNetwork(vnModel);
            fipPoolModel.build(_manager.getModelController());
            try {
                fipPoolModel.update(_manager.getModelController());
                vnModel.setFipPoolModel(fipPoolModel);
            } catch (Exception ex) {
                s_logger.warn("floating-ip-pool create: ", ex);
                return false;
            }
        }
View Full Code Here

        types.add(TrafficType.Control);

        List<NetworkVO> dbNets = findManagedNetworks(types);
        for (NetworkVO net:dbNets) {
           
            VirtualNetworkModel vnModel = getDatabase().lookupVirtualNetwork(null, getCanonicalName(net), net.getTrafficType());
            if (vnModel == null) {
                vnModel = new VirtualNetworkModel(net, null, getCanonicalName(net), net.getTrafficType());
                vnModel.build(getModelController(), net);
                try {
                    if (!vnModel.verify(getModelController())) {
                        vnModel.update(getModelController());
                    }
                } catch (Exception ex) {
                    s_logger.warn("virtual-network update: ", ex);
                }
                getDatabase().getVirtualNetworks().add(vnModel);
View Full Code Here

        List<NetworkVO> dbNets = findManagedNetworks(types);
        if (dbNets == null) {
            return null;
        }
        NetworkVO network = dbNets.get(0);
        VirtualNetworkModel vnModel = getDatabase().lookupVirtualNetwork(network.getUuid(), getCanonicalName(network), TrafficType.Public);
        if (vnModel == null) {
            vnModel = new VirtualNetworkModel(network, network.getUuid(),
                        getCanonicalName(network), network.getTrafficType());
            vnModel.setProperties(getModelController(), network);
        }
        try {
            if (!vnModel.verify(getModelController())) {
                vnModel.update(getModelController());
            }
            getDatabase().getVirtualNetworks().add(vnModel);
        } catch (Exception ex) {
            s_logger.warn("virtual-network update: ", ex);
        }
View Full Code Here

        }
        return vnModel;
    }

    public boolean createFloatingIp(PublicIpAddress ip) {
        VirtualNetworkModel vnModel = lookupPublicNetworkModel();
        assert vnModel != null : "public network vn model is null";
        FloatingIpPoolModel fipPoolModel = vnModel.getFipPoolModel();

        /* create only, no updates */
        if (fipPoolModel == null) {
            fipPoolModel = new FloatingIpPoolModel();
            fipPoolModel.addToVirtualNetwork(vnModel);
            fipPoolModel.build(getModelController());
            try {
                fipPoolModel.update(getModelController());
                vnModel.setFipPoolModel(fipPoolModel);
            } catch (Exception ex) {
                s_logger.warn("floating-ip-pool create: ", ex);
                return false;
            }
        }
View Full Code Here

TOP

Related Classes of org.apache.cloudstack.network.contrail.model.VirtualNetworkModel

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.