1 | #!/usr/bin/python |
---|
2 | """ |
---|
3 | Copyright (C) International Business Machines Corp., 2005 |
---|
4 | Author: Dan Smith <danms@us.ibm.com> |
---|
5 | |
---|
6 | This program is free software; you can redistribute it and/or modify |
---|
7 | it under the terms of the GNU General Public License as published by |
---|
8 | the Free Software Foundation; under version 2 of the License. |
---|
9 | |
---|
10 | This program is distributed in the hope that it will be useful, |
---|
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
13 | GNU General Public License for more details. |
---|
14 | |
---|
15 | You should have received a copy of the GNU General Public License |
---|
16 | along with this program; if not, write to the Free Software |
---|
17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
---|
18 | |
---|
19 | """ |
---|
20 | |
---|
21 | import atexit |
---|
22 | import Test |
---|
23 | import xapi |
---|
24 | |
---|
25 | # Tracking of managed domains |
---|
26 | _managedDomains = [] |
---|
27 | _VMuuids = [] |
---|
28 | registered = 0 |
---|
29 | |
---|
30 | def addManagedDomain(name): |
---|
31 | global registered |
---|
32 | _managedDomains.append(name) |
---|
33 | if not registered: |
---|
34 | atexit.register(destroyManagedDomains) |
---|
35 | registered = 1 |
---|
36 | |
---|
37 | def delManagedDomain(name): |
---|
38 | if name in _managedDomains: |
---|
39 | del _managedDomains[_managedDomains.index(name)] |
---|
40 | |
---|
41 | def addXAPIDomain(uuid): |
---|
42 | global registered |
---|
43 | _VMuuids.append(uuid) |
---|
44 | if not registered: |
---|
45 | atexit.register(destroyManagedDomains) |
---|
46 | registered = 1 |
---|
47 | |
---|
48 | def delXAPIDomain(uuid): |
---|
49 | _VMuuids.remove(uuid) |
---|
50 | |
---|
51 | def destroyManagedDomains(): |
---|
52 | if len(_managedDomains) > 0: |
---|
53 | for m in _managedDomains: |
---|
54 | Test.traceCommand("xm destroy %s" % m) |
---|
55 | Test.traceCommand("xm delete %s" % m) |
---|
56 | if len(_VMuuids) > 0: |
---|
57 | for uuid in _VMuuids: |
---|
58 | Test.traceCommand("xm destroy %s" % uuid) |
---|
59 | Test.traceCommand("xm delete %s" % uuid) |
---|
60 | |
---|
61 | |
---|