Search in sources :

Example 56 with Vpc

use of com.cloud.legacymodel.network.vpc.Vpc in project cosmic by MissionCriticalCloud.

the class QueryManagerImpl method listWhoHasThisIp.

@Override
public ListResponse<WhoHasThisAddressResponse> listWhoHasThisIp(final ListWhoHasThisIpCmd cmd) {
    final ListResponse<WhoHasThisAddressResponse> whoHasThisIpList = new ListResponse<>();
    final List<WhoHasThisAddressResponse> responsesList = new ArrayList<>();
    final String cleanedIpAddress = StringUtils.deleteWhitespace(cmd.getIpAddress());
    final List<IPAddressVO> ipAddresses = _ipAddressDao.listByIpAddress(cleanedIpAddress);
    ipAddresses.forEach(ipAddress -> {
        final WhoHasThisAddressResponse response = new WhoHasThisAddressResponse();
        response.setObjectName("whohasthisip");
        response.setIpAddress(ipAddress.getAddress().toString());
        response.setUuid(ipAddress.getUuid());
        response.setState(ipAddress.getState().toString());
        final Domain domain = _domainDao.findById(ipAddress.getDomainId());
        if (domain != null) {
            response.setDomainName(domain.getName());
            response.setDomainUuid(domain.getUuid());
        }
        final Network network = _networkDao.findById(ipAddress.getNetworkId());
        if (network != null) {
            response.setNetworkUuid(network.getUuid());
            response.setCreated(ipAddress.getAllocatedTime());
            response.setMode(network.getMode());
        }
        if (ipAddress.getVpcId() != null) {
            final Vpc vpc = _vpcDao.findById(ipAddress.getVpcId());
            if (vpc != null) {
                response.setNetworkName(vpc.getName());
                response.setVpcName(vpc.getName());
                response.setVpcUuid(vpc.getUuid());
            }
        } else if (network != null && !StringUtils.isEmpty(network.getName())) {
            response.setNetworkName(network.getName());
        }
        final Network associatedNetwork = _networkDao.findById(ipAddress.getAssociatedWithNetworkId());
        if (associatedNetwork != null) {
            response.setAssociatedNetworkName(associatedNetwork.getName());
            response.setAssociatedNetworkUuid(associatedNetwork.getUuid());
        }
        responsesList.add(response);
    });
    final List<NicVO> nics = _nicDao.listByIpAddress(cleanedIpAddress);
    nics.forEach(nic -> {
        final WhoHasThisAddressResponse response = new WhoHasThisAddressResponse();
        response.setObjectName("whohasthisip");
        queryNicsTableResponse(responsesList, nic, response);
    });
    final List<NicSecondaryIpVO> nicSecondaryIps = _nicSecondaryIpDao.listByIpAddress(cleanedIpAddress);
    nicSecondaryIps.forEach(nicSecondaryIp -> {
        final WhoHasThisAddressResponse response = new WhoHasThisAddressResponse();
        response.setObjectName("whohasthisip");
        response.setIpAddress(nicSecondaryIp.getIp4Address());
        response.setUuid(nicSecondaryIp.getUuid());
        response.setCreated(nicSecondaryIp.getCreated());
        final NicVO nicVO = _nicDao.findById(nicSecondaryIp.getNicId());
        if (nicVO != null) {
            response.setMode(nicVO.getMode());
            response.setBroadcastUri(nicVO.getBroadcastUri());
            response.setNetmask(nicVO.getIPv4Netmask());
            response.setMacAddress(nicVO.getMacAddress());
            response.setState(nicVO.getState().toString());
        }
        final Network network = _networkDao.findById(nicSecondaryIp.getNetworkId());
        if (network != null) {
            response.setNetworkUuid(network.getUuid());
            if (!StringUtils.isEmpty(network.getName())) {
                response.setNetworkName(network.getName());
            }
        }
        final VMInstanceVO vm = _vmInstanceDao.findById(nicSecondaryIp.getVmId());
        getVMInfo(response, nicVO, vm);
        responsesList.add(response);
    });
    final Account account = CallContext.current().getCallingAccount();
    final Domain domain = _domainDao.findById(account.getDomainId());
    final List<WhoHasThisAddressResponse> filteredResponsesList = responsesList.stream().filter(response -> ((account.getDomainId() == Domain.ROOT_DOMAIN || domain.getUuid().equals(response.getDomainUuid())) && (StringUtils.isEmpty(cmd.getUuid()) || (!StringUtils.isEmpty(cmd.getUuid()) && response.getUuid().equals(cmd.getUuid()))))).skip(cmd.getStartIndex()).limit(cmd.getPageSizeVal()).collect(Collectors.toList());
    whoHasThisIpList.setResponses(filteredResponsesList);
    return whoHasThisIpList;
}
Also used : WhoHasThisAddressResponse(com.cloud.api.response.WhoHasThisAddressResponse) ServiceOfferingJoinVO(com.cloud.api.query.vo.ServiceOfferingJoinVO) ListDiskOfferingsCmd(com.cloud.api.command.user.offering.ListDiskOfferingsCmd) StringUtils(org.apache.commons.lang.StringUtils) HostDao(com.cloud.host.dao.HostDao) ListHostsCmd(com.cloud.api.command.admin.host.ListHostsCmd) HostTagVO(com.cloud.api.query.vo.HostTagVO) ListProjectResourcesCriteria(com.cloud.projects.Project.ListProjectResourcesCriteria) DomainManager(com.cloud.user.DomainManager) PermissionDeniedException(com.cloud.legacymodel.exceptions.PermissionDeniedException) Map(java.util.Map) AllocationState(com.cloud.model.enumeration.AllocationState) UserResponse(com.cloud.api.response.UserResponse) ProjectAccountJoinVO(com.cloud.api.query.vo.ProjectAccountJoinVO) ACLType(com.cloud.legacymodel.acl.ControlledEntity.ACLType) ListUsersCmd(com.cloud.api.command.admin.user.ListUsersCmd) ProjectInvitation(com.cloud.projects.ProjectInvitation) ProjectManager(com.cloud.projects.ProjectManager) ResourceTagVO(com.cloud.tags.ResourceTagVO) Project(com.cloud.projects.Project) ServiceOfferingVO(com.cloud.service.ServiceOfferingVO) ListAccountsCmd(com.cloud.api.command.user.account.ListAccountsCmd) ListVMsCmdByAdmin(com.cloud.api.command.admin.vm.ListVMsCmdByAdmin) ProjectInvitationJoinVO(com.cloud.api.query.vo.ProjectInvitationJoinVO) ManagerBase(com.cloud.utils.component.ManagerBase) TemplateState(com.cloud.engine.subsystem.api.storage.TemplateState) VMTemplateDao(com.cloud.storage.dao.VMTemplateDao) QueryService(com.cloud.query.QueryService) DataCenterJoinVO(com.cloud.api.query.vo.DataCenterJoinVO) ListVMGroupsCmd(com.cloud.api.command.user.vmgroup.ListVMGroupsCmd) ResourceMetaDataService(com.cloud.server.ResourceMetaDataService) AffinityGroupVMMapDao(com.cloud.affinity.dao.AffinityGroupVMMapDao) ImageStoreJoinVO(com.cloud.api.query.vo.ImageStoreJoinVO) SearchCriteria(com.cloud.utils.db.SearchCriteria) DomainRouterVO(com.cloud.vm.DomainRouterVO) DomainRouterJoinDao(com.cloud.api.query.dao.DomainRouterJoinDao) ProjectAccountResponse(com.cloud.api.response.ProjectAccountResponse) ListVMsCmd(com.cloud.api.command.user.vm.ListVMsCmd) ResourceTag(com.cloud.server.ResourceTag) ListTemplatesCmdByAdmin(com.cloud.api.command.admin.template.ListTemplatesCmdByAdmin) HostJoinVO(com.cloud.api.query.vo.HostJoinVO) HAWorkerResponse(com.cloud.api.response.HAWorkerResponse) HighAvailabilityManager(com.cloud.ha.HighAvailabilityManager) ListVolumesCmd(com.cloud.api.command.user.volume.ListVolumesCmd) DomainJoinDao(com.cloud.api.query.dao.DomainJoinDao) UserVmDao(com.cloud.vm.dao.UserVmDao) NicDao(com.cloud.vm.dao.NicDao) ProjectResponse(com.cloud.api.response.ProjectResponse) Volume(com.cloud.legacymodel.storage.Volume) Date(java.util.Date) StorageTagVO(com.cloud.api.query.vo.StorageTagVO) UserVmJoinVO(com.cloud.api.query.vo.UserVmJoinVO) StorageTagResponse(com.cloud.api.response.StorageTagResponse) ManagementServerHost(com.cloud.cluster.ManagementServerHost) ResourceObjectType(com.cloud.server.ResourceTag.ResourceObjectType) DiskOfferingResponse(com.cloud.api.response.DiskOfferingResponse) ListTagsCmd(com.cloud.api.command.user.tag.ListTagsCmd) InstanceGroupJoinVO(com.cloud.api.query.vo.InstanceGroupJoinVO) CloudAuthenticationException(com.cloud.legacymodel.exceptions.CloudAuthenticationException) VMInstanceVO(com.cloud.vm.VMInstanceVO) ListResourceDetailsCmd(com.cloud.api.command.user.volume.ListResourceDetailsCmd) NicVO(com.cloud.vm.NicVO) Collectors(java.util.stream.Collectors) HypervisorType(com.cloud.model.enumeration.HypervisorType) DiskOfferingVO(com.cloud.storage.DiskOfferingVO) DomainResponse(com.cloud.api.response.DomainResponse) ListIsosCmdByAdmin(com.cloud.api.command.admin.iso.ListIsosCmdByAdmin) HaWorkVO(com.cloud.ha.HaWorkVO) DedicatedResourceVO(com.cloud.dc.DedicatedResourceVO) HostTagDao(com.cloud.api.query.dao.HostTagDao) ProjectAccountJoinDao(com.cloud.api.query.dao.ProjectAccountJoinDao) AffinityGroupDomainMapDao(com.cloud.affinity.dao.AffinityGroupDomainMapDao) EventJoinDao(com.cloud.event.dao.EventJoinDao) NetworkDetailsDao(com.cloud.network.dao.NetworkDetailsDao) StoragePoolJoinDao(com.cloud.api.query.dao.StoragePoolJoinDao) TemplateType(com.cloud.legacymodel.storage.TemplateType) Inject(javax.inject.Inject) HashSet(java.util.HashSet) VolumeJoinVO(com.cloud.api.query.vo.VolumeJoinVO) ManagementServerHostDao(com.cloud.cluster.dao.ManagementServerHostDao) ListWhoHasThisMacCmd(com.cloud.api.command.admin.cloudops.ListWhoHasThisMacCmd) AsyncJobJoinVO(com.cloud.api.query.vo.AsyncJobJoinVO) AsyncJobJoinDao(com.cloud.api.query.dao.AsyncJobJoinDao) Ternary(com.cloud.legacymodel.utils.Ternary) IPAddressVO(com.cloud.network.dao.IPAddressVO) ListDomainsCmdByAdmin(com.cloud.api.command.admin.domain.ListDomainsCmdByAdmin) ServiceOfferingResponse(com.cloud.api.response.ServiceOfferingResponse) IPAddressDao(com.cloud.network.dao.IPAddressDao) ListWhoHasThisIpCmd(com.cloud.api.command.admin.cloudops.ListWhoHasThisIpCmd) WhoHasThisAddressResponse(com.cloud.api.response.WhoHasThisAddressResponse) VMTemplateVO(com.cloud.storage.VMTemplateVO) StorageTagDao(com.cloud.api.query.dao.StorageTagDao) Logger(org.slf4j.Logger) Pair(com.cloud.legacymodel.utils.Pair) ListIsosCmd(com.cloud.api.command.user.iso.ListIsosCmd) ListAsyncJobsCmd(com.cloud.api.command.user.job.ListAsyncJobsCmd) ListHAWorkersCmd(com.cloud.api.command.admin.cloudops.ListHAWorkersCmd) NicSecondaryIpVO(com.cloud.vm.dao.NicSecondaryIpVO) ListStorageTagsCmd(com.cloud.api.command.admin.storage.ListStorageTagsCmd) ListSecondaryStagingStoresCmd(com.cloud.api.command.admin.storage.ListSecondaryStagingStoresCmd) ConfigKey(com.cloud.framework.config.ConfigKey) UserVmJoinDao(com.cloud.api.query.dao.UserVmJoinDao) InvalidParameterValueException(com.cloud.legacymodel.exceptions.InvalidParameterValueException) ProjectJoinVO(com.cloud.api.query.vo.ProjectJoinVO) AccountResponse(com.cloud.api.response.AccountResponse) BaseListProjectAndAccountResourcesCmd(com.cloud.api.BaseListProjectAndAccountResourcesCmd) DataStore(com.cloud.engine.subsystem.api.storage.DataStore) ListServiceOfferingsCmd(com.cloud.api.command.user.offering.ListServiceOfferingsCmd) ServiceOfferingDao(com.cloud.service.dao.ServiceOfferingDao) ListTemplatesCmd(com.cloud.api.command.user.template.ListTemplatesCmd) Host(com.cloud.legacymodel.dc.Host) DataStoreDriver(com.cloud.engine.subsystem.api.storage.DataStoreDriver) AsyncJobResponse(com.cloud.api.response.AsyncJobResponse) EventJoinVO(com.cloud.api.query.vo.EventJoinVO) State(com.cloud.legacymodel.storage.VirtualMachineTemplate.State) ResourceManager(com.cloud.resource.ResourceManager) ListAffinityGroupsCmd(com.cloud.api.command.user.affinitygroup.ListAffinityGroupsCmd) HostJoinDao(com.cloud.api.query.dao.HostJoinDao) ProjectJoinDao(com.cloud.api.query.dao.ProjectJoinDao) ScopeType(com.cloud.storage.ScopeType) Set(java.util.Set) StoragePoolJoinVO(com.cloud.api.query.vo.StoragePoolJoinVO) ResponseView(com.cloud.api.ResponseObject.ResponseView) DataStoreCapabilities(com.cloud.engine.subsystem.api.storage.DataStoreCapabilities) DomainJoinVO(com.cloud.api.query.vo.DomainJoinVO) ImageStoreJoinDao(com.cloud.api.query.dao.ImageStoreJoinDao) ServiceOfferingJoinDao(com.cloud.api.query.dao.ServiceOfferingJoinDao) AccountDao(com.cloud.user.dao.AccountDao) StoragePoolResponse(com.cloud.api.response.StoragePoolResponse) ZoneResponse(com.cloud.api.response.ZoneResponse) ResourceDetailResponse(com.cloud.api.response.ResourceDetailResponse) ResourceTagResponse(com.cloud.api.response.ResourceTagResponse) VirtualMachine(com.cloud.legacymodel.vm.VirtualMachine) CallContext(com.cloud.context.CallContext) ListEventsCmd(com.cloud.api.command.user.event.ListEventsCmd) ListProjectsCmd(com.cloud.api.command.user.project.ListProjectsCmd) DiskOfferingJoinDao(com.cloud.api.query.dao.DiskOfferingJoinDao) ArrayList(java.util.ArrayList) AffinityGroupJoinDao(com.cloud.api.query.dao.AffinityGroupJoinDao) ConfigurationDao(com.cloud.framework.config.dao.ConfigurationDao) AccountJoinDao(com.cloud.api.query.dao.AccountJoinDao) VolumeJoinDao(com.cloud.api.query.dao.VolumeJoinDao) ResourceDetail(com.cloud.api.ResourceDetail) VMInstanceDao(com.cloud.vm.dao.VMInstanceDao) DomainRouterDao(com.cloud.vm.dao.DomainRouterDao) ImageStoreResponse(com.cloud.api.response.ImageStoreResponse) Op(com.cloud.utils.db.SearchCriteria.Op) AffinityGroupResponse(com.cloud.affinity.AffinityGroupResponse) ProjectDao(com.cloud.projects.dao.ProjectDao) InstanceGroupJoinDao(com.cloud.api.query.dao.InstanceGroupJoinDao) DiskOfferingJoinVO(com.cloud.api.query.vo.DiskOfferingJoinVO) ListZonesCmdByAdmin(com.cloud.api.command.admin.zone.ListZonesCmdByAdmin) ResourceTagDao(com.cloud.tags.dao.ResourceTagDao) ListResponse(com.cloud.api.response.ListResponse) AffinityGroupDomainMapVO(com.cloud.affinity.AffinityGroupDomainMapVO) AffinityGroupJoinVO(com.cloud.api.query.vo.AffinityGroupJoinVO) EventResponse(com.cloud.api.response.EventResponse) ProjectAccountDao(com.cloud.projects.dao.ProjectAccountDao) InstanceGroupResponse(com.cloud.api.response.InstanceGroupResponse) HostTagResponse(com.cloud.api.response.HostTagResponse) AccountManager(com.cloud.user.AccountManager) DataCenterDetailsDao(com.cloud.dc.dao.DataCenterDetailsDao) NicSecondaryIpDao(com.cloud.vm.dao.NicSecondaryIpDao) ListRoutersCmd(com.cloud.api.command.admin.router.ListRoutersCmd) LoggerFactory(org.slf4j.LoggerFactory) ListAccountsCmdByAdmin(com.cloud.api.command.admin.account.ListAccountsCmdByAdmin) Func(com.cloud.utils.db.SearchCriteria.Func) Filter(com.cloud.utils.db.Filter) UserAccountJoinDao(com.cloud.api.query.dao.UserAccountJoinDao) JoinBuilder(com.cloud.utils.db.JoinBuilder) DataStoreRole(com.cloud.model.enumeration.DataStoreRole) DomainDao(com.cloud.domain.dao.DomainDao) ResourceTagJoinDao(com.cloud.api.query.dao.ResourceTagJoinDao) ProjectInvitationResponse(com.cloud.api.response.ProjectInvitationResponse) TemplateResponse(com.cloud.api.response.TemplateResponse) ListStoragePoolsCmd(com.cloud.api.command.admin.storage.ListStoragePoolsCmd) DedicatedResourceDao(com.cloud.dc.dao.DedicatedResourceDao) DataStoreManager(com.cloud.engine.subsystem.api.storage.DataStoreManager) DataCenterJoinDao(com.cloud.api.query.dao.DataCenterJoinDao) DomainRouterResponse(com.cloud.api.response.DomainRouterResponse) List(java.util.List) ImageFormat(com.cloud.model.enumeration.ImageFormat) TaggedResourceService(com.cloud.server.TaggedResourceService) ListProjectInvitationsCmd(com.cloud.api.command.user.project.ListProjectInvitationsCmd) VolumeResponse(com.cloud.api.response.VolumeResponse) ListDomainsCmd(com.cloud.api.command.admin.domain.ListDomainsCmd) SearchBuilder(com.cloud.utils.db.SearchBuilder) UserAccountJoinVO(com.cloud.api.query.vo.UserAccountJoinVO) Configurable(com.cloud.framework.config.Configurable) NetworkDao(com.cloud.network.dao.NetworkDao) Domain(com.cloud.legacymodel.domain.Domain) HostResponse(com.cloud.api.response.HostResponse) TemplateJoinVO(com.cloud.api.query.vo.TemplateJoinVO) UserVmDetailsDao(com.cloud.vm.dao.UserVmDetailsDao) ListZonesCmd(com.cloud.api.command.user.zone.ListZonesCmd) AffinityGroupVMMapVO(com.cloud.affinity.AffinityGroupVMMapVO) ListProjectAccountsCmd(com.cloud.api.command.user.account.ListProjectAccountsCmd) Network(com.cloud.legacymodel.network.Network) ResourceTagJoinVO(com.cloud.api.query.vo.ResourceTagJoinVO) DomainRouterJoinVO(com.cloud.api.query.vo.DomainRouterJoinVO) ListImageStoresCmd(com.cloud.api.command.admin.storage.ListImageStoresCmd) Account(com.cloud.legacymodel.user.Account) UserVmResponse(com.cloud.api.response.UserVmResponse) DateUtil(com.cloud.utils.DateUtil) TemplateJoinDao(com.cloud.api.query.dao.TemplateJoinDao) UserVmVO(com.cloud.vm.UserVmVO) Component(org.springframework.stereotype.Component) ListHostTagsCmd(com.cloud.api.command.admin.host.ListHostTagsCmd) ListVolumesCmdByAdmin(com.cloud.api.command.admin.volume.ListVolumesCmdByAdmin) ProjectInvitationJoinDao(com.cloud.api.query.dao.ProjectInvitationJoinDao) VpcDao(com.cloud.network.vpc.dao.VpcDao) AccountJoinVO(com.cloud.api.query.vo.AccountJoinVO) DomainVO(com.cloud.domain.DomainVO) Vpc(com.cloud.legacymodel.network.vpc.Vpc) HighAvailabilityDao(com.cloud.ha.dao.HighAvailabilityDao) TemplateFilter(com.cloud.legacymodel.storage.VirtualMachineTemplate.TemplateFilter) Account(com.cloud.legacymodel.user.Account) ListResponse(com.cloud.api.response.ListResponse) ArrayList(java.util.ArrayList) Vpc(com.cloud.legacymodel.network.vpc.Vpc) VMInstanceVO(com.cloud.vm.VMInstanceVO) NicSecondaryIpVO(com.cloud.vm.dao.NicSecondaryIpVO) Network(com.cloud.legacymodel.network.Network) IPAddressVO(com.cloud.network.dao.IPAddressVO) Domain(com.cloud.legacymodel.domain.Domain) NicVO(com.cloud.vm.NicVO)

