kvmtools/kvm/action.py
author Jens Kasten <jens@kasten-edv.de>
Tue, 22 Nov 2011 14:42:43 +0100
branchfeatures_editor
changeset 54 17b08e781dc6
parent 53 9eb8be6341f3
child 55 1d4c061d1502
permissions -rw-r--r--
update and fixes befor merging branch
53
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
     1
#
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
     2
# Modulde which contain the methodes which can call from commandline
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
     3
#
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
     4
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
     5
"""
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
     6
(c) 2011 Jens Kasten <jens@kasten-edv.de>
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
     7
"""
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
     8
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
     9
import os
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
    10
import sys
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
    11
from subprocess import Popen, PIPE
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
    12
from time import sleep
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
    13
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
    14
from kvmtools.config.domain import Domain
54
17b08e781dc6 update and fixes befor merging branch
Jens Kasten <jens@kasten-edv.de>
parents: 53
diff changeset
    15
from kvmtools.kvm.monitor import Monitor
53
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
    16
from kvmtools.kvm.build_config import BuildConfig
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
    17
from kvmtools.kvm.build_command import BuildCommand
54
17b08e781dc6 update and fixes befor merging branch
Jens Kasten <jens@kasten-edv.de>
parents: 53
diff changeset
    18
from kvmtools.kvm.system import System
53
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
    19
54
17b08e781dc6 update and fixes befor merging branch
Jens Kasten <jens@kasten-edv.de>
parents: 53
diff changeset
    20
class Action(Domain, BuildConfig, BuildCommand, Monitor, System):
53
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
    21
    
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
    22
    def __init__(self):
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
    23
        Domain.__init__(self)
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
    24
        BuildConfig.__init__(self)
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
    25
        BuildCommand.__init__(self)
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
    26
        System.__init__(self)
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
    27
        self.command = ()
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
    28
        self.socket = None
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
    29
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
    30
    def load_command(self):
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
    31
        """Load config"""
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
    32
        try:
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
    33
            self.build_config()
54
17b08e781dc6 update and fixes befor merging branch
Jens Kasten <jens@kasten-edv.de>
parents: 53
diff changeset
    34
        except Exception, error_msg:
17b08e781dc6 update and fixes befor merging branch
Jens Kasten <jens@kasten-edv.de>
parents: 53
diff changeset
    35
            print error_msg
17b08e781dc6 update and fixes befor merging branch
Jens Kasten <jens@kasten-edv.de>
parents: 53
diff changeset
    36
            #self.kvm_modify_action()
53
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
    37
        self.command = self.build_command()
54
17b08e781dc6 update and fixes befor merging branch
Jens Kasten <jens@kasten-edv.de>
parents: 53
diff changeset
    38
        Monitor.__init__(self)
17b08e781dc6 update and fixes befor merging branch
Jens Kasten <jens@kasten-edv.de>
parents: 53
diff changeset
    39
        self.get_pid()
53
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
    40
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
    41
    def available_actions(self):
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
    42
        """Return all methods which start with kvm_ and end with _action."""
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
    43
        actions = []
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
    44
        for action in dir(self):
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
    45
            if action.startswith("kvm_") and action.endswith("_action"):
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
    46
                methode = action.replace("kvm_", "").replace("_action", "")
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
    47
                actions.append(methode)
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
    48
        return actions
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
    49
   
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
    50
    def kvm_show_action(self):
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
    51
        """show the command as string"""
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
    52
        print self.command[1]
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
    53
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
    54
    def kvm_modify_action(self):
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
    55
        """Modify a domain configuration file."""
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
    56
        self.modify()
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
    57
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
    58
    def kvm_create_action(self):
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
    59
        """Create a domain configuration file."""
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
    60
        if os.path.isfile(self.kvm_domain_file):
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
    61
            self.modify()
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
    62
        else:
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
    63
            self.create()
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
    64
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
    65
    def kvm_migrate_action(self, command_monitor):
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
    66
        self.kvm_monitor_action(command_monitor)
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
    67
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
    68
    def kvm_monitor_action(self, command_monitor):
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
    69
        """Monitor to the qemu-kvm guest on commandline."""
