Search in sources :

Example 1 with CustomFieldDef

use of com.vmware.vim25.CustomFieldDef in project cloudstack by apache.

the class BaseMO method setCustomFieldValue.

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);
}
Also used : CustomFieldDef(com.vmware.vim25.CustomFieldDef)

Example 2 with CustomFieldDef

use of com.vmware.vim25.CustomFieldDef in project CloudStack-archive by CloudStack-extras.

the class BaseMO method setCustomFieldValue.

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);
}
Also used : CustomFieldDef(com.vmware.vim25.CustomFieldDef)

Aggregations

CustomFieldDef (com.vmware.vim25.CustomFieldDef)2