Example 57 with Vpc

use of com.cloud.legacymodel.network.vpc.Vpc in project cosmic by MissionCriticalCloud.

the class VpcVirtualRouterElement method implement.

@Override
public boolean implement(final Network network, final NetworkOffering offering, final DeployDestination dest, final ReservationContext context) throws ResourceUnavailableException, ConcurrentOperationException, InsufficientCapacityException {
    final Long vpcId = network.getVpcId();
    if (vpcId == null) {
        s_logger.trace("Network " + network + " is not associated with any VPC");
        return false;
    }
    final Vpc vpc = _vpcMgr.getActiveVpc(vpcId);
    if (vpc == null) {
        s_logger.warn("Unable to find Enabled VPC by id " + vpcId);
        return false;
    }
    final Map<VirtualMachineProfile.Param, Object> params = new HashMap<>(1);
    params.put(VirtualMachineProfile.Param.ReProgramGuestNetworks, true);
    final RouterDeploymentDefinition routerDeploymentDefinition = routerDeploymentDefinitionBuilder.create().setGuestNetwork(network).setVpc(vpc).setDeployDestination(dest).setAccountOwner(_accountMgr.getAccount(vpc.getAccountId())).setParams(params).build();
    final List<DomainRouterVO> routers = routerDeploymentDefinition.deployVirtualRouter();
    if (routers == null || routers.size() == 0) {
        throw new ResourceUnavailableException("Can't find at least one running router!", DataCenter.class, network.getDataCenterId());
    }
    configureGuestNetwork(network, routers);
    return true;
}
Also used : RouterDeploymentDefinition(com.cloud.network.router.deployment.RouterDeploymentDefinition) HashMap(java.util.HashMap) Vpc(com.cloud.legacymodel.network.vpc.Vpc) ResourceUnavailableException(com.cloud.legacymodel.exceptions.ResourceUnavailableException) DomainRouterVO(com.cloud.vm.DomainRouterVO)

