Package com.cloud.network

Examples of com.cloud.network.Site2SiteCustomerGatewayVO


        }
       
        response.setCustomerGatewayId(result.getCustomerGatewayId());
        Long customerGatewayId = result.getCustomerGatewayId();
        if(customerGatewayId != null) {
          Site2SiteCustomerGatewayVO customerGateway = ApiDBUtils.findCustomerGatewayById(customerGatewayId);
          response.setGatewayIp(customerGateway.getGatewayIp());
          response.setGuestCidrList(customerGateway.getGuestCidrList());
          response.setIpsecPsk(customerGateway.getIpsecPsk());
          response.setIkePolicy(customerGateway.getIkePolicy());
          response.setEspPolicy(customerGateway.getEspPolicy());
                response.setIkeLifetime(customerGateway.getIkeLifetime());
                response.setEspLifetime(customerGateway.getEspLifetime());
                response.setDpd(customerGateway.getDpd());
        }     
               
        populateAccount(response, result.getAccountId());
        populateDomain(response, result.getDomainId());
       
View Full Code Here


        createSite2SiteVpnCfgCommands(conn, isCreate, router, cmds);
        return sendCommandsToRouter(router, cmds);
    }

    private void createSite2SiteVpnCfgCommands(Site2SiteVpnConnection conn, boolean isCreate, VirtualRouter router, Commands cmds) {
        Site2SiteCustomerGatewayVO gw = _s2sCustomerGatewayDao.findById(conn.getCustomerGatewayId());
        Site2SiteVpnGatewayVO vpnGw = _s2sVpnGatewayDao.findById(conn.getVpnGatewayId());
        IpAddress ip = _ipAddressDao.findById(vpnGw.getAddrId());
        Vpc vpc = _vpcDao.findById(ip.getVpcId());
        String localPublicIp = ip.getAddress().toString();
        String localGuestCidr = vpc.getCidr();
        String localPublicGateway = _vlanDao.findById(ip.getVlanId()).getVlanGateway();
        String peerGatewayIp = gw.getGatewayIp();
        String peerGuestCidrList = gw.getGuestCidrList();
        String ipsecPsk = gw.getIpsecPsk();
        String ikePolicy = gw.getIkePolicy();
        String espPolicy = gw.getEspPolicy();
        Long ikeLifetime = gw.getIkeLifetime();
        Long espLifetime = gw.getEspLifetime();
        Boolean dpd = gw.getDpd();

        Site2SiteVpnCfgCommand cmd = new Site2SiteVpnCfgCommand(isCreate, localPublicIp, localPublicGateway, localGuestCidr,
                peerGatewayIp, peerGuestCidrList, ikePolicy, espPolicy, ipsecPsk, ikeLifetime, espLifetime, dpd);
        cmd.setAccessDetail(NetworkElementCommand.ROUTER_IP, getRouterControlIp(router.getId()));
        cmd.setAccessDetail(NetworkElementCommand.ROUTER_IP, getRouterControlIp(router.getId()));
View Full Code Here

            throw new InvalidParameterValueException("The customer gateway with name " + name + " already existed!");
        }
       
        checkCustomerGatewayCidrList(guestCidrList);
       
        Site2SiteCustomerGatewayVO gw = new Site2SiteCustomerGatewayVO(name, accountId, owner.getDomainId(), gatewayIp, guestCidrList, ipsecPsk,
                ikePolicy, espPolicy, ikeLifetime, espLifetime, dpd);
        _customerGatewayDao.persist(gw);
        return gw;
    }
View Full Code Here

        }
        for (Site2SiteVpnConnectionVO vc : conns) {
            if (vc == null) {
                continue;
            }
            Site2SiteCustomerGatewayVO gw = _customerGatewayDao.findById(vc.getCustomerGatewayId());
            String[] oldCidrList = gw.getGuestCidrList().split(",");
            for (String oldCidr : oldCidrList) {
                for (String cidr : cidrList) {
                    if (NetUtils.isNetworksOverlap(cidr, oldCidr)) {
                        throw new InvalidParameterValueException("The new connection's remote subnet " + cidr + " is overlapped with existed VPN connection to customer gateway "
                                + gw.getName() + "'s subnet " + oldCidr);
                    }
                }
            }
        }
