protected ProjectAccountDaoImpl() {
    AllFieldsSearch = createSearchBuilder();
    AllFieldsSearch.and("role", AllFieldsSearch.entity().getAccountRole(), SearchCriteria.Op.EQ);
    AllFieldsSearch.and("projectId", AllFieldsSearch.entity().getProjectId(), SearchCriteria.Op.EQ);
    AllFieldsSearch.and("accountId", AllFieldsSearch.entity().getAccountId(), SearchCriteria.Op.EQ);
    AllFieldsSearch.and(
        "projectAccountId", AllFieldsSearch.entity().getProjectAccountId(), SearchCriteria.Op.EQ);
    AllFieldsSearch.done();

    AdminSearch = createSearchBuilder(Long.class);
    AdminSearch.selectFields(AdminSearch.entity().getProjectId());
    AdminSearch.and("role", AdminSearch.entity().getAccountRole(), Op.EQ);
    AdminSearch.and("accountId", AdminSearch.entity().getAccountId(), Op.EQ);
    AdminSearch.done();

    ProjectAccountSearch = createSearchBuilder(Long.class);
    ProjectAccountSearch.selectFields(ProjectAccountSearch.entity().getProjectAccountId());
    ProjectAccountSearch.and("accountId", ProjectAccountSearch.entity().getAccountId(), Op.EQ);
    ProjectAccountSearch.done();

    CountByRoleSearch = createSearchBuilder(Long.class);
    CountByRoleSearch.select(null, Func.COUNT, CountByRoleSearch.entity().getId());
    CountByRoleSearch.and("accountId", CountByRoleSearch.entity().getAccountId(), Op.EQ);
    CountByRoleSearch.and("role", CountByRoleSearch.entity().getAccountRole(), Op.EQ);
    CountByRoleSearch.done();
  }
  protected SecurityGroupVMMapDaoImpl() {
    ListByIpAndVmId = createSearchBuilder();
    ListByIpAndVmId.and(
        "ipAddress", ListByIpAndVmId.entity().getGuestIpAddress(), SearchCriteria.Op.EQ);
    ListByIpAndVmId.and(
        "instanceId", ListByIpAndVmId.entity().getInstanceId(), SearchCriteria.Op.EQ);
    ListByIpAndVmId.done();

    ListVmIdBySecurityGroup = createSearchBuilder(Long.class);
    ListVmIdBySecurityGroup.and(
        "securityGroupId",
        ListVmIdBySecurityGroup.entity().getSecurityGroupId(),
        SearchCriteria.Op.EQ);
    ListVmIdBySecurityGroup.selectFields(ListVmIdBySecurityGroup.entity().getInstanceId());
    ListVmIdBySecurityGroup.done();

    ListBySecurityGroup = createSearchBuilder();
    ListBySecurityGroup.and(
        "securityGroupId", ListBySecurityGroup.entity().getSecurityGroupId(), SearchCriteria.Op.EQ);
    ListBySecurityGroup.done();

    ListByIp = createSearchBuilder();
    ListByIp.and("ipAddress", ListByIp.entity().getGuestIpAddress(), SearchCriteria.Op.EQ);
    ListByIp.done();

    ListByVmId = createSearchBuilder();
    ListByVmId.and("instanceId", ListByVmId.entity().getInstanceId(), SearchCriteria.Op.EQ);
    ListByVmId.done();

    ListBySecurityGroupAndStates = createSearchBuilder();
    ListBySecurityGroupAndStates.and(
        "securityGroupId",
        ListBySecurityGroupAndStates.entity().getSecurityGroupId(),
        SearchCriteria.Op.EQ);
    ListBySecurityGroupAndStates.and(
        "states", ListBySecurityGroupAndStates.entity().getVmState(), SearchCriteria.Op.IN);
    ListBySecurityGroupAndStates.done();

    ListByVmIdGroupId = createSearchBuilder();
    ListByVmIdGroupId.and(
        "instanceId", ListByVmIdGroupId.entity().getInstanceId(), SearchCriteria.Op.EQ);
    ListByVmIdGroupId.and(
        "securityGroupId", ListByVmIdGroupId.entity().getSecurityGroupId(), SearchCriteria.Op.EQ);
    ListByVmIdGroupId.done();

    CountSGForVm = createSearchBuilder(Long.class);
    CountSGForVm.select(null, Func.COUNT, null);
    CountSGForVm.and("vmId", CountSGForVm.entity().getInstanceId(), SearchCriteria.Op.EQ);
    CountSGForVm.done();
  }
  protected VpcServiceMapDaoImpl() {
    super();
    AllFieldsSearch = createSearchBuilder();
    AllFieldsSearch.and("vpcId", AllFieldsSearch.entity().getVpcId(), SearchCriteria.Op.EQ);
    AllFieldsSearch.and("service", AllFieldsSearch.entity().getService(), SearchCriteria.Op.EQ);
    AllFieldsSearch.and("provider", AllFieldsSearch.entity().getProvider(), SearchCriteria.Op.EQ);
    AllFieldsSearch.done();

    MultipleServicesSearch = createSearchBuilder();
    MultipleServicesSearch.and(
        "vpcId", MultipleServicesSearch.entity().getVpcId(), SearchCriteria.Op.EQ);
    MultipleServicesSearch.and(
        "service", MultipleServicesSearch.entity().getService(), SearchCriteria.Op.IN);
    MultipleServicesSearch.and(
        "provider", MultipleServicesSearch.entity().getProvider(), SearchCriteria.Op.EQ);
    MultipleServicesSearch.done();

    DistinctProvidersSearch = createSearchBuilder(String.class);
    DistinctProvidersSearch.and(
        "vpcId", DistinctProvidersSearch.entity().getVpcId(), SearchCriteria.Op.EQ);
    DistinctProvidersSearch.and(
        "provider", DistinctProvidersSearch.entity().getProvider(), SearchCriteria.Op.EQ);
    DistinctProvidersSearch.selectFields(DistinctProvidersSearch.entity().getProvider());
    DistinctProvidersSearch.done();
  }
  protected HypervisorCapabilitiesDaoImpl() {
    HypervisorTypeSearch = createSearchBuilder();
    HypervisorTypeSearch.and(
        "hypervisorType", HypervisorTypeSearch.entity().getHypervisorType(), SearchCriteria.Op.EQ);
    HypervisorTypeSearch.done();

    HypervisorTypeAndVersionSearch = createSearchBuilder();
    HypervisorTypeAndVersionSearch.and(
        "hypervisorType",
        HypervisorTypeAndVersionSearch.entity().getHypervisorType(),
        SearchCriteria.Op.EQ);
    HypervisorTypeAndVersionSearch.and(
        "hypervisorVersion",
        HypervisorTypeAndVersionSearch.entity().getHypervisorVersion(),
        SearchCriteria.Op.EQ);
    HypervisorTypeAndVersionSearch.done();

    MaxGuestLimitByHypervisorSearch = createSearchBuilder(Long.class);
    MaxGuestLimitByHypervisorSearch.selectField(
        MaxGuestLimitByHypervisorSearch.entity().getMaxGuestsLimit());
    MaxGuestLimitByHypervisorSearch.and(
        "hypervisorType",
        MaxGuestLimitByHypervisorSearch.entity().getHypervisorType(),
        SearchCriteria.Op.EQ);
    MaxGuestLimitByHypervisorSearch.and(
        "hypervisorVersion",
        MaxGuestLimitByHypervisorSearch.entity().getHypervisorVersion(),
        SearchCriteria.Op.EQ);
    MaxGuestLimitByHypervisorSearch.done();
  }
  protected StorageNetworkIpAddressDaoImpl() {
    countInUserIp = createSearchBuilder(Long.class);
    countInUserIp.select(null, Func.COUNT, null);
    countInUserIp.and("rangeId", countInUserIp.entity().getRangeId(), Op.EQ);
    countInUserIp.and("taken", countInUserIp.entity().getTakenAt(), Op.NNULL);
    countInUserIp.done();

    listInUseIp = createSearchBuilder(String.class);
    listInUseIp.selectField(listInUseIp.entity().getIpAddress());
    listInUseIp.and("rangeId", listInUseIp.entity().getRangeId(), Op.EQ);
    listInUseIp.and("taken", listInUseIp.entity().getTakenAt(), Op.NNULL);
    listInUseIp.done();

    untakenIp = createSearchBuilder();
    untakenIp.and("rangeId", untakenIp.entity().getRangeId(), Op.EQ);
    untakenIp.and("taken", untakenIp.entity().getTakenAt(), Op.NULL);
    untakenIp.done();

    ipSearch = createSearchBuilder();
    ipSearch.and("ipAddress", ipSearch.entity().getIpAddress(), Op.EQ);
    ipSearch.done();
  }