54
17b08e781dc6 update and fixes befor merging branch
Jens Kasten <jens@kasten-edv.de>
parents: 53
diff changeset
    70
        if not self.is_running():
53
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
    71
            print ("Guest is not running.")
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
    72
            return
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
    73
        self.monitor_send(command_monitor)
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
    74
        data = self.monitor_recieve()
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
    75
        data = "\n".join([i for i in data])
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
    76
        print data
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
    77
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
    78
    def kvm_boot_action(self):
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
    79
        """Boot the qemu-kvm guest."""
54
17b08e781dc6 update and fixes befor merging branch
Jens Kasten <jens@kasten-edv.de>
parents: 53
diff changeset
    80
        if self.is_running():
53
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
    81
            print ("Guest already running.")
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
    82
            return True
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
    83
        env = os.environ.copy()
54
17b08e781dc6 update and fixes befor merging branch
Jens Kasten <jens@kasten-edv.de>
parents: 53
diff changeset
    84
        # add the  to the enviroment
53
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
    85
        if len(self.bridge) > 0:
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
    86
            for key, value in self.bridge.iteritems():
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
    87
                env[key] = value
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
    88
        try:
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
    89
            result = Popen(self.command[0], env=env, stdin=PIPE, stdout=PIPE)
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
    90
            result.wait()
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
    91
            return (True, "")
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
    92
        except OSError, error_msg:
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
    93
            return (False, error_msg)
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
    94
        except IOError, error_msg:
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
    95
            return (False, error_msg)
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
    96
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
    97
    def kvm_reboot_action(self):
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
    98
        """Reboot the guest."""
54
17b08e781dc6 update and fixes befor merging branch
Jens Kasten <jens@kasten-edv.de>
parents: 53
diff changeset
    99
        if not self.is_running():
53
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
   100
            print ("Guest is not running.")
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
   101
            return False
54
17b08e781dc6 update and fixes befor merging branch
Jens Kasten <jens@kasten-edv.de>
parents: 53
diff changeset
   102
        if not self.monitor_send(self.qemu_monitor["reboot"]):
53
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
   103
            print ("Could not send signal reboot to guest.")
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
   104
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
   105
    def kvm_shutdown_action(self):
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
   106
        """Shutdown the guest.
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
   107
        Its work for windows and linux guests, 
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
   108
        but not on linux when the Xserver is looked.
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
   109
        """
54
17b08e781dc6 update and fixes befor merging branch
Jens Kasten <jens@kasten-edv.de>
parents: 53
diff changeset
   110
        if not self.is_running():
53
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
   111
            print ("Guest is not running.")
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
   112
        flag = 0
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
   113
        if self.monitor_send(self.qemu_monitor["shutdown"]):
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
   114
            self.monitor_send(self.qemu_monitor["enter"])
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
   115
            print ("Shutdown ...")
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
   116
            while True:
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
   117
                # some fancy ticker
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
   118
                if flag == 0:
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
   119
                    sign = "\\" 
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
   120
                    flag = 1
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
   121
                elif flag == 1:    
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
   122
                    sign = "|"
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
   123
                    flag = 2
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
   124
                elif flag == 2:
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
   125
                    sign = "/"
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
   126
                    flag = 3
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
   127
                elif flag == 3:
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
   128
                    sign = "-"
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
   129
                    flag = 0
54
17b08e781dc6 update and fixes befor merging branch
Jens Kasten <jens@kasten-edv.de>
parents: 53
diff changeset
   130
                if not self.is_running():
53
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
   131
                    sys.stdout.write("Done.         \n")
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
   132
                    sys.stdout.flush()
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
   133
                    sys.exit(0) 
54
17b08e781dc6 update and fixes befor merging branch
Jens Kasten <jens@kasten-edv.de>
parents: 53
diff changeset
   134
                else:
17b08e781dc6 update and fixes befor merging branch
Jens Kasten <jens@kasten-edv.de>
parents: 53
diff changeset
   135
                    sys.stdout.write("waiting ... %s\r" % sign)
