Java 类com.vmware.vim25.CustomFieldDef 实例源码

项目:jcloud-vsphere    文件:VSphereComputeServiceAdapter.java   
@Inject
public VSphereComputeServiceAdapter(Supplier<VSphereServiceInstance> serviceInstance, Supplier<Map<String, CustomFieldDef>> customFields, Supplier<VSphereHost> vSphereHost,
                                    VirtualMachineToImage virtualMachineToImage,
                                    Function<String, DistributedVirtualPortgroup> distributedVirtualSwitchFunction,
                                    NetworkConfigurationForNetworkAndOptions networkConfigurationForNetworkAndOptions,
                                    Function<String, VSphereHost> hostFunction,
                                    @Named(VSphereConstants.JCLOUDS_VSPHERE_VM_PASSWORD) String vmInitPassword) {
   this.serviceInstance = checkNotNull(serviceInstance, "serviceInstance");
   this.customFields = checkNotNull(customFields, "customFields");
   this.virtualMachineToImage = virtualMachineToImage;
   this.vmInitPassword = checkNotNull(vmInitPassword, "vmInitPassword");
   this.networkConfigurationForNetworkAndOptions = checkNotNull(networkConfigurationForNetworkAndOptions, "networkConfigurationForNetworkAndOptions");
   this.vSphereHost = checkNotNull(vSphereHost, "vSphereHost");
   this.distributedVirtualPortgroupFunction = distributedVirtualSwitchFunction;
   this.hostFunction = hostFunction;
}
项目:jcloud-vsphere    文件:CreateOrGetTagsId.java   
@Inject
public synchronized void start() {
   try (VSphereServiceInstance client = serviceInstance.get();) {

      CustomFieldDef[] customFieldDefs = client.getInstance().getCustomFieldsManager().getField();
      if (null != customFieldDefs) {
         for (CustomFieldDef field : customFieldDefs) {
            if (field.getName().equalsIgnoreCase(VSphereConstants.JCLOUDS_TAGS)) {
               customFieldDefMap.put(VSphereConstants.JCLOUDS_TAGS, field);
            } else if (field.getName().equalsIgnoreCase(VSphereConstants.JCLOUDS_GROUP)) {
               customFieldDefMap.put(VSphereConstants.JCLOUDS_GROUP, field);
            }
         }
      }
      if (!customFieldDefMap.containsKey(VSphereConstants.JCLOUDS_TAGS))
         customFieldDefMap.put(VSphereConstants.JCLOUDS_TAGS, client.getInstance().getCustomFieldsManager().addCustomFieldDef(VSphereConstants.JCLOUDS_TAGS, null, null, null));
      if (!customFieldDefMap.containsKey(VSphereConstants.JCLOUDS_GROUP))
         customFieldDefMap.put(VSphereConstants.JCLOUDS_GROUP, client.getInstance().getCustomFieldsManager().addCustomFieldDef(VSphereConstants.JCLOUDS_GROUP, null, null, null));
   } catch (Throwable t) {
      Throwables.propagate(t);
   }
}
项目:primecloud-controller    文件:VmwareMachineProcess.java   
/**
 * TODO: メソッドコメントを記述
 *
 * @param vmwareProcessClient
 * @param instanceNo
 */