Пример #6
0
  protected StoragePoolDaoImpl() {
    AllFieldSearch = createSearchBuilder();
    AllFieldSearch.and("name", AllFieldSearch.entity().getName(), SearchCriteria.Op.EQ);
    AllFieldSearch.and("uuid", AllFieldSearch.entity().getUuid(), SearchCriteria.Op.EQ);
    AllFieldSearch.and(
        "datacenterId", AllFieldSearch.entity().getDataCenterId(), SearchCriteria.Op.EQ);
    AllFieldSearch.and(
        "hostAddress", AllFieldSearch.entity().getHostAddress(), SearchCriteria.Op.EQ);
    AllFieldSearch.and("status", AllFieldSearch.entity().getStatus(), SearchCriteria.Op.EQ);
    AllFieldSearch.and("path", AllFieldSearch.entity().getPath(), SearchCriteria.Op.EQ);
    AllFieldSearch.and("podId", AllFieldSearch.entity().getPodId(), Op.EQ);
    AllFieldSearch.done();

    DcPodSearch = createSearchBuilder();
    DcPodSearch.and("datacenterId", DcPodSearch.entity().getDataCenterId(), SearchCriteria.Op.EQ);
    DcPodSearch.and().op("nullpod", DcPodSearch.entity().getPodId(), SearchCriteria.Op.NULL);
    DcPodSearch.or("podId", DcPodSearch.entity().getPodId(), SearchCriteria.Op.EQ);
    DcPodSearch.cp();
    DcPodSearch.and()
        .op("nullcluster", DcPodSearch.entity().getClusterId(), SearchCriteria.Op.NULL);
    DcPodSearch.or("cluster", DcPodSearch.entity().getClusterId(), SearchCriteria.Op.EQ);
    DcPodSearch.cp();
    DcPodSearch.done();

    DcPodAnyClusterSearch = createSearchBuilder();
    DcPodAnyClusterSearch.and(
        "datacenterId", DcPodAnyClusterSearch.entity().getDataCenterId(), SearchCriteria.Op.EQ);
    DcPodAnyClusterSearch.and()
        .op("nullpod", DcPodAnyClusterSearch.entity().getPodId(), SearchCriteria.Op.NULL);
    DcPodAnyClusterSearch.or(
        "podId", DcPodAnyClusterSearch.entity().getPodId(), SearchCriteria.Op.EQ);
    DcPodAnyClusterSearch.cp();
    DcPodAnyClusterSearch.done();

    DeleteLvmSearch = createSearchBuilder();
    DeleteLvmSearch.and("ids", DeleteLvmSearch.entity().getId(), SearchCriteria.Op.IN);
    DeleteLvmSearch.and().op("LVM", DeleteLvmSearch.entity().getPoolType(), SearchCriteria.Op.EQ);
    DeleteLvmSearch.or("Filesystem", DeleteLvmSearch.entity().getPoolType(), SearchCriteria.Op.EQ);
    DeleteLvmSearch.cp();
    DeleteLvmSearch.done();

    StatusCountSearch = createSearchBuilder(Long.class);
    StatusCountSearch.and("status", StatusCountSearch.entity().getStatus(), SearchCriteria.Op.IN);
    StatusCountSearch.select(null, Func.COUNT, null);
    StatusCountSearch.done();

    _detailsDao = ComponentLocator.inject(StoragePoolDetailsDaoImpl.class);
  }
Пример #7
0
  protected NicIpAliasDaoImpl() {
    super();
    AllFieldsSearch = createSearchBuilder();
    AllFieldsSearch.and("instanceId", AllFieldsSearch.entity().getVmId(), Op.EQ);
    AllFieldsSearch.and("network", AllFieldsSearch.entity().getNetworkId(), Op.EQ);
    AllFieldsSearch.and("address", AllFieldsSearch.entity().getIp4Address(), Op.EQ);
    AllFieldsSearch.and("nicId", AllFieldsSearch.entity().getNicId(), Op.EQ);
    AllFieldsSearch.and("gateway", AllFieldsSearch.entity().getGateway(), Op.EQ);
    AllFieldsSearch.and("state", AllFieldsSearch.entity().getState(), Op.EQ);
    AllFieldsSearch.done();

    IpSearch = createSearchBuilder(String.class);
    IpSearch.select(null, Func.DISTINCT, IpSearch.entity().getIp4Address());
    IpSearch.and("network", IpSearch.entity().getNetworkId(), Op.EQ);
    IpSearch.and("address", IpSearch.entity().getIp4Address(), Op.NNULL);
    IpSearch.done();
  }
  protected StaticRouteDaoImpl() {
    super();

    AllFieldsSearch = createSearchBuilder();
    AllFieldsSearch.and("gatewayId", AllFieldsSearch.entity().getVpcGatewayId(), Op.EQ);
    AllFieldsSearch.and("vpcId", AllFieldsSearch.entity().getVpcId(), Op.EQ);
    AllFieldsSearch.and("state", AllFieldsSearch.entity().getState(), Op.EQ);
    AllFieldsSearch.and("id", AllFieldsSearch.entity().getId(), Op.EQ);
    AllFieldsSearch.done();

    NotRevokedSearch = createSearchBuilder();
    NotRevokedSearch.and("gatewayId", NotRevokedSearch.entity().getVpcGatewayId(), Op.EQ);
    NotRevokedSearch.and("state", NotRevokedSearch.entity().getState(), Op.NEQ);
    NotRevokedSearch.done();

    RoutesByGatewayCount = createSearchBuilder(Long.class);
    RoutesByGatewayCount.select(null, Func.COUNT, RoutesByGatewayCount.entity().getId());
    RoutesByGatewayCount.and("gatewayId", RoutesByGatewayCount.entity().getVpcGatewayId(), Op.EQ);
    RoutesByGatewayCount.done();
  }