Example 58 with Vpc

use of com.cloud.legacymodel.network.vpc.Vpc in project cosmic by MissionCriticalCloud.

the class VpcVirtualRouterElement method prepare.

@Override
public boolean prepare(final Network network, final NicProfile nic, final VirtualMachineProfile vm, final DeployDestination dest, final ReservationContext context) throws ConcurrentOperationException, InsufficientCapacityException, ResourceUnavailableException, IllegalVirtualMachineException {
    final Long vpcId = network.getVpcId();
    if (vpcId == null) {
        s_logger.trace("Network " + network + " is not associated with any VPC");
        return false;
    }
    final Vpc vpc = _vpcMgr.getActiveVpc(vpcId);
    if (vpc == null) {
        s_logger.warn("Unable to find Enabled VPC by id " + vpcId);
        return false;
    }
    if (vm.getType() == VirtualMachineType.User) {
        final Map<VirtualMachineProfile.Param, Object> params = new HashMap<>(1);
        params.put(VirtualMachineProfile.Param.ReProgramGuestNetworks, true);
        final RouterDeploymentDefinition routerDeploymentDefinition = routerDeploymentDefinitionBuilder.create().setGuestNetwork(network).setVpc(vpc).setDeployDestination(dest).setAccountOwner(_accountMgr.getAccount(vpc.getAccountId())).setParams(params).build();
        final List<DomainRouterVO> routers = routerDeploymentDefinition.deployVirtualRouter();
        if (routers == null || routers.size() == 0) {
            throw new ResourceUnavailableException("Can't find at least one running router!", DataCenter.class, network.getDataCenterId());
        }
        configureGuestNetwork(network, routers);
    }
    return true;
}
Also used : RouterDeploymentDefinition(com.cloud.network.router.deployment.RouterDeploymentDefinition) HashMap(java.util.HashMap) Vpc(com.cloud.legacymodel.network.vpc.Vpc) ResourceUnavailableException(com.cloud.legacymodel.exceptions.ResourceUnavailableException) DomainRouterVO(com.cloud.vm.DomainRouterVO)

