[PATCH] (#4) ProcessorRASD, the class that won't go away
by Jay Gagnon
# HG changeset patch
# User Jay Gagnon <grendel(a)linux.vnet.ibm.com>
# Date 1211297079 14400
# Node ID f00dd77c664c258551c5f884a0bee5d842241e4e
# Parent c949b1845113e11e01329abb5aa81ca6ade8e3ec
(#4) ProcessorRASD, the class that won't go away
Around and round we go on the merry-go-round of indecision, hopefully for our last ride. The definitely probably absolutely tentative final plan is that the default representation of processors as virt_device structs will be one per domain, with a quantity. Virt_Devices will just need to be told how to handle that, and all the RASD stuff will be much happier for it. And then we will never speak of this again.
So today being my last official day on the team, I kind of have to get this out in a not perfect state. From what I can see it does what it is supposed to do, but it is entirely possible (likely?) that there are a few things in here that aren't really great things to do. I wish I could polish it more but I think I've at least got it to the point where any work left to be done is generic "not a great idea in C" problems, as opposed to the much more annoying "what exactly are we supposed to do in this case" problems.
Changes from 1 to 2:
Close brace on if block. That one is really embarrassing; I have no idea what happened there. I mean that crap won't even compile.
Removed unnecessary proc_found boolean. That was me being lazy after changing my mind on something.
Cleaned up a couple leftover CU_DEBUG calls.
Addition of vcpu_inst function, which is similar to vcpu_instances but always only works on one instance and takes a dev_id. This is to prevent all instances from being given a dev_id of zero. It is unfortunately similar to vcpu_instances in other regards, but I'm not sure if it's worth the overhead of trying to combine the similar parts.
Fixed quantity v number problem in xml_parse_test that I appear to have been failing to address for about six years.
Changes from 2 to 3:
Actually include changes needed for associations.
Make vcpu_instances use vcpu_inst.
Changes from 3 to 4:
Rename list_devs to something more meaningful
Fix misplaced free.
Signed-off-by: Jay Gagnon <grendel(a)linux.vnet.ibm.com>
Signed-off-by: Kaitlin Rupert <karupert(a)us.ibm.com>
Signed-off-by: Dan Smith <danms(a)us.ibm.com>
diff -r c949b1845113 -r f00dd77c664c libxkutil/device_parsing.c
--- a/libxkutil/device_parsing.c Thu May 15 17:56:39 2008 -0700
+++ b/libxkutil/device_parsing.c Tue May 20 11:24:39 2008 -0400
@@ -337,7 +337,6 @@ static int parse_vcpu_device(xmlNode *no
struct virt_device *list = NULL;
char *count_str;
int count;
- int i;
count_str = get_node_content(node);
if (count_str == NULL)
@@ -347,24 +346,15 @@ static int parse_vcpu_device(xmlNode *no
free(count_str);
- list = calloc(count, sizeof(*list));
+ list = calloc(1, sizeof(*list));
if (list == NULL)
goto err;
-
- for (i = 0; i < count; i++) {
- struct virt_device *vdev = &list[i];
- struct vcpu_device *cdev = &vdev->dev.vcpu;
-
- cdev->number = i;
-
- vdev->type = CIM_RES_TYPE_PROC;
- if (asprintf(&vdev->id, "%i", i) == -1)
- vdev->id = NULL;
- }
+
+ list->dev.vcpu.quantity = count;
*vdevs = list;
- return count;
+ return 1;
err:
free(list);
@@ -620,7 +610,7 @@ struct virt_device *virt_device_dup(stru
dev->dev.mem.size = _dev->dev.mem.size;
dev->dev.mem.maxsize = _dev->dev.mem.maxsize;
} else if (dev->type == CIM_RES_TYPE_PROC) {
- dev->dev.vcpu.number = _dev->dev.vcpu.number;
+ dev->dev.vcpu.quantity = _dev->dev.vcpu.quantity;
} else if (dev->type == CIM_RES_TYPE_EMU) {
DUP_FIELD(dev, _dev, dev.emu.path);
} else if (dev->type == CIM_RES_TYPE_GRAPHICS) {
@@ -672,6 +662,32 @@ static int _get_mem_device(const char *x
return 1;
}
+static int _get_proc_device(const char *xml, struct virt_device **list)
+{
+ struct virt_device *proc_devs = NULL;
+ struct virt_device *proc_dev = NULL;
+ int ret;
+
+ ret = parse_devices(xml, &proc_devs, CIM_RES_TYPE_PROC);
+ if (ret <= 0)
+ return ret;
+
+ proc_dev = malloc(sizeof(*proc_dev));
+ if (proc_dev == NULL)
+ return 0;
+
+ memset(proc_dev, 0, sizeof(*proc_dev));
+
+ proc_dev->type = CIM_RES_TYPE_PROC;
+ proc_dev->id = strdup("proc");
+ proc_dev->dev.vcpu.quantity = proc_devs[0].dev.vcpu.quantity;
+ *list = proc_dev;
+
+ cleanup_virt_devices(&proc_devs, ret);
+
+ return 1;
+};
+
int get_devices(virDomainPtr dom, struct virt_device **list, int type)
{
char *xml;
@@ -683,6 +699,8 @@ int get_devices(virDomainPtr dom, struct
if (type == CIM_RES_TYPE_MEM)
ret = _get_mem_device(xml, list);
+ else if (type == CIM_RES_TYPE_PROC)
+ ret = _get_proc_device(xml, list);
else
ret = parse_devices(xml, list, type);
diff -r c949b1845113 -r f00dd77c664c libxkutil/device_parsing.h
--- a/libxkutil/device_parsing.h Thu May 15 17:56:39 2008 -0700
+++ b/libxkutil/device_parsing.h Tue May 20 11:24:39 2008 -0400
@@ -50,7 +50,7 @@ struct mem_device {
};
struct vcpu_device {
- uint64_t number;
+ uint64_t quantity;
};
struct emu_device {
diff -r c949b1845113 -r f00dd77c664c libxkutil/xml_parse_test.c
--- a/libxkutil/xml_parse_test.c Thu May 15 17:56:39 2008 -0700
+++ b/libxkutil/xml_parse_test.c Tue May 20 11:24:39 2008 -0400
@@ -96,7 +96,7 @@ static void print_dev_vcpu(struct virt_d
static void print_dev_vcpu(struct virt_device *dev,
FILE *d)
{
- print_u64(d, "Virtual CPU", dev->dev.vcpu.number);
+ print_u64(d, "Virtual CPU", dev->dev.vcpu.quantity);
}
static void print_dev_emu(struct virt_device *dev,
diff -r c949b1845113 -r f00dd77c664c src/Virt_Device.c
--- a/src/Virt_Device.c Thu May 15 17:56:39 2008 -0700
+++ b/src/Virt_Device.c Tue May 20 11:24:39 2008 -0400
@@ -174,23 +174,6 @@ static CMPIInstance *mem_instance(const
return inst;
}
-static CMPIInstance *vcpu_instance(const CMPIBroker *broker,
- struct vcpu_device *dev,
- const virDomainPtr dom,
- const char *ns)
-{
- CMPIInstance *inst;
- virConnectPtr conn;
-
- conn = virDomainGetConnect(dom);
- inst = get_typed_instance(broker,
- pfx_from_conn(conn),
- "Processor",
- ns);
-
- return inst;
-}
-
static int device_set_devid(CMPIInstance *instance,
struct virt_device *dev,
const virDomainPtr dom)
@@ -229,43 +212,127 @@ static int device_set_systemname(CMPIIns
return 1;
}
-static CMPIInstance *device_instance(const CMPIBroker *broker,
- struct virt_device *dev,
- const virDomainPtr dom,
- const char *ns)
+static char *get_vcpu_inst_id(const virDomainPtr dom,
+ int proc_num)
{
- CMPIInstance *instance;
+ int rc;
+ char *id_num = NULL;
+ char *dev_id = NULL;
- if (dev->type == CIM_RES_TYPE_NET)
- instance = net_instance(broker,
- &dev->dev.net,
- dom,
- ns);
- else if (dev->type == CIM_RES_TYPE_DISK)
- instance = disk_instance(broker,
- &dev->dev.disk,
- dom,
- ns);
- else if (dev->type == CIM_RES_TYPE_MEM)
- instance = mem_instance(broker,
- &dev->dev.mem,
- dom,
- ns);
- else if (dev->type == CIM_RES_TYPE_PROC)
- instance = vcpu_instance(broker,
- &dev->dev.vcpu,
- dom,
- ns);
- else
- return NULL;
+ rc = asprintf(&id_num, "%d", proc_num);
+ if (rc == -1) {
+ free(dev_id);
+ dev_id = NULL;
+ goto out;
+ }
+
+ dev_id = get_fq_devid((char *)virDomainGetName(dom), id_num);
+ free(id_num);
- if (!instance)
- return NULL;
+ out:
+ return dev_id;
+}
- device_set_devid(instance, dev, dom);
- device_set_systemname(instance, dom);
+static bool vcpu_inst(const CMPIBroker *broker,
+ const virDomainPtr dom,
+ const char *ns,
+ int dev_id_num,
+ struct inst_list *list)
+{
+ char *dev_id;
+ CMPIInstance *inst;
+ virConnectPtr conn = NULL;
- return instance;
+ conn = virDomainGetConnect(dom);
+ inst = get_typed_instance(broker,
+ pfx_from_conn(conn),
+ "Processor",
+ ns);
+ if (inst == NULL)
+ return false;
+
+ dev_id = get_vcpu_inst_id(dom, dev_id_num);
+ CMSetProperty(inst, "DeviceID",
+ (CMPIValue *)dev_id, CMPI_chars);
+ free(dev_id);
+
+ device_set_systemname(inst, dom);
+ inst_list_add(list, inst);
+
+ return true;
+}
+
+static bool vcpu_instances(const CMPIBroker *broker,
+ const virDomainPtr dom,
+ const char *ns,
+ uint64_t proc_count,
+ struct inst_list *list)
+{
+ int i;
+ bool rc;
+
+ for (i = 0; i < proc_count; i++) {
+ rc = vcpu_inst(broker, dom, ns, i, list);
+ if (!rc)
+ return false;
+ }
+
+ return true;
+}
+
+static bool device_instances(const CMPIBroker *broker,
+ struct virt_device *devs,
+ int count,
+ const virDomainPtr dom,
+ const char *ns,
+ struct inst_list *list)
+{
+ int i;
+ bool ret;
+ uint64_t proc_count = 0;
+ CMPIInstance *instance = NULL;
+
+ for (i = 0; i < count; i++) {
+ struct virt_device *dev = &devs[i];
+
+ if (dev->type == CIM_RES_TYPE_NET)
+ instance = net_instance(broker,
+ &dev->dev.net,
+ dom,
+ ns);
+ else if (dev->type == CIM_RES_TYPE_DISK)
+ instance = disk_instance(broker,
+ &dev->dev.disk,
+ dom,
+ ns);
+ else if (dev->type == CIM_RES_TYPE_MEM)
+ instance = mem_instance(broker,
+ &dev->dev.mem,
+ dom,
+ ns);
+ else if (dev->type == CIM_RES_TYPE_PROC) {
+ proc_count = dev->dev.vcpu.quantity;
+ continue;
+ } else
+ return false;
+
+ if (!instance)
+ return false;
+
+ device_set_devid(instance, dev, dom);
+ device_set_systemname(instance, dom);
+ inst_list_add(list, instance);
+ }
+
+ if (proc_count) {
+ ret = vcpu_instances(broker,
+ dom,
+ ns,
+ proc_count,
+ list);
+ }
+
+ return true;
}
uint16_t res_type_from_device_classname(const char *classname)
@@ -290,25 +357,27 @@ static CMPIStatus _get_devices(const CMP
{
CMPIStatus s = {CMPI_RC_OK, NULL};
int count;
- int i;
+ bool rc;
struct virt_device *devs = NULL;
count = get_devices(dom, &devs, type);
if (count <= 0)
goto out;
- for (i = 0; i < count; i++) {
- CMPIInstance *dev = NULL;
+ rc = device_instances(broker,
+ devs,
+ count,
+ dom,
+ NAMESPACE(reference),
+ list);
- dev = device_instance(broker,
- &devs[i],
- dom,
- NAMESPACE(reference));
- if (dev)
- inst_list_add(list, dev);
+ if (!rc) {
+ cu_statusf(broker, &s,
+ CMPI_RC_ERR_FAILED,
+ "Couldn't get device instances");
+ }
- cleanup_virt_device(&devs[i]);
- }
+ cleanup_virt_devices(&devs, count);
out:
free(devs);
@@ -427,6 +496,29 @@ static int parse_devid(const char *devid
return 1;
}
+static int proc_dev_list(uint64_t quantity,
+ struct virt_device **list)
+{
+ int i;
+ int rc;
+
+
+ *list = (struct virt_device *)calloc(quantity,
+ sizeof(struct virt_device));
+
+ for (i = 0; i < quantity; i++) {
+ char *dev_num;
+
+ rc = asprintf(&dev_num, "%d", i);
+
+ (*list)[i].id = strdup(dev_num);
+
+ free(dev_num);
+ }
+
+ return quantity;
+}
+
static struct virt_device *find_dom_dev(virDomainPtr dom,
char *device,
int type)
@@ -439,6 +531,17 @@ static struct virt_device *find_dom_dev(
count = get_devices(dom, &list, type);
if (!count)
goto out;
+
+ if (type == CIM_RES_TYPE_PROC) {
+ struct virt_device *tmp_list;
+ int tmp_count;
+
+ tmp_count = proc_dev_list(list[0].dev.vcpu.quantity,
+ &tmp_list);
+ cleanup_virt_devices(&list, count);
+ list = tmp_list;
+ count = tmp_count;
+ }
for (i = 0; i < count; i++) {
if (STREQC(device, list[i].id))
@@ -462,10 +565,13 @@ CMPIStatus get_device_by_name(const CMPI
CMPIStatus s = {CMPI_RC_OK, NULL};
char *domain = NULL;
char *device = NULL;
- CMPIInstance *instance = NULL;
virConnectPtr conn = NULL;
virDomainPtr dom = NULL;
struct virt_device *dev = NULL;
+ struct inst_list tmp_list;
+ bool rc;
+
+ inst_list_init(&tmp_list);
conn = connect_by_classname(broker, CLASSNAME(reference), &s);
if (conn == NULL) {
@@ -501,13 +607,30 @@ CMPIStatus get_device_by_name(const CMPI
goto err;
}
- instance = device_instance(broker,
- dev,
- dom,
- NAMESPACE(reference));
+ if (type == CIM_RES_TYPE_PROC) {
+ int ret;
+ int dev_id_num;
+
+ ret = sscanf(dev->id, "%d", &dev_id_num);
+
+ rc = vcpu_inst(broker,
+ dom,
+ NAMESPACE(reference),
+ dev_id_num,
+ &tmp_list);
+ } else {
+
+ rc = device_instances(broker,
+ dev,
+ 1,
+ dom,
+ NAMESPACE(reference),
+ &tmp_list);
+ }
+
cleanup_virt_device(dev);
- *_inst = instance;
+ *_inst = tmp_list.list[0];
err:
virDomainFree(dom);
@@ -515,6 +638,7 @@ CMPIStatus get_device_by_name(const CMPI
free(device);
out:
+ inst_list_free(&tmp_list);
virConnectClose(conn);
return s;
diff -r c949b1845113 -r f00dd77c664c src/Virt_RASD.c
--- a/src/Virt_RASD.c Thu May 15 17:56:39 2008 -0700
+++ b/src/Virt_RASD.c Tue May 20 11:24:39 2008 -0400
@@ -31,7 +31,6 @@
#include <libcmpiutil/libcmpiutil.h>
#include <libcmpiutil/std_instance.h>
-#include "device_parsing.h"
#include "misc_util.h"
#include "cs_util.h"
@@ -56,10 +55,10 @@ static struct virt_device *_find_dev(str
return NULL;
}
-static int list_devs(virConnectPtr conn,
- const uint16_t type,
- const char *host,
- struct virt_device **list)
+int list_rasds(virConnectPtr conn,
+ const uint16_t type,
+ const char *host,
+ struct virt_device **list)
{
virDomainPtr dom;
@@ -79,7 +78,7 @@ static struct virt_device *find_dev(virC
struct virt_device *list = NULL;
struct virt_device *dev = NULL;
- count = list_devs(conn, type, host, &list);
+ count = list_rasds(conn, type, host, &list);
if (count > 0) {
dev = _find_dev(list, count, devid);
cleanup_virt_devices(&list, count);
@@ -173,10 +172,8 @@ static CMPIInstance *rasd_from_vdev(cons
CMSetProperty(inst, "Limit",
(CMPIValue *)&dev->dev.mem.maxsize, CMPI_uint64);
} else if (dev->type == CIM_RES_TYPE_PROC) {
- /* This would be the place to set the virtualquantity. */
- uint64_t quantity = dev->dev.vcpu.number + 1;
CMSetProperty(inst, "VirtualQuantity",
- (CMPIValue *)&quantity, CMPI_uint64);
+ (CMPIValue *)&dev->dev.vcpu.quantity, CMPI_uint64);
}
/* FIXME: Put the HostResource in place */
diff -r c949b1845113 -r f00dd77c664c src/Virt_RASD.h
--- a/src/Virt_RASD.h Thu May 15 17:56:39 2008 -0700
+++ b/src/Virt_RASD.h Tue May 20 11:24:39 2008 -0400
@@ -20,6 +20,8 @@
*/
#ifndef __VIRT_RASD_H
#define __VIRT_RASD_H
+
+#include "device_parsing.h"
char *rasd_to_xml(CMPIInstance *rasd);
@@ -55,6 +57,10 @@ CMPIStatus get_rasd_by_ref(const CMPIBro
const char **properties,
CMPIInstance **_inst);
+int list_rasds(virConnectPtr conn,
+ const uint16_t type,
+ const char *host,
+ struct virt_device **list);
#endif
/*
diff -r c949b1845113 -r f00dd77c664c src/Virt_SettingsDefineState.c
--- a/src/Virt_SettingsDefineState.c Thu May 15 17:56:39 2008 -0700
+++ b/src/Virt_SettingsDefineState.c Tue May 20 11:24:39 2008 -0400
@@ -39,13 +39,95 @@
const static CMPIBroker *_BROKER;
+static int get_proc_dev_count(const char *name,
+ const char *cn,
+ uint16_t type,
+ char *host,
+ CMPIStatus *s)
+{
+ virConnectPtr conn = NULL;
+ struct virt_device *list = NULL;
+ struct virt_device *dev = NULL;
+ int dev_count = -1;
+ int count = -1;
+
+ conn = connect_by_classname(_BROKER, cn, s);
+ if (conn == NULL) {
+ cu_statusf(_BROKER, s,
+ CMPI_RC_ERR_NOT_FOUND,
+ "No such instance (%s)",
+ name);
+ goto out;
+ }
+
+ dev_count = list_rasds(conn, type, host, &list);
+ if (dev_count <= 0) {
+ cu_statusf(_BROKER, s,
+ CMPI_RC_ERR_FAILED,
+ "Unable to get list of processors");
+ goto out;
+ }
+
+ dev = &list[0];
+ count = dev->dev.vcpu.quantity;
+
+ cleanup_virt_devices(&list, dev_count);
+
+ out:
+ virConnectClose(conn);
+ return count;
+}
+
+static char *get_rasd_id(const CMPIInstance *inst, uint16_t type)
+{
+ char *id = NULL;
+ int ret;
+ const char *tmp;
+
+ if (type == CIM_RES_TYPE_PROC) {
+ ret = cu_get_str_prop(inst, "SystemName", &tmp);
+ if (ret != CMPI_RC_OK) {
+ CU_DEBUG("No SystemName in device instance");
+ goto out;
+ }
+
+ ret = asprintf(&id, "%s/proc", tmp);
+ if (ret == -1) {
+ id = NULL;
+ goto out;
+ }
+ } else {
+ ret = cu_get_str_prop(inst, "DeviceID", &tmp);
+ if (ret != CMPI_RC_OK) {
+ CU_DEBUG("No DeviceID in device instance");
+ id = NULL;
+ goto out;
+ }
+
+ id = strdup(tmp);
+ }
+
+ out:
+ return id;
+}
+
+static char *get_dev_id(const char *host, int devid)
+{
+ char *id = NULL;
+
+ if (asprintf(&id, "%s/%d", host, devid) == -1)
+ id = NULL;
+
+ return id;
+}
+
static CMPIStatus dev_to_rasd(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 *id = NULL;
if (!match_hypervisor_prefix(ref, info))
return s;
@@ -54,16 +136,18 @@ static CMPIStatus dev_to_rasd(const CMPI
if (s.rc != CMPI_RC_OK)
goto out;
- if (cu_get_str_path(ref, "DeviceID", &name) != CMPI_RC_OK) {
+ id = get_rasd_id(inst,
+ res_type_from_device_classname(CLASSNAME(ref)));
+ if (id == NULL) {
cu_statusf(_BROKER, &s,
- CMPI_RC_ERR_FAILED,
- "Missing DeviceID");
+ CMPI_RC_ERR_NOT_FOUND,
+ "Unable to get RASD id from DeviceID");
goto out;
- }
+ }
s = get_rasd_by_name(_BROKER,
ref,
- name,
+ id,
res_type_from_device_classname(CLASSNAME(ref)),
NULL,
&inst);
@@ -73,6 +157,7 @@ static CMPIStatus dev_to_rasd(const CMPI
inst_list_add(list, inst);
out:
+ free(id);
return s;
}
@@ -83,7 +168,12 @@ static CMPIStatus rasd_to_dev(const CMPI
CMPIStatus s = {CMPI_RC_OK, NULL};
CMPIInstance *inst = NULL;
const char *name = NULL;
+ char *host = NULL;
+ char *devid = NULL;
+ char *id = NULL;
uint16_t type;
+ int count = 1;
+ int i;
if (!match_hypervisor_prefix(ref, info))
return s;
@@ -92,6 +182,13 @@ static CMPIStatus rasd_to_dev(const CMPI
if (s.rc != CMPI_RC_OK)
goto out;
+ if (res_type_from_rasd_classname(CLASSNAME(ref), &type) != CMPI_RC_OK) {
+ cu_statusf(_BROKER, &s,
+ CMPI_RC_ERR_FAILED,
+ "Missing ResourceType");
+ goto out;
+ }
+
if (cu_get_str_path(ref, "InstanceID", &name) != CMPI_RC_OK) {
cu_statusf(_BROKER, &s,
CMPI_RC_ERR_FAILED,
@@ -99,20 +196,48 @@ static CMPIStatus rasd_to_dev(const CMPI
goto out;
}
- if (res_type_from_rasd_classname(CLASSNAME(ref), &type) != CMPI_RC_OK) {
- cu_statusf(_BROKER, &s,
- CMPI_RC_ERR_FAILED,
- "Missing ResourceType");
- goto out;
+ if (type == CIM_RES_TYPE_PROC) {
+ if (parse_fq_devid((char *)name, &host, &devid) != 1) {
+ cu_statusf(_BROKER, &s,
+ CMPI_RC_ERR_NOT_FOUND,
+ "No such instance (%s)",
+ name);
+ goto out;
+ }
+
+ count = get_proc_dev_count(name,
+ CLASSNAME(ref),
+ type,
+ host,
+ &s);
+ if (count <= 0)
+ goto out;
}
- s = get_device_by_name(_BROKER, ref, name, type, &inst);
- if (s.rc != CMPI_RC_OK)
- goto out;
+ for (i = 0; i < count; i++) {
+ if (type == CIM_RES_TYPE_PROC)
+ id = get_dev_id(host, i);
+ else
+ id = strdup(name);
- inst_list_add(list, inst);
+ if (id == NULL) {
+ cu_statusf(_BROKER, &s,
+ CMPI_RC_ERR_NOT_FOUND,
+ "Unable to get RASD id from DeviceID");
+ goto out;
+ }
+
+ s = get_device_by_name(_BROKER, ref, id, type, &inst);
+ if (s.rc != CMPI_RC_OK)
+ goto out;
+
+ inst_list_add(list, inst);
+ free(id);
+ }
out:
+ free(host);
+ free(devid);
return s;
}
16 years, 5 months
[PATCH] (#3) ProcessorRASD, the class that won't go away
by Jay Gagnon
# HG changeset patch
# User Jay Gagnon <grendel(a)linux.vnet.ibm.com>
# Date 1211291977 14400
# Node ID d18a3d2d57a9402f9db8993212ed24316e05d657
# Parent c949b1845113e11e01329abb5aa81ca6ade8e3ec
(#3) ProcessorRASD, the class that won't go away
Around and round we go on the merry-go-round of indecision, hopefully for our last ride. The definitely probably absolutely tentative final plan is that the default representation of processors as virt_device structs will be one per domain, with a quantity. Virt_Devices will just need to be told how to handle that, and all the RASD stuff will be much happier for it. And then we will never speak of this again.
So today being my last official day on the team, I kind of have to get this out in a not perfect state. From what I can see it does what it is supposed to do, but it is entirely possible (likely?) that there are a few things in here that aren't really great things to do. I wish I could polish it more but I think I've at least got it to the point where any work left to be done is generic "not a great idea in C" problems, as opposed to the much more annoying "what exactly are we supposed to do in this case" problems.
Changes from 1 to 2:
Close brace on if block. That one is really embarrassing; I have no idea what happened there. I mean that crap won't even compile.
Removed unnecessary proc_found boolean. That was me being lazy after changing my mind on something.
Cleaned up a couple leftover CU_DEBUG calls.
Addition of vcpu_inst function, which is similar to vcpu_instances but always only works on one instance and takes a dev_id. This is to prevent all instances from being given a dev_id of zero. It is unfortunately similar to vcpu_instances in other regards, but I'm not sure if it's worth the overhead of trying to combine the similar parts.
Fixed quantity v number problem in xml_parse_test that I appear to have been failing to address for about six years.
Changes from 2 to 3:
Actually include changes needed for associations.
Make vcpu_instances use vcpu_inst.
Signed-off-by: Jay Gagnon <grendel(a)linux.vnet.ibm.com>
Signed-off-by: Kaitlin Rupert <karupert(a)us.ibm.com>
Signed-off-by: Dan Smith <danms(a)us.ibm.com>
diff -r c949b1845113 -r d18a3d2d57a9 libxkutil/device_parsing.c
--- a/libxkutil/device_parsing.c Thu May 15 17:56:39 2008 -0700
+++ b/libxkutil/device_parsing.c Tue May 20 09:59:37 2008 -0400
@@ -337,7 +337,6 @@ static int parse_vcpu_device(xmlNode *no
struct virt_device *list = NULL;
char *count_str;
int count;
- int i;
count_str = get_node_content(node);
if (count_str == NULL)
@@ -347,24 +346,15 @@ static int parse_vcpu_device(xmlNode *no
free(count_str);
- list = calloc(count, sizeof(*list));
+ list = calloc(1, sizeof(*list));
if (list == NULL)
goto err;
-
- for (i = 0; i < count; i++) {
- struct virt_device *vdev = &list[i];
- struct vcpu_device *cdev = &vdev->dev.vcpu;
-
- cdev->number = i;
-
- vdev->type = CIM_RES_TYPE_PROC;
- if (asprintf(&vdev->id, "%i", i) == -1)
- vdev->id = NULL;
- }
+
+ list->dev.vcpu.quantity = count;
*vdevs = list;
- return count;
+ return 1;
err:
free(list);
@@ -620,7 +610,7 @@ struct virt_device *virt_device_dup(stru
dev->dev.mem.size = _dev->dev.mem.size;
dev->dev.mem.maxsize = _dev->dev.mem.maxsize;
} else if (dev->type == CIM_RES_TYPE_PROC) {
- dev->dev.vcpu.number = _dev->dev.vcpu.number;
+ dev->dev.vcpu.quantity = _dev->dev.vcpu.quantity;
} else if (dev->type == CIM_RES_TYPE_EMU) {
DUP_FIELD(dev, _dev, dev.emu.path);
} else if (dev->type == CIM_RES_TYPE_GRAPHICS) {
@@ -672,6 +662,32 @@ static int _get_mem_device(const char *x
return 1;
}
+static int _get_proc_device(const char *xml, struct virt_device **list)
+{
+ struct virt_device *proc_devs = NULL;
+ struct virt_device *proc_dev = NULL;
+ int ret;
+
+ ret = parse_devices(xml, &proc_devs, CIM_RES_TYPE_PROC);
+ if (ret <= 0)
+ return ret;
+
+ proc_dev = malloc(sizeof(*proc_dev));
+ if (proc_dev == NULL)
+ return 0;
+
+ memset(proc_dev, 0, sizeof(*proc_dev));
+
+ proc_dev->type = CIM_RES_TYPE_PROC;
+ proc_dev->id = strdup("proc");
+ proc_dev->dev.vcpu.quantity = proc_devs[0].dev.vcpu.quantity;
+ *list = proc_dev;
+
+ cleanup_virt_devices(&proc_devs, ret);
+
+ return 1;
+};
+
int get_devices(virDomainPtr dom, struct virt_device **list, int type)
{
char *xml;
@@ -683,6 +699,8 @@ int get_devices(virDomainPtr dom, struct
if (type == CIM_RES_TYPE_MEM)
ret = _get_mem_device(xml, list);
+ else if (type == CIM_RES_TYPE_PROC)
+ ret = _get_proc_device(xml, list);
else
ret = parse_devices(xml, list, type);
diff -r c949b1845113 -r d18a3d2d57a9 libxkutil/device_parsing.h
--- a/libxkutil/device_parsing.h Thu May 15 17:56:39 2008 -0700
+++ b/libxkutil/device_parsing.h Tue May 20 09:59:37 2008 -0400
@@ -50,7 +50,7 @@ struct mem_device {
};
struct vcpu_device {
- uint64_t number;
+ uint64_t quantity;
};
struct emu_device {
diff -r c949b1845113 -r d18a3d2d57a9 libxkutil/xml_parse_test.c
--- a/libxkutil/xml_parse_test.c Thu May 15 17:56:39 2008 -0700
+++ b/libxkutil/xml_parse_test.c Tue May 20 09:59:37 2008 -0400
@@ -96,7 +96,7 @@ static void print_dev_vcpu(struct virt_d
static void print_dev_vcpu(struct virt_device *dev,
FILE *d)
{
- print_u64(d, "Virtual CPU", dev->dev.vcpu.number);
+ print_u64(d, "Virtual CPU", dev->dev.vcpu.quantity);
}
static void print_dev_emu(struct virt_device *dev,
diff -r c949b1845113 -r d18a3d2d57a9 src/Virt_Device.c
--- a/src/Virt_Device.c Thu May 15 17:56:39 2008 -0700
+++ b/src/Virt_Device.c Tue May 20 09:59:37 2008 -0400
@@ -174,23 +174,6 @@ static CMPIInstance *mem_instance(const
return inst;
}
-static CMPIInstance *vcpu_instance(const CMPIBroker *broker,
- struct vcpu_device *dev,
- const virDomainPtr dom,
- const char *ns)
-{
- CMPIInstance *inst;
- virConnectPtr conn;
-
- conn = virDomainGetConnect(dom);
- inst = get_typed_instance(broker,
- pfx_from_conn(conn),
- "Processor",
- ns);
-
- return inst;
-}
-
static int device_set_devid(CMPIInstance *instance,
struct virt_device *dev,
const virDomainPtr dom)
@@ -229,43 +212,127 @@ static int device_set_systemname(CMPIIns
return 1;
}
-static CMPIInstance *device_instance(const CMPIBroker *broker,
- struct virt_device *dev,
- const virDomainPtr dom,
- const char *ns)
+static char *get_vcpu_inst_id(const virDomainPtr dom,
+ int proc_num)
{
- CMPIInstance *instance;
+ int rc;
+ char *id_num = NULL;
+ char *dev_id = NULL;
- if (dev->type == CIM_RES_TYPE_NET)
- instance = net_instance(broker,
- &dev->dev.net,
- dom,
- ns);
- else if (dev->type == CIM_RES_TYPE_DISK)
- instance = disk_instance(broker,
- &dev->dev.disk,
- dom,
- ns);
- else if (dev->type == CIM_RES_TYPE_MEM)
- instance = mem_instance(broker,
- &dev->dev.mem,
- dom,
- ns);
- else if (dev->type == CIM_RES_TYPE_PROC)
- instance = vcpu_instance(broker,
- &dev->dev.vcpu,
- dom,
- ns);
- else
- return NULL;
+ rc = asprintf(&id_num, "%d", proc_num);
+ if (rc == -1) {
+ free(dev_id);
+ dev_id = NULL;
+ goto out;
+ }
+
+ dev_id = get_fq_devid((char *)virDomainGetName(dom), id_num);
+ free(id_num);
- if (!instance)
- return NULL;
+ out:
+ return dev_id;
+}
- device_set_devid(instance, dev, dom);
- device_set_systemname(instance, dom);
+static bool vcpu_inst(const CMPIBroker *broker,
+ const virDomainPtr dom,
+ const char *ns,
+ int dev_id_num,
+ struct inst_list *list)
+{
+ char *dev_id;
+ CMPIInstance *inst;
+ virConnectPtr conn = NULL;
- return instance;
+ conn = virDomainGetConnect(dom);
+ inst = get_typed_instance(broker,
+ pfx_from_conn(conn),
+ "Processor",
+ ns);
+ if (inst == NULL)
+ return false;
+
+ dev_id = get_vcpu_inst_id(dom, dev_id_num);
+ CMSetProperty(inst, "DeviceID",
+ (CMPIValue *)dev_id, CMPI_chars);
+ free(dev_id);
+
+ device_set_systemname(inst, dom);
+ inst_list_add(list, inst);
+
+ return true;
+}
+
+static bool vcpu_instances(const CMPIBroker *broker,
+ const virDomainPtr dom,
+ const char *ns,
+ uint64_t proc_count,
+ struct inst_list *list)
+{
+ int i;
+ bool rc;
+
+ for (i = 0; i < proc_count; i++) {
+ rc = vcpu_inst(broker, dom, ns, i, list);
+ if (!rc)
+ return false;
+ }
+
+ return true;
+}
+
+static bool device_instances(const CMPIBroker *broker,
+ struct virt_device *devs,
+ int count,
+ const virDomainPtr dom,
+ const char *ns,
+ struct inst_list *list)
+{
+ int i;
+ bool ret;
+ uint64_t proc_count = 0;
+ CMPIInstance *instance = NULL;
+
+ for (i = 0; i < count; i++) {
+ struct virt_device *dev = &devs[i];
+
+ if (dev->type == CIM_RES_TYPE_NET)
+ instance = net_instance(broker,
+ &dev->dev.net,
+ dom,
+ ns);
+ else if (dev->type == CIM_RES_TYPE_DISK)
+ instance = disk_instance(broker,
+ &dev->dev.disk,
+ dom,
+ ns);
+ else if (dev->type == CIM_RES_TYPE_MEM)
+ instance = mem_instance(broker,
+ &dev->dev.mem,
+ dom,
+ ns);
+ else if (dev->type == CIM_RES_TYPE_PROC) {
+ proc_count = dev->dev.vcpu.quantity;
+ continue;
+ } else
+ return false;
+
+ if (!instance)
+ return false;
+
+ device_set_devid(instance, dev, dom);
+ device_set_systemname(instance, dom);
+ inst_list_add(list, instance);
+ }
+
+ if (proc_count) {
+ ret = vcpu_instances(broker,
+ dom,
+ ns,
+ proc_count,
+ list);
+ }
+
+ return true;
}
uint16_t res_type_from_device_classname(const char *classname)
@@ -290,25 +357,27 @@ static CMPIStatus _get_devices(const CMP
{
CMPIStatus s = {CMPI_RC_OK, NULL};
int count;
- int i;
+ bool rc;
struct virt_device *devs = NULL;
count = get_devices(dom, &devs, type);
if (count <= 0)
goto out;
- for (i = 0; i < count; i++) {
- CMPIInstance *dev = NULL;
+ rc = device_instances(broker,
+ devs,
+ count,
+ dom,
+ NAMESPACE(reference),
+ list);
- dev = device_instance(broker,
- &devs[i],
- dom,
- NAMESPACE(reference));
- if (dev)
- inst_list_add(list, dev);
+ if (!rc) {
+ cu_statusf(broker, &s,
+ CMPI_RC_ERR_FAILED,
+ "Couldn't get device instances");
+ }
- cleanup_virt_device(&devs[i]);
- }
+ cleanup_virt_devices(&devs, count);
out:
free(devs);
@@ -427,6 +496,29 @@ static int parse_devid(const char *devid
return 1;
}
+static int proc_dev_list(uint64_t quantity,
+ struct virt_device **list)
+{
+ int i;
+ int rc;
+
+
+ *list = (struct virt_device *)calloc(quantity,
+ sizeof(struct virt_device));
+
+ for (i = 0; i < quantity; i++) {
+ char *dev_num;
+
+ rc = asprintf(&dev_num, "%d", i);
+
+ (*list)[i].id = strdup(dev_num);
+
+ free(dev_num);
+ }
+
+ return quantity;
+}
+
static struct virt_device *find_dom_dev(virDomainPtr dom,
char *device,
int type)
@@ -439,6 +531,17 @@ static struct virt_device *find_dom_dev(
count = get_devices(dom, &list, type);
if (!count)
goto out;
+
+ if (type == CIM_RES_TYPE_PROC) {
+ struct virt_device *tmp_list;
+ int tmp_count;
+
+ tmp_count = proc_dev_list(list[0].dev.vcpu.quantity,
+ &tmp_list);
+ cleanup_virt_devices(&list, count);
+ list = tmp_list;
+ count = tmp_count;
+ }
for (i = 0; i < count; i++) {
if (STREQC(device, list[i].id))
@@ -462,10 +565,13 @@ CMPIStatus get_device_by_name(const CMPI
CMPIStatus s = {CMPI_RC_OK, NULL};
char *domain = NULL;
char *device = NULL;
- CMPIInstance *instance = NULL;
virConnectPtr conn = NULL;
virDomainPtr dom = NULL;
struct virt_device *dev = NULL;
+ struct inst_list tmp_list;
+ bool rc;
+
+ inst_list_init(&tmp_list);
conn = connect_by_classname(broker, CLASSNAME(reference), &s);
if (conn == NULL) {
@@ -501,13 +607,30 @@ CMPIStatus get_device_by_name(const CMPI
goto err;
}
- instance = device_instance(broker,
- dev,
- dom,
- NAMESPACE(reference));
+ if (type == CIM_RES_TYPE_PROC) {
+ int ret;
+ int dev_id_num;
+
+ ret = sscanf(dev->id, "%d", &dev_id_num);
+
+ rc = vcpu_inst(broker,
+ dom,
+ NAMESPACE(reference),
+ dev_id_num,
+ &tmp_list);
+ } else {
+
+ rc = device_instances(broker,
+ dev,
+ 1,
+ dom,
+ NAMESPACE(reference),
+ &tmp_list);
+ }
+
cleanup_virt_device(dev);
- *_inst = instance;
+ *_inst = tmp_list.list[0];
err:
virDomainFree(dom);
@@ -515,6 +638,7 @@ CMPIStatus get_device_by_name(const CMPI
free(device);
out:
+ inst_list_free(&tmp_list);
virConnectClose(conn);
return s;
diff -r c949b1845113 -r d18a3d2d57a9 src/Virt_RASD.c
--- a/src/Virt_RASD.c Thu May 15 17:56:39 2008 -0700
+++ b/src/Virt_RASD.c Tue May 20 09:59:37 2008 -0400
@@ -31,7 +31,6 @@
#include <libcmpiutil/libcmpiutil.h>
#include <libcmpiutil/std_instance.h>
-#include "device_parsing.h"
#include "misc_util.h"
#include "cs_util.h"
@@ -56,10 +55,10 @@ static struct virt_device *_find_dev(str
return NULL;
}
-static int list_devs(virConnectPtr conn,
- const uint16_t type,
- const char *host,
- struct virt_device **list)
+int list_devs(virConnectPtr conn,
+ const uint16_t type,
+ const char *host,
+ struct virt_device **list)
{
virDomainPtr dom;
@@ -173,10 +172,8 @@ static CMPIInstance *rasd_from_vdev(cons
CMSetProperty(inst, "Limit",
(CMPIValue *)&dev->dev.mem.maxsize, CMPI_uint64);
} else if (dev->type == CIM_RES_TYPE_PROC) {
- /* This would be the place to set the virtualquantity. */
- uint64_t quantity = dev->dev.vcpu.number + 1;
CMSetProperty(inst, "VirtualQuantity",
- (CMPIValue *)&quantity, CMPI_uint64);
+ (CMPIValue *)&dev->dev.vcpu.quantity, CMPI_uint64);
}
/* FIXME: Put the HostResource in place */
diff -r c949b1845113 -r d18a3d2d57a9 src/Virt_RASD.h
--- a/src/Virt_RASD.h Thu May 15 17:56:39 2008 -0700
+++ b/src/Virt_RASD.h Tue May 20 09:59:37 2008 -0400
@@ -20,6 +20,8 @@
*/
#ifndef __VIRT_RASD_H
#define __VIRT_RASD_H
+
+#include "device_parsing.h"
char *rasd_to_xml(CMPIInstance *rasd);
@@ -55,6 +57,10 @@ CMPIStatus get_rasd_by_ref(const CMPIBro
const char **properties,
CMPIInstance **_inst);
+int list_devs(virConnectPtr conn,
+ const uint16_t type,
+ const char *host,
+ struct virt_device **list);
#endif
/*
diff -r c949b1845113 -r d18a3d2d57a9 src/Virt_SettingsDefineState.c
--- a/src/Virt_SettingsDefineState.c Thu May 15 17:56:39 2008 -0700
+++ b/src/Virt_SettingsDefineState.c Tue May 20 09:59:37 2008 -0400
@@ -39,13 +39,95 @@
const static CMPIBroker *_BROKER;
+static int get_proc_dev_count(const char *name,
+ const char *cn,
+ uint16_t type,
+ char *host,
+ CMPIStatus *s)
+{
+ virConnectPtr conn = NULL;
+ struct virt_device *list = NULL;
+ struct virt_device *dev = NULL;
+ int dev_count = -1;
+ int count = -1;
+
+ conn = connect_by_classname(_BROKER, cn, s);
+ if (conn == NULL) {
+ cu_statusf(_BROKER, s,
+ CMPI_RC_ERR_NOT_FOUND,
+ "No such instance (%s)",
+ name);
+ goto out;
+ }
+
+ dev_count = list_devs(conn, type, host, &list);
+ if (dev_count <= 0) {
+ cu_statusf(_BROKER, s,
+ CMPI_RC_ERR_FAILED,
+ "Unable to get list of processors");
+ goto out;
+ }
+
+ dev = &list[0];
+ count = dev->dev.vcpu.quantity;
+
+ cleanup_virt_devices(&list, dev_count);
+
+ out:
+ virConnectClose(conn);
+ return count;
+}
+
+static char *get_rasd_id(const CMPIInstance *inst, uint16_t type)
+{
+ char *id = NULL;
+ int ret;
+ const char *tmp;
+
+ if (type == CIM_RES_TYPE_PROC) {
+ ret = cu_get_str_prop(inst, "SystemName", &tmp);
+ if (ret != CMPI_RC_OK) {
+ CU_DEBUG("No SystemName in device instance");
+ goto out;
+ }
+
+ ret = asprintf(&id, "%s/proc", tmp);
+ if (ret == -1) {
+ id = NULL;
+ goto out;
+ }
+ } else {
+ ret = cu_get_str_prop(inst, "DeviceID", &tmp);
+ if (ret != CMPI_RC_OK) {
+ CU_DEBUG("No DeviceID in device instance");
+ id = NULL;
+ goto out;
+ }
+
+ id = strdup(tmp);
+ }
+
+ out:
+ return id;
+}
+
+static char *get_dev_id(const char *host, int devid)
+{
+ char *id = NULL;
+
+ if (asprintf(&id, "%s/%d", host, devid) == -1)
+ id = NULL;
+
+ return id;
+}
+
static CMPIStatus dev_to_rasd(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 *id = NULL;
if (!match_hypervisor_prefix(ref, info))
return s;
@@ -54,16 +136,18 @@ static CMPIStatus dev_to_rasd(const CMPI
if (s.rc != CMPI_RC_OK)
goto out;
- if (cu_get_str_path(ref, "DeviceID", &name) != CMPI_RC_OK) {
+ id = get_rasd_id(inst,
+ res_type_from_device_classname(CLASSNAME(ref)));
+ if (id == NULL) {
cu_statusf(_BROKER, &s,
- CMPI_RC_ERR_FAILED,
- "Missing DeviceID");
+ CMPI_RC_ERR_NOT_FOUND,
+ "Unable to get RASD id from DeviceID");
goto out;
- }
+ }
s = get_rasd_by_name(_BROKER,
ref,
- name,
+ id,
res_type_from_device_classname(CLASSNAME(ref)),
NULL,
&inst);
@@ -73,6 +157,7 @@ static CMPIStatus dev_to_rasd(const CMPI
inst_list_add(list, inst);
out:
+ free(id);
return s;
}
@@ -83,7 +168,12 @@ static CMPIStatus rasd_to_dev(const CMPI
CMPIStatus s = {CMPI_RC_OK, NULL};
CMPIInstance *inst = NULL;
const char *name = NULL;
+ char *host = NULL;
+ char *devid = NULL;
+ char *id = NULL;
uint16_t type;
+ int count = 1;
+ int i;
if (!match_hypervisor_prefix(ref, info))
return s;
@@ -92,6 +182,13 @@ static CMPIStatus rasd_to_dev(const CMPI
if (s.rc != CMPI_RC_OK)
goto out;
+ if (res_type_from_rasd_classname(CLASSNAME(ref), &type) != CMPI_RC_OK) {
+ cu_statusf(_BROKER, &s,
+ CMPI_RC_ERR_FAILED,
+ "Missing ResourceType");
+ goto out;
+ }
+
if (cu_get_str_path(ref, "InstanceID", &name) != CMPI_RC_OK) {
cu_statusf(_BROKER, &s,
CMPI_RC_ERR_FAILED,
@@ -99,20 +196,48 @@ static CMPIStatus rasd_to_dev(const CMPI
goto out;
}
- if (res_type_from_rasd_classname(CLASSNAME(ref), &type) != CMPI_RC_OK) {
- cu_statusf(_BROKER, &s,
- CMPI_RC_ERR_FAILED,
- "Missing ResourceType");
- goto out;
+ if (type == CIM_RES_TYPE_PROC) {
+ if (parse_fq_devid((char *)name, &host, &devid) != 1) {
+ cu_statusf(_BROKER, &s,
+ CMPI_RC_ERR_NOT_FOUND,
+ "No such instance (%s)",
+ name);
+ goto out;
+ }
+
+ count = get_proc_dev_count(name,
+ CLASSNAME(ref),
+ type,
+ host,
+ &s);
+ if (count <= 0)
+ goto out;
}
- s = get_device_by_name(_BROKER, ref, name, type, &inst);
- if (s.rc != CMPI_RC_OK)
- goto out;
+ for (i = 0; i < count; i++) {
+ if (type == CIM_RES_TYPE_PROC)
+ id = get_dev_id(host, i);
+ else
+ id = strdup(name);
- inst_list_add(list, inst);
+ if (id == NULL) {
+ cu_statusf(_BROKER, &s,
+ CMPI_RC_ERR_NOT_FOUND,
+ "Unable to get RASD id from DeviceID");
+ goto out;
+ }
+
+ s = get_device_by_name(_BROKER, ref, id, type, &inst);
+ if (s.rc != CMPI_RC_OK)
+ goto out;
+
+ inst_list_add(list, inst);
+ }
out:
+ free(id);
+ free(host);
+ free(devid);
return s;
}
16 years, 5 months
[PATCH] (#2) ProcessorRASD, the class that won't go away
by Jay Gagnon
# HG changeset patch
# User Jay Gagnon <grendel(a)linux.vnet.ibm.com>
# Date 1211234740 14400
# Node ID d9042b4ea61771df5110e97872c9e504f71859e7
# Parent c949b1845113e11e01329abb5aa81ca6ade8e3ec
(#2) ProcessorRASD, the class that won't go away
Around and round we go on the merry-go-round of indecision, hopefully for our last ride. The definitely probably absolutely tentative final plan is that the default representation of processors as virt_device structs will be one per domain, with a quantity. Virt_Devices will just need to be told how to handle that, and all the RASD stuff will be much happier for it. And then we will never speak of this again.
So today being my last official day on the team, I kind of have to get this out in a not perfect state. From what I can see it does what it is supposed to do, but it is entirely possible (likely?) that there are a few things in here that aren't really great things to do. I wish I could polish it more but I think I've at least got it to the point where any work left to be done is generic "not a great idea in C" problems, as opposed to the much more annoying "what exactly are we supposed to do in this case" problems.
Changes from 1 to 2:
Close brace on if block. That one is really embarrassing; I have no idea what happened there. I mean that crap won't even compile.
Removed unnecessary proc_found boolean. That was me being lazy after changing my mind on something.
Cleaned up a couple leftover CU_DEBUG calls.
Addition of vcpu_inst function, which is similar to vcpu_instances but always only works on one instance and takes a dev_id. This is to prevent all instances from being given a dev_id of zero. It is unfortunately similar to vcpu_instances in other regards, but I'm not sure if it's worth the overhead of trying to combine the similar parts.
Fixed quantity v number problem in xml_parse_test that I appear to have been failing to address for about six years.
Signed-off-by: Jay Gagnon <grendel(a)linux.vnet.ibm.com>
Signed-off-by: Kaitlin Rupert <karupert(a)us.ibm.com>
Signed-off-by: Dan Smith <danms(a)us.ibm.com>
diff -r c949b1845113 -r d9042b4ea617 libxkutil/device_parsing.c
--- a/libxkutil/device_parsing.c Thu May 15 17:56:39 2008 -0700
+++ b/libxkutil/device_parsing.c Mon May 19 18:05:40 2008 -0400
@@ -337,7 +337,6 @@ static int parse_vcpu_device(xmlNode *no
struct virt_device *list = NULL;
char *count_str;
int count;
- int i;
count_str = get_node_content(node);
if (count_str == NULL)
@@ -347,24 +346,15 @@ static int parse_vcpu_device(xmlNode *no
free(count_str);
- list = calloc(count, sizeof(*list));
+ list = calloc(1, sizeof(*list));
if (list == NULL)
goto err;
-
- for (i = 0; i < count; i++) {
- struct virt_device *vdev = &list[i];
- struct vcpu_device *cdev = &vdev->dev.vcpu;
-
- cdev->number = i;
-
- vdev->type = CIM_RES_TYPE_PROC;
- if (asprintf(&vdev->id, "%i", i) == -1)
- vdev->id = NULL;
- }
+
+ list->dev.vcpu.quantity = count;
*vdevs = list;
- return count;
+ return 1;
err:
free(list);
@@ -620,7 +610,7 @@ struct virt_device *virt_device_dup(stru
dev->dev.mem.size = _dev->dev.mem.size;
dev->dev.mem.maxsize = _dev->dev.mem.maxsize;
} else if (dev->type == CIM_RES_TYPE_PROC) {
- dev->dev.vcpu.number = _dev->dev.vcpu.number;
+ dev->dev.vcpu.quantity = _dev->dev.vcpu.quantity;
} else if (dev->type == CIM_RES_TYPE_EMU) {
DUP_FIELD(dev, _dev, dev.emu.path);
} else if (dev->type == CIM_RES_TYPE_GRAPHICS) {
@@ -672,6 +662,32 @@ static int _get_mem_device(const char *x
return 1;
}
+static int _get_proc_device(const char *xml, struct virt_device **list)
+{
+ struct virt_device *proc_devs = NULL;
+ struct virt_device *proc_dev = NULL;
+ int ret;
+
+ ret = parse_devices(xml, &proc_devs, CIM_RES_TYPE_PROC);
+ if (ret <= 0)
+ return ret;
+
+ proc_dev = malloc(sizeof(*proc_dev));
+ if (proc_dev == NULL)
+ return 0;
+
+ memset(proc_dev, 0, sizeof(*proc_dev));
+
+ proc_dev->type = CIM_RES_TYPE_PROC;
+ proc_dev->id = strdup("proc");
+ proc_dev->dev.vcpu.quantity = proc_devs[0].dev.vcpu.quantity;
+ *list = proc_dev;
+
+ cleanup_virt_devices(&proc_devs, ret);
+
+ return 1;
+};
+
int get_devices(virDomainPtr dom, struct virt_device **list, int type)
{
char *xml;
@@ -683,6 +699,8 @@ int get_devices(virDomainPtr dom, struct
if (type == CIM_RES_TYPE_MEM)
ret = _get_mem_device(xml, list);
+ else if (type == CIM_RES_TYPE_PROC)
+ ret = _get_proc_device(xml, list);
else
ret = parse_devices(xml, list, type);
diff -r c949b1845113 -r d9042b4ea617 libxkutil/device_parsing.h
--- a/libxkutil/device_parsing.h Thu May 15 17:56:39 2008 -0700
+++ b/libxkutil/device_parsing.h Mon May 19 18:05:40 2008 -0400
@@ -50,7 +50,7 @@ struct mem_device {
};
struct vcpu_device {
- uint64_t number;
+ uint64_t quantity;
};
struct emu_device {
diff -r c949b1845113 -r d9042b4ea617 libxkutil/xml_parse_test.c
--- a/libxkutil/xml_parse_test.c Thu May 15 17:56:39 2008 -0700
+++ b/libxkutil/xml_parse_test.c Mon May 19 18:05:40 2008 -0400
@@ -96,7 +96,7 @@ static void print_dev_vcpu(struct virt_d
static void print_dev_vcpu(struct virt_device *dev,
FILE *d)
{
- print_u64(d, "Virtual CPU", dev->dev.vcpu.number);
+ print_u64(d, "Virtual CPU", dev->dev.vcpu.quantity);
}
static void print_dev_emu(struct virt_device *dev,
diff -r c949b1845113 -r d9042b4ea617 src/Virt_Device.c
--- a/src/Virt_Device.c Thu May 15 17:56:39 2008 -0700
+++ b/src/Virt_Device.c Mon May 19 18:05:40 2008 -0400
@@ -174,23 +174,6 @@ static CMPIInstance *mem_instance(const
return inst;
}
-static CMPIInstance *vcpu_instance(const CMPIBroker *broker,
- struct vcpu_device *dev,
- const virDomainPtr dom,
- const char *ns)
-{
- CMPIInstance *inst;
- virConnectPtr conn;
-
- conn = virDomainGetConnect(dom);
- inst = get_typed_instance(broker,
- pfx_from_conn(conn),
- "Processor",
- ns);
-
- return inst;
-}
-
static int device_set_devid(CMPIInstance *instance,
struct virt_device *dev,
const virDomainPtr dom)
@@ -229,43 +212,141 @@ static int device_set_systemname(CMPIIns
return 1;
}
-static CMPIInstance *device_instance(const CMPIBroker *broker,
- struct virt_device *dev,
- const virDomainPtr dom,
- const char *ns)
+static char *get_vcpu_inst_id(const virDomainPtr dom,
+ int proc_num)
{
- CMPIInstance *instance;
+ int rc;
+ char *id_num = NULL;
+ char *dev_id = NULL;
- if (dev->type == CIM_RES_TYPE_NET)
- instance = net_instance(broker,
- &dev->dev.net,
- dom,
- ns);
- else if (dev->type == CIM_RES_TYPE_DISK)
- instance = disk_instance(broker,
- &dev->dev.disk,
- dom,
- ns);
- else if (dev->type == CIM_RES_TYPE_MEM)
- instance = mem_instance(broker,
- &dev->dev.mem,
- dom,
- ns);
- else if (dev->type == CIM_RES_TYPE_PROC)
- instance = vcpu_instance(broker,
- &dev->dev.vcpu,
- dom,
- ns);
- else
- return NULL;
+ rc = asprintf(&id_num, "%d", proc_num);
+ if (rc == -1) {
+ free(dev_id);
+ dev_id = NULL;
+ goto out;
+ }
+
+ dev_id = get_fq_devid((char *)virDomainGetName(dom), id_num);
+ free(id_num);
- if (!instance)
- return NULL;
+ out:
+ return dev_id;
+}
- device_set_devid(instance, dev, dom);
- device_set_systemname(instance, dom);
+static bool vcpu_instances(const CMPIBroker *broker,
+ const virDomainPtr dom,
+ const char *ns,
+ uint64_t proc_count,
+ struct inst_list *list)
+{
+ int i;
+ char *dev_id;
+ CMPIInstance *inst;
+ virConnectPtr conn = NULL;
- return instance;
+ for (i = 0; i < proc_count; i++) {
+ conn = virDomainGetConnect(dom);
+ inst = get_typed_instance(broker,
+ pfx_from_conn(conn),
+ "Processor",
+ ns);
+ if (inst == NULL)
+ return false;
+
+ dev_id = get_vcpu_inst_id(dom, i);
+ CMSetProperty(inst, "DeviceID",
+ (CMPIValue *)dev_id, CMPI_chars);
+ free(dev_id);
+
+ device_set_systemname(inst, dom);
+ inst_list_add(list, inst);
+ }
+
+ return true;
+}
+
+static bool vcpu_inst(const CMPIBroker *broker,
+ const virDomainPtr dom,
+ const char *ns,
+ int dev_id_num,
+ struct inst_list *list)
+{
+ char *dev_id;
+ CMPIInstance *inst;
+ virConnectPtr conn = NULL;
+
+ conn = virDomainGetConnect(dom);
+ inst = get_typed_instance(broker,
+ pfx_from_conn(conn),
+ "Processor",
+ ns);
+ if (inst == NULL)
+ return false;
+
+ dev_id = get_vcpu_inst_id(dom, dev_id_num);
+ CMSetProperty(inst, "DeviceID",
+ (CMPIValue *)dev_id, CMPI_chars);
+ free(dev_id);
+
+ device_set_systemname(inst, dom);
+ inst_list_add(list, inst);
+
+ return true;
+}
+
+static bool device_instances(const CMPIBroker *broker,
+ struct virt_device *devs,
+ int count,
+ const virDomainPtr dom,
+ const char *ns,
+ struct inst_list *list)
+{
+ int i;
+ bool ret;
+ uint64_t proc_count = 0;
+ CMPIInstance *instance = NULL;
+
+ for (i = 0; i < count; i++) {
+ struct virt_device *dev = &devs[i];
+
+ if (dev->type == CIM_RES_TYPE_NET)
+ instance = net_instance(broker,
+ &dev->dev.net,
+ dom,
+ ns);
+ else if (dev->type == CIM_RES_TYPE_DISK)
+ instance = disk_instance(broker,
+ &dev->dev.disk,
+ dom,
+ ns);
+ else if (dev->type == CIM_RES_TYPE_MEM)
+ instance = mem_instance(broker,
+ &dev->dev.mem,
+ dom,
+ ns);
+ else if (dev->type == CIM_RES_TYPE_PROC) {
+ proc_count = dev->dev.vcpu.quantity;
+ continue;
+ } else
+ return false;
+
+ if (!instance)
+ return false;
+
+ device_set_devid(instance, dev, dom);
+ device_set_systemname(instance, dom);
+ inst_list_add(list, instance);
+ }
+
+ if (proc_count) {
+ ret = vcpu_instances(broker,
+ dom,
+ ns,
+ proc_count,
+ list);
+ }
+
+ return true;
}
uint16_t res_type_from_device_classname(const char *classname)
@@ -290,25 +371,27 @@ static CMPIStatus _get_devices(const CMP
{
CMPIStatus s = {CMPI_RC_OK, NULL};
int count;
- int i;
+ bool rc;
struct virt_device *devs = NULL;
count = get_devices(dom, &devs, type);
if (count <= 0)
goto out;
- for (i = 0; i < count; i++) {
- CMPIInstance *dev = NULL;
+ rc = device_instances(broker,
+ devs,
+ count,
+ dom,
+ NAMESPACE(reference),
+ list);
- dev = device_instance(broker,
- &devs[i],
- dom,
- NAMESPACE(reference));
- if (dev)
- inst_list_add(list, dev);
+ if (!rc) {
+ cu_statusf(broker, &s,
+ CMPI_RC_ERR_FAILED,
+ "Couldn't get device instances");
+ }
- cleanup_virt_device(&devs[i]);
- }
+ cleanup_virt_devices(&devs, count);
out:
free(devs);
@@ -427,6 +510,29 @@ static int parse_devid(const char *devid
return 1;
}
+static int proc_dev_list(uint64_t quantity,
+ struct virt_device **list)
+{
+ int i;
+ int rc;
+
+
+ *list = (struct virt_device *)calloc(quantity,
+ sizeof(struct virt_device));
+
+ for (i = 0; i < quantity; i++) {
+ char *dev_num;
+
+ rc = asprintf(&dev_num, "%d", i);
+
+ (*list)[i].id = strdup(dev_num);
+
+ free(dev_num);
+ }
+
+ return quantity;
+}
+
static struct virt_device *find_dom_dev(virDomainPtr dom,
char *device,
int type)
@@ -439,6 +545,17 @@ static struct virt_device *find_dom_dev(
count = get_devices(dom, &list, type);
if (!count)
goto out;
+
+ if (type == CIM_RES_TYPE_PROC) {
+ struct virt_device *tmp_list;
+ int tmp_count;
+
+ tmp_count = proc_dev_list(list[0].dev.vcpu.quantity,
+ &tmp_list);
+ cleanup_virt_devices(&list, count);
+ list = tmp_list;
+ count = tmp_count;
+ }
for (i = 0; i < count; i++) {
if (STREQC(device, list[i].id))
@@ -462,10 +579,13 @@ CMPIStatus get_device_by_name(const CMPI
CMPIStatus s = {CMPI_RC_OK, NULL};
char *domain = NULL;
char *device = NULL;
- CMPIInstance *instance = NULL;
virConnectPtr conn = NULL;
virDomainPtr dom = NULL;
struct virt_device *dev = NULL;
+ struct inst_list tmp_list;
+ bool rc;
+
+ inst_list_init(&tmp_list);
conn = connect_by_classname(broker, CLASSNAME(reference), &s);
if (conn == NULL) {
@@ -501,13 +621,30 @@ CMPIStatus get_device_by_name(const CMPI
goto err;
}
- instance = device_instance(broker,
- dev,
- dom,
- NAMESPACE(reference));
+ if (type == CIM_RES_TYPE_PROC) {
+ int ret;
+ int dev_id_num;
+
+ ret = sscanf(dev->id, "%d", &dev_id_num);
+
+ rc = vcpu_inst(broker,
+ dom,
+ NAMESPACE(reference),
+ dev_id_num,
+ &tmp_list);
+ } else {
+
+ rc = device_instances(broker,
+ dev,
+ 1,
+ dom,
+ NAMESPACE(reference),
+ &tmp_list);
+ }
+
cleanup_virt_device(dev);
- *_inst = instance;
+ *_inst = tmp_list.list[0];
err:
virDomainFree(dom);
@@ -515,6 +652,7 @@ CMPIStatus get_device_by_name(const CMPI
free(device);
out:
+ inst_list_free(&tmp_list);
virConnectClose(conn);
return s;
diff -r c949b1845113 -r d9042b4ea617 src/Virt_RASD.c
--- a/src/Virt_RASD.c Thu May 15 17:56:39 2008 -0700
+++ b/src/Virt_RASD.c Mon May 19 18:05:40 2008 -0400
@@ -173,10 +173,8 @@ static CMPIInstance *rasd_from_vdev(cons
CMSetProperty(inst, "Limit",
(CMPIValue *)&dev->dev.mem.maxsize, CMPI_uint64);
} else if (dev->type == CIM_RES_TYPE_PROC) {
- /* This would be the place to set the virtualquantity. */
- uint64_t quantity = dev->dev.vcpu.number + 1;
CMSetProperty(inst, "VirtualQuantity",
- (CMPIValue *)&quantity, CMPI_uint64);
+ (CMPIValue *)&dev->dev.vcpu.quantity, CMPI_uint64);
}
/* FIXME: Put the HostResource in place */
16 years, 5 months
[PATCH] [TEST]Fixing 03_hs_to_settdefcap.py tc to accomadate the ValueRole/ValueRange changes in RASDs
by Deepti B. Kalakeri
# HG changeset patch
# User Deepti B. Kalakeri <deeptik(a)linux.vnet.ibm.com>
# Date 1211219013 25200
# Node ID 509c5b7c0923e1b56defa1f9f9bf04e20703d6e1
# Parent 1650b84084a49965c2088f56248d6018b470e60c
[TEST]Fixing 03_hs_to_settdefcap.py tc to accomadate the ValueRole/ValueRange changes in RASDs.
Tested with KVM, XenFV, Xen with latest and rpm libvirt-cim.
Signed-off-by: Deepti B. Kalakeri <deeptik(a)linux.vnet.ibm.com>
diff -r 1650b84084a4 -r 509c5b7c0923 suites/libvirt-cim/cimtest/HostSystem/03_hs_to_settdefcap.py
--- a/suites/libvirt-cim/cimtest/HostSystem/03_hs_to_settdefcap.py Mon May 19 09:31:22 2008 -0700
+++ b/suites/libvirt-cim/cimtest/HostSystem/03_hs_to_settdefcap.py Mon May 19 10:43:33 2008 -0700
@@ -48,11 +48,13 @@ from CimTest.Globals import logger, CIM_
from CimTest.Globals import logger, CIM_ERROR_ASSOCIATORNAMES, do_main
from CimTest.ReturnCodes import PASS, FAIL
from XenKvmLib.test_xml import testxml
-from XenKvmLib.test_doms import test_domain_function, destroy_and_undefine_all
+from XenKvmLib.test_doms import destroy_and_undefine_all
+from XenKvmLib.const import CIM_REV
sup_types = ['Xen', 'KVM', 'XenFV']
test_dom = "domgst"
test_vcpus = 1
+libvirtcim_sdc_rasd_rev = 571
def setup_env(server, virt="Xen"):
status = PASS
@@ -64,7 +66,7 @@ def setup_env(server, virt="Xen"):
logger.error("Failed to define the dom: %s", test_dom)
status = FAIL
- return status
+ return status, vsxml
def print_err(err, detail, cn):
logger.error(err % cn)
@@ -154,7 +156,7 @@ def get_alloccap(server, devpool, virt="
'%s_MemoryPool' % virt : 4,
'%s_DiskPool' % virt : 17 ,
'%s_NetworkPool' % virt : 10 }
-
+
for inst in devpool:
try:
assoc_info = Associators(server,
@@ -240,22 +242,26 @@ def check_rasd_vals(inst, cn, rt, rangel
if inst['ResourceType'] != rt:
logger.error("In ResourceType for %s " % rt)
return FAIL
+
+ # The following properties have been removed in the patchset 571
+ # but is present in the rpm libvirt-cim and hence retained it.
- ppolicy = inst['PropertyPolicy']
- if ppolicy != 0 and ppolicy != 1:
- logger.error("In PropertyPolicy for %s " % ppolicy)
- return FAIL
+ if CIM_REV < libvirtcim_sdc_rasd_rev:
+ ppolicy = inst['PropertyPolicy']
+ if ppolicy != 0 and ppolicy != 1:
+ logger.error("In PropertyPolicy for %s " % ppolicy)
+ return FAIL
- vrole = inst['ValueRole']
- if vrole < 0 or vrole > 4:
- logger.error("In ValueRole %s " % vrole)
- return FAIL
+ vrole = inst['ValueRole']
+ if vrole < 0 or vrole > 4:
+ logger.error("In ValueRole %s " % vrole)
+ return FAIL
- insid = inst['InstanceID']
- vrange = rangelist[insid]
- if vrange != inst['ValueRange']:
- logger.error("In ValueRange for %s " % vrange)
- return FAIL
+ insid = inst['InstanceID']
+ vrange = rangelist[insid]
+ if vrange != inst['ValueRange']:
+ logger.error("In ValueRange for %s " % vrange)
+ return FAIL
except Exception, detail:
logger.error("Error checking RASD attribute values %s" % detail)
@@ -263,40 +269,40 @@ def check_rasd_vals(inst, cn, rt, rangel
return PASS
-def clean_up(server, status):
- """
- Removing the guest and returning status
- """
- test_domain_function(test_dom, server, "undefine")
- sys.exit(status)
-
@do_main(sup_types)
def main():
options = main.options
status = PASS
- if options.virt == 'XenFV':
- options.virt = 'Xen'
+ server = options.ip
+ virt = options.virt
- status = setup_env(options.ip, options.virt)
+ if virt == 'XenFV':
+ virt = 'Xen'
+
+ status, vsxml = setup_env(server, virt)
if status != PASS:
return status
- status, hs, clsname = get_hostsys(options.ip, options.virt)
+ status, hs, clsname = get_hostsys(server, virt)
if status != PASS or hs == None:
- clean_up(options.ip, status)
+ vsxml.undefine(server)
+ return status
- status, devpool = get_hostrespool(options.ip, hs, clsname, options.virt)
+ status, devpool = get_hostrespool(server, hs, clsname, virt)
if status != PASS or devpool == None:
- clean_up(options.ip, status)
+ vsxml.undefine(server)
+ return status
- status, alloccap = get_alloccap(options.ip, devpool, options.virt)
+ status, alloccap = get_alloccap(server, devpool, virt)
if status != PASS or alloccap == None:
- clean_up(options.ip, status)
+ vsxml.undefine(server)
+ return status
- status = get_rasddetails(options.ip, alloccap, options.virt)
+ status = get_rasddetails(server, alloccap, virt)
- clean_up(options.ip, status)
+ vsxml.undefine(server)
+ return status
if __name__ == "__main__":
sys.exit(main())
16 years, 5 months
[PATCH] [TEST]Fixing 01_memory.py tc to accomdate the memory changes
by Deepti B. Kalakeri
# HG changeset patch
# User Deepti B. Kalakeri <deeptik(a)linux.vnet.ibm.com>
# Date 1211214682 25200
# Node ID 1650b84084a49965c2088f56248d6018b470e60c
# Parent 80682d57c067810c97a92fce162c29dab2ea5451
[TEST]Fixing 01_memory.py tc to accomdate the memory changes.
Tested with KVM, XenFV, Xen with latest and rpm libvirt-cim.
Signed-off-by: Deepti B. Kalakeri <deeptik(a)linux.vnet.ibm.com>
diff -r 80682d57c067 -r 1650b84084a4 suites/libvirt-cim/cimtest/Memory/01_memory.py
--- a/suites/libvirt-cim/cimtest/Memory/01_memory.py Mon May 19 08:36:16 2008 -0700
+++ b/suites/libvirt-cim/cimtest/Memory/01_memory.py Mon May 19 09:31:22 2008 -0700
@@ -31,11 +31,13 @@ from XenKvmLib.vxml import XenXML, KVMXM
from XenKvmLib.vxml import XenXML, KVMXML, get_class
from CimTest.Globals import logger
from CimTest.Globals import do_main
+from XenKvmLib.const import CIM_REV
sup_types = ['Xen', 'KVM', 'XenFV']
test_dom = "test_domain"
mem = 256 #MB
+mem_change_version=585
@do_main(sup_types)
def main():
@@ -43,7 +45,11 @@ def main():
vsxml = get_class(options.virt)(test_dom, mem)
vsxml.define(options.ip)
-
+ if CIM_REV >= mem_change_version:
+ alloc_mem = int(vsxml.xml_get_mem())
+ else:
+ alloc_mem = int(vsxml.xml_get_mem())/1024
+
devid = "%s/mem" % test_dom
key_list = { 'DeviceID' : devid,
'CreationClassName' : get_typed_class(options.virt, "Memory"),
@@ -60,8 +66,8 @@ def main():
capacity = dev.ConsumableBlocks * dev.BlockSize / 1024
- if capacity != mem:
- logger.error("Capacity should be %i MB instead of %i MB" % (mem, capacity))
+ if capacity != alloc_mem:
+ logger.error("Capacity should be %i MB instead of %i MB" % (alloc_mem, capacity))
status = 1
if status == 0:
16 years, 5 months
[PATCH] [TEST] #2 Updating the cleanup_restore() function call in the tc to pass the server and virt parameters
by Deepti B. Kalakeri
# HG changeset patch
# User Deepti B. Kalakeri <deeptik(a)linux.vnet.ibm.com>
# Date 1211211376 25200
# Node ID 80682d57c067810c97a92fce162c29dab2ea5451
# Parent d013f73cf783cac1b458cec6dbc0c0308786f1e9
[TEST] #2 Updating the cleanup_restore() function call in the tc to pass the server and virt parameters.
Signed-off-by: Deepti B. Kalakeri <deeptik(a)linux.vnet.ibm.com>
diff -r d013f73cf783 -r 80682d57c067 suites/libvirt-cim/cimtest/AllocationCapabilities/02_alloccap_gi_errs.py
--- a/suites/libvirt-cim/cimtest/AllocationCapabilities/02_alloccap_gi_errs.py Thu May 15 06:07:17 2008 -0700
+++ b/suites/libvirt-cim/cimtest/AllocationCapabilities/02_alloccap_gi_errs.py Mon May 19 08:36:16 2008 -0700
@@ -76,6 +76,7 @@ def main():
options = main.options
server = options.ip
+ virt = options.virt
# Verify DiskPool on machine
status = create_diskpool_file()
if status != PASS:
@@ -130,7 +131,7 @@ def main():
status = ret_value
if status != PASS:
break
- cleanup_restore()
+ cleanup_restore(server, virt)
return status
if __name__ == "__main__":
sys.exit(main())
diff -r d013f73cf783 -r 80682d57c067 suites/libvirt-cim/cimtest/ElementAllocatedFromPool/03_reverse_errs.py
--- a/suites/libvirt-cim/cimtest/ElementAllocatedFromPool/03_reverse_errs.py Thu May 15 06:07:17 2008 -0700
+++ b/suites/libvirt-cim/cimtest/ElementAllocatedFromPool/03_reverse_errs.py Mon May 19 08:36:16 2008 -0700
@@ -170,9 +170,9 @@ def err_invalid_keyvalue():
break
return status
-def clean_and_exit(server, msg):
+def clean_and_exit(server, virt, msg):
logger.error("------FAILED: Invalid %s.------", msg)
- cleanup_restore()
+ cleanup_restore(server, virt)
vsxml.undefine(server)
@do_main(platform_sup)
@@ -207,20 +207,20 @@ def main():
assoc_classname = get_typed_class(virt, "ElementAllocatedFromPool")
ret = err_invalid_keyname()
if ret != PASS:
- clean_and_exit(options.ip, "KeyName")
+ clean_and_exit(options.ip, virt, "KeyName")
return ret
ret = err_invalid_keyvalue()
if ret != PASS:
- clean_and_exit(options.ip, "KeyValue")
+ clean_and_exit(options.ip, virt, "KeyValue")
return ret
ret = err_invalid_ccname()
if ret != PASS:
- clean_and_exit(options.ip, "CCName")
+ clean_and_exit(options.ip, virt, "CCName")
return ret
- cleanup_restore()
+ cleanup_restore(options.ip, virt)
vsxml.undefine(options.ip)
return PASS
if __name__ == "__main__":
diff -r d013f73cf783 -r 80682d57c067 suites/libvirt-cim/cimtest/ElementAllocatedFromPool/04_forward_errs.py
--- a/suites/libvirt-cim/cimtest/ElementAllocatedFromPool/04_forward_errs.py Thu May 15 06:07:17 2008 -0700
+++ b/suites/libvirt-cim/cimtest/ElementAllocatedFromPool/04_forward_errs.py Mon May 19 08:36:16 2008 -0700
@@ -477,9 +477,9 @@ def err_invalid_syscreationclassname_key
return try_assoc(conn, exp_ret, test_dom, test_keys, test_vals, log_msg)
-def clean_and_exit(server, msg):
+def clean_and_exit(server, virt, msg):
logger.error("------FAILED: Invalid %s.------", msg)
- cleanup_restore()
+ cleanup_restore(server, virt)
vsxml.undefine(server)
@do_main(platform_sup)
@@ -519,50 +519,50 @@ def main():
ret = err_invalid_sysname_keyname(conn, exp_list[0])
if ret != PASS:
- clean_and_exit(options.ip, "SystemName KeyName")
+ clean_and_exit(options.ip, virt, "SystemName KeyName")
return ret
ret = err_invalid_sysname_keyvalue(conn, exp_list[0])
if ret != PASS:
- clean_and_exit(options.ip, "SystemName Key Value")
+ clean_and_exit(options.ip, virt, "SystemName Key Value")
return ret
ret = err_invalid_devid_keyname(conn, exp_list[1])
if ret != PASS:
- clean_and_exit(options.ip, "DeviceID Keyname")
+ clean_and_exit(options.ip, virt, "DeviceID Keyname")
return ret
ret = err_invalid_devid_keyvalue(conn, exp_list[2])
if ret != PASS:
- clean_and_exit(options.ip, "DeviceID Keyvalue")
+ clean_and_exit(options.ip, virt, "DeviceID Keyvalue")
return ret
ret = err_invalid_classname(conn, exp_list[3])
if ret != PASS:
- clean_and_exit(options.ip, "classname Keyname")
+ clean_and_exit(options.ip, virt, "classname Keyname")
return ret
ret = err_invalid_creationclassname_keyname(conn, exp_list[4])
if ret != PASS:
- clean_and_exit(options.ip, "creationclassname Keyname")
+ clean_and_exit(options.ip, virt, "creationclassname Keyname")
return ret
ret = err_invalid_creationclassname_keyvalue(conn, exp_list[4])
if ret != PASS:
- clean_and_exit(options.ip, "creationclassname Keyvalue")
+ clean_and_exit(options.ip, virt, "creationclassname Keyvalue")
return ret
ret = err_invalid_syscreationclassname_keyname(conn, exp_list[5])
if ret != PASS:
- clean_and_exit(options.ip, "System creationclassname Keyname")
+ clean_and_exit(options.ip, virt, "System creationclassname Keyname")
return ret
ret = err_invalid_syscreationclassname_keyvalue(conn, exp_list[5])
if ret != PASS:
- clean_and_exit(options.ip, "System creationclassname Keyvalue")
+ clean_and_exit(options.ip, virt, "System creationclassname Keyvalue")
return ret
- cleanup_restore()
+ cleanup_restore(options.ip, virt)
vsxml.undefine(options.ip)
return PASS
if __name__ == "__main__":
diff -r d013f73cf783 -r 80682d57c067 suites/libvirt-cim/cimtest/HostSystem/04_hs_to_EAPF.py
--- a/suites/libvirt-cim/cimtest/HostSystem/04_hs_to_EAPF.py Thu May 15 06:07:17 2008 -0700
+++ b/suites/libvirt-cim/cimtest/HostSystem/04_hs_to_EAPF.py Mon May 19 08:36:16 2008 -0700
@@ -179,7 +179,7 @@ def get_assocname_info(server, cn, an, q
status = FAIL
if status != PASS:
- cleanup_restore()
+ cleanup_restore(server, virt='Xen')
test_domain_function(test_dom, server, "destroy")
return status, assoc_info
@@ -221,7 +221,7 @@ def verify_eafp_values(server, in_pllist
except Exception, detail:
logger.error(CIM_ERROR_ASSOCIATORS, an)
logger.error("Exception: %s", detail)
- cleanup_restore()
+ cleanup_restore(server, virt='Xen')
status = FAIL
return status
@@ -229,7 +229,7 @@ def main():
def main():
options= main.options
server = options.ip
-
+ virt=options.virt
# Get the host info
status, host_name, classname = get_host_info(server)
if status != PASS:
@@ -256,14 +256,14 @@ def main():
status = setup_env(server)
if status != PASS:
- cleanup_restore()
+ cleanup_restore(server, vir=virt)
test_domain_function(test_dom, server, cmd = "destroy")
return status
in_pllist = pool_init_list(pool)
status = verify_eafp_values(server, in_pllist)
ret = test_domain_function(test_dom, server, cmd = "destroy")
- cleanup_restore()
+ cleanup_restore(server, virt=virt)
return status
if __name__ == "__main__":
sys.exit(main())
diff -r d013f73cf783 -r 80682d57c067 suites/libvirt-cim/cimtest/ResourcePool/01_enum.py
--- a/suites/libvirt-cim/cimtest/ResourcePool/01_enum.py Thu May 15 06:07:17 2008 -0700
+++ b/suites/libvirt-cim/cimtest/ResourcePool/01_enum.py Mon May 19 08:36:16 2008 -0700
@@ -141,7 +141,7 @@ def main():
return FAIL
status = verify_fields(pool_list, netpool, get_typed_class(virt, np_cn))
- cleanup_restore()
+ cleanup_restore(ip, virt)
return status
if __name__ == "__main__":
diff -r d013f73cf783 -r 80682d57c067 suites/libvirt-cim/cimtest/ResourcePool/02_rp_gi_errors.py
--- a/suites/libvirt-cim/cimtest/ResourcePool/02_rp_gi_errors.py Thu May 15 06:07:17 2008 -0700
+++ b/suites/libvirt-cim/cimtest/ResourcePool/02_rp_gi_errors.py Mon May 19 08:36:16 2008 -0700
@@ -109,7 +109,7 @@ def main():
if not ret:
logger.error("Failed to create the Virtual Network '%s'",
test_network)
- cleanup_restore()
+ cleanup_restore(ip, virt)
return SKIP
netid = "%s/%s" % ("NetworkPool", test_network)
@@ -124,16 +124,16 @@ def main():
ret_value = err_invalid_instid_keyname(conn, cn, instid)
if ret_value != PASS:
logger.error("------ FAILED: Invalid InstanceID Key Name.------")
- cleanup_restore()
+ cleanup_restore(ip, virt)
return ret_value
ret_value = err_invalid_instid_keyvalue(conn, cn)
if ret_value != PASS:
logger.error("------ FAILED: Invalid InstanceID Key Value.------")
- cleanup_restore()
+ cleanup_restore(ip, virt)
return ret_value
- cleanup_restore()
+ cleanup_restore(ip, virt)
return PASS
if __name__ == "__main__":
16 years, 5 months
[PATCH 0 of 3] [TEST] bundles of LXC support
by Guo Lian Yun
patch 1 includes all the helper function changes for LXC tc running
patch 2 adds LXCXML class, you can use it to define a lxc domain, also you can add more functions
in it to support more devices
patch 3 changes ComputerSystem.01&03 and related lib to reflect the lxc changes
Signed-off-by: Guolian Yun <yunguol(a)cn.ibm.com>
16 years, 5 months
[PATCH] [TEST] Updating the cleanup_restore() function call in the tc to pass the server and virt parameters
by Deepti B. Kalakeri
# HG changeset patch
# User Deepti B. Kalakeri <deeptik(a)linux.vnet.ibm.com>
# Date 1210858387 25200
# Node ID c778e1b632afb62c95f05e663199cdf2d24af562
# Parent fa608cfd2be35b4170e14620253f95a9b0e016ed
[TEST] Updating the cleanup_restore() function call in the tc to pass the server and virt parameters.
Signed-off-by: Deepti B. Kalakeri <deeptik(a)linux.vnet.ibm.com>
diff -r fa608cfd2be3 -r c778e1b632af suites/libvirt-cim/cimtest/AllocationCapabilities/02_alloccap_gi_errs.py
--- a/suites/libvirt-cim/cimtest/AllocationCapabilities/02_alloccap_gi_errs.py Thu May 15 06:07:17 2008 -0700
+++ b/suites/libvirt-cim/cimtest/AllocationCapabilities/02_alloccap_gi_errs.py Thu May 15 06:33:07 2008 -0700
@@ -76,6 +76,7 @@ def main():
options = main.options
server = options.ip
+ virt = options.virt
# Verify DiskPool on machine
status = create_diskpool_file()
if status != PASS:
@@ -130,7 +131,7 @@ def main():
status = ret_value
if status != PASS:
break
- cleanup_restore()
+ cleanup_restore(server, virt)
return status
if __name__ == "__main__":
sys.exit(main())
diff -r fa608cfd2be3 -r c778e1b632af suites/libvirt-cim/cimtest/ElementAllocatedFromPool/03_reverse_errs.py
--- a/suites/libvirt-cim/cimtest/ElementAllocatedFromPool/03_reverse_errs.py Thu May 15 06:07:17 2008 -0700
+++ b/suites/libvirt-cim/cimtest/ElementAllocatedFromPool/03_reverse_errs.py Thu May 15 06:33:07 2008 -0700
@@ -170,9 +170,9 @@ def err_invalid_keyvalue():
break
return status
-def clean_and_exit(server, msg):
+def clean_and_exit(server, virt, msg):
logger.error("------FAILED: Invalid %s.------", msg)
- cleanup_restore()
+ cleanup_restore(server, virt)
vsxml.undefine(server)
@do_main(platform_sup)
@@ -207,20 +207,20 @@ def main():
assoc_classname = get_typed_class(virt, "ElementAllocatedFromPool")
ret = err_invalid_keyname()
if ret != PASS:
- clean_and_exit(options.ip, "KeyName")
+ clean_and_exit(options.ip, virt, "KeyName")
return ret
ret = err_invalid_keyvalue()
if ret != PASS:
- clean_and_exit(options.ip, "KeyValue")
+ clean_and_exit(options.ip, virt, "KeyValue")
return ret
ret = err_invalid_ccname()
if ret != PASS:
- clean_and_exit(options.ip, "CCName")
+ clean_and_exit(options.ip, virt, "CCName")
return ret
- cleanup_restore()
+ cleanup_restore(options.ip, virt)
vsxml.undefine(options.ip)
return PASS
if __name__ == "__main__":
diff -r fa608cfd2be3 -r c778e1b632af suites/libvirt-cim/cimtest/ElementAllocatedFromPool/04_forward_errs.py
--- a/suites/libvirt-cim/cimtest/ElementAllocatedFromPool/04_forward_errs.py Thu May 15 06:07:17 2008 -0700
+++ b/suites/libvirt-cim/cimtest/ElementAllocatedFromPool/04_forward_errs.py Thu May 15 06:33:07 2008 -0700
@@ -477,9 +477,9 @@ def err_invalid_syscreationclassname_key
return try_assoc(conn, exp_ret, test_dom, test_keys, test_vals, log_msg)
-def clean_and_exit(server, msg):
+def clean_and_exit(server, virt, msg):
logger.error("------FAILED: Invalid %s.------", msg)
- cleanup_restore()
+ cleanup_restore(server, virt)
vsxml.undefine(server)
@do_main(platform_sup)
@@ -519,50 +519,50 @@ def main():
ret = err_invalid_sysname_keyname(conn, exp_list[0])
if ret != PASS:
- clean_and_exit(options.ip, "SystemName KeyName")
+ clean_and_exit(options.ip, virt, "SystemName KeyName")
return ret
ret = err_invalid_sysname_keyvalue(conn, exp_list[0])
if ret != PASS:
- clean_and_exit(options.ip, "SystemName Key Value")
+ clean_and_exit(options.ip, virt, "SystemName Key Value")
return ret
ret = err_invalid_devid_keyname(conn, exp_list[1])
if ret != PASS:
- clean_and_exit(options.ip, "DeviceID Keyname")
+ clean_and_exit(options.ip, virt, "DeviceID Keyname")
return ret
ret = err_invalid_devid_keyvalue(conn, exp_list[2])
if ret != PASS:
- clean_and_exit(options.ip, "DeviceID Keyvalue")
+ clean_and_exit(options.ip, virt, "DeviceID Keyvalue")
return ret
ret = err_invalid_classname(conn, exp_list[3])
if ret != PASS:
- clean_and_exit(options.ip, "classname Keyname")
+ clean_and_exit(options.ip, virt, "classname Keyname")
return ret
ret = err_invalid_creationclassname_keyname(conn, exp_list[4])
if ret != PASS:
- clean_and_exit(options.ip, "creationclassname Keyname")
+ clean_and_exit(options.ip, virt, "creationclassname Keyname")
return ret
ret = err_invalid_creationclassname_keyvalue(conn, exp_list[4])
if ret != PASS:
- clean_and_exit(options.ip, "creationclassname Keyvalue")
+ clean_and_exit(options.ip, virt, "creationclassname Keyvalue")
return ret
ret = err_invalid_syscreationclassname_keyname(conn, exp_list[5])
if ret != PASS:
- clean_and_exit(options.ip, "System creationclassname Keyname")
+ clean_and_exit(options.ip, virt, "System creationclassname Keyname")
return ret
ret = err_invalid_syscreationclassname_keyvalue(conn, exp_list[5])
if ret != PASS:
- clean_and_exit(options.ip, "System creationclassname Keyvalue")
+ clean_and_exit(options.ip, virt, "System creationclassname Keyvalue")
return ret
- cleanup_restore()
+ cleanup_restore(options.ip, virt)
vsxml.undefine(options.ip)
return PASS
if __name__ == "__main__":
diff -r fa608cfd2be3 -r c778e1b632af suites/libvirt-cim/cimtest/HostSystem/04_hs_to_EAPF.py
--- a/suites/libvirt-cim/cimtest/HostSystem/04_hs_to_EAPF.py Thu May 15 06:07:17 2008 -0700
+++ b/suites/libvirt-cim/cimtest/HostSystem/04_hs_to_EAPF.py Thu May 15 06:33:07 2008 -0700
@@ -179,7 +179,7 @@ def get_assocname_info(server, cn, an, q
status = FAIL
if status != PASS:
- cleanup_restore()
+ cleanup_restore(server, virt='Xen')
test_domain_function(test_dom, server, "destroy")
return status, assoc_info
@@ -221,7 +221,7 @@ def verify_eafp_values(server, in_pllist
except Exception, detail:
logger.error(CIM_ERROR_ASSOCIATORS, an)
logger.error("Exception: %s", detail)
- cleanup_restore()
+ cleanup_restore(server, virt='Xen')
status = FAIL
return status
@@ -229,7 +229,7 @@ def main():
def main():
options= main.options
server = options.ip
-
+ virt=options.virt
# Get the host info
status, host_name, classname = get_host_info(server)
if status != PASS:
@@ -256,14 +256,14 @@ def main():
status = setup_env(server)
if status != PASS:
- cleanup_restore()
+ cleanup_restore(server, vir=tvirt)
test_domain_function(test_dom, server, cmd = "destroy")
return status
in_pllist = pool_init_list(pool)
status = verify_eafp_values(server, in_pllist)
ret = test_domain_function(test_dom, server, cmd = "destroy")
- cleanup_restore()
+ cleanup_restore(server, virt=virt)
return status
if __name__ == "__main__":
sys.exit(main())
diff -r fa608cfd2be3 -r c778e1b632af suites/libvirt-cim/cimtest/ResourcePool/01_enum.py
--- a/suites/libvirt-cim/cimtest/ResourcePool/01_enum.py Thu May 15 06:07:17 2008 -0700
+++ b/suites/libvirt-cim/cimtest/ResourcePool/01_enum.py Thu May 15 06:33:07 2008 -0700
@@ -141,7 +141,7 @@ def main():
return FAIL
status = verify_fields(pool_list, netpool, get_typed_class(virt, np_cn))
- cleanup_restore()
+ cleanup_restore(ip, virt)
return status
if __name__ == "__main__":
diff -r fa608cfd2be3 -r c778e1b632af suites/libvirt-cim/cimtest/ResourcePool/02_rp_gi_errors.py
--- a/suites/libvirt-cim/cimtest/ResourcePool/02_rp_gi_errors.py Thu May 15 06:07:17 2008 -0700
+++ b/suites/libvirt-cim/cimtest/ResourcePool/02_rp_gi_errors.py Thu May 15 06:33:07 2008 -0700
@@ -109,7 +109,7 @@ def main():
if not ret:
logger.error("Failed to create the Virtual Network '%s'",
test_network)
- cleanup_restore()
+ cleanup_restore(ip, virt)
return SKIP
netid = "%s/%s" % ("NetworkPool", test_network)
@@ -124,16 +124,16 @@ def main():
ret_value = err_invalid_instid_keyname(conn, cn, instid)
if ret_value != PASS:
logger.error("------ FAILED: Invalid InstanceID Key Name.------")
- cleanup_restore()
+ cleanup_restore(ip, virt)
return ret_value
ret_value = err_invalid_instid_keyvalue(conn, cn)
if ret_value != PASS:
logger.error("------ FAILED: Invalid InstanceID Key Value.------")
- cleanup_restore()
+ cleanup_restore(ip, virt)
return ret_value
- cleanup_restore()
+ cleanup_restore(ip, virt)
return PASS
if __name__ == "__main__":
16 years, 5 months
[PATCH] Add interop mofs to pkgdata_DATA
by Jim Fehlig
# HG changeset patch
# User Jim Fehlig <jfehlig(a)novell.com>
# Date 1210975875 21600
# Node ID 16f34df87c5b344961bbb9d16721c91081e9b7f2
# Parent b9ddfef54aa7b51515efea27b95faf00edc5ace7
Add interop mofs to pkgdata_DATA
ReferencedProfile.mof was not being included in pkgdata_DATA since it is
only listed in INTEROP_MOFS.
Signed-off-by: Jim Fehlig <jfehlig(a)novell.com>
diff -r b9ddfef54aa7 -r 16f34df87c5b Makefile.am
--- a/Makefile.am Mon May 12 16:11:58 2008 -0700
+++ b/Makefile.am Fri May 16 16:11:15 2008 -0600
@@ -95,7 +95,7 @@ INTEROP_REGS = \
schema/ElementConformsToProfile.registration \
schema/ReferencedProfile.registration
-pkgdata_DATA = $(MOFS) $(REGS) $(INTEROP_REGS)
+pkgdata_DATA = $(MOFS) $(REGS) $(INTEROP_MOFS) $(INTEROP_REGS)
pkgdata_SCRIPTS = provider-register.sh
EXTRA_DIST = schema $(pkgdata_DATA) $(pkgdata_SCRIPTS) \
16 years, 5 months
[PATCH] [TEST]Fixing 01_forward.py tc to incorporate the AC-to-Pool association with EC
by Deepti B. Kalakeri
# HG changeset patch
# User Deepti B. Kalakeri <deeptik(a)linux.vnet.ibm.com>
# Date 1211189852 25200
# Node ID edb58c44c9ce3be425fceda5a67af18cf5243ce8
# Parent a8dbad0a9854623167932386e4bae8a737b46672
[TEST]Fixing 01_forward.py tc to incorporate the AC-to-Pool association with EC.
Tested with KVM, XenFV, Xen with latest and rpm libvirt-cim.
Signed-off-by: Deepti B. Kalakeri <deeptik(a)linux.vnet.ibm.com>
diff -r a8dbad0a9854 -r edb58c44c9ce suites/libvirt-cim/cimtest/ElementCapabilities/01_forward.py
--- a/suites/libvirt-cim/cimtest/ElementCapabilities/01_forward.py Thu May 15 04:51:47 2008 -0700
+++ b/suites/libvirt-cim/cimtest/ElementCapabilities/01_forward.py Mon May 19 02:37:32 2008 -0700
@@ -27,69 +27,106 @@ from XenKvmLib import hostsystem
from XenKvmLib import hostsystem
from XenKvmLib.classes import get_typed_class
from CimTest import Globals
-from CimTest.Globals import do_main
+from CimTest.Globals import do_main, logger, CIM_ERROR_ASSOCIATORNAMES, \
+CIM_ERROR_ENUMERATE
from CimTest.ReturnCodes import PASS, FAIL, SKIP
+from XenKvmLib.const import CIM_REV
+from XenKvmLib.enumclass import enumerate
sup_types = ['Xen', 'XenFV', 'KVM']
+ac_to_pool_version = 561
+
+def append_to_list(server, virt, poolname, valid_elc_id):
+ keys_list = ['InstanceID']
+ pool_list = enumerate(server, poolname, keys_list, virt)
+ if len(pool_list) > 0:
+ for pool in pool_list:
+ valid_elc_id.append(pool.InstanceID)
+ return valid_elc_id
+
+def set_pool_info(server, virt, valid_elc_id):
+ try:
+ valid_elc_id = append_to_list(server, virt, "DiskPool", valid_elc_id)
+ valid_elc_id = append_to_list(server, virt, "MemoryPool", valid_elc_id)
+ valid_elc_id = append_to_list(server, virt, "ProcessorPool", valid_elc_id)
+ valid_elc_id = append_to_list(server, virt, "NetworkPool", valid_elc_id)
+ except Exception, details:
+ logger.error("Exception: In fn set_pool_info(): %s", details)
+ return FAIL, valid_elc_id
+
+ return PASS, valid_elc_id
+
@do_main(sup_types)
def main():
options = main.options
+ server = options.ip
+ virt = options.virt
try:
- host_sys = hostsystem.enumerate(options.ip, options.virt)[0]
+ host_sys = hostsystem.enumerate(server, virt)[0]
except Exception:
- Globals.logger.error(Globals.CIM_ERROR_ENUMERATE, get_typed_class(options.virt, 'HostSystem'))
+ logger.error(CIM_ERROR_ENUMERATE, get_typed_class(virt, 'HostSystem'))
return FAIL
try:
- elc = assoc.AssociatorNames(options.ip,
+ elc = assoc.AssociatorNames(server,
"ElementCapabilities",
"HostSystem",
- options.virt,
+ virt,
Name = host_sys.Name,
CreationClassName = host_sys.CreationClassName)
except Exception:
- Globals.logger.error(Globals.CIM_ERROR_ASSOCIATORNAMES % host_sys.Name)
+ logger.error(CIM_ERROR_ASSOCIATORNAMES % host_sys.Name)
return FAIL
- valid_elc_name = [get_typed_class(options.virt, "VirtualSystemManagementCapabilities"),
- get_typed_class(options.virt, "VirtualSystemMigrationCapabilities")]
+ valid_elc_name = [get_typed_class(virt, "VirtualSystemManagementCapabilities"),
+ get_typed_class(virt, "VirtualSystemMigrationCapabilities")]
+
valid_elc_id = ["ManagementCapabilities",
"MigrationCapabilities"]
+ if CIM_REV >= ac_to_pool_version:
+ valid_elc_name.append(get_typed_class(virt, "AllocationCapabilities"))
+ status, valid_elc_id = set_pool_info(server, virt, valid_elc_id)
+ if status != PASS:
+ return status
+
if len(elc) == 0:
- Globals.logger.error("ElementCapabilities association failed, excepted at least one instance")
+ logger.error("ElementCapabilities association failed, excepted at least one instance")
return FAIL
- for i in range(0,len(elc)):
- if elc[i].classname not in valid_elc_name:
- Globals.logger.error("ElementCapabilities association classname error")
+
+ for i in elc:
+ if i.classname not in valid_elc_name:
+ logger.error("ElementCapabilities association classname error")
return FAIL
- elif elc[i].keybindings['InstanceID'] not in valid_elc_id:
- Globals.logger.error("ElementCapabilities association InstanceID error")
+ if i['InstanceID'] not in valid_elc_id:
+ logger.error("ElementCapabilities association InstanceID error ")
return FAIL
-
- cs = live.domain_list(options.ip, options.virt)
+ cs = live.domain_list(server, virt)
+ ccn = get_typed_class(virt, "ComputerSystem")
for system in cs:
try:
- elec = assoc.AssociatorNames(options.ip,
+ elec = assoc.AssociatorNames(server,
"ElementCapabilities",
"ComputerSystem",
- options.virt,
+ virt,
Name = system,
- CreationClassName = get_typed_class(options.virt, "ComputerSystem"))
+ CreationClassName = ccn)
except Exception:
- Globals.logger.error(Globals.CIM_ERROR_ASSOCIATORNAMES % system)
+ logger.error(Globals.CIM_ERROR_ASSOCIATORNAMES % system)
return FAIL
-
- if elec[0].classname != get_typed_class(options.virt, "EnabledLogicalElementCapabilities"):
- Globals.logger.error("ElementCapabilities association classname error")
+ cn = get_typed_class(virt, "EnabledLogicalElementCapabilities")
+ if elec[0].classname != cn:
+ logger.error("ElementCapabilities association classname error")
return FAIL
elif elec[0].keybindings['InstanceID'] != system:
- Globals.logger.error("ElementCapabilities association InstanceID error")
+ logger.error("ElementCapabilities association InstanceID error")
return FAIL
+
+ return PASS
if __name__ == "__main__":
sys.exit(main())
16 years, 5 months