blob: 3fc6ea914074acda5ba41eecc51a844643b4e38d [file] [log] [blame]
mblighdcd57a82007-07-11 23:06:47 +00001#!/usr/bin/python
2#
3# Copyright 2007 Google Inc. Released under the GPL v2
4
5"""This module defines the Guest class in the Host hierarchy.
6
7Implementation details:
8You should import the "hosts" package instead of importing each type of host.
9
10 Guest: a virtual machine on which you can run programs
11"""
12
13__author__ = """mbligh@google.com (Martin J. Bligh),
14poirier@google.com (Benjamin Poirier),
15stutsman@google.com (Ryan Stutsman)"""
16
17
18import ssh_host
19
20
21class Guest(ssh_host.SSHHost):
22 """This class represents a virtual machine on which you can run
23 programs.
24
25 It is not the machine autoserv is running on.
26
27 Implementation details:
28 This is an abstract class, leaf subclasses must implement the methods
29 listed here and in parent classes which have no implementation. They
30 may reimplement methods which already have an implementation. You
31 must not instantiate this class but should instantiate one of those
32 leaf subclasses."""
33
mbligh34169c22007-07-23 16:38:51 +000034 controlling_hypervisor = None
mblighdcd57a82007-07-11 23:06:47 +000035
mbligh34169c22007-07-23 16:38:51 +000036 def __init__(self, controlling_hypervisor):
mblighdcd57a82007-07-11 23:06:47 +000037 """Construct a Guest object
38
39 Args:
mbligh34169c22007-07-23 16:38:51 +000040 controlling_hypervisor: Hypervisor object that is
41 responsible for the creation and management of
42 this guest
mblighdcd57a82007-07-11 23:06:47 +000043 """
mbligh34169c22007-07-23 16:38:51 +000044 hostname= controlling_hypervisor.new_guest()
mblighdcd57a82007-07-11 23:06:47 +000045 super(Guest, self).__init__(hostname)
mbligh34169c22007-07-23 16:38:51 +000046 self.controlling_hypervisor= controlling_hypervisor
mblighdcd57a82007-07-11 23:06:47 +000047
48 def __del__(self):
49 """Destroy a Guest object
50 """
mbligh34169c22007-07-23 16:38:51 +000051 self.controlling_hypervisor.delete_guest(self.hostname)
mblighdcd57a82007-07-11 23:06:47 +000052
53 def hardreset(self):
54 """Perform a "hardreset" of the guest.
55
56 It is restarted through the hypervisor. That will restart it
57 even if the guest otherwise innaccessible through ssh.
58 """
mbligh34169c22007-07-23 16:38:51 +000059 return self.controlling_hypervisor.reset_guest(self.hostname)
mblighdcd57a82007-07-11 23:06:47 +000060