Example 59 with Vpc

use of com.cloud.legacymodel.network.vpc.Vpc in project cosmic by MissionCriticalCloud.

the class VpcVirtualRouterElement method applyVpnUsers.

@Override
public String[] applyVpnUsers(final RemoteAccessVpn vpn, final List<? extends VpnUser> users) throws ResourceUnavailableException {
    final Long vpcId = vpn.getVpcId();
    if (vpcId == null) {
        return null;
    }
    final List<DomainRouterVO> routers = _vpcRouterMgr.getVpcRouters(vpcId);
    if (routers == null) {
        s_logger.debug("Cannot apply vpn users on the backend; virtual router doesn't exist in the network " + vpcId);
        return null;
    }
    final Vpc vpc = _entityMgr.findById(Vpc.class, vpcId);
    final Zone zone = zoneRepository.findById(vpc.getZoneId()).orElse(null);
    final NetworkTopology networkTopology = networkTopologyContext.retrieveNetworkTopology(zone);
    String[] result;
    final List<String> combinedResults = new ArrayList<>();
    for (final DomainRouterVO domainRouterVO : routers) {
        result = networkTopology.applyVpnUsers(vpn, users, domainRouterVO);
        combinedResults.addAll(Arrays.asList(result));
    }
    result = new String[combinedResults.size()];
    final Object[] resultCast = combinedResults.toArray();
    System.arraycopy(resultCast, 0, result, 0, resultCast.length);
    return result;
}
Also used : Zone(com.cloud.db.model.Zone) NetworkTopology(com.cloud.network.topology.NetworkTopology) Vpc(com.cloud.legacymodel.network.vpc.Vpc) ArrayList(java.util.ArrayList) DomainRouterVO(com.cloud.vm.DomainRouterVO)