Пример #9
0
  @SuppressWarnings("unchecked")
  @Override
  public List<IAMPolicy> listIAMPolicies(long accountId) {

    // static policies of the account
    SearchBuilder<IAMGroupAccountMapVO> groupSB = _aclGroupAccountMapDao.createSearchBuilder();
    groupSB.and("account", groupSB.entity().getAccountId(), Op.EQ);

    GenericSearchBuilder<IAMGroupPolicyMapVO, Long> policySB =
        _aclGroupPolicyMapDao.createSearchBuilder(Long.class);
    policySB.selectFields(policySB.entity().getAclPolicyId());
    policySB.join(
        "accountgroupjoin",
        groupSB,
        groupSB.entity().getAclGroupId(),
        policySB.entity().getAclGroupId(),
        JoinType.INNER);
    policySB.done();
    SearchCriteria<Long> policySc = policySB.create();
    policySc.setJoinParameters("accountgroupjoin", "account", accountId);

    List<Long> policyIds = _aclGroupPolicyMapDao.customSearch(policySc, null);
    // add policies directly attached to the account
    List<IAMAccountPolicyMapVO> acctPolicies = _aclAccountPolicyMapDao.listByAccountId(accountId);
    for (IAMAccountPolicyMapVO p : acctPolicies) {
      policyIds.add(p.getIamPolicyId());
    }
    if (policyIds.size() == 0) {
      return new ArrayList<IAMPolicy>();
    }
    SearchBuilder<IAMPolicyVO> sb = _aclPolicyDao.createSearchBuilder();
    sb.and("ids", sb.entity().getId(), Op.IN);
    SearchCriteria<IAMPolicyVO> sc = sb.create();
    sc.setParameters("ids", policyIds.toArray(new Object[policyIds.size()]));
    @SuppressWarnings("rawtypes")
    List policies = _aclPolicyDao.customSearch(sc, null);

    return policies;
  }
