Remove libvirt code 65/38965/3
authorDariusz Michaluk <d.michaluk@samsung.com>
Mon, 4 May 2015 15:33:28 +0000 (17:33 +0200)
committerJan Olszak <j.olszak@samsung.com>
Tue, 5 May 2015 07:35:31 +0000 (00:35 -0700)
[Bug/Feature]   N/A
[Cause]         N/A
[Solution]      N/A
[Verification]  N/A

Change-Id: Ic288d52a0408d17a6b898d7ab96ef9ed116b4af5

client/utils.cpp
server/zone.hpp
tests/unit_tests/client/ut-client-utils.cpp

index 305b848..7e5655e 100644 (file)
@@ -31,10 +31,6 @@ namespace {
 
 const std::string CPUSET_HOST = "/";
 const std::string CPUSET_LXC_PREFIX = "/lxc/";
-const std::string CPUSET_LIBVIRT_PREFIX_OLD = "/machine/";
-const std::string CPUSET_LIBVIRT_SUFFIX_OLD = ".libvirt-lxc";
-const std::string CPUSET_LIBVIRT_PREFIX = "/machine.slice/machine-lxc\\x2d";
-const std::string CPUSET_LIBVIRT_SUFFIX = ".scope";
 
 bool parseLxcFormat(const std::string& cpuset, std::string& id)
 {
@@ -46,75 +42,6 @@ bool parseLxcFormat(const std::string& cpuset, std::string& id)
     return true;
 }
 
-bool parseOldLibvirtFormat(const std::string& cpuset, std::string& id)
-{
-    // '/machine/<id>.libvirt-lxc'
-    if (!boost::starts_with(cpuset, CPUSET_LIBVIRT_PREFIX_OLD)) {
-        return false;
-    }
-
-    if (!boost::ends_with(cpuset, CPUSET_LIBVIRT_SUFFIX_OLD)) {
-        return false;
-    }
-
-    id.assign(cpuset,
-              CPUSET_LIBVIRT_PREFIX_OLD.size(),
-              cpuset.size() - CPUSET_LIBVIRT_PREFIX_OLD.size() - CPUSET_LIBVIRT_SUFFIX_OLD.size());
-    return true;
-}
-
-inline int unhex(char c)
-{
-    if (c >= '0' && c <= '9') {
-        return c - '0';
-    }
-    if (c >= 'a' && c <= 'f') {
-        return c - 'a' + 10;
-    }
-    if (c >= 'A' && c <= 'F') {
-        return c - 'A' + 10;
-    }
-    return -1;
-}
-
-void unescape(std::string& value)
-{
-    const size_t len = value.size();
-    size_t inPos = 0;
-    size_t outPos = 0;
-    while (inPos < len) {
-        const char c = value[inPos++];
-        if (c == '-') {
-            value[outPos++] = '/';
-        } else if (c == '\\' && value[inPos] == 'x') {
-            const int a = unhex(value[inPos+1]);
-            const int b = unhex(value[inPos+2]);
-            value[outPos++] = (char) ((a << 4) | b);
-            inPos += 3;
-        } else {
-            value[outPos++] = c;
-        }
-    }
-    value.resize(outPos);
-}
-
-bool parseNewLibvirtFormat(const std::string& cpuset, std::string& id)
-{
-    // '/machine.slice/machine-lxc\x2d<id>.scope'
-    if (!boost::starts_with(cpuset, CPUSET_LIBVIRT_PREFIX)) {
-        return false;
-    }
-
-    if (!boost::ends_with(cpuset, CPUSET_LIBVIRT_SUFFIX)) {
-        return false;
-    }
-
-    id = cpuset.substr(CPUSET_LIBVIRT_PREFIX.size(),
-                       cpuset.size() - CPUSET_LIBVIRT_PREFIX.size() - CPUSET_LIBVIRT_SUFFIX.size());
-    unescape(id);
-    return true;
-}
-
 } // namespace
 
 bool parseZoneIdFromCpuSet(const std::string& cpuset, std::string& id)
@@ -124,8 +51,6 @@ bool parseZoneIdFromCpuSet(const std::string& cpuset, std::string& id)
         return true;
     }
 
-    return parseLxcFormat(cpuset, id) ||
-           parseNewLibvirtFormat(cpuset, id) ||
-           parseOldLibvirtFormat(cpuset, id);
+    return parseLxcFormat(cpuset, id);
 }
 
index e7e929a..f24a6e6 100644 (file)
@@ -152,7 +152,7 @@ public:
 
     /**
      * Check if the zone is stopped. It's NOT equivalent to !isRunning,
-     * because it checks different internal libvirt's states. There are other states,
+     * because it checks different internal LXC states. There are other states,
      * (e.g. paused) when the zone isn't running nor stopped.
      *
      * @return Is the zone stopped?
index 459a1b1..7a1b5ac 100644 (file)
@@ -47,10 +47,6 @@ BOOST_AUTO_TEST_CASE(ParseZoneIdFromCpuSet)
     testBad("/foo");
 
     testOK("/", "host");
-    testOK("/machine/a-b.libvirt-lxc", "a-b");
-    testOK("/machine.slice/machine-lxc\\x2da\\x2db.scope", "a-b");
-    testOK("/machine.slice/machine-lxc\\x2da-b.scope", "a/b");
-
     testOK("/lxc/test", "test");
 }