blob: 9f4d89c12fc8e66db33a255c396836b49f723122 [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
34 controllingHypervisor = None
35
36 def __init__(self, controllingHypervisor):
37 """Construct a Guest object
38
39 Args:
40 controllingHypervisor: Hypervisor object that is
41 responsible for the creation and management of this
42 guest
43 hostname: network hostname or address of virtual machine
44 """
45 hostname= controllingHypervisor.new_guest()
46 super(Guest, self).__init__(hostname)
47 self.controllingHypervisor= controllingHypervisor
48
49 def __del__(self):
50 """Destroy a Guest object
51 """
52 self.controllingHypervisor.delete_guest(self.hostname)
53
54 def hardreset(self):
55 """Perform a "hardreset" of the guest.
56
57 It is restarted through the hypervisor. That will restart it
58 even if the guest otherwise innaccessible through ssh.
59 """
60 return self.controllingHypervisor.reset_guest(self.name)
61