mirror of
https://github.com/virt-manager/virt-manager.git
synced 2025-02-25 18:55:27 -06:00
Added pause domain to VMM TUI.
This commit is contained in:
parent
41c98a1822
commit
3c068b9971
@ -24,6 +24,7 @@ from configscreen import ConfigScreen
|
||||
from adddomain import AddDomain
|
||||
from startdomain import StartDomain
|
||||
from stopdomain import StopDomain
|
||||
from pausedomain import PauseDomain
|
||||
from removedomain import RemoveDomain
|
||||
from listdomains import ListDomains
|
||||
from migratedomain import MigrateDomain
|
||||
@ -35,10 +36,11 @@ import logging
|
||||
ADD_DOMAIN = 1
|
||||
START_DOMAIN = 2
|
||||
STOP_DOMAIN = 3
|
||||
REMOVE_DOMAIN = 4
|
||||
LIST_DOMAINS = 5
|
||||
MIGRATE_DOMAIN = 6
|
||||
CREATE_USER = 7
|
||||
PAUSE_DOMAIN = 4
|
||||
REMOVE_DOMAIN = 5
|
||||
LIST_DOMAINS = 6
|
||||
MIGRATE_DOMAIN = 7
|
||||
CREATE_USER = 8
|
||||
|
||||
class NodeMenuScreen(MenuScreen):
|
||||
def __init__(self):
|
||||
@ -48,6 +50,7 @@ class NodeMenuScreen(MenuScreen):
|
||||
return (("Add A Virtual Machine", ADD_DOMAIN),
|
||||
("Start A Virtual Machine", START_DOMAIN),
|
||||
("Stop A Virtual Machine", STOP_DOMAIN),
|
||||
("Pause A Virtual Machine", PAUSE_DOMAIN),
|
||||
("Remove A Virtual Machine", REMOVE_DOMAIN),
|
||||
("List All Virtual Machines", LIST_DOMAINS),
|
||||
("Migrate Virtual Machine", MIGRATE_DOMAIN),
|
||||
@ -57,6 +60,7 @@ class NodeMenuScreen(MenuScreen):
|
||||
if item is ADD_DOMAIN: AddDomain()
|
||||
elif item is START_DOMAIN: StartDomain()
|
||||
elif item is STOP_DOMAIN: StopDomain()
|
||||
elif item is PAUSE_DOMAIN: PauseDomain()
|
||||
elif item is REMOVE_DOMAIN: RemoveDomain()
|
||||
elif item is LIST_DOMAINS: ListDomains()
|
||||
elif item is MIGRATE_DOMAIN: MigrateDomain()
|
||||
|
69
src/virtManagerTui/pausedomain.py
Normal file
69
src/virtManagerTui/pausedomain.py
Normal file
@ -0,0 +1,69 @@
|
||||
#!/usr/bin/env python
|
||||
#
|
||||
# pausedomain.py - Copyright (C) 2011 Red Hat, Inc.
|
||||
# Written by Darryl L. Pierce <dpierce@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 *
|
||||
|
||||
class PauseDomainConfigScreen(DomainListConfigScreen):
|
||||
LIST_PAGE = 1
|
||||
STOP_PAGE = 2
|
||||
|
||||
def __init__(self):
|
||||
DomainListConfigScreen.__init__(self, "Pause A Domain")
|
||||
|
||||
def get_elements_for_page(self, screen, page):
|
||||
if page is self.LIST_PAGE:
|
||||
return self.get_domain_list_page(screen, defined = False)
|
||||
elif page is self.STOP_PAGE:
|
||||
return self.get_stop_page(screen)
|
||||
|
||||
def page_has_next(self, page):
|
||||
if page is self.LIST_PAGE: return self.has_selectable_domains()
|
||||
return False
|
||||
|
||||
def page_has_back(self, page):
|
||||
if page is self.STOP_PAGE: return True
|
||||
return False
|
||||
|
||||
def validate_input(self, page, errors):
|
||||
if page is self.LIST_PAGE:
|
||||
if self.get_selected_domain() is not None:
|
||||
domain = self.get_selected_domain()
|
||||
try:
|
||||
if domain.is_pauseable():
|
||||
domain.suspend()
|
||||
return True
|
||||
else:
|
||||
errors.append("%s is not in a pauseable state: state=%s" % (domain.get_name(), domain.run_status()))
|
||||
except Exception, error:
|
||||
errors.append("There was an error pausing the domain: %s" % domain)
|
||||
errors.append(str(error))
|
||||
else:
|
||||
errors.append("You must first select a domain to stop.")
|
||||
return False
|
||||
|
||||
def get_stop_page(self, screen):
|
||||
grid = Grid(1, 1)
|
||||
grid.setField(Label("%s was successfully paused." % self.get_selected_domain().get_name()), 0, 0)
|
||||
return [grid]
|
||||
|
||||
def PauseDomain():
|
||||
screen = PauseDomainConfigScreen()
|
||||
screen.start()
|
@ -58,7 +58,7 @@ class RemoveDomainConfigScreen(DomainListConfigScreen):
|
||||
if self.__confirm_remove.value():
|
||||
domain = self.get_selected_domain()
|
||||
try:
|
||||
self.get_libvirt().undefine_domain(domain)
|
||||
domain.delete()
|
||||
return True
|
||||
except Exception, error:
|
||||
errors.append("Failed to remove %s." % domain)
|
||||
@ -68,14 +68,14 @@ class RemoveDomainConfigScreen(DomainListConfigScreen):
|
||||
return False
|
||||
|
||||
def get_confirm_page(self, screen):
|
||||
self.__confirm_remove = Checkbox("Check here to confirm undefining %s." % self.get_selected_domain(), 0)
|
||||
self.__confirm_remove = Checkbox("Check here to confirm undefining %s." % self.get_selected_domain().get_name(), 0)
|
||||
grid = Grid(1, 1)
|
||||
grid.setField(self.__confirm_remove, 0, 0)
|
||||
return [grid]
|
||||
|
||||
def get_remove_page(self, screen):
|
||||
grid = Grid(1, 1)
|
||||
grid.setField(Label("%s has been removed." % self.get_selected_domain()), 0, 0)
|
||||
grid.setField(Label("%s has been removed." % self.get_selected_domain().get_name()), 0, 0)
|
||||
return [grid]
|
||||
|
||||
def RemoveDomain():
|
||||
|
@ -28,6 +28,7 @@ setup(name = "nodeadmin",
|
||||
'addvm = nodeadmin.adddomain:AddDomain',
|
||||
'startvm = nodeadmin.startdomain:StartDomain',
|
||||
'stopvm = nodeadmin.stopdomain:StopDomain',
|
||||
'pausevm = nodeadmin.pausdomain:PauseDomain',
|
||||
'rmvm = nodeadmin.removedomain:RemoveDomain',
|
||||
'migratevm = nodeadmin.migratedomain:MigradeDomain',
|
||||
'createuser = nodeadmin.createuser:CreateUser',
|
||||
|
Loading…
Reference in New Issue
Block a user