[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Ovirt-devel] [PATCH matahari] Removes all code for the previous CPUWrapper class.



This class has been replaced by the ProcessorsAgent.

Signed-off-by: Darryl L. Pierce <dpierce redhat com>
---
 src/Makefile.am |    4 -
 src/cpu.cpp     |  216 -------------------------------------------------------
 src/cpu.h       |  111 ----------------------------
 src/host.cpp    |   24 ------
 src/host.h      |    3 -
 src/schema.xml  |   16 ----
 6 files changed, 0 insertions(+), 374 deletions(-)
 delete mode 100644 src/cpu.cpp
 delete mode 100644 src/cpu.h

diff --git a/src/Makefile.am b/src/Makefile.am
index b4668b9..7606e20 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -6,8 +6,6 @@ first = qmf/com/redhat/matahari/Host.cpp
 
 generated_file_list = \
 	qmf/com/redhat/matahari/ArgsNICIdentify_nic.h \
-	qmf/com/redhat/matahari/CPU.cpp \
-	qmf/com/redhat/matahari/CPU.h \
 	qmf/com/redhat/matahari/Host.h \
 	qmf/com/redhat/matahari/NIC.cpp \
 	qmf/com/redhat/matahari/NIC.h \
@@ -19,8 +17,6 @@ generated_file_list = \
 nodist_matahari_SOURCES = $(generated_file_list) $(first)
 
 matahari_SOURCES = \
-	cpu.cpp \
-	cpu.h \
 	hal.cpp \
 	hal.h \
 	host.cpp \