View Full Code Here

    public Site2SiteCustomerGateway updateCustomerGateway(UpdateVpnCustomerGatewayCmd cmd) {
        UserContext.current().setEventDetails(" Id: " + cmd.getId());
        Account caller = UserContext.current().getCaller();

        Long id = cmd.getId();
        Site2SiteCustomerGatewayVO gw = _customerGatewayDao.findById(id);
        if (gw == null) {
            throw new InvalidParameterValueException("Find to find customer gateway with id " + id);
        }
        _accountMgr.checkAccess(caller, null, false, gw);

        List<Site2SiteVpnConnectionVO> conns = _vpnConnectionDao.listByCustomerGatewayId(id);
        if (conns != null) {
            for (Site2SiteVpnConnection conn : conns) {
                if (conn.getState() != State.Error) {
                    throw new InvalidParameterValueException("Unable to update customer gateway with connections in non-Error state!");
                }
            }
        }
        String name = cmd.getName();
        String gatewayIp = cmd.getGatewayIp();
        if (!NetUtils.isValidIp(gatewayIp)) {
            throw new InvalidParameterValueException("The customer gateway ip " + gatewayIp + " is invalid!");
        }
        if (name == null) {
            name = "VPN-" + gatewayIp;
        }
        String guestCidrList = cmd.getGuestCidrList();
        if (!NetUtils.validateGuestCidrList(guestCidrList)) {
            throw new InvalidParameterValueException("The customer gateway guest cidr list " + guestCidrList + " contains invalid guest cidr!");
        }
        String ipsecPsk = cmd.getIpsecPsk();
        String ikePolicy = cmd.getIkePolicy();
        String espPolicy = cmd.getEspPolicy();
        if (!NetUtils.isValidS2SVpnPolicy(ikePolicy)) {
            throw new InvalidParameterValueException("The customer gateway IKE policy" + ikePolicy + " is invalid!");
        }
        if (!NetUtils.isValidS2SVpnPolicy(espPolicy)) {
            throw new InvalidParameterValueException("The customer gateway ESP policy" + espPolicy + " is invalid!");
        }
        Long ikeLifetime = cmd.getIkeLifetime();
        if (ikeLifetime == null) {
            // Default value of lifetime is 1 day
            ikeLifetime = (long) 86400;
        }
        if (ikeLifetime > 86400) {
            throw new InvalidParameterValueException("The IKE lifetime " + ikeLifetime + " of vpn connection is invalid!");
        }
        Long espLifetime = cmd.getEspLifetime();
        if (espLifetime == null) {
            // Default value of lifetime is 1 hour
            espLifetime = (long) 3600;
        }
        if (espLifetime > 86400) {
            throw new InvalidParameterValueException("The ESP lifetime " + espLifetime + " of vpn connection is invalid!");
        }

        Boolean dpd = cmd.getDpd();
        if (dpd == null) {
            dpd = false;
        }

        checkCustomerGatewayCidrList(guestCidrList);

        long accountId = gw.getAccountId();
        Site2SiteCustomerGatewayVO existedGw = _customerGatewayDao.findByGatewayIp(gatewayIp);
        if (existedGw != null && existedGw.getId() != gw.getId()) {
            throw new InvalidParameterValueException("The customer gateway with ip " + gatewayIp + " already existed in the system!");
        }
        existedGw = _customerGatewayDao.findByNameAndAccountId(name, accountId);
        if (existedGw != null && existedGw.getId() != gw.getId()) {
            throw new InvalidParameterValueException("The customer gateway with name " + name + " already existed!");
        }

        gw.setName(name);
        gw.setGatewayIp(gatewayIp);
View Full Code Here

            }
            if (conn.getState() == Site2SiteVpnConnection.State.Disconnected) {
                try {
                    startVpnConnection(conn.getId());
                } catch (ResourceUnavailableException e) {
                    Site2SiteCustomerGatewayVO gw = _customerGatewayDao.findById(conn.getCustomerGatewayId());
                    s_logger.warn("Site2SiteVpnManager: Fail to re-initiate VPN connection " + conn.getId() + " which connect to " + gw.getName());
                }
            }
        }
    }
View Full Code Here

TOP

Related Classes of com.cloud.network.Site2SiteCustomerGatewayVO

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.