Example 60 with Vpc

use of com.cloud.legacymodel.network.vpc.Vpc in project cosmic by MissionCriticalCloud.

the class VpcVirtualRouterElement method startSite2SiteVpn.

@Override
public boolean startSite2SiteVpn(final Site2SiteVpnConnection conn) throws ResourceUnavailableException {
    final Site2SiteVpnGateway vpnGw = _vpnGatewayDao.findById(conn.getVpnGatewayId());
    final IpAddress ip = _ipAddressDao.findById(vpnGw.getAddrId());
    final Map<Capability, String> vpnCapabilities = capabilities.get(Service.Vpn);
    if (!vpnCapabilities.get(Capability.VpnTypes).contains("s2svpn")) {
        s_logger.error("try to start site 2 site vpn on unsupported network element?");
        return false;
    }
    final Long vpcId = ip.getVpcId();
    final Vpc vpc = _entityMgr.findById(Vpc.class, vpcId);
    if (!_ntwkModel.isProviderEnabledInZone(vpc.getZoneId(), Provider.VPCVirtualRouter.getName())) {
        throw new ResourceUnavailableException("VPC provider is not enabled in zone " + vpc.getZoneId(), DataCenter.class, vpc.getZoneId());
    }
    final List<DomainRouterVO> routers = _vpcRouterMgr.getVpcRouters(ip.getVpcId());
    if (routers == null) {
        throw new ResourceUnavailableException("Cannot enable site-to-site VPN on the backend; virtual router doesn't exist in the vpc " + ip.getVpcId(), DataCenter.class, vpc.getZoneId());
    }
    boolean result = true;
    for (final DomainRouterVO domainRouterVO : routers) {
        result = result && _vpcRouterMgr.startSite2SiteVpn(conn, domainRouterVO);
    }
    return result;
}
Also used : Site2SiteVpnGateway(com.cloud.network.Site2SiteVpnGateway) Capability(com.cloud.legacymodel.network.Network.Capability) Vpc(com.cloud.legacymodel.network.vpc.Vpc) ResourceUnavailableException(com.cloud.legacymodel.exceptions.ResourceUnavailableException) IpAddress(com.cloud.network.IpAddress) PublicIpAddress(com.cloud.network.PublicIpAddress) DomainRouterVO(com.cloud.vm.DomainRouterVO)