17b08e781dc6 update and fixes befor merging branch
Jens Kasten <jens@kasten-edv.de>
parents: 53
diff changeset
   136
                    sys.stdout.flush()
17b08e781dc6 update and fixes befor merging branch
Jens Kasten <jens@kasten-edv.de>
parents: 53
diff changeset
   137
                    sleep(0.05)
53
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
   138
            else:
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
   139
                print ("Could not send signal shutdown.")
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
   140
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
   141
    def kvm_kill_action(self):
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
   142
        """Kill the guest.
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
   143
        Dangerous option, its simply like pull the power cable out.
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
   144
        """
54
17b08e781dc6 update and fixes befor merging branch
Jens Kasten <jens@kasten-edv.de>
parents: 53
diff changeset
   145
        if not self.is_running():
53
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
   146
            print ("Guest is not running.")
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
   147
            return False
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
   148
        try:    
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
   149
            os.kill(self.kvm_pid, 9)
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
   150
            sleep(0.8)
54
17b08e781dc6 update and fixes befor merging branch
Jens Kasten <jens@kasten-edv.de>
parents: 53
diff changeset
   151
            self.is_running()
53
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
   152
            sys.exit(0)
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
   153
        except OSError, error_msg:
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
   154
            print error_msg
54
17b08e781dc6 update and fixes befor merging branch
Jens Kasten <jens@kasten-edv.de>
parents: 53
diff changeset
   155
            self.is_running()
53
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
   156
            sys.exit(1)
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
   157
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
   158
    def kvm_status_action(self):
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
   159
        """Show information about the guest."""
54
17b08e781dc6 update and fixes befor merging branch
Jens Kasten <jens@kasten-edv.de>
parents: 53
diff changeset
   160
        if not self.is_running():
53
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
   161
            print ("Guest is not running.")
9eb8be6341f3 new structur for file and class layout
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
   162
            return False
54
17b08e781dc6 update and fixes befor merging branch
Jens Kasten <jens@kasten-edv.de>
parents: 53
diff changeset
   163
        self.get_process_information()
17b08e781dc6 update and fixes befor merging branch
Jens Kasten <jens@kasten-edv.de>
parents: 53
diff changeset
   164
        print "Process name: %s" % self.kvm_process_name
17b08e781dc6 update and fixes befor merging branch
Jens Kasten <jens@kasten-edv.de>
parents: 53
diff changeset
   165
        print "%s" % self.kvm_process_status
17b08e781dc6 update and fixes befor merging branch
Jens Kasten <jens@kasten-edv.de>
parents: 53
diff changeset
   166
        print "Domain uuid: %s" % self.kvm_process_uuid
17b08e781dc6 update and fixes befor merging branch
Jens Kasten <jens@kasten-edv.de>
parents: 53
diff changeset
   167
        print "Process state: %s" % self.kvm_process_state
17b08e781dc6 update and fixes befor merging branch
Jens Kasten <jens@kasten-edv.de>
parents: 53
diff changeset
   168
        print "UID: %s" % self.kvm_process_uid
17b08e781dc6 update and fixes befor merging branch
Jens Kasten <jens@kasten-edv.de>
parents: 53
diff changeset
   169
        print "GID: %s" % self.kvm_process_gid
17b08e781dc6 update and fixes befor merging branch
Jens Kasten <jens@kasten-edv.de>
parents: 53
diff changeset
   170
        print "Groups: %s" % self.kvm_process_groups
17b08e781dc6 update and fixes befor merging branch
Jens Kasten <jens@kasten-edv.de>
parents: 53
diff changeset
   171
        print "PID: %s :: PPID: %s" % (self.kvm_process_pid, 
17b08e781dc6 update and fixes befor merging branch
Jens Kasten <jens@kasten-edv.de>
parents: 53
diff changeset
   172
            self.kvm_process_ppid)
17b08e781dc6 update and fixes befor merging branch
Jens Kasten <jens@kasten-edv.de>
parents: 53
diff changeset
   173
        print "VNC: %s" % self.kvm_process_vnc