diff --git a/src/cpu.cpp b/src/cpu.cpp
deleted file mode 100644
index 453c571..0000000
--- a/src/cpu.cpp
+++ /dev/null
@@ -1,216 +0,0 @@
-/* cpu.cpp - Copyright (C) 2009 Red Hat, Inc.
- * Written by Arjun Roy <arroy redhat com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA  02110-1301, USA.  A copy of the GNU General Public License is
- * also available at http://www.gnu.org/copyleft/gpl.html.
- */
-
-#include <iostream>
-#include <fstream>
-#include <sstream>
-#include <string>
-#include <vector>
-#include <stdexcept>
-
-#include <pcre.h>
-
-#include "cpu.h"
-#include "qmf/com/redhat/matahari/CPU.h"
-
-using namespace std;
-namespace _qmf = qmf::com::redhat::matahari;
-
-template<typename targetType> targetType convert(const std::string& str)
-{
-    istringstream i(str);
-    targetType t;
-    if (!(i >> t))
-        throw invalid_argument("Conversion failure for " + str);
-    return t;
-}
-
-ostream& operator<<(ostream& output, const CPUWrapper& cpu)
-{
-    output << "Processor" << endl;
-    output << "CPU #: " << cpu.cpunum << endl;
-    output << "Core #: " << cpu.corenum << endl;
-    output << "Num. Cores: " << cpu.numcores << endl;
-    output << "Model: " << cpu.model << endl;
-    output << "Family: " << cpu.family << endl;
-    output << "CPU ID Level: " << cpu.cpuid_lvl << endl;
-    output << "Speed (Mhz): " << cpu.speed << endl;
-    output << "Cache (kB): " << cpu.cache << endl;
-    output << "Vendor: " << cpu.vendor << endl;
-    output << "Flags: " << cpu.flags << endl;
-    return output;
-}
-
-void CPUWrapper::setupQMFObject(ManagementAgent *agent, Manageable *parent)
-{
-    mgmt_object = new _qmf::CPU(agent, this, parent);
-    agent->addObject(mgmt_object);
-    syncQMFObject();
-}
-
-void CPUWrapper::cleanupQMFObject(void)
-{
-    mgmt_object->resourceDestroy();
-}
-
-void CPUWrapper::syncQMFObject(void)
-{
-    mgmt_object->set_cpunum(cpunum);
-    mgmt_object->set_corenum(corenum);
-    mgmt_object->set_numcores(numcores);
-    mgmt_object->set_model(model);
-    mgmt_object->set_family(family);
-    mgmt_object->set_cpuid_lvl(cpuid_lvl);
-    mgmt_object->set_speed(speed);
-    mgmt_object->set_cache(cache);
-    mgmt_object->set_vendor(vendor);
-    mgmt_object->set_flags(flags);
-}
-
-/**
- * void fillCPUInfo(vector <CPUWrapper*> &cpus, ManagementAgent *agent)
- *
- * Takes in a vector of CPUWrapper object pointers and populates it with
- * CPUs found by querying /proc/cpuinfo. NOTE: This method is very sensitive
- * to the output format of /proc/cpuinfo.
- *
- * Throws a runtime error if file io is unsuccessful.
- */
-void CPUWrapper::fillCPUInfo(vector<CPUWrapper*> &cpus, ManagementAgent *agent)
-{
-    string line;
-    string regexstr = "(.*\\S)\\s*:\\s*(\\S.*)";
-    int desiredmatches = 3; // Match string and two captured substrings
-    int matchArraySize = desiredmatches * 3;
-    int results[matchArraySize]; // pcre requires this much
-    const char *pcre_err;
-    int pcre_err_offset;
-    pcre *regex;
-
-    regex = pcre_compile(regexstr.c_str(), // input
-                         0,                // no options
-                         &pcre_err,        // where to place static error str
-                         &pcre_err_offset, // index in regex string of error
-                         NULL              // use the default charset
-                        );
-    if (!regex) {
-        ostringstream err;
-        err << "Error: Bad regex: " << regexstr << endl;
-        err << "Error was: " << pcre_err << " at " << pcre_err_offset << endl;
-        throw runtime_error(err.str());
-    }
-
-    ifstream cpuinfo("/proc/cpuinfo", ios::in);
-    if (!cpuinfo.is_open() || cpuinfo.fail())
-        throw runtime_error("Unable to open /proc/cpuinfo");
-
-    // Each line is a key:value pair. New processor
-    // delimiter is the "processor" key.
-    while (!cpuinfo.eof()) {
-        getline(cpuinfo, line);
-        int match = pcre_exec(regex,         // Regex
-                              NULL,          // No extra optimizations
-                              line.c_str(),  // Input
-                              line.length(), // Input length
-                              0,             // Start offset
-                              PCRE_NOTEMPTY, // options bitvector
-                              results,       // Results vector
-                              matchArraySize // Vector size
-                              );
-
-        if (match == desiredmatches) {
-            if (line.substr(results[2], results[3] - results[2]) == "processor") {
-                // Start pulling data for a new processor
-                int cpunum = -1;
-                int coreid = -1;
-                int cpucores = -1;
-                int model = -1;
-                int family = -1;
-                int cpuid_lvl = -1;
-                double speed = -1;
-                int cache = -1;
-                string vendor = "unknown";
-                string flags = "unknown";
-
-                // Get the cpu # from this line
-                cpunum = convert<int>(line.substr(results[4],
-                                       results[5] - results[4]));
-                // And now grab the rest
-                do {
-                    getline(cpuinfo, line);
-                    match = pcre_exec(regex,         // Regex
-                                      NULL,          // No extra optimizations
-                                      line.c_str(),  // Input
-                                      line.length(), // Input length
-                                      0,             // Start offset
-                                      PCRE_NOTEMPTY, // options bitvector
-                                      results,       // Results vector
-                                      matchArraySize // Vector size
-                                                      );
-
-                    if (match == desiredmatches) {
-                        string key = line.substr(results[2],
-                                                 results[3] - results[2]);
-
-                        string value = line.substr(results[4],
-                                                    results[5] - results[4]);
-
-                        if (key == "core id") {
-                            coreid = convert<int>(value);
-                        } else if (key == "cpu cores") {
-                            cpucores = convert<int>(value);
-                        } else if (key == "model") {
-                            model = convert<int>(value);
-                        } else if (key == "cpu family") {
-                            family = convert<int>(value);
-                        } else if (key == "cpuid level") {
-                            cpuid_lvl = convert<int>(value);
-                        } else if (key == "cpu MHz") {
-                            speed = convert<int>(value);
-                        } else if (key == "cache size") {
-                            int space = value.find(' ');
-                            cache = convert<int>(value.substr(0, space));
-                        } else if (key == "vendor_id") {
-                            vendor = value;
-                        } else if (key == "flags") {
-                            flags = value;
-                        }
-                            }
-                    }
-                    while (line != "");
-
-                        // Got all the data. Add the CPU to our list
-                CPUWrapper *cpu = new CPUWrapper(cpunum,
-                                                coreid,
-                                                cpucores,
-                                                model,
-                                                family,
-                                                cpuid_lvl,
-                                                speed,
-                                                cache,
-                                                vendor,
-                                                flags);
-                    cpus.push_back(cpu);
-                }
-        }
-        else
-            continue;
-    }
-        cpuinfo.close();
-}
diff --git a/src/cpu.h b/src/cpu.h
deleted file mode 100644
index bb3a9b3..0000000
--- a/src/cpu.h
+++ /dev/null
@@ -1,111 +0,0 @@
-/* cpu.h - Copyright (C) 2009 Red Hat, Inc.
- * Written by Arjun Roy <arroy redhat com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA  02110-1301, USA.  A copy of the GNU General Public License is
- * also available at http://www.gnu.org/copyleft/gpl.html.
- */
-
-#include <qpid/management/Manageable.h>
-#include <qpid/management/ManagementObject.h>
-#include <qpid/agent/ManagementAgent.h>
-
-#include "qmf/com/redhat/matahari/CPU.h"
-
-using namespace qpid::management;
-using namespace std;
-
-using qpid::management::Manageable;
-
-class CPUWrapper : public Manageable
-{
-    friend ostream& operator<<(ostream &output, const CPUWrapper& cpu);
-    friend class HostWrapper;
-
-    // CPU Parameters
-    int cpunum;
-    int corenum;
-    int numcores;
-
-    int model;
-    int family;
-    int cpuid_lvl;
-    double speed;
-    int cache;
-
-    string vendor;
-    string flags;
-
-    // QMF related fields
-    ManagementAgent *agent;
-    qmf::com::redhat::matahari::CPU *mgmt_object;
-
-    // Methods to put up / take down QMF Objects
-    void setupQMFObject(ManagementAgent *agent, Manageable *parent);
-    void cleanupQMFObject(void);
-    void syncQMFObject(void);
-
-    // Constructors and Destructor are private
-    CPUWrapper() {}
-    CPUWrapper(const CPUWrapper&) {}
-    ~CPUWrapper() {}
-
-    CPUWrapper(int cpunum__,
-               int corenum__,
-               int numcores__,
-               int model__,
-               int family__,
-               int cpuid_lvl__,
-               double speed__,
-               int cache__,
-               const string &vendor__,
-               const string &flags__) {
-            cpunum = cpunum__;
-        corenum = corenum__;
-        numcores = numcores__;
-        model = model__;
-        family = family__;
-        cpuid_lvl = cpuid_lvl__;
-        speed = speed__;
-        cache = cache__;
-        vendor = vendor__;
-        flags = flags__;
-    }
-
-public:
-
-    // Factory like method
-    static void fillCPUInfo(vector<CPUWrapper*> &cpus, ManagementAgent *agent);
-
-    // QMF Methods
-    ManagementObject* GetManagementObject(void) const { return mgmt_object; }
-
-    status_t ManagementMethod(uint32_t methodId, Args& args, string& text) {
-        return STATUS_NOT_IMPLEMENTED;
-    }
-
-    // Field Accessors
-    int getCpunum(void) { return cpunum; }
-    int getCorenum(void) { return corenum; }
-    int getNumcores(void) { return numcores; }
-
-    int getModel(void) { return model; }
-    int getFamily(void) { return family; }
-    int getCpuid_Lvl(void) { return cpuid_lvl; }
-    double getSpeed(void) { return speed; }
-    int getCache(void) { return cache; }
-
-    const string &getVendor(void) { return vendor; }
-    const string &getFlags(void) { return flags; }
-};
diff --git a/src/host.cpp b/src/host.cpp
index ac04f47..b3ed51f 100644
--- a/src/host.cpp
+++ b/src/host.cpp
@@ -46,14 +46,8 @@ ostream& operator<<(ostream &output, const HostWrapper& host)
     output << "Hypervisor: " << host.hypervisor << endl;
     output << "Arch: " << host.arch << endl << endl;
 