Aggregations

Vpc (com.cloud.legacymodel.network.vpc.Vpc)60 InvalidParameterValueException (com.cloud.legacymodel.exceptions.InvalidParameterValueException)24 Account (com.cloud.legacymodel.user.Account)24 ResourceUnavailableException (com.cloud.legacymodel.exceptions.ResourceUnavailableException)17 DomainRouterVO (com.cloud.vm.DomainRouterVO)17 Network (com.cloud.legacymodel.network.Network)15 ArrayList (java.util.ArrayList)14 NetworkACL (com.cloud.legacymodel.network.vpc.NetworkACL)11 ActionEvent (com.cloud.event.ActionEvent)9 ConcurrentOperationException (com.cloud.legacymodel.exceptions.ConcurrentOperationException)9 CloudRuntimeException (com.cloud.legacymodel.exceptions.CloudRuntimeException)8 NetworkVO (com.cloud.network.dao.NetworkVO)8 List (java.util.List)8 ServerApiException (com.cloud.api.ServerApiException)7 InsufficientCapacityException (com.cloud.legacymodel.exceptions.InsufficientCapacityException)7 IPAddressVO (com.cloud.network.dao.IPAddressVO)7 DB (com.cloud.utils.db.DB)7 VpcResponse (com.cloud.api.response.VpcResponse)6 CallContext (com.cloud.context.CallContext)6 DataCenter (com.cloud.legacymodel.dc.DataCenter)6