示例#1
0
  public static void getVcenterTenantOptions(String id) {
    List<TenantOrgRestRep> vCenterTenantOptions = new ArrayList<TenantOrgRestRep>();
    if (StringUtils.isBlank(id) || id.equalsIgnoreCase("null")) {
      renderJSON(vCenterTenantOptions);
      return;
    }

    List<ACLEntry> vcenterAcls = VCenterUtils.getAcl(uri(id));
    if (CollectionUtils.isEmpty(vcenterAcls)) {
      renderJSON(vCenterTenantOptions);
      return;
    }

    addNoneTenantOption(id, vCenterTenantOptions);

    Iterator<ACLEntry> aclEntryIterator = vcenterAcls.iterator();
    while (aclEntryIterator.hasNext()) {
      ACLEntry aclEntry = aclEntryIterator.next();
      if (aclEntry == null) {
        continue;
      }

      TenantOrgRestRep tenantOrgRestRep = TenantUtils.getTenant(aclEntry.getTenant());
      if (tenantOrgRestRep != null) {
        vCenterTenantOptions.add(tenantOrgRestRep);
      }
    }
    renderJSON(vCenterTenantOptions);
  }
示例#2
0
 public static void itemDetails(String id) {
   VcenterRestRep vcenter = VCenterUtils.getVCenter(uri(id));
   List<VcenterDataCenterRestRep> dataCenters =
       VCenterUtils.getDataCentersInVCenter(
           vcenter, TenantUtils.getTenantFilter(Models.currentAdminTenantForVcenter()));
   render(vcenter, dataCenters);
 }
示例#3
0
 public static void listJson() {
   URI tenantId = TenantUtils.getTenantFilter(Models.currentAdminTenantForVcenter());
   List<VcenterRestRep> vcenters = VCenterUtils.getVCenters(tenantId);
   List<VCenterInfo> vcenterInfos = Lists.newArrayList();
   for (VcenterRestRep vcenter : vcenters) {
     vcenterInfos.add(new VCenterInfo(vcenter));
   }
   renderJSON(DataTablesSupport.createJSON(vcenterInfos, params));
 }
示例#4
0
  private static void renderTenantOptions() {
    if (TenantUtils.canReadAllTenantsForVcenters() && VCenterUtils.canUpdateACLs()) {
      List<StringOption> tenantOptions = dataObjectOptions(await(new TenantsCall().asPromise()));
      renderArgs.put("tenantOptions", tenantOptions);

      List<StringOption> tenantOptionsWithNone = new ArrayList<StringOption>();

      tenantOptionsWithNone.add(
          new StringOption(NullColumnValueGetter.getNullStr().toString(), "None"));
      tenantOptionsWithNone.addAll(tenantOptions);
      renderArgs.put("tenantOptionsWithNone", tenantOptionsWithNone);
    }
  }
示例#5
0
 public void setTenantsForCreation() {
   this.tenants = new HashSet<String>();
   if (StringUtils.isNotBlank(Models.currentAdminTenantForVcenter())
       && Models.currentAdminTenantForVcenter()
           .equalsIgnoreCase(TenantUtils.getNoTenantSelector())) {
     List<TenantOrgRestRep> allTenants = TenantUtils.getAllTenants();
     Iterator<TenantOrgRestRep> tenantsIterator = allTenants.iterator();
     while (tenantsIterator.hasNext()) {
       TenantOrgRestRep tenant = tenantsIterator.next();
       if (tenant == null) {
         continue;
       }
       this.tenants.add(tenant.getId().toString());
       this.cascadeTenancy = Boolean.FALSE;
     }
   } else if (StringUtils.isNotBlank(Models.currentAdminTenantForVcenter())
       && !Models.currentAdminTenantForVcenter()
           .equalsIgnoreCase(TenantUtils.getTenantSelectorForUnassigned())) {
     this.tenants.clear();
     this.tenant = Models.currentAdminTenantForVcenter();
     this.cascadeTenancy = Boolean.TRUE;
   }
 }
示例#6
0
    protected Task<VcenterRestRep> createVCenter(boolean validateConnection) {
      VcenterCreateParam vcenterCreateParam = new VcenterCreateParam();
      doWriteTo(vcenterCreateParam);

      if (Security.isSystemAdmin()) {
        return VCenterUtils.createVCenter(
            vcenterCreateParam, validateConnection, getAclAssignmentChanges());
      }

      return VCenterUtils.createVCenter(
          TenantUtils.getTenantFilter(Models.currentAdminTenantForVcenter()),
          vcenterCreateParam,
          validateConnection);
    }