public void updateCustomValue(VmwareProcessClient vmwareProcessClient, Long instanceNo) {
    // カスタムフィールドがない場合は作成
    CustomFieldDef customFieldDef = vmwareProcessClient.getCustomFieldDef(fieldUserName, VirtualMachine.class);
    if (customFieldDef == null) {
        vmwareProcessClient.addCustomFieldDef(fieldUserName, VirtualMachine.class);
    }

    VmwareInstance vmwareInstance = vmwareInstanceDao.read(instanceNo);
    Instance instance = instanceDao.read(instanceNo);
    Farm farm = farmDao.read(instance.getFarmNo());
    User user = userDao.read(farm.getUserNo());

    // カスタムフィールドの値を設定
    vmwareProcessClient.setCustomValue(vmwareInstance.getMachineName(), fieldUserName, user.getUsername());
}
项目:cloudstack    文件:BaseMO.java   
public void setCustomFieldValue(String fieldName, String value) throws Exception {
    CustomFieldsManagerMO cfmMo = new CustomFieldsManagerMO(_context, _context.getServiceContent().getCustomFieldsManager());

    int key = getCustomFieldKey(fieldName);
    if (key == 0) {
        try {
            CustomFieldDef field = cfmMo.addCustomerFieldDef(fieldName, getMor().getType(), null, null);
            key = field.getKey();
        } catch (Exception e) {
            // assuming the exception is caused by concurrent operation from other places
            // so we retieve the key again
            key = getCustomFieldKey(fieldName);
        }
    }

    if (key == 0)
        throw new Exception("Unable to setup custom field facility");

    cfmMo.setField(getMor(), key, value);
}
项目:cloudstack    文件:CustomFieldsManagerMO.java   
public int ensureCustomFieldDef(String morType, String fieldName) throws Exception {
    int key = getCustomFieldKey(morType, fieldName);
    if (key > 0)
        return key;

    try {
        CustomFieldDef field = addCustomerFieldDef(fieldName, morType, null, null);
        return field.getKey();
    } catch (Exception e) {
        // assuming that someone is adding it
        key = getCustomFieldKey(morType, fieldName);
    }

    if (key == 0)
        throw new Exception("Unable to setup custom field facility for " + morType + ":" + fieldName);

    return key;
}
项目:jcloud-vsphere    文件:VirtualMachineToNodeMetadata.java   
@Inject
public VirtualMachineToNodeMetadata(Map<VirtualMachinePowerState, NodeMetadata.Status> toPortableNodeStatus,
                                    Supplier<Map<String, CustomFieldDef>> customFields,
                                    Supplier<VSphereServiceInstance> serviceInstanceSupplier,
                                    Function<String, DistributedVirtualPortgroup> distributedVirtualPortgroupFunction,
                                    @Named(VSphereConstants.JCLOUDS_VSPHERE_VM_PASSWORD) String vmInitPassword) {
   this.toPortableNodeStatus = checkNotNull(toPortableNodeStatus, "PortableNodeStatus");
   this.customFields = checkNotNull(customFields, "customFields");
   this.serviceInstanceSupplier = checkNotNull(serviceInstanceSupplier, "serviceInstanceSupplier");
   this.distributedVirtualPortgroupFunction = checkNotNull(distributedVirtualPortgroupFunction, "distributedVirtualPortgroupFunction");
   this.vmInitPassword = vmInitPassword;
}
项目:primecloud-controller    文件:VmwareProcessClient.java   
public List<CustomFieldDef> getCustomFieldDefs() {
    CustomFieldsManager manager = vmwareClient.getServiceInstance().getCustomFieldsManager();
    CustomFieldDef[] defs = manager.getField();

    List<CustomFieldDef> customFieldDefs = new ArrayList<CustomFieldDef>();
    if (defs != null) {
        for (CustomFieldDef def : defs) {
            customFieldDefs.add(def);
        }
    }
    return customFieldDefs;
}
项目:primecloud-controller    文件:VmwareProcessClient.java   
public CustomFieldDef getCustomFieldDef(String name, Class<?> type) {
    CustomFieldsManager manager = vmwareClient.getServiceInstance().getCustomFieldsManager();
    CustomFieldDef[] defs = manager.getField();

    String typeName = type.getSimpleName();

    if (defs != null) {
        for (CustomFieldDef def : defs) {
            if (def.getName().equals(name) && def.getManagedObjectType().equals(typeName)) {
                return def;
            }
        }
    }
    return null;
}
项目:primecloud-controller    文件:VmwareProcessClient.java   
public void addCustomFieldDef(String name, Class<?> type) {
    CustomFieldsManager manager = vmwareClient.getServiceInstance().getCustomFieldsManager();
    CustomFieldDef[] defs = manager.getField();

    String typeName = type.getSimpleName();

    if (defs != null) {
        for (CustomFieldDef def : defs) {
            if (def.getName().equals(name) && def.getManagedObjectType().equals(typeName)) {
                // 既にカスタムフィールドが追加されている場合はスキップ
                return;
            }
        }
    }

    try {
        manager.addCustomFieldDef(name, typeName, null, null);
    } catch (DuplicateName ignore) {
        // 他のスレッドで同時に追加された場合に備えて握りつぶす
        return;
    } catch (RemoteException e) {
        throw new AutoException("EPROCESS-000525", e, name, typeName);
    }

    if (log.isInfoEnabled()) {
        log.info(MessageUtils.getMessage("IPROCESS-100461", name));
    }
}
项目:primecloud-controller    文件:VmwareProcessClient.java   
public void removeCustomFieldDef(String name, Class<?> type) {
    CustomFieldsManager manager = vmwareClient.getServiceInstance().getCustomFieldsManager();
    CustomFieldDef[] defs = manager.getField();

    String typeName = type.getSimpleName();

    CustomFieldDef customFieldDef = null;
    if (defs != null) {
        for (CustomFieldDef def : defs) {
            if (def.getName().equals(name) && def.getManagedObjectType().equals(typeName)) {
                customFieldDef = def;
            }
        }
    }

    if (customFieldDef == null) {
        // 既にカスタムフィールドが存在しない場合はスキップ
    }

    try {
        manager.removeCustomFieldDef(customFieldDef.getKey());
    } catch (InvalidArgument ignore) {
        // 他のスレッドで同時に削除された場合に備えて握りつぶす
        return;
    } catch (RemoteException e) {
        throw new AutoException("EPROCESS-000526", e, name, typeName);
    }

    if (log.isInfoEnabled()) {
        log.info(MessageUtils.getMessage("IPROCESS-100462", name));
    }
}
项目:cloudstack    文件:CustomFieldsManagerMO.java   
@Override
public int getCustomFieldKey(String morType, String fieldName) throws Exception {
    List<CustomFieldDef> fields = getFields();
    if (fields != null) {
        for (CustomFieldDef field : fields) {
            if (field.getName().equals(fieldName) && field.getManagedObjectType().equals(morType))
                return field.getKey();
        }
    }
    return 0;
}
项目:jcloud-vsphere    文件:VSphereComputeServiceContextModule.java   
@Override
   protected void configure() {
      super.configure();

      //bind(ComputeService.class).to(VSphereComputeService.class);
      bind(TemplateOptions.class).to(VSphereTemplateOptions.class);
      bind(LocationsSupplier.class).to(VSphereLocationSupplier.class);
      bind(FileManagerApi.class).to(VSphereFileManager.class);

      bind(new TypeLiteral<ComputeServiceAdapter<VirtualMachine, Hardware, Image, Location>>() {
      }).to(VSphereComputeServiceAdapter.class);

      bind(new TypeLiteral<Function<String, DistributedVirtualPortgroup>>() {
      }).to(Class.class.cast(VLanNameToDistributedVirtualPortgroup.class));

      bind(new TypeLiteral<Function<Location, Location>>() {
      }).to(Class.class.cast(IdentityFunction.class));

      bind(new TypeLiteral<Function<Image, Image>>() {
      }).to(Class.class.cast(IdentityFunction.class));

      bind(new TypeLiteral<Function<Hardware, Hardware>>() {
      }).to(Class.class.cast(IdentityFunction.class));

      bind(new TypeLiteral<Function<VirtualMachine, NodeMetadata>>() {
      }).to(VirtualMachineToNodeMetadata.class);

      bind(new TypeLiteral<Function<HostSystem, VSphereHost>>() {
      }).to(HostSystemToVSphereHost.class);

      bind(new TypeLiteral<Supplier<VSphereServiceInstance>>() {
      }).to((Class) CreateAndConnectVSphereClient.class);

//        bind(new TypeLiteral<Supplier<Set<? extends Location>>>() {
//        }).to((Class) VSphereLocationSupplier.class);

      bind(new TypeLiteral<Supplier<VSphereHost>>() {
      }).to((Class) VSphereHostSupplier.class);

      bind(new TypeLiteral<Supplier<Map<String, CustomFieldDef>>>() {
      }).to((Class) CreateOrGetTagsId.class);

      bind(new TypeLiteral<Supplier<NetworkConfigSupplier>>() {
      }).to((Class) NetworkConfigSupplier.class);

      bind(new TypeLiteral<Function<VirtualMachine, SshClient>>() {
      }).to(VirtualMachineToSshClient.class);

      bind(new TypeLiteral<Function<VirtualMachine, Image>>() {
      }).to(VirtualMachineToImage.class);

      bind(new TypeLiteral<Function<String, VSphereHost>>() {
      }).to(GetRecommendedVSphereHost.class);
   }
