
add the association of Net_SettingSDefineState. Signed-off-by: Wayne Xia <xiawenc@linux.vnet.ibm.com> --- schema/SettingsDefineState.mof | 9 +- schema/SettingsDefineState.registration | 3 +- src/Virt_SettingsDefineState.c | 256 +++++++++++++++++++++++++++++++ 3 files changed, 266 insertions(+), 2 deletions(-) diff --git a/schema/SettingsDefineState.mof b/schema/SettingsDefineState.mof index 7664ae2..1ee6698 100644 --- a/schema/SettingsDefineState.mof +++ b/schema/SettingsDefineState.mof @@ -1,4 +1,4 @@ -// Copyright IBM Corp. 2007 +// Copyright IBM Corp. 2011 [Association, Provider("cmpi::Virt_SettingsDefineState") @@ -20,3 +20,10 @@ class KVM_SettingsDefineState : CIM_SettingsDefineState class LXC_SettingsDefineState : CIM_SettingsDefineState { }; + +[Association, + Provider("cmpi::Virt_SettingsDefineState") +] +class Net_SettingsDefineState : CIM_SettingsDefineState +{ +}; diff --git a/schema/SettingsDefineState.registration b/schema/SettingsDefineState.registration index 0563491..b5e03ba 100644 --- a/schema/SettingsDefineState.registration +++ b/schema/SettingsDefineState.registration @@ -1,5 +1,6 @@ -# Copyright IBM Corp. 2007 +# Copyright IBM Corp. 2011 # Classname Namespace ProviderName ProviderModule ProviderTypes Xen_SettingsDefineState root/virt Virt_SettingsDefineState Virt_SettingsDefineState association KVM_SettingsDefineState root/virt Virt_SettingsDefineState Virt_SettingsDefineState association LXC_SettingsDefineState root/virt Virt_SettingsDefineState Virt_SettingsDefineState association +Net_SettingsDefineState root/virt Virt_SettingsDefineState Virt_SettingsDefineState association diff --git a/src/Virt_SettingsDefineState.c b/src/Virt_SettingsDefineState.c index b4e4b80..ae7054f 100644 --- a/src/Virt_SettingsDefineState.c +++ b/src/Virt_SettingsDefineState.c @@ -4,6 +4,9 @@ * Authors: * Dan Smith <danms@us.ibm.com> * + * Modified by: + * Wenchao Xia <xiawenc@cn.ibm.com> + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either @@ -36,6 +39,11 @@ #include "Virt_ComputerSystem.h" #include "Virt_VSSD.h" #include "svpc_types.h" +#include "Virt_VESSSD.h" +#include "Virt_VirtualEthernetSwitchSystem.h" +#include "Virt_EASD.h" +#include "Virt_EthernetPort.h" +#include "network_model.h" const static CMPIBroker *_BROKER; @@ -319,6 +327,172 @@ static CMPIStatus vssd_to_vs(const CMPIObjectPath *ref, return s; } +static CMPIStatus vess_to_vesssd(const CMPIObjectPath *ref, + struct std_assoc_info *info, + struct inst_list *list) +{ + CMPIStatus s = {CMPI_RC_OK, NULL}; + CMPIInstance *inst; + const char *name = NULL; + + if (!match_hypervisor_prefix(ref, info)) { + return s; + } + /* the step of creating a vess instance is skipped to make it fast */ + if (cu_get_str_path(ref, "Name", &name) != CMPI_RC_OK) { + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_FAILED, + "Missing Name property"); + goto out; + } + + CU_DEBUG("vess to vesssd , name %s", name); + s = get_vesssd_by_name(_BROKER, name, ref, &inst); + if (s.rc != CMPI_RC_OK) { + goto out; + } + + inst_list_add(list, inst); + + out: + return s; +} + +static CMPIStatus vesssd_to_vess(const CMPIObjectPath *ref, + struct std_assoc_info *info, + struct inst_list *list) +{ + const char *id = NULL; + char *pfx = NULL; + char *name = NULL; + int ret; + CMPIStatus s = {CMPI_RC_OK, NULL}; + CMPIInstance *inst = NULL; + + if (!match_hypervisor_prefix(ref, info)) { + return s; + } + + /* the step of creating a vesssd instance is skipped to make it fast */ + if (cu_get_str_path(ref, "InstanceID", &id) != CMPI_RC_OK) { + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_FAILED, + "Missing InstanceID"); + goto out; + } + + ret = sscanf(id, "%a[^:]:%as", &pfx, &name); + if (ret != 2) { + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_FAILED, + "Invalid InstanceID"); + goto out; + } + + CU_DEBUG("vesssd to vess , name %s", name); + s = get_switch_by_name(_BROKER, name, ref, &inst); + if (s.rc != CMPI_RC_OK) { + goto out; + } + + inst_list_add(list, inst); + + out: + free(name); + free(pfx); + + return s; +} + +/* according to DSP 1050.1.0.0_0 page 41, SDS only associate EP with EASD_EA */ +static CMPIStatus ep_to_easd(const CMPIObjectPath *ref, + struct std_assoc_info *info, + struct inst_list *list) +{ + CMPIStatus s = {CMPI_RC_OK, NULL}; + CMPIInstance *inst = NULL; + char *newid = NULL; + const char *name; + + if (!match_hypervisor_prefix(ref, info)) { + return s; + } + + /* the step of creating a ep instance is skipped to make it fast */ + if (cu_get_str_path(ref, "DeviceID", &name) != CMPI_RC_OK) { + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_FAILED, + "No DeviceID specified"); + goto out; + } + + newid = ep_id_to_easdea_id(name); + if (newid == NULL) { + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_NOT_FOUND, + "Invalid DeviceID set."); + goto out; + } + + s = get_easd_by_id(_BROKER, + newid, + ref, + NULL, + &inst); + if (s.rc != CMPI_RC_OK) { + goto out; + } + + inst_list_add(list, inst); + + out: + free(newid); + return s; +} + +static CMPIStatus easd_to_ep(const CMPIObjectPath *ref, + struct std_assoc_info *info, + struct inst_list *list) +{ + CMPIStatus s = {CMPI_RC_OK, NULL}; + CMPIInstance *inst = NULL; + const char *name = NULL; + char *newid = NULL; + + if (!match_hypervisor_prefix(ref, info)) { + return s; + } + + /* the step of creating a easd instance is skipped to make it fast */ + + if (cu_get_str_path(ref, "InstanceID", &name) != CMPI_RC_OK) { + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_FAILED, + "Missing InstanceID"); + goto out; + } + newid = easdea_id_to_ep_id(name); + + if (newid == NULL) { + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_NOT_FOUND, + "Invalid InstanceID set."); + goto out; + } + + s = get_ep_by_id(_BROKER, newid, ref, NULL, &inst); + if (s.rc != CMPI_RC_OK) { + goto out; + } + + inst_list_add(list, inst); + + + out: + free(newid); + return s; +} + LIBVIRT_CIM_DEFAULT_MAKEREF() static char* logical_device[] = { @@ -386,6 +560,32 @@ static char* assoc_classname[] = { NULL }; + +static char *vess_name[] = { + "Net_VirtualEthernetSwitchSystem", + NULL +}; + +static char *vesssd_name[] = { + "Net_VirtualEthernetSwitchSystemSettingData", + NULL +}; + +static char *ep_name[] = { + "Net_EthernetPort", + NULL +}; + +static char *easd_name[] = { + "Net_EthernetPortAllocationSettingData", + NULL +}; + +static char *vess_assoc_name[] = { + "Net_SettingsDefineState", + NULL +}; + static struct std_assoc _dev_to_rasd = { .source_class = (char**)&logical_device, .source_prop = "ManagedElement", @@ -438,11 +638,67 @@ static struct std_assoc _vssd_to_vs = { .make_ref = make_ref }; +static struct std_assoc _vess_to_vesssd = { + .source_class = (char **)&vess_name, + .source_prop = "ManagedElement", + + .target_class = (char **)&vesssd_name, + .target_prop = "SettingData", + + .assoc_class = (char **)&vess_assoc_name, + + .handler = vess_to_vesssd, + .make_ref = make_ref +}; + +static struct std_assoc _vesssd_to_vess = { + .source_class = (char **)&vesssd_name, + .source_prop = "SettingData", + + .target_class = (char **)&vess_name, + .target_prop = "ManagedElement", + + .assoc_class = (char **)&vess_assoc_name, + + .handler = vesssd_to_vess, + .make_ref = make_ref +}; + +static struct std_assoc _ep_to_easd = { + .source_class = (char **)&ep_name, + .source_prop = "ManagedElement", + + .target_class = (char **)&easd_name, + .target_prop = "SettingData", + + .assoc_class = (char **)&vess_assoc_name, + + .handler = ep_to_easd, + .make_ref = make_ref +}; + +static struct std_assoc _easd_to_ep = { + .source_class = (char **)&easd_name, + .source_prop = "SettingData", + + .target_class = (char **)&ep_name, + .target_prop = "ManagedElement", + + .assoc_class = (char **)&vess_assoc_name, + + .handler = easd_to_ep, + .make_ref = make_ref +}; + static struct std_assoc *handlers[] = { &_dev_to_rasd, &_rasd_to_dev, &_vs_to_vssd, &_vssd_to_vs, + &_vess_to_vesssd, + &_vesssd_to_vess, + &_ep_to_easd, + &_easd_to_ep, NULL }; -- 1.7.6