-    vector<CPUWrapper*> cpus = host.cpus;
     vector<NICWrapper*> nics = host.nics;
 
-    for (vector<CPUWrapper*>::iterator iter = cpus.begin();
-         iter!= cpus.end();
-         iter++) {
-        output << **iter << endl;
-    }
     for (vector<NICWrapper*>::iterator iter = nics.begin();
          iter!= nics.end();
          iter++) {
@@ -84,12 +78,6 @@ void HostWrapper::setupQMFObjects(ManagementAgent *agent)
 
     processors.setup(agent, this);
 
-    // Iterate over list and set up CPU objects
-    for (vector<CPUWrapper*>::iterator iter = cpus.begin();
-         iter!= cpus.end();
-         iter++) {
-        (*iter)->setupQMFObject(agent, this);
-    }
     // Iterate over list and set up NIC objects
     for (vector<NICWrapper*>::iterator iter = nics.begin();
          iter!= nics.end();
@@ -113,12 +101,6 @@ void HostWrapper::cleanupQMFObjects(void)
     // Clean up Host object
     mgmt_object->resourceDestroy();
 
-    // Iterate over list and clean up CPU objects
-    for (vector<CPUWrapper*>::iterator iter = cpus.begin();
-         iter!= cpus.end();
-         iter++) {
-        (*iter)->cleanupQMFObject();
-    }
     // Iterate over list and clean up NIC objects
     for (vector<NICWrapper*>::iterator iter = nics.begin();
          iter!= nics.end();
@@ -129,11 +111,6 @@ void HostWrapper::cleanupQMFObjects(void)
 
 void HostWrapper::cleanupMemberObjects(void)
 {
-    // Get rid of the CPUWrapper objects for this host
-    for (vector<CPUWrapper*>::iterator iter = cpus.begin(); iter != cpus.end();) {
-        delete (*iter);
-        iter = cpus.erase(iter);
-    }
     // Get rid of the NICWrapper objects for this host
     for (vector<NICWrapper*>::iterator iter = nics.begin(); iter != nics.end();) {
         delete (*iter);
@@ -169,7 +146,6 @@ HostWrapper* HostWrapper::setupHostWrapper(ManagementAgent *agent)
     HostWrapper *host = new HostWrapper();
 
     try {
-        CPUWrapper::fillCPUInfo(host->cpus, agent);
         NICWrapper::fillNICInfo(host->nics, agent, hal_ctx);
 
         // Host UUID
diff --git a/src/host.h b/src/host.h
index 148c91f..bdf43fa 100644
--- a/src/host.h
+++ b/src/host.h
@@ -23,7 +23,6 @@
 
 #include "qmf/com/redhat/matahari/Host.h"
 
-#include "cpu.h"
 #include "nic.h"
 #include "processors.h"
 
@@ -47,7 +46,6 @@ class HostWrapper : public Manageable
     int memory;
 
     // Aggregated components
-    vector<CPUWrapper*> cpus;
     vector<NICWrapper*> nics;
 
     ProcessorsAgent processors;
@@ -90,7 +88,6 @@ class HostWrapper : public Manageable
     bool isBeeping(void) { return beeping; }
     int getMemory(void) { return memory; }
 
-    const vector<CPUWrapper*> &getCPUList(void) { return cpus; }
     const vector<NICWrapper*> &getNICList(void) { return nics; }
 
     // Main Loop
diff --git a/src/schema.xml b/src/schema.xml
index f9c6f6b..e6b54db 100644
--- a/src/schema.xml
+++ b/src/schema.xml
@@ -23,22 +23,6 @@
     <statistic name="load_average" type="float" desc="The processing load average." />
   </class>
 
-  <class name="CPU">
-
-    <property name="host"      type="objId"  access="RO" desc="Host that this cpu belongs to" index="y" references="Host" parentRef="y"/>
-    <property name="cpunum"    type="int32"  access="RO" desc="CPU # for this host"           index="y"/>
-    <property name="corenum"   type="int32"  access="RO" desc="Index of core within CPU"/>
-    <property name="numcores"  type="int32"  access="RO" desc="Total # of cores for CPU"/>
-    <property name="model"     type="int32"  access="RO" desc="Processor Model"/>
-    <property name="family"    type="int32"  access="RO" desc="Processor Family"/>
-    <property name="cpuid_lvl" type="int32"  access="RO" desc="CPU ID Level"/>
-    <property name="speed"     type="double" access="RO" desc="CPU Speed"      unit="MHz"/>
-    <property name="cache"     type="int32"  access="RO" desc="CPU Cache Size" unit="kb"/>
-    <property name="vendor"    type="sstr"   access="RO" desc="CPU Vendor"/>
-    <property name="flags"     type="lstr"   access="RO" desc="CPU Flags"/>
-
-  </class>
-
   <class name="NIC">
 
     <property name="host"      type="objId" access="RO" desc="Host that this NIC belongs to" index="y" references="Host" parentRef="y"/>
-- 
1.6.6.1


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]