[Ovirt-devel] [PATCH 1/2] Provides a new storage administration system to the managed node.

Darryl L. Pierce dpierce at redhat.com
Thu Dec 3 21:24:35 UTC 2009


Users can now:
 * Add a new storage pool.
 * Delete a storage pool.
 * Start and stop storage pools.
 * Add a new storage volume.
 * Delete a storage volume.
 * List existing storage pools, with details.

Signed-off-by: Darryl L. Pierce <dpierce at redhat.com>
---
 nodeadmin/listpools.py~  |   65 ++++++++++++++++++++++++++++++++++++++++++++++
 nodeadmin/poolconfig.py~ |   46 ++++++++++++++++++++++++++++++++
 nodeadmin/removepool.py~ |   46 ++++++++++++++++++++++++++++++++
 nodeadmin/setup.py       |   46 ++++++++++++++++++++++++++++++++
 nodeadmin/stoppool.py~   |   64 +++++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 267 insertions(+), 0 deletions(-)
 create mode 100644 nodeadmin/listpools.py~
 create mode 100644 nodeadmin/poolconfig.py~
 create mode 100644 nodeadmin/removepool.py~
 create mode 100644 nodeadmin/setup.py
 create mode 100644 nodeadmin/stoppool.py~

diff --git a/nodeadmin/listpools.py~ b/nodeadmin/listpools.py~
new file mode 100644
index 0000000..6302c46
--- /dev/null
+++ b/nodeadmin/listpools.py~
@@ -0,0 +1,65 @@
+# listpools.py - Copyright (C) 2009 Red Hat, Inc.
+# Written by Darryl L. Pierce <dpierce at 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.
+
+from snack import *
+
+from configscreen import *
+
+LIST_PAGE    = 1
+DETAILS_PAGE = 2
+
+class ListStoragePoolsConfigScreen(StorageListConfigScreen):
+    def __init__(self):
+        StorageListConfigScreen.__init__(self, "List Storage Pools")
+
+    def get_elements_for_page(self, screen, page):
+        if   page is LIST_PAGE:    return self.get_storage_pool_list_page(screen)
+        elif page is DETAILS_PAGE: return self.get_pool_details_page(screen)
+
+    def page_has_next(self, page):
+        if page is LIST_PAGE and self.has_selectable_pools():
+                return True
+        return False
+
+    def page_has_back(self, page):
+        if page is DETAILS_PAGE: return True
+        return False
+
+    def get_pool_details_page(self, screen):
+        pool = self.get_libvirt().get_storage_pool(self.get_selected_pool())
+        volumes = Listbox(0);
+        for name in pool.listVolumes():
+        volumes = Listbox(0);
+        for name in pool.listVolumes():
+            volume = pool.storageVolLookupByName(name)
+            volumes.append("%s (%0.1f G)" % (name, volume.info()[1] / 1024**3), name)
+        grid = Grid(2, 3)
+        grid.setField(Label("Name:"), 0, 0, anchorRight = 1)
+        grid.setField(Label(pool.name()), 1, 0, anchorLeft = 1)
+        grid.setField(Label("Volumes:"), 0, 1, anchorRight = 1)
+        grid.setField(volumes, 1, 1, anchorLeft = 1)
+        grid.setField(Label("Autostart:"), 0, 2, anchorRight = 1)
+        label = "No"
+        if pool.autostart(): label = "Yes"
+        grid.setField(Label(label), 1, 2, anchorLeft = 1)
+        return [Label("Details For Storage Pool: %s" % self.get_selected_pool()),
+                grid]
+
+def ListStoragePools():
+    screen = ListStoragePoolsConfigScreen()
+    screen.start()
diff --git a/nodeadmin/poolconfig.py~ b/nodeadmin/poolconfig.py~
new file mode 100644
index 0000000..6bc9fa0
--- /dev/null
+++ b/nodeadmin/poolconfig.py~
@@ -0,0 +1,46 @@
+# poolconfig.py - Copyright (C) 2009 Red Hat, Inc.
+# Written by Darryl L. Pierce <dpierce at 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.
+
+from virtinst import Storage
+
+ROOT_TARGET_PATH="/var/lib/libvirt/images/%s"
+
+class PoolConfig:
+    def __init__(self, libvirt):
+        self.__libvirt = libvirt
+        self.__name = ""
+        self.set_type(None)
+        self.__format = None
+        self.__hostname = ""
+        self.__target_path = ""
+        self.__source_path = ""
+        self.__build_pool  = False
+
+    def get_pool(self):
+        return self.__pool
+
+    def set_name(self, name):
+        self.__name = name
+
+    def get_name(self):
+        return self.__name
+
+    def set_type(self, pooltype):
+        self.__type = pooltype
+        self.__needs_target_path = False
+        self.__needs_format      = False
diff --git a/nodeadmin/removepool.py~ b/nodeadmin/removepool.py~
new file mode 100644
index 0000000..cd9c2d5
--- /dev/null
+++ b/nodeadmin/removepool.py~
@@ -0,0 +1,46 @@
+#!/usr/bin/env python
+#
+# removepool.py - Copyright (C) 2009 Red Hat, Inc.
+# Written by Darryl L. Pierce <dpierce at 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.
+
+from snack import *
+from configscreen import *
+
+LIST_POOLS_PAGE    = 1
+CONFIRM_PAGE       = 2
+
+class RemoveStoragePoolConfigScreen(StorageListConfigScreen):
+    def __init__(self):
+        StorageListConfigScreen.__init__(self, "Remove A Storage Pool")
+
+    def get_elements_for_page(self, screen, page):
+        if   page is LIST_POOLS_PAGE: return self.get_storage_pool_list_page(screen)
+        elif page is CONFIRM_PAGE:    return self.get_confirm_page(screen)
+
+    def page_has_next(self, page):
+        return page is LIST_POOLS_PAGE and self.has_selectable_pools()
+
+    def page_has_back(self, page):
+        return False
+
+    def page_has_finish(self, page):
+        return page is CONFIRM_PAGE
+
+    def validate_input(self, page, errors):
+        if page is LIST_POOLS_PAGE:
+            if self.get_selected_pool() is not None:
diff --git a/nodeadmin/setup.py b/nodeadmin/setup.py
new file mode 100644
index 0000000..9af2752
--- /dev/null
+++ b/nodeadmin/setup.py
@@ -0,0 +1,46 @@
+# setup.py - Copyright (C) 2009 Red Hat, Inc.
+# Written by Darryl L. Pierce <dpierce at 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.
+
+from setuptools import setup, find_packages
+
+setup(name = "nodeadmin",
+      version = "1.0.3",
+      package_dir = {'nodeadmin': 'nodeadmin'},
+      packages = find_packages('.'),
+      entry_points = {
+        'console_scripts': [
+            'nodeadmin   = nodeadmin.nodeadmin:NodeAdmin',
+            'addvm       = nodeadmin.adddomain:AddDomain',
+            'startvm     = nodeadmin.startdomain:StartDomain',
+            'stopvm      = nodeadmin.stopdomain:StopDomain',
+            'rmvm        = nodeadmin.removedomain:RemoveDomain',
+            'createuser  = nodeadmin.createuser:CreateUser',
+            'listvms     = nodeadmin.listdomains:ListDomains',
+            'definenet   = nodeadmin.definenet:DefineNetwork',
+            'createnet   = nodeadmin.createnetwork:CreateNetwork',
+            'destroynet  = nodeadmin.destroynetwork:DestroyNetwork',
+            'undefinenet = nodeadmin.undefinenetwork:UndefineNetwork',
+            'listnets    = nodeadmin.listnetworks:ListNetworks',
+            'addpool     = nodeadmin.addpool:AddStoragePool',
+            'rmpool      = nodeadmin.removepool:RemoveStoragePool',
+            'startpool   = nodeadmin.startpool:StartStoragePool',
+            'stoppool    = nodeadmin.stoppool:StopStoragePool',
+            'addvolume   = nodeadmin.addvolume:AddStorageVolume',
+            'rmvolume    = nodeadmin.removevolume:RemoveStorageVolume',
+            'listpools   = nodeadmin.listpools:ListPools']
+        })
diff --git a/nodeadmin/stoppool.py~ b/nodeadmin/stoppool.py~
new file mode 100644
index 0000000..80a2f0b
--- /dev/null
+++ b/nodeadmin/stoppool.py~
@@ -0,0 +1,64 @@
+#!/usr/bin/env python
+#
+# stoppool.py - Copyright (C) 2009 Red Hat, Inc.
+# Written by Darryl L. Pierce <dpierce at 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.
+
+from snack import *
+from configscreen import *
+
+LIST_POOLS_PAGE    = 1
+FINAL_PAGE         = 2
+
+class StopStoragePoolConfigScreen(StorageListConfigScreen):
+    def __init__(self):
+        StorageListConfigScreen.__init__(self, "Stop A Storage Pool")
+
+    def get_elements_for_page(self, screen, page):
+        if   page is LIST_POOLS_PAGE: return self.get_storage_pool_list_page(screen, defined = False)
+        elif page is FINAL_PAGE:      return self.get_final_page(screen)
+
+    def page_has_next(self, page):
+        return page is LIST_POOLS_PAGE and self.has_selectable_pools()
+
+    def page_has_back(self, page):
+        return False
+
+    def page_has_finish(self, page):
+        return page is FINAL_PAGE
+
+    def validate_input(self, page, errors):
+        if page is LIST_POOLS_PAGE:
+            if self.get_selected_pool() is not None:
+        if page is LIST_POOLS_PAGE:
+            if self.get_selected_pool() is not None:
+                return True
+            else:
+                errors.append("Please select a storage pool to be stopped.")
+        return False
+
+    def process_input(self, page):
+        if page is LIST_POOLS_PAGE:
+            self.get_libvirt().destroy_storage_pool(self.get_selected_pool())
+            self.set_finished()
+
+    def get_final_page(self, screen):
+        return [Label("Storage pool stopped: %s" % self.get_selected_pool())]
+
+def StopStoragePool():
+    screen = StopStoragePoolConfigScreen()
+    screen.start()
-- 
1.6.5.2




More information about the ovirt-devel mailing list