Пример #10
0
  @PostConstruct
  protected void init() {
    VolumeIdSearch = createSearchBuilder();
    VolumeIdSearch.and("volumeId", VolumeIdSearch.entity().getVolumeId(), SearchCriteria.Op.EQ);
    VolumeIdSearch.done();

    VolumeIdTypeSearch = createSearchBuilder();
    VolumeIdTypeSearch.and(
        "volumeId", VolumeIdTypeSearch.entity().getVolumeId(), SearchCriteria.Op.EQ);
    VolumeIdTypeSearch.and(
        "type", VolumeIdTypeSearch.entity().getsnapshotType(), SearchCriteria.Op.EQ);
    VolumeIdTypeSearch.done();

    VolumeIdVersionSearch = createSearchBuilder();
    VolumeIdVersionSearch.and(
        "volumeId", VolumeIdVersionSearch.entity().getVolumeId(), SearchCriteria.Op.EQ);
    VolumeIdVersionSearch.and(
        "version", VolumeIdVersionSearch.entity().getVersion(), SearchCriteria.Op.EQ);
    VolumeIdVersionSearch.done();
    /*
     * ParentIdSearch = createSearchBuilder();
     * ParentIdSearch.and("prevSnapshotId",
     * ParentIdSearch.entity().getPrevSnapshotId(), SearchCriteria.Op.EQ);
     * ParentIdSearch.done();
     *
     * backupUuidSearch = createSearchBuilder();
     * backupUuidSearch.and("backupUuid",
     * backupUuidSearch.entity().getBackupSnapshotId(),
     * SearchCriteria.Op.EQ); backupUuidSearch.done();
     */
    AccountIdSearch = createSearchBuilder();
    AccountIdSearch.and("accountId", AccountIdSearch.entity().getAccountId(), SearchCriteria.Op.EQ);
    AccountIdSearch.done();

    StatusSearch = createSearchBuilder();
    StatusSearch.and("volumeId", StatusSearch.entity().getVolumeId(), SearchCriteria.Op.EQ);
    StatusSearch.and("status", StatusSearch.entity().getState(), SearchCriteria.Op.IN);
    StatusSearch.done();

    CountSnapshotsByAccount = createSearchBuilder(Long.class);
    CountSnapshotsByAccount.select(null, Func.COUNT, null);
    CountSnapshotsByAccount.and(
        "account", CountSnapshotsByAccount.entity().getAccountId(), SearchCriteria.Op.EQ);
    CountSnapshotsByAccount.and(
        "status", CountSnapshotsByAccount.entity().getState(), SearchCriteria.Op.NIN);
    CountSnapshotsByAccount.and(
        "removed", CountSnapshotsByAccount.entity().getRemoved(), SearchCriteria.Op.NULL);
    CountSnapshotsByAccount.done();

    InstanceIdSearch = createSearchBuilder();
    InstanceIdSearch.and("status", InstanceIdSearch.entity().getState(), SearchCriteria.Op.IN);

    SearchBuilder<VMInstanceVO> instanceSearch = _instanceDao.createSearchBuilder();
    instanceSearch.and("instanceId", instanceSearch.entity().getId(), SearchCriteria.Op.EQ);

    SearchBuilder<VolumeVO> volumeSearch = _volumeDao.createSearchBuilder();
    volumeSearch.and("state", volumeSearch.entity().getState(), SearchCriteria.Op.EQ);
    volumeSearch.join(
        "instanceVolumes",
        instanceSearch,
        instanceSearch.entity().getId(),
        volumeSearch.entity().getInstanceId(),
        JoinType.INNER);

    InstanceIdSearch.join(
        "instanceSnapshots",
        volumeSearch,
        volumeSearch.entity().getId(),
        InstanceIdSearch.entity().getVolumeId(),
        JoinType.INNER);
    InstanceIdSearch.done();
  }
  @Override
  public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
    boolean result = super.configure(name, params);

    PublicSearch = createSearchBuilder();
    PublicSearch.and("public", PublicSearch.entity().isPublicTemplate(), SearchCriteria.Op.EQ);

    routerTmpltName = (String) params.get("routing.uniquename");

    s_logger.debug("Found parameter routing unique name " + routerTmpltName);
    if (routerTmpltName == null) {
      routerTmpltName = "routing";
    }

    consoleProxyTmpltName = (String) params.get("consoleproxy.uniquename");
    if (consoleProxyTmpltName == null) {
      consoleProxyTmpltName = "routing";
    }
    if (s_logger.isDebugEnabled()) {
      s_logger.debug("Use console proxy template : " + consoleProxyTmpltName);
    }

    UniqueNameSearch = createSearchBuilder();
    UniqueNameSearch.and(
        "uniqueName", UniqueNameSearch.entity().getUniqueName(), SearchCriteria.Op.EQ);
    NameSearch = createSearchBuilder();
    NameSearch.and("name", NameSearch.entity().getName(), SearchCriteria.Op.EQ);

    NameAccountIdSearch = createSearchBuilder();
    NameAccountIdSearch.and("name", NameAccountIdSearch.entity().getName(), SearchCriteria.Op.EQ);
    NameAccountIdSearch.and(
        "accountId", NameAccountIdSearch.entity().getAccountId(), SearchCriteria.Op.EQ);

    PublicIsoSearch = createSearchBuilder();
    PublicIsoSearch.and(
        "public", PublicIsoSearch.entity().isPublicTemplate(), SearchCriteria.Op.EQ);
    PublicIsoSearch.and("format", PublicIsoSearch.entity().getFormat(), SearchCriteria.Op.EQ);
    PublicIsoSearch.and("type", PublicIsoSearch.entity().getTemplateType(), SearchCriteria.Op.EQ);
    PublicIsoSearch.and("bootable", PublicIsoSearch.entity().isBootable(), SearchCriteria.Op.EQ);
    PublicIsoSearch.and("removed", PublicIsoSearch.entity().getRemoved(), SearchCriteria.Op.EQ);

    tmpltTypeHyperSearch = createSearchBuilder();
    tmpltTypeHyperSearch.and(
        "templateType", tmpltTypeHyperSearch.entity().getTemplateType(), SearchCriteria.Op.EQ);
    SearchBuilder<HostVO> hostHyperSearch = _hostDao.createSearchBuilder();
    hostHyperSearch.and("type", hostHyperSearch.entity().getType(), SearchCriteria.Op.EQ);
    hostHyperSearch.and("zoneId", hostHyperSearch.entity().getDataCenterId(), SearchCriteria.Op.EQ);
    hostHyperSearch.groupBy(hostHyperSearch.entity().getHypervisorType());

    tmpltTypeHyperSearch.join(
        "tmplHyper",
        hostHyperSearch,
        hostHyperSearch.entity().getHypervisorType(),
        tmpltTypeHyperSearch.entity().getHypervisorType(),
        JoinBuilder.JoinType.INNER);
    hostHyperSearch.done();
    tmpltTypeHyperSearch.done();

    tmpltTypeHyperSearch2 = createSearchBuilder();
    tmpltTypeHyperSearch2.and(
        "templateType", tmpltTypeHyperSearch2.entity().getTemplateType(), SearchCriteria.Op.EQ);
    tmpltTypeHyperSearch2.and(
        "hypervisorType", tmpltTypeHyperSearch2.entity().getHypervisorType(), SearchCriteria.Op.EQ);

    tmpltTypeSearch = createSearchBuilder();
    tmpltTypeSearch.and(
        "templateType", tmpltTypeSearch.entity().getTemplateType(), SearchCriteria.Op.EQ);

    AccountIdSearch = createSearchBuilder();
    AccountIdSearch.and("accountId", AccountIdSearch.entity().getAccountId(), SearchCriteria.Op.EQ);
    AccountIdSearch.and(
        "publicTemplate", AccountIdSearch.entity().isPublicTemplate(), SearchCriteria.Op.EQ);
    AccountIdSearch.done();

    SearchBuilder<VMTemplateZoneVO> tmpltZoneSearch = _templateZoneDao.createSearchBuilder();
    tmpltZoneSearch.and("removed", tmpltZoneSearch.entity().getRemoved(), SearchCriteria.Op.NULL);
    tmpltZoneSearch.and("zoneId", tmpltZoneSearch.entity().getZoneId(), SearchCriteria.Op.EQ);

    TmpltsInZoneSearch = createSearchBuilder();
    TmpltsInZoneSearch.and(
        "removed", TmpltsInZoneSearch.entity().getRemoved(), SearchCriteria.Op.NULL);
    TmpltsInZoneSearch.and()
        .op("avoidtype", TmpltsInZoneSearch.entity().getTemplateType(), SearchCriteria.Op.NEQ);
    TmpltsInZoneSearch.or(
        "templateType", TmpltsInZoneSearch.entity().getTemplateType(), SearchCriteria.Op.NULL);
    TmpltsInZoneSearch.cp();
    TmpltsInZoneSearch.join(
        "tmpltzone",
        tmpltZoneSearch,
        tmpltZoneSearch.entity().getTemplateId(),
        TmpltsInZoneSearch.entity().getId(),
        JoinBuilder.JoinType.INNER);
    tmpltZoneSearch.done();
    TmpltsInZoneSearch.done();

    CountTemplatesByAccount = createSearchBuilder(Long.class);
    CountTemplatesByAccount.select(null, Func.COUNT, null);
    CountTemplatesByAccount.and(
        "account", CountTemplatesByAccount.entity().getAccountId(), SearchCriteria.Op.EQ);
    CountTemplatesByAccount.and(
        "removed", CountTemplatesByAccount.entity().getRemoved(), SearchCriteria.Op.NULL);
    CountTemplatesByAccount.done();

    return result;
  }
  protected PhysicalNetworkTrafficTypeDaoImpl() {
    super();
    physicalNetworkSearch = createSearchBuilder();
    physicalNetworkSearch.and(
        "physicalNetworkId", physicalNetworkSearch.entity().getPhysicalNetworkId(), Op.EQ);
    physicalNetworkSearch.and(
        "trafficType", physicalNetworkSearch.entity().getTrafficType(), Op.EQ);
    physicalNetworkSearch.done();

    kvmAllFieldsSearch = createSearchBuilder(String.class);
    kvmAllFieldsSearch.and(
        "physicalNetworkId", kvmAllFieldsSearch.entity().getPhysicalNetworkId(), Op.EQ);
    kvmAllFieldsSearch.and("trafficType", kvmAllFieldsSearch.entity().getTrafficType(), Op.EQ);
    kvmAllFieldsSearch.selectFields(kvmAllFieldsSearch.entity().getKvmNetworkLabel());
    kvmAllFieldsSearch.done();

    hypervAllFieldsSearch = createSearchBuilder(String.class);
    hypervAllFieldsSearch.and(
        "physicalNetworkId", hypervAllFieldsSearch.entity().getPhysicalNetworkId(), Op.EQ);
    hypervAllFieldsSearch.and(
        "trafficType", hypervAllFieldsSearch.entity().getTrafficType(), Op.EQ);
    hypervAllFieldsSearch.selectFields(hypervAllFieldsSearch.entity().getHypervNetworkLabel());
    hypervAllFieldsSearch.done();

    xenAllFieldsSearch = createSearchBuilder(String.class);
    xenAllFieldsSearch.and(
        "physicalNetworkId", xenAllFieldsSearch.entity().getPhysicalNetworkId(), Op.EQ);
    xenAllFieldsSearch.and("trafficType", xenAllFieldsSearch.entity().getTrafficType(), Op.EQ);
    xenAllFieldsSearch.selectFields(xenAllFieldsSearch.entity().getXenNetworkLabel());
    xenAllFieldsSearch.done();

    vmWareAllFieldsSearch = createSearchBuilder(String.class);
    vmWareAllFieldsSearch.and(
        "physicalNetworkId", vmWareAllFieldsSearch.entity().getPhysicalNetworkId(), Op.EQ);
    vmWareAllFieldsSearch.and(
        "trafficType", vmWareAllFieldsSearch.entity().getTrafficType(), Op.EQ);
    vmWareAllFieldsSearch.selectFields(vmWareAllFieldsSearch.entity().getVmwareNetworkLabel());
    vmWareAllFieldsSearch.done();

    simulatorAllFieldsSearch = createSearchBuilder(String.class);
    simulatorAllFieldsSearch.and(
        "physicalNetworkId", simulatorAllFieldsSearch.entity().getPhysicalNetworkId(), Op.EQ);
    simulatorAllFieldsSearch.and(
        "trafficType", simulatorAllFieldsSearch.entity().getTrafficType(), Op.EQ);
    simulatorAllFieldsSearch.selectFields(
        simulatorAllFieldsSearch.entity().getSimulatorNetworkLabel());
    simulatorAllFieldsSearch.done();

    ovmAllFieldsSearch = createSearchBuilder(String.class);
    ovmAllFieldsSearch.and(
        "physicalNetworkId", ovmAllFieldsSearch.entity().getPhysicalNetworkId(), Op.EQ);
    ovmAllFieldsSearch.and("trafficType", ovmAllFieldsSearch.entity().getTrafficType(), Op.EQ);
    ovmAllFieldsSearch.selectFields(ovmAllFieldsSearch.entity().getSimulatorNetworkLabel());
    ovmAllFieldsSearch.done();

    ovm3AllFieldsSearch = createSearchBuilder(String.class);
    ovm3AllFieldsSearch.and(
        "physicalNetworkId", ovm3AllFieldsSearch.entity().getPhysicalNetworkId(), Op.EQ);
    ovm3AllFieldsSearch.and("trafficType", ovm3AllFieldsSearch.entity().getTrafficType(), Op.EQ);
    ovm3AllFieldsSearch.selectFields(ovm3AllFieldsSearch.entity().getOvm3NetworkLabel());
    ovm3AllFieldsSearch.done();
  }
