Examples of VlanDao


Examples of com.cloud.dc.dao.VlanDao

        List<IPAddressVO> fakeList = new ArrayList<IPAddressVO>();
        IPAddressVO fakeIp = new IPAddressVO(new Ip("75.75.75.75"), 1, 0xaabbccddeeffL, 10, false);
        fakeList.add(fakeIp);
        SearchBuilder<IPAddressVO> fakeSearch = mock(SearchBuilder.class);
        modelImpl.IpAddressSearch = fakeSearch;
        VlanDao fakeVlanDao = mock(VlanDao.class);
        when (fakeVlanDao.findById(anyLong())).thenReturn(mock(VlanVO.class));
        modelImpl._vlanDao = fakeVlanDao;
        when(fakeSearch.create()).thenReturn(mock(SearchCriteria.class));
        when(
                ipAddressDao.search(
                        any(SearchCriteria.class),
View Full Code Here

Examples of com.cloud.dc.dao.VlanDao

        List<IPAddressVO> fakeList = new ArrayList<IPAddressVO>();
        IPAddressVO fakeIp = new IPAddressVO(new Ip("75.75.75.75"), 1, 0xaabbccddeeffL, 10, false);
        fakeList.add(fakeIp);
        SearchBuilder<IPAddressVO> fakeSearch = mock(SearchBuilder.class);
        modelImpl.IpAddressSearch = fakeSearch;
        VlanDao fakeVlanDao = mock(VlanDao.class);
        when(fakeVlanDao.findById(anyLong())).thenReturn(mock(VlanVO.class));
        modelImpl._vlanDao = fakeVlanDao;
        when(fakeSearch.create()).thenReturn(mock(SearchCriteria.class));
        when(ipAddressDao.search(any(SearchCriteria.class), (Filter)org.mockito.Matchers.isNull())).thenReturn(fakeList);
        when(ipAddressDao.findById(anyLong())).thenReturn(fakeIp);
        Account fakeAccount = mock(Account.class);
View Full Code Here

Examples of com.cloud.dc.dao.VlanDao

        //ContrailManager
        ContrailManagerImpl contrailMgr = mock(ContrailManagerImpl.class);

        controller = mock(ModelController.class);
        VlanDao vlanDao = mock(VlanDao.class);

        ApiConnector api = mock(ApiConnectorMock.class);

        //Mock classes/methods
        when(controller.getManager()).thenReturn(contrailMgr);
View Full Code Here

Examples of com.cloud.dc.dao.VlanDao

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

        assert _initialized;

        ApiConnector api = controller.getApiAccessor();
        VlanDao vlanDao = controller.getVlanDao();
        VirtualNetwork vn = _vn;

        if (!isDynamicNetwork()) {
            _vn = (VirtualNetwork)controller.getApiAccessor().findById(VirtualNetwork.class, _uuid);
            return;
        }

        assert _uuid != null : "uuid is not set";

        if (_vn == null) {
            vn = _vn = (VirtualNetwork)controller.getApiAccessor().findById(VirtualNetwork.class, _uuid);
            if (vn == null) {
                vn = new VirtualNetwork();
                if (_projectId != null) {
                    Project project;
                    try {
                        project = (Project)api.findById(Project.class, _projectId);
                    } catch (IOException ex) {
                        s_logger.debug("project read", ex);
                        throw new CloudRuntimeException("Failed to read project", ex);
                    }
                    vn.setParent(project);
                }
                vn.setName(_name);
                vn.setUuid(_uuid);
            }
        }

        if (_policyModel == null) {
            vn.clearNetworkPolicy();
        } else if (!_policyModel.hasPolicyRules()) {
            vn.clearNetworkPolicy();
            _policyModel.removeSuccessor(this);
        } else {
            vn.setNetworkPolicy(_policyModel.getPolicy(), new VirtualNetworkPolicyType(
                    new VirtualNetworkPolicyType.SequenceType(1, 0), null));
        }

        if (_ipam == null) {
            NetworkIpam ipam = null;
            try {
                String ipam_id = api.findByName(NetworkIpam.class, null, "default-network-ipam");
                if (ipam_id == null) {
                    s_logger.debug("could not find default-network-ipam");
                    return;
                }
                ipam = (NetworkIpam)api.findById(NetworkIpam.class, ipam_id);
                if (ipam == null) {
                    s_logger.debug("could not find NetworkIpam with ipam_id: " + ipam_id);
                    return;
                }
            } catch (IOException ex) {
                s_logger.error(ex);
                return;
            }
            _ipam = ipam;
        }

        if (_prefix != null) {
            VnSubnetsType subnet = new VnSubnetsType();
            String[] addr_pair = _prefix.split("\\/");
            subnet.addIpamSubnets(new SubnetType(addr_pair[0], Integer.parseInt(addr_pair[1])), _gateway);
            vn.setNetworkIpam(_ipam, subnet);
        } else if (_trafficType == TrafficType.Public) {
            vn.clearNetworkIpam();
            /* Subnet information for Public is stored in the vlan table */
            List<VlanVO> vlan_list = vlanDao.listVlansByNetworkId(_id);
            for (VlanVO vlan : vlan_list) {
                String cidr = NetUtils.ipAndNetMaskToCidr(vlan.getVlanGateway(), vlan.getVlanNetmask());
                int slash = cidr.indexOf('/');
                String ip_addr = cidr.substring(0, slash);
                int plen = Integer.parseInt(cidr.substring(slash + 1));
View Full Code Here

Examples of com.cloud.dc.dao.VlanDao

        }
    }

    public void read(ModelController controller) {
        ApiConnector api = controller.getApiAccessor();
        VlanDao vlanDao = controller.getVlanDao();
        try {
            _vn = (VirtualNetwork)api.findById(VirtualNetwork.class, _uuid);
        } catch (IOException e) {
            e.printStackTrace();
        }
        if (_vn == null) {
            return;
        }
        if (_ipam == null) {
            NetworkIpam ipam = null;
            try {
                String ipam_id = api.findByName(NetworkIpam.class, null, "default-network-ipam");
                if (ipam_id == null) {
                    s_logger.debug("could not find default-network-ipam");
                    return;
                }
                ipam = (NetworkIpam)api.findById(NetworkIpam.class, ipam_id);
                if (ipam == null) {
                    s_logger.debug("could not find NetworkIpam with ipam_id: " + ipam_id);
                    return;
                }
            } catch (IOException ex) {
                s_logger.error(ex);
                return;
            }
            _ipam = ipam;
        }

        if (_prefix != null) {
            VnSubnetsType subnet = new VnSubnetsType();
            String[] addr_pair = _prefix.split("\\/");
            subnet.addIpamSubnets(new SubnetType(addr_pair[0], Integer.parseInt(addr_pair[1])), _gateway);
            _vn.setNetworkIpam(_ipam, subnet);
        } else if (_trafficType == TrafficType.Public) {
            _vn.clearNetworkIpam();
            /* Subnet information for Public is stored in the vlan table */
            List<VlanVO> vlan_list = vlanDao.listVlansByNetworkId(_id);
            for (VlanVO vlan : vlan_list) {
                String cidr = NetUtils.ipAndNetMaskToCidr(vlan.getVlanGateway(), vlan.getVlanNetmask());
                int slash = cidr.indexOf('/');
                String ip_addr = cidr.substring(0, slash);
                int plen = Integer.parseInt(cidr.substring(slash + 1));
View Full Code Here

Examples of com.cloud.dc.dao.VlanDao

    public boolean verify(ModelController controller) {
        assert _initialized : "initialized is false";
    assert _uuid != null : "uuid is not set";

    ApiConnector api = controller.getApiAccessor();
    VlanDao vlanDao = controller.getVlanDao();

    try {
        _vn = (VirtualNetwork)api.findById(VirtualNetwork.class, _uuid);
    } catch (IOException e) {
        e.printStackTrace();
    }

    if (_vn == null) {
        return false;
    }

    if (!isDynamicNetwork()) {
        return true;
    }

    List<String> dbSubnets = new ArrayList<String>();
    if (_trafficType == TrafficType.Public) {
        List<VlanVO> vlan_list = vlanDao.listVlansByNetworkId(_id);
        for (VlanVO vlan : vlan_list) {
            String cidr = NetUtils.ipAndNetMaskToCidr(vlan.getVlanGateway(), vlan.getVlanNetmask());
            dbSubnets.add(vlan.getVlanGateway() + cidr);
        }
    } else {
View Full Code Here

Examples of com.cloud.dc.dao.VlanDao

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

        assert _initialized;

        ApiConnector api = controller.getApiAccessor();
        VlanDao vlanDao = controller.getVlanDao();
        VirtualNetwork vn = _vn;
       
        if (!isDynamicNetwork()) {
            _vn = (VirtualNetwork) controller.getApiAccessor().findById(VirtualNetwork.class, _uuid);
            return;
        }
       
        assert _uuid != null : "uuid is not set";

        if (_vn == null) {
            vn = _vn = (VirtualNetwork) controller.getApiAccessor().findById(VirtualNetwork.class, _uuid);
            if (vn == null) {
                vn = new VirtualNetwork();
                if (_projectId != null) {
                    Project project;
                    try {
                        project = (Project) api.findById(Project.class, _projectId);
                    } catch (IOException ex) {
                        s_logger.debug("project read", ex);
                        throw new CloudRuntimeException("Failed to read project", ex);                   
                    }
                    vn.setParent(project);
                }
                vn.setName(_name);
                vn.setUuid(_uuid);
            }
        }

        if (_policyModel == null) {
            vn.clearNetworkPolicy();
        } else if (!_policyModel.hasPolicyRules()) {
            vn.clearNetworkPolicy();
            _policyModel.removeSuccessor(this);
        } else {
            vn.setNetworkPolicy(_policyModel.getPolicy(), new VirtualNetworkPolicyType(
                    new VirtualNetworkPolicyType.SequenceType(1, 0), null));
        }
    
        if (_ipam == null) {
            NetworkIpam ipam = null;
            try {
                String ipam_id = api.findByName(NetworkIpam.class, null, "default-network-ipam");
                if (ipam_id == null) {
                    s_logger.debug("could not find default-network-ipam");
                    return;
                }
                ipam = (NetworkIpam) api.findById(NetworkIpam.class, ipam_id);
                if (ipam == null) {
                    s_logger.debug("could not find NetworkIpam with ipam_id: " + ipam_id);
                    return;
                }
            } catch (IOException ex) {
                s_logger.error(ex);
                return;
            }
            _ipam = ipam;
        }

        if (_prefix != null) {
            VnSubnetsType subnet = new VnSubnetsType();
            String[] addr_pair = _prefix.split("\\/");
            subnet.addIpamSubnets(new SubnetType(addr_pair[0], Integer.parseInt(addr_pair[1])), _gateway);
            vn.setNetworkIpam(_ipam, subnet);
        } else if (_trafficType == TrafficType.Public) {
            vn.clearNetworkIpam();
            /* Subnet information for Public is stored in the vlan table */
            List<VlanVO> vlan_list = vlanDao.listVlansByNetworkId(_id);
            for (VlanVO vlan : vlan_list) {
                String cidr = NetUtils.ipAndNetMaskToCidr(vlan.getVlanGateway(), vlan.getVlanNetmask());
                int slash = cidr.indexOf('/');
                String ip_addr = cidr.substring(0, slash);
                int plen = Integer.parseInt(cidr.substring(slash + 1));
View Full Code Here

Examples of com.cloud.dc.dao.VlanDao

        }
    }

    public void read(ModelController controller) {
        ApiConnector api = controller.getApiAccessor();
        VlanDao vlanDao = controller.getVlanDao();
        try {
            _vn = (VirtualNetwork) api.findById(VirtualNetwork.class, _uuid);
        } catch (IOException e) {
            e.printStackTrace();
        }
        if (_vn == null) {
            return;
        }
        if (_ipam == null) {
            NetworkIpam ipam = null;
            try {
                String ipam_id = api.findByName(NetworkIpam.class, null, "default-network-ipam");
                if (ipam_id == null) {
                    s_logger.debug("could not find default-network-ipam");
                    return;
                }
                ipam = (NetworkIpam) api.findById(NetworkIpam.class, ipam_id);
                if (ipam == null) {
                    s_logger.debug("could not find NetworkIpam with ipam_id: " + ipam_id);
                    return;
                }
            } catch (IOException ex) {
                s_logger.error(ex);
                return;
            }
            _ipam = ipam;
        }

        if (_prefix != null) {
            VnSubnetsType subnet = new VnSubnetsType();
            String[] addr_pair = _prefix.split("\\/");
            subnet.addIpamSubnets(new SubnetType(addr_pair[0], Integer.parseInt(addr_pair[1])), _gateway);
            _vn.setNetworkIpam(_ipam, subnet);
        } else if (_trafficType == TrafficType.Public) {
            _vn.clearNetworkIpam();
            /* Subnet information for Public is stored in the vlan table */
            List<VlanVO> vlan_list = vlanDao.listVlansByNetworkId(_id);
            for (VlanVO vlan : vlan_list) {
                String cidr = NetUtils.ipAndNetMaskToCidr(vlan.getVlanGateway(), vlan.getVlanNetmask());
                int slash = cidr.indexOf('/');
                String ip_addr = cidr.substring(0, slash);
                int plen = Integer.parseInt(cidr.substring(slash + 1));
View Full Code Here

Examples of com.cloud.dc.dao.VlanDao

    public boolean verify(ModelController controller) {
        assert _initialized : "initialized is false";
        assert _uuid != null : "uuid is not set";

        ApiConnector api = controller.getApiAccessor();
        VlanDao vlanDao = controller.getVlanDao();

        try {
            _vn = (VirtualNetwork) api.findById(VirtualNetwork.class, _uuid);
        } catch (IOException e) {
            e.printStackTrace();
        }

        if (_vn == null) {
            return false;
        }

        if (!isDynamicNetwork()) {
            return true;
        }
       
        List<String> dbSubnets = new ArrayList<String>();
        if (_trafficType == TrafficType.Public) {
            List<VlanVO> vlan_list = vlanDao.listVlansByNetworkId(_id);
            for (VlanVO vlan:vlan_list) {
                String cidr = NetUtils.ipAndNetMaskToCidr(vlan.getVlanGateway(), vlan.getVlanNetmask());
                dbSubnets.add(vlan.getVlanGateway() + cidr);
            }
        } else {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.