function_t *function_new() { type_t *fn_type = vm_get()->function_type; function_t *fn = (function_t*)type_allocate(fn_type); type_initialize(fn_type, (object_t*)fn); return fn; }
bool_t *bool_new(bool value) { type_t *bool_type = vm_get()->bool_type; bool_t *self = (bool_t*)type_allocate(bool_type); type_initialize(bool_type, (object_t*)self); self->value = value; return self; }
type_t *stringtype_new() { type_t *st = type_new(L"string", vm_get()->object_type); st->basicsize = sizeof(struct string); st->fn_initialize = &string_fn_initialize; st->fn_deinitialize = &string_fn_deinitialize; st->fn_repr = &string_fn_repr; st->fn_hash = &string_fn_hash; return st; }
type_t *functiontype_new() { type_t *st = type_new(L"func", vm_get()->object_type); st->basicsize = sizeof(struct function); st->fn_initialize = &function_fn_initialize; st->fn_deinitialize = &function_fn_deinitialize; st->fn_repr = &function_fn_repr; st->fn_hash = &function_fn_hash; return st; }
type_t *booltype_new() { type_t *nt = (type_t*)type_new(L"bool", vm_get()->object_type); nt->basicsize = sizeof(struct bool_); nt->fn_initialize = &bool_fn_initialize; nt->fn_deinitialize = &bool_fn_deinitialize; nt->fn_repr = &bool_fn_repr; nt->fn_hash = &bool_fn_hash; return nt; }
string_t *string_new(const wchar_t *chars) { type_t *str_type = vm_get()->string_type; string_t *self = (string_t*)type_allocate(str_type); type_initialize(str_type, (object_t*)self); free(self->s_chars); self->length = wcslen(chars); self->s_chars = wcsdup(chars); return self; }
static zbx_vmware_vm_t *service_vm_get(zbx_vmware_service_t *service, const char *uuid) { int i; for (i = 0; i < service->data->hvs.values_num; i++) { zbx_vmware_vm_t *vm; zbx_vmware_hv_t *hv = (zbx_vmware_hv_t *)service->data->hvs.values[i]; if (NULL != (vm = vm_get(&hv->vms, uuid))) return vm; } return NULL; }
int check_vcenter_vm_cluster_name(AGENT_REQUEST *request, const char *username, const char *password, AGENT_RESULT *result) { int i, ret = SYSINFO_RET_FAIL; char *url, *uuid; zbx_vmware_service_t *service; zbx_vmware_cluster_t *cluster = NULL; if (2 != request->nparam) return SYSINFO_RET_FAIL; url = get_rparam(request, 0); uuid = get_rparam(request, 1); if ('\0' == *uuid) return SYSINFO_RET_FAIL; zbx_vmware_lock(); if (NULL == (service = get_vmware_service(url, username, password, result, &ret))) goto unlock; for (i = 0; i < service->data->hvs.values_num; i++) { zbx_vmware_hv_t *hv = service->data->hvs.values[i]; zbx_vmware_vm_t *vm; if (NULL != (vm = vm_get(&hv->vms, uuid))) { if (NULL != hv->clusterid) cluster = cluster_get(&service->data->clusters, hv->clusterid); break; } } SET_STR_RESULT(result, zbx_strdup(NULL, NULL != cluster ? cluster->name : "")); ret = SYSINFO_RET_OK; unlock: zbx_vmware_unlock(); return ret; }
int check_vcenter_vm_hv_name(AGENT_REQUEST *request, const char *username, const char *password, AGENT_RESULT *result) { int ret = SYSINFO_RET_FAIL; zbx_vmware_service_t *service; zbx_vmware_hv_t *hv; char *url, *uuid, *name; int i; if (2 != request->nparam) return SYSINFO_RET_FAIL; url = get_rparam(request, 0); uuid = get_rparam(request, 1); if ('\0' == *uuid) return SYSINFO_RET_FAIL; zbx_vmware_lock(); if (NULL == (service = get_vmware_service(url, username, password, result, &ret))) goto unlock; for (i = 0; i < service->data->hvs.values_num; i++) { hv = (zbx_vmware_hv_t *)service->data->hvs.values[i]; if (NULL != vm_get(&hv->vms, uuid)) break; } if (i != service->data->hvs.values_num) { name = zbx_xml_read_value(hv->details, ZBX_XPATH_LN2("config", "name")); SET_STR_RESULT(result, name); ret = SYSINFO_RET_OK; } unlock: zbx_vmware_unlock(); return ret; }
bool string_check(object_t *self) { return is_instance(self, vm_get()->string_type); }
bool function_check(object_t *self) { return is_instance(self, vm_get()->function_type); }
bool bool_check(object_t *self) { return is_instance(self, vm_get()->bool_type); }