项目:jcloud-vsphere    文件:CustomFieldsManagerApi.java   
CustomFieldDef addCustomFieldDef(String name, String moType, PrivilegePolicyDef fieldDefPolicy,
PrivilegePolicyDef fieldPolicy) throws DuplicateName, InvalidPrivilege, RuntimeFault, RemoteException;
项目:jcloud-vsphere    文件:CreateOrGetTagsId.java   
@Override
public Map<String, CustomFieldDef> get() {
   checkState(customFieldDefMap.size() > 0, "(CreateOrGetTagsId) start not called");
   return customFieldDefMap;
}
项目:cloudstack    文件:CustomFieldsManagerMO.java   
public CustomFieldDef addCustomerFieldDef(String fieldName, String morType, PrivilegePolicyDef fieldDefPolicy, PrivilegePolicyDef fieldPolicy) throws Exception {
    return _context.getService().addCustomFieldDef(getMor(), fieldName, morType, fieldDefPolicy, fieldPolicy);
}
项目:cloudstack    文件:CustomFieldsManagerMO.java   
public List<CustomFieldDef> getFields() throws Exception {
    return _context.getVimClient().getDynamicProperty(getMor(), "field");
}
项目:jcloud-vsphere    文件:CustomFieldsManagerApi.java   
List<CustomFieldDef> getField();