Пример #13
0
  @PostConstruct
  protected void init() {
    AllFieldsSearch = createSearchBuilder();
    AllFieldsSearch.and("trafficType", AllFieldsSearch.entity().getTrafficType(), Op.EQ);
    AllFieldsSearch.and("cidr", AllFieldsSearch.entity().getCidr(), Op.EQ);
    AllFieldsSearch.and("broadcastType", AllFieldsSearch.entity().getBroadcastDomainType(), Op.EQ);
    AllFieldsSearch.and("offering", AllFieldsSearch.entity().getNetworkOfferingId(), Op.EQ);
    AllFieldsSearch.and("datacenter", AllFieldsSearch.entity().getDataCenterId(), Op.EQ);
    AllFieldsSearch.and("account", AllFieldsSearch.entity().getAccountId(), Op.EQ);
    AllFieldsSearch.and("related", AllFieldsSearch.entity().getRelated(), Op.EQ);
    AllFieldsSearch.and("guestType", AllFieldsSearch.entity().getGuestType(), Op.EQ);
    AllFieldsSearch.and("physicalNetwork", AllFieldsSearch.entity().getPhysicalNetworkId(), Op.EQ);
    AllFieldsSearch.and("broadcastUri", AllFieldsSearch.entity().getBroadcastUri(), Op.EQ);
    AllFieldsSearch.and("vpcId", AllFieldsSearch.entity().getVpcId(), Op.EQ);
    AllFieldsSearch.and("aclId", AllFieldsSearch.entity().getNetworkACLId(), Op.EQ);
    SearchBuilder<NetworkOfferingVO> join1 = _ntwkOffDao.createSearchBuilder();
    join1.and("isSystem", join1.entity().isSystemOnly(), Op.EQ);
    join1.and("isRedundant", join1.entity().getRedundantRouter(), Op.EQ);
    AllFieldsSearch.join(
        "offerings",
        join1,
        AllFieldsSearch.entity().getNetworkOfferingId(),
        join1.entity().getId(),
        JoinBuilder.JoinType.INNER);
    AllFieldsSearch.done();

    AccountSearch = createSearchBuilder();
    AccountSearch.and("offering", AccountSearch.entity().getNetworkOfferingId(), Op.EQ);
    SearchBuilder<NetworkAccountVO> join = _accountsDao.createSearchBuilder();
    join.and("account", join.entity().getAccountId(), Op.EQ);
    AccountSearch.join(
        "accounts",
        join,
        AccountSearch.entity().getId(),
        join.entity().getNetworkId(),
        JoinBuilder.JoinType.INNER);
    AccountSearch.and("datacenter", AccountSearch.entity().getDataCenterId(), Op.EQ);
    AccountSearch.and("cidr", AccountSearch.entity().getCidr(), Op.EQ);
    AccountSearch.and("vpcId", AccountSearch.entity().getVpcId(), Op.EQ);
    AccountSearch.done();

    RelatedConfigSearch = createSearchBuilder();
    RelatedConfigSearch.and("offering", RelatedConfigSearch.entity().getNetworkOfferingId(), Op.EQ);
    RelatedConfigSearch.and("datacenter", RelatedConfigSearch.entity().getDataCenterId(), Op.EQ);
    SearchBuilder<NetworkAccountVO> join2 = _accountsDao.createSearchBuilder();
    join2.and("account", join2.entity().getAccountId(), Op.EQ);
    RelatedConfigSearch.join(
        "account",
        join2,
        join2.entity().getNetworkId(),
        RelatedConfigSearch.entity().getId(),
        JoinType.INNER);
    RelatedConfigSearch.done();

    AccountNetworkSearch = createSearchBuilder();
    AccountNetworkSearch.and("networkId", AccountNetworkSearch.entity().getId(), Op.EQ);
    SearchBuilder<NetworkAccountVO> mapJoin = _accountsDao.createSearchBuilder();
    mapJoin.and("accountId", mapJoin.entity().getAccountId(), Op.EQ);
    AccountNetworkSearch.join(
        "networkSearch",
        mapJoin,
        AccountNetworkSearch.entity().getId(),
        mapJoin.entity().getNetworkId(),
        JoinBuilder.JoinType.INNER);
    AccountNetworkSearch.done();

    ZoneBroadcastUriSearch = createSearchBuilder();
    ZoneBroadcastUriSearch.and(
        "dataCenterId", ZoneBroadcastUriSearch.entity().getDataCenterId(), Op.EQ);
    ZoneBroadcastUriSearch.and(
        "broadcastUri", ZoneBroadcastUriSearch.entity().getBroadcastUri(), Op.EQ);
    ZoneBroadcastUriSearch.and("guestType", ZoneBroadcastUriSearch.entity().getGuestType(), Op.EQ);
    ZoneBroadcastUriSearch.done();

    CountByZoneAndURI = createSearchBuilder(Long.class);
    CountByZoneAndURI.select(null, Func.COUNT, null);
    CountByZoneAndURI.and("dataCenterId", CountByZoneAndURI.entity().getDataCenterId(), Op.EQ);
    CountByZoneAndURI.and("broadcastUri", CountByZoneAndURI.entity().getBroadcastUri(), Op.EQ);
    CountByZoneAndURI.and("guestType", CountByZoneAndURI.entity().getGuestType(), Op.EQ);

    CountByZoneAndURI.done();

    ZoneSecurityGroupSearch = createSearchBuilder();
    ZoneSecurityGroupSearch.and(
        "dataCenterId", ZoneSecurityGroupSearch.entity().getDataCenterId(), Op.EQ);
    SearchBuilder<NetworkServiceMapVO> offJoin = _ntwkSvcMap.createSearchBuilder();
    offJoin.and("service", offJoin.entity().getService(), Op.EQ);
    ZoneSecurityGroupSearch.join(
        "services",
        offJoin,
        ZoneSecurityGroupSearch.entity().getId(),
        offJoin.entity().getNetworkId(),
        JoinBuilder.JoinType.INNER);
    ZoneSecurityGroupSearch.done();

    CountBy = createSearchBuilder(Integer.class);
    CountBy.select(null, Func.COUNT, CountBy.entity().getId());
    CountBy.and("offeringId", CountBy.entity().getNetworkOfferingId(), Op.EQ);
    CountBy.and("vpcId", CountBy.entity().getVpcId(), Op.EQ);
    CountBy.and("removed", CountBy.entity().getRemoved(), Op.NULL);
    SearchBuilder<NetworkOfferingVO> ntwkOffJoin = _ntwkOffDao.createSearchBuilder();
    ntwkOffJoin.and("isSystem", ntwkOffJoin.entity().isSystemOnly(), Op.EQ);
    CountBy.join(
        "offerings",
        ntwkOffJoin,
        CountBy.entity().getNetworkOfferingId(),
        ntwkOffJoin.entity().getId(),
        JoinBuilder.JoinType.INNER);
    CountBy.done();

    PhysicalNetworkSearch = createSearchBuilder();
    PhysicalNetworkSearch.and(
        "physicalNetworkId", PhysicalNetworkSearch.entity().getPhysicalNetworkId(), Op.EQ);
    PhysicalNetworkSearch.done();

    SecurityGroupSearch = createSearchBuilder();
    SearchBuilder<NetworkServiceMapVO> join3 = _ntwkSvcMap.createSearchBuilder();
    join3.and("service", join3.entity().getService(), Op.EQ);
    SecurityGroupSearch.join(
        "services",
        join3,
        SecurityGroupSearch.entity().getId(),
        join3.entity().getNetworkId(),
        JoinBuilder.JoinType.INNER);
    SecurityGroupSearch.done();

    NetworksCount = createSearchBuilder(Integer.class);
    NetworksCount.select(null, Func.COUNT, NetworksCount.entity().getId());
    NetworksCount.and(
        "networkOfferingId", NetworksCount.entity().getNetworkOfferingId(), SearchCriteria.Op.EQ);
    NetworksCount.done();

    NetworksRegularUserCanCreateSearch = createSearchBuilder(Long.class);
    NetworksRegularUserCanCreateSearch.and(
        "aclType", NetworksRegularUserCanCreateSearch.entity().getAclType(), Op.EQ);
    NetworksRegularUserCanCreateSearch.select(
        null, Func.COUNT, NetworksRegularUserCanCreateSearch.entity().getId());
    SearchBuilder<NetworkAccountVO> join4 = _accountsDao.createSearchBuilder();
    join4.and("account", join4.entity().getAccountId(), Op.EQ);
    join4.and("isOwner", join4.entity().isOwner(), Op.EQ);
    NetworksRegularUserCanCreateSearch.join(
        "accounts",
        join4,
        NetworksRegularUserCanCreateSearch.entity().getId(),
        join4.entity().getNetworkId(),
        JoinBuilder.JoinType.INNER);
    SearchBuilder<NetworkOfferingVO> join5 = _ntwkOffDao.createSearchBuilder();
    join5.and("specifyVlan", join5.entity().getSpecifyVlan(), Op.EQ);
    NetworksRegularUserCanCreateSearch.join(
        "ntwkOff",
        join5,
        NetworksRegularUserCanCreateSearch.entity().getNetworkOfferingId(),
        join5.entity().getId(),
        JoinBuilder.JoinType.INNER);
    NetworksRegularUserCanCreateSearch.done();

    _tgMacAddress = _tgs.get("macAddress");

    SourceNATSearch = createSearchBuilder();
    SourceNATSearch.and("account", SourceNATSearch.entity().getAccountId(), Op.EQ);
    SourceNATSearch.and("datacenter", SourceNATSearch.entity().getDataCenterId(), Op.EQ);
    SourceNATSearch.and("guestType", SourceNATSearch.entity().getGuestType(), Op.EQ);
    SearchBuilder<NetworkServiceMapVO> join6 = _ntwkSvcMap.createSearchBuilder();
    join6.and("service", join6.entity().getService(), Op.EQ);
    SourceNATSearch.join(
        "services",
        join6,
        SourceNATSearch.entity().getId(),
        join6.entity().getNetworkId(),
        JoinBuilder.JoinType.INNER);
    SourceNATSearch.done();

    VpcNetworksCount = createSearchBuilder(Long.class);
    VpcNetworksCount.and("vpcId", VpcNetworksCount.entity().getVpcId(), Op.EQ);
    VpcNetworksCount.select(null, Func.COUNT, VpcNetworksCount.entity().getId());
    SearchBuilder<NetworkOfferingVO> join9 = _ntwkOffDao.createSearchBuilder();
    join9.and("isSystem", join9.entity().isSystemOnly(), Op.EQ);
    VpcNetworksCount.join(
        "offerings",
        join9,
        VpcNetworksCount.entity().getNetworkOfferingId(),
        join9.entity().getId(),
        JoinBuilder.JoinType.INNER);
    VpcNetworksCount.done();

    OfferingAccountNetworkSearch = createSearchBuilder();
    OfferingAccountNetworkSearch.select(
        null, Func.DISTINCT, OfferingAccountNetworkSearch.entity().getId());
    SearchBuilder<NetworkOfferingVO> ntwkOfferingJoin = _ntwkOffDao.createSearchBuilder();
    ntwkOfferingJoin.and("isSystem", ntwkOfferingJoin.entity().isSystemOnly(), Op.EQ);
    OfferingAccountNetworkSearch.join(
        "ntwkOfferingSearch",
        ntwkOfferingJoin,
        OfferingAccountNetworkSearch.entity().getNetworkOfferingId(),
        ntwkOfferingJoin.entity().getId(),
        JoinBuilder.JoinType.LEFT);
    SearchBuilder<NetworkAccountVO> ntwkAccountJoin = _accountsDao.createSearchBuilder();
    ntwkAccountJoin.and("accountId", ntwkAccountJoin.entity().getAccountId(), Op.EQ);
    OfferingAccountNetworkSearch.join(
        "ntwkAccountSearch",
        ntwkAccountJoin,
        OfferingAccountNetworkSearch.entity().getId(),
        ntwkAccountJoin.entity().getNetworkId(),
        JoinBuilder.JoinType.INNER);
    OfferingAccountNetworkSearch.and(
        "zoneId", OfferingAccountNetworkSearch.entity().getDataCenterId(), Op.EQ);
    OfferingAccountNetworkSearch.and(
        "type", OfferingAccountNetworkSearch.entity().getGuestType(), Op.EQ);
    OfferingAccountNetworkSearch.done();

    GarbageCollectedSearch = createSearchBuilder(Long.class);
    GarbageCollectedSearch.selectFields(GarbageCollectedSearch.entity().getId());
    SearchBuilder<NetworkOpVO> join7 = _ntwkOpDao.createSearchBuilder();
    join7.and("activenics", join7.entity().getActiveNicsCount(), Op.EQ);
    join7.and("gc", join7.entity().isGarbageCollected(), Op.EQ);
    join7.and("check", join7.entity().isCheckForGc(), Op.EQ);
    GarbageCollectedSearch.join(
        "ntwkOpGC",
        join7,
        GarbageCollectedSearch.entity().getId(),
        join7.entity().getId(),
        JoinBuilder.JoinType.INNER);
    SearchBuilder<NetworkOfferingVO> join8 = _ntwkOffDao.createSearchBuilder();
    join8.and("isPersistent", join8.entity().getIsPersistent(), Op.EQ);
    GarbageCollectedSearch.join(
        "ntwkOffGC",
        join8,
        GarbageCollectedSearch.entity().getNetworkOfferingId(),
        join8.entity().getId(),
        JoinBuilder.JoinType.INNER);
    GarbageCollectedSearch.done();
  }
