Machine
1 class Machine(__builtin__.object)
2 # Provide a generic class to provision an arbitrary machine.
3
4 # Raise exceptions for most methods, since subclasses should provide them.
5 # A fully implemented subclass will provide all public methods except read,
6 # I.E.:
7 # provisioncheck, activecheck, getclientdeb, installclient
8 # (all these can be used from Machine or replaced.)
9 # destroy, stop, uploadfiles, downloadfiles, run
10 # (these must be implemented separately.)
11
12 # Methods defined here:
13
14 __init__(self, arch=None, debug=False, image=None, initrd=None,
15 installtype=None, kernel=None, machineid=None, name=None,
16 new=False, preseed=None, series=None, template=None)
17 # Initialize the object representing the machine.
18 # One of these groups of arguments should be included to specify the
19 # provisioning method:
20 # series, installtype, arch: Download an ISO from the mirrors and use
21 # it to install the machine.
22 # image, kernel, initrd, preseed: Install the machine from a
23 # specified image/ISO file, with an optional kernel, initrd, and
24 # preseed.
25 # template: Clone the machine from a template or existing machine.
26 # name: Request a specific machine. Combine with other groups to
27 # reinstall a specific machine.
28 # Other arguments:
29 # debug: Enable debug logging.
30 # new: Request a new machine (or a reinstall if a specific machine
31 # was requested.)
32
33 activecheck(self)
34 # Check if the machine is running and able to accept comamnds, start it
35 # if necessary, and raise an exception if it cannot be started.
36
37 destroy(self)
38 # Release resources consumed by the machine, set provisioned to False,
39 # and return True on success.
40 # For a VM, this should destory the VM files on the disk, and remove it
41 # from libvirt if it is registered there.
42 # For a physical machine, this should free it up to be used by another
43 # process in the future, and destroy sensitive data if any exists.
44 # Destroying the install on a physical machine is optional, but it
45 # should be powered off if remote power management is available.
46
47 downloadfiles(self, files, target='/tmp')
48 # Download a list of files from the machine to a local target and return
49 # True if all downloads succeed.
50 # Support for files as a string specifying a single file is recommended
51 # but not required.
52 # target should be a valid target path for cp, i.e. a filename for a
53 # single file, a directory name for multiple files.
54
55 getclientdeb(self)
56 # Return the path of the .deb file for the
57 # ubuntu-automation-test-harness-client installed as part of the main
58 # package.
59
60 installclient(self)
61 # Install the ubuntu-automation-test-harness-client package on the
62 # machine, and raise an exception if this fails.
63
64 provisioncheck(self)
65 # Check if the machine is provisioned, provision it if necessary, and
66 # raise an exception if it cannot be provisioned.
67
68 read(self)
69 # Load information about the machine into the machine object.
70 # This can be install information like series, arch, etc., or machine
71 # specific information like IP/MAC address, SSH key, or location of VM
72 # files or physical hardware.
73 # This method is optional.
74
75 run(self, command, quiet=None, root=False, timeout=None)
76 # Run a command on the machine and return the output status of that
77 # command.
78 # If quiet is True, all output other than the output of the command
79 # should be suppressed (i.e., no output from helper programs such as ssh.)
80 # If root is true, the command should be executed with elevated
81 # priveleges.
82 # If timeout is not None, it should be treated as a value in seconds
83 # after which run() will abort and return an error if no response was
84 # received.
85
86 stop(self, force=False)
87 # Stop the machine, and set active to False.
88 # Graceful shutdown should be attempted if supported and force is False.
89 # A True value in force should ensure the machine is shutdown or raise
90 # an exception.
91
92 uploadfiles(self, files, target='/tmp')
93 # Upload a list of local files to a target on the machine and return
94 # True if all uploads succeed.
95 # Support for files as a string specifying a single file is recommended
96 # but not required.
97 # target should be a valid target path for cp, i.e. a filename for a
98 # single file, a directory name for multiple files.
QATeam/AutomatedTesting/UbuntuAutomationTestHarness/Provisioning/Machine (last edited 2012-05-01 19:10:24 by c-98-223-36-80)