root / trunk / src / haizea / core / enact / actions.py @ 641
1 |
# -------------------------------------------------------------------------- #
|
---|---|
2 |
# Copyright 2006-2009, University of Chicago #
|
3 |
# Copyright 2008-2009, Distributed Systems Architecture Group, Universidad #
|
4 |
# Complutense de Madrid (dsa-research.org) #
|
5 |
# #
|
6 |
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
7 |
# not use this file except in compliance with the License. You may obtain #
|
8 |
# a copy of the License at #
|
9 |
# #
|
10 |
# http://www.apache.org/licenses/LICENSE-2.0 #
|
11 |
# #
|
12 |
# Unless required by applicable law or agreed to in writing, software #
|
13 |
# distributed under the License is distributed on an "AS IS" BASIS, #
|
14 |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
|
15 |
# See the License for the specific language governing permissions and #
|
16 |
# limitations under the License. #
|
17 |
# -------------------------------------------------------------------------- #
|
18 |
|
19 |
class EnactmentAction(object): |
20 |
def __init__(self): |
21 |
self.lease_haizea_id = None |
22 |
self.lease_enactment_info = None |
23 |
|
24 |
def from_rr(self, rr): |
25 |
self.lease_haizea_id = rr.lease.id
|
26 |
self.lease_enactment_info = rr.lease.enactment_info
|
27 |
|
28 |
class VNode(object): |
29 |
def __init__(self, enactment_info): |
30 |
self.enactment_info = enactment_info
|
31 |
self.pnode = None |
32 |
self.resources = None |
33 |
self.diskimage = None |
34 |
|
35 |
class VMEnactmentAction(EnactmentAction): |
36 |
def __init__(self): |
37 |
EnactmentAction.__init__(self)
|
38 |
self.vnodes = {}
|
39 |
|
40 |
def from_rr(self, rr): |
41 |
EnactmentAction.from_rr(self, rr)
|
42 |
self.vnodes = dict([(vnode, VNode(info)) for (vnode, info) in rr.lease.vnode_enactment_info.items()]) |
43 |
|
44 |
class VMEnactmentStartAction(VMEnactmentAction): |
45 |
def __init__(self): |
46 |
VMEnactmentAction.__init__(self)
|
47 |
|
48 |
class VMEnactmentStopAction(VMEnactmentAction): |
49 |
def __init__(self): |
50 |
VMEnactmentAction.__init__(self)
|
51 |
|
52 |
class VMEnactmentSuspendAction(VMEnactmentAction): |
53 |
def __init__(self): |
54 |
VMEnactmentAction.__init__(self)
|
55 |
|
56 |
def from_rr(self, rr): |
57 |
VMEnactmentAction.from_rr(self, rr)
|
58 |
self.vnodes = dict([(k, v) for (k,v) in self.vnodes.items() if k in rr.vnodes]) |
59 |
|
60 |
class VMEnactmentResumeAction(VMEnactmentAction): |
61 |
def __init__(self): |
62 |
VMEnactmentAction.__init__(self)
|
63 |
|
64 |
def from_rr(self, rr): |
65 |
VMEnactmentAction.from_rr(self, rr)
|
66 |
self.vnodes = dict([(k, v) for (k,v) in self.vnodes.items() if k in rr.vnodes]) |
67 |
|
68 |
class VMEnactmentConfirmSuspendAction(VMEnactmentAction): |
69 |
def __init__(self): |
70 |
VMEnactmentAction.__init__(self)
|
71 |
|
72 |
def from_rr(self, rr): |
73 |
VMEnactmentAction.from_rr(self, rr)
|
74 |
self.vnodes = dict([(k, v) for (k,v) in self.vnodes.items() if k in rr.vnodes]) |
75 |
|
76 |
class VMEnactmentConfirmResumeAction(VMEnactmentAction): |
77 |
def __init__(self): |
78 |
VMEnactmentAction.__init__(self)
|
79 |
|
80 |
def from_rr(self, rr): |
81 |
VMEnactmentAction.from_rr(self, rr)
|
82 |
self.vnodes = dict([(k, v) for (k,v) in self.vnodes.items() if k in rr.vnodes]) |