Пример #14
0
  @PostConstruct
  void init() {
    AccountSearch = createSearchBuilder();
    AccountSearch.and("account", AccountSearch.entity().getAccountId(), SearchCriteria.Op.EQ);
    AccountSearch.done();

    HostSearch = createSearchBuilder();
    HostSearch.and("host", HostSearch.entity().getHostId(), SearchCriteria.Op.EQ);
    HostSearch.done();

    LastHostSearch = createSearchBuilder();
    LastHostSearch.and("lastHost", LastHostSearch.entity().getLastHostId(), SearchCriteria.Op.EQ);
    LastHostSearch.and("state", LastHostSearch.entity().getState(), SearchCriteria.Op.EQ);
    LastHostSearch.done();

    HostUpSearch = createSearchBuilder();
    HostUpSearch.and("host", HostUpSearch.entity().getHostId(), SearchCriteria.Op.EQ);
    HostUpSearch.and("states", HostUpSearch.entity().getState(), SearchCriteria.Op.NIN);
    HostUpSearch.done();

    HostRunningSearch = createSearchBuilder();
    HostRunningSearch.and("host", HostRunningSearch.entity().getHostId(), SearchCriteria.Op.EQ);
    HostRunningSearch.and("state", HostRunningSearch.entity().getState(), SearchCriteria.Op.EQ);
    HostRunningSearch.done();

    AccountPodSearch = createSearchBuilder();
    AccountPodSearch.and("account", AccountPodSearch.entity().getAccountId(), SearchCriteria.Op.EQ);
    AccountPodSearch.and(
        "pod", AccountPodSearch.entity().getPodIdToDeployIn(), SearchCriteria.Op.EQ);
    AccountPodSearch.done();

    AccountDataCenterSearch = createSearchBuilder();
    AccountDataCenterSearch.and(
        "account", AccountDataCenterSearch.entity().getAccountId(), SearchCriteria.Op.EQ);
    AccountDataCenterSearch.and(
        "dc", AccountDataCenterSearch.entity().getDataCenterId(), SearchCriteria.Op.EQ);
    AccountDataCenterSearch.done();

    StateChangeSearch = createSearchBuilder();
    StateChangeSearch.and("id", StateChangeSearch.entity().getId(), SearchCriteria.Op.EQ);
    StateChangeSearch.and("states", StateChangeSearch.entity().getState(), SearchCriteria.Op.EQ);
    StateChangeSearch.and("host", StateChangeSearch.entity().getHostId(), SearchCriteria.Op.EQ);
    StateChangeSearch.and("update", StateChangeSearch.entity().getUpdated(), SearchCriteria.Op.EQ);
    StateChangeSearch.done();

    DestroySearch = createSearchBuilder();
    DestroySearch.and("state", DestroySearch.entity().getState(), SearchCriteria.Op.IN);
    DestroySearch.and("updateTime", DestroySearch.entity().getUpdateTime(), SearchCriteria.Op.LT);
    DestroySearch.done();

    AccountHostSearch = createSearchBuilder();
    AccountHostSearch.and(
        "accountId", AccountHostSearch.entity().getAccountId(), SearchCriteria.Op.EQ);
    AccountHostSearch.and("hostId", AccountHostSearch.entity().getHostId(), SearchCriteria.Op.EQ);
    AccountHostSearch.done();

    CountByAccountPod = createSearchBuilder(Long.class);
    CountByAccountPod.select(null, Func.COUNT, null);
    CountByAccountPod.and(
        "account", CountByAccountPod.entity().getAccountId(), SearchCriteria.Op.EQ);
    CountByAccountPod.and(
        "pod", CountByAccountPod.entity().getPodIdToDeployIn(), SearchCriteria.Op.EQ);
    CountByAccountPod.done();

    CountByAccount = createSearchBuilder(Long.class);
    CountByAccount.select(null, Func.COUNT, null);
    CountByAccount.and("account", CountByAccount.entity().getAccountId(), SearchCriteria.Op.EQ);
    CountByAccount.and("type", CountByAccount.entity().getType(), SearchCriteria.Op.EQ);
    CountByAccount.and("state", CountByAccount.entity().getState(), SearchCriteria.Op.NIN);
    CountByAccount.done();

    SearchBuilder<NicVO> nicSearch = _nicDao.createSearchBuilder();
    nicSearch.and("networkId", nicSearch.entity().getNetworkId(), SearchCriteria.Op.EQ);
    nicSearch.and("ip4Address", nicSearch.entity().getIp4Address(), SearchCriteria.Op.NNULL);

    AccountDataCenterVirtualSearch = createSearchBuilder();
    AccountDataCenterVirtualSearch.and(
        "account", AccountDataCenterVirtualSearch.entity().getAccountId(), SearchCriteria.Op.EQ);
    AccountDataCenterVirtualSearch.and(
        "dc", AccountDataCenterVirtualSearch.entity().getDataCenterId(), SearchCriteria.Op.EQ);
    AccountDataCenterVirtualSearch.join(
        "nicSearch",
        nicSearch,
        AccountDataCenterVirtualSearch.entity().getId(),
        nicSearch.entity().getInstanceId(),
        JoinBuilder.JoinType.INNER);
    AccountDataCenterVirtualSearch.done();

    UserVmByIsoSearch = createSearchBuilder();
    UserVmByIsoSearch.and("isoId", UserVmByIsoSearch.entity().getIsoId(), SearchCriteria.Op.EQ);
    UserVmByIsoSearch.done();

    _updateTimeAttr = _allAttributes.get("updateTime");
    assert _updateTimeAttr != null : "Couldn't get this updateTime attribute";
  }
