@Override public String getEventDescription() { return "Create site-to-site VPN connection for account " + getEntityOwnerId(); }
@Override public Long getSyncObjId() { Site2SiteVpnGateway vpnGw = getVpnGateway(); if (vpnGw != null) { return vpnGw.getVpcId(); } return null; }
public Site2SiteVpnConnection createVpnConnection(CreateVpnConnectionCmd cmd) throws NetworkRuleConflictException { Account caller = CallContext.current().getCallingAccount(); Account owner = _accountMgr.getAccount(cmd.getEntityOwnerId()); Long customerGatewayId = cmd.getCustomerGatewayId(); Site2SiteCustomerGateway customerGateway = _customerGatewayDao.findById(customerGatewayId); if (customerGateway == null) { Long vpnGatewayId = cmd.getVpnGatewayId(); Site2SiteVpnGateway vpnGateway = _vpnGatewayDao.findById(vpnGatewayId); if (vpnGateway == null) { Site2SiteVpnConnectionVO conn = new Site2SiteVpnConnectionVO(owner.getAccountId(), owner.getDomainId(), vpnGatewayId, customerGatewayId, cmd.isPassive()); conn.setState(State.Pending); if (cmd.getDisplay() != null) { conn.setDisplay(cmd.getDisplay());
@Override public void execute() { try { Site2SiteVpnConnection result = _s2sVpnService.startVpnConnection(getEntityId()); if (result != null) { Site2SiteVpnConnectionResponse response = _responseGenerator.createSite2SiteVpnConnectionResponse(result); response.setResponseName(getCommandName()); setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create site to site vpn connection"); } } catch (ResourceUnavailableException ex) { s_logger.warn("Exception: ", ex); throw new ServerApiException(ApiErrorCode.RESOURCE_UNAVAILABLE_ERROR, ex.getMessage()); } }
@Override public void create() { try { Site2SiteVpnConnection conn = _s2sVpnService.createVpnConnection(this); if (conn != null) { setEntityId(conn.getId()); setEntityUuid(conn.getUuid()); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create site to site vpn connection"); } } catch (NetworkRuleConflictException e) { s_logger.info("Network rule conflict: " + e.getMessage()); s_logger.trace("Network Rule Conflict: ", e); throw new ServerApiException(ApiErrorCode.NETWORK_RULE_CONFLICT_ERROR, e.getMessage()); } }
@Override public long getEntityOwnerId() { Site2SiteVpnGateway vpnGw = getVpnGateway(); if (vpnGw != null) { Vpc vpc = _entityMgr.findById(Vpc.class, getVpnGateway().getVpcId()); return vpc.getAccountId(); } return -1; }