Пример #15
0
  @PostConstruct
  public void init() {
    AllFieldsSearch = createSearchBuilder();
    AllFieldsSearch.and("id", AllFieldsSearch.entity().getId(), Op.EQ);
    AllFieldsSearch.and("dataCenterId", AllFieldsSearch.entity().getDataCenterId(), Op.EQ);
    AllFieldsSearch.and("ipAddress", AllFieldsSearch.entity().getAddress(), Op.EQ);
    AllFieldsSearch.and("vlan", AllFieldsSearch.entity().getVlanId(), Op.EQ);
    AllFieldsSearch.and("accountId", AllFieldsSearch.entity().getAllocatedToAccountId(), Op.EQ);
    AllFieldsSearch.and("sourceNat", AllFieldsSearch.entity().isSourceNat(), Op.EQ);
    AllFieldsSearch.and("network", AllFieldsSearch.entity().getAssociatedWithNetworkId(), Op.EQ);
    AllFieldsSearch.and(
        "associatedWithVmId", AllFieldsSearch.entity().getAssociatedWithVmId(), Op.EQ);
    AllFieldsSearch.and("oneToOneNat", AllFieldsSearch.entity().isOneToOneNat(), Op.EQ);
    AllFieldsSearch.and("sourcenetwork", AllFieldsSearch.entity().getSourceNetworkId(), Op.EQ);
    AllFieldsSearch.and(
        "physicalNetworkId", AllFieldsSearch.entity().getPhysicalNetworkId(), Op.EQ);
    AllFieldsSearch.and("vpcId", AllFieldsSearch.entity().getVpcId(), Op.EQ);
    AllFieldsSearch.and("associatedVmIp", AllFieldsSearch.entity().getVmIp(), Op.EQ);
    AllFieldsSearch.done();

    VlanDbIdSearchUnallocated = createSearchBuilder();
    VlanDbIdSearchUnallocated.and(
        "allocated", VlanDbIdSearchUnallocated.entity().getAllocatedTime(), Op.NULL);
    VlanDbIdSearchUnallocated.and(
        "vlanDbId", VlanDbIdSearchUnallocated.entity().getVlanId(), Op.EQ);
    VlanDbIdSearchUnallocated.done();

    AllIpCount = createSearchBuilder(Integer.class);
    AllIpCount.select(null, Func.COUNT, AllIpCount.entity().getAddress());
    AllIpCount.and("dc", AllIpCount.entity().getDataCenterId(), Op.EQ);
    AllIpCount.and("vlan", AllIpCount.entity().getVlanId(), Op.EQ);
    AllIpCount.done();

    AllocatedIpCount = createSearchBuilder(Integer.class);
    AllocatedIpCount.select(null, Func.COUNT, AllocatedIpCount.entity().getAddress());
    AllocatedIpCount.and("dc", AllocatedIpCount.entity().getDataCenterId(), Op.EQ);
    AllocatedIpCount.and("vlan", AllocatedIpCount.entity().getVlanId(), Op.EQ);
    AllocatedIpCount.and("allocated", AllocatedIpCount.entity().getAllocatedTime(), Op.NNULL);
    AllocatedIpCount.done();

    AllIpCountForDashboard = createSearchBuilder(Integer.class);
    AllIpCountForDashboard.select(null, Func.COUNT, AllIpCountForDashboard.entity().getAddress());
    AllIpCountForDashboard.and("dc", AllIpCountForDashboard.entity().getDataCenterId(), Op.EQ);
    AllIpCountForDashboard.and(
        "state", AllIpCountForDashboard.entity().getState(), SearchCriteria.Op.NEQ);

    SearchBuilder<VlanVO> virtaulNetworkVlan = _vlanDao.createSearchBuilder();
    virtaulNetworkVlan.and(
        "vlanType", virtaulNetworkVlan.entity().getVlanType(), SearchCriteria.Op.EQ);

    AllIpCountForDashboard.join(
        "vlan",
        virtaulNetworkVlan,
        virtaulNetworkVlan.entity().getId(),
        AllIpCountForDashboard.entity().getVlanId(),
        JoinBuilder.JoinType.INNER);
    virtaulNetworkVlan.done();
    AllIpCountForDashboard.done();

    AllocatedIpCountForAccount = createSearchBuilder(Long.class);
    AllocatedIpCountForAccount.select(
        null, Func.COUNT, AllocatedIpCountForAccount.entity().getAddress());
    AllocatedIpCountForAccount.and(
        "account", AllocatedIpCountForAccount.entity().getAllocatedToAccountId(), Op.EQ);
    AllocatedIpCountForAccount.and(
        "allocated", AllocatedIpCountForAccount.entity().getAllocatedTime(), Op.NNULL);
    AllocatedIpCountForAccount.and(
        "network", AllocatedIpCountForAccount.entity().getAssociatedWithNetworkId(), Op.NNULL);
    AllocatedIpCountForAccount.done();

    CountFreePublicIps = createSearchBuilder(Long.class);
    CountFreePublicIps.select(null, Func.COUNT, null);
    CountFreePublicIps.and("state", CountFreePublicIps.entity().getState(), SearchCriteria.Op.EQ);
    CountFreePublicIps.and(
        "networkId", CountFreePublicIps.entity().getSourceNetworkId(), SearchCriteria.Op.EQ);
    SearchBuilder<VlanVO> join = _vlanDao.createSearchBuilder();
    join.and("vlanType", join.entity().getVlanType(), Op.EQ);
    CountFreePublicIps.join(
        "vlans",
        join,
        CountFreePublicIps.entity().getVlanId(),
        join.entity().getId(),
        JoinBuilder.JoinType.INNER);
    CountFreePublicIps.done();

    DeleteAllExceptGivenIp = createSearchBuilder();
    DeleteAllExceptGivenIp.and("vlanDbId", DeleteAllExceptGivenIp.entity().getVlanId(), Op.EQ);
    DeleteAllExceptGivenIp.and("ip", DeleteAllExceptGivenIp.entity().getAddress(), Op.NEQ);
  }
Пример #16
0
  protected NetworkDaoImpl() {
    super();

    AllFieldsSearch = createSearchBuilder();
    AllFieldsSearch.and("trafficType", AllFieldsSearch.entity().getTrafficType(), Op.EQ);
    AllFieldsSearch.and("cidr", AllFieldsSearch.entity().getCidr(), Op.EQ);
    AllFieldsSearch.and("broadcastType", AllFieldsSearch.entity().getBroadcastDomainType(), Op.EQ);
    AllFieldsSearch.and("offering", AllFieldsSearch.entity().getNetworkOfferingId(), Op.EQ);
    AllFieldsSearch.and("datacenter", AllFieldsSearch.entity().getDataCenterId(), Op.EQ);
    AllFieldsSearch.and("account", AllFieldsSearch.entity().getAccountId(), Op.EQ);
    AllFieldsSearch.and("related", AllFieldsSearch.entity().getRelated(), Op.EQ);
    AllFieldsSearch.and("guestType", AllFieldsSearch.entity().getGuestType(), Op.EQ);
    AllFieldsSearch.and("physicalNetwork", AllFieldsSearch.entity().getPhysicalNetworkId(), Op.EQ);
    AllFieldsSearch.done();

    AccountSearch = createSearchBuilder();
    AccountSearch.and("offering", AccountSearch.entity().getNetworkOfferingId(), Op.EQ);
    SearchBuilder<NetworkAccountVO> join = _accountsDao.createSearchBuilder();
    join.and("account", join.entity().getAccountId(), Op.EQ);
    AccountSearch.join(
        "accounts",
        join,
        AccountSearch.entity().getId(),
        join.entity().getNetworkId(),
        JoinBuilder.JoinType.INNER);
    AccountSearch.and("datacenter", AccountSearch.entity().getDataCenterId(), Op.EQ);
    AccountSearch.and("cidr", AccountSearch.entity().getCidr(), Op.EQ);
    AccountSearch.done();

    RelatedConfigSearch = createSearchBuilder();
    RelatedConfigSearch.and("offering", RelatedConfigSearch.entity().getNetworkOfferingId(), Op.EQ);
    RelatedConfigSearch.and("datacenter", RelatedConfigSearch.entity().getDataCenterId(), Op.EQ);
    SearchBuilder<NetworkAccountVO> join2 = _accountsDao.createSearchBuilder();
    join2.and("account", join2.entity().getAccountId(), Op.EQ);
    RelatedConfigSearch.join(
        "account",
        join2,
        join2.entity().getNetworkId(),
        RelatedConfigSearch.entity().getId(),
        JoinType.INNER);
    RelatedConfigSearch.done();

    AccountNetworkSearch = createSearchBuilder();
    AccountNetworkSearch.and("networkId", AccountNetworkSearch.entity().getId(), Op.EQ);
    SearchBuilder<NetworkAccountVO> mapJoin = _accountsDao.createSearchBuilder();
    mapJoin.and("accountId", mapJoin.entity().getAccountId(), Op.EQ);
    AccountNetworkSearch.join(
        "networkSearch",
        mapJoin,
        AccountNetworkSearch.entity().getId(),
        mapJoin.entity().getNetworkId(),
        JoinBuilder.JoinType.INNER);
    AccountNetworkSearch.done();

    ZoneBroadcastUriSearch = createSearchBuilder();
    ZoneBroadcastUriSearch.and(
        "dataCenterId", ZoneBroadcastUriSearch.entity().getDataCenterId(), Op.EQ);
    ZoneBroadcastUriSearch.and(
        "broadcastUri", ZoneBroadcastUriSearch.entity().getBroadcastUri(), Op.EQ);
    ZoneBroadcastUriSearch.done();

    ZoneSecurityGroupSearch = createSearchBuilder();
    ZoneSecurityGroupSearch.and(
        "dataCenterId", ZoneSecurityGroupSearch.entity().getDataCenterId(), Op.EQ);
    SearchBuilder<NetworkServiceMapVO> join1 = _ntwkSvcMap.createSearchBuilder();
    join1.and("service", join1.entity().getService(), Op.EQ);
    ZoneSecurityGroupSearch.join(
        "services",
        join1,
        ZoneSecurityGroupSearch.entity().getId(),
        join1.entity().getNetworkId(),
        JoinBuilder.JoinType.INNER);
    ZoneSecurityGroupSearch.done();

    CountByOfferingId = createSearchBuilder(Long.class);
    CountByOfferingId.select(null, Func.COUNT, CountByOfferingId.entity().getId());
    CountByOfferingId.and("offeringId", CountByOfferingId.entity().getNetworkOfferingId(), Op.EQ);
    CountByOfferingId.and("removed", CountByOfferingId.entity().getRemoved(), Op.NULL);
    CountByOfferingId.done();

    PhysicalNetworkSearch = createSearchBuilder();
    PhysicalNetworkSearch.and(
        "physicalNetworkId", PhysicalNetworkSearch.entity().getPhysicalNetworkId(), Op.EQ);
    PhysicalNetworkSearch.done();

    securityGroupSearch = createSearchBuilder();
    SearchBuilder<NetworkServiceMapVO> join3 = _ntwkSvcMap.createSearchBuilder();
    join3.and("service", join3.entity().getService(), Op.EQ);
    securityGroupSearch.join(
        "services",
        join3,
        securityGroupSearch.entity().getId(),
        join3.entity().getNetworkId(),
        JoinBuilder.JoinType.INNER);
    securityGroupSearch.done();

    _tgMacAddress = _tgs.get("macAddress");
  }