Revision 632
Added by Borja Sotomayor almost 15 years ago
utils.py | ||
---|---|---|
76 | 76 |
LEASE_ID += 1 |
77 | 77 |
return l |
78 | 78 |
|
79 |
def reset_lease_id_counter(): |
|
80 |
global LEASE_ID |
|
81 |
LEASE_ID = 1 |
|
82 |
|
|
79 | 83 |
def pretty_nodemap(nodes): |
80 | 84 |
pnodes = list(set(nodes.values())) |
81 | 85 |
normmap = [([y[0] for y in nodes.items() if y[1]==x], x) for x in pnodes] |
... | ... | |
96 | 100 |
else: |
97 | 101 |
return value |
98 | 102 |
|
103 |
def import_class(fq_name): |
|
104 |
fq_name = fq_name.split(".") |
|
105 |
package_name = ".".join(fq_name[:-1]) |
|
106 |
class_name = fq_name[-1] |
|
107 |
module = __import__(package_name, fromlist=[class_name]) |
|
108 |
exec("cls = module.%s" % class_name) |
|
109 |
return cls |
|
110 |
|
|
99 | 111 |
class Singleton(object): |
100 | 112 |
""" |
101 | 113 |
A singleton base class. |
... | ... | |
116 | 128 |
|
117 | 129 |
|
118 | 130 |
def get_config(): |
119 |
from haizea.resourcemanager.rm import ResourceManager
|
|
120 |
return ResourceManager.get_singleton().config
|
|
131 |
from haizea.core.manager import Manager
|
|
132 |
return Manager.get_singleton().config |
|
121 | 133 |
|
122 | 134 |
def get_accounting(): |
123 |
from haizea.resourcemanager.rm import ResourceManager
|
|
124 |
return ResourceManager.get_singleton().accounting
|
|
135 |
from haizea.core.manager import Manager
|
|
136 |
return Manager.get_singleton().accounting |
|
125 | 137 |
|
126 | 138 |
def get_clock(): |
127 |
from haizea.resourcemanager.rm import ResourceManager
|
|
128 |
return ResourceManager.get_singleton().clock
|
|
139 |
from haizea.core.manager import Manager
|
|
140 |
return Manager.get_singleton().clock |
|
129 | 141 |
|
142 |
def get_policy(): |
|
143 |
from haizea.core.manager import Manager |
|
144 |
return Manager.get_singleton().policy |
|
145 |
|
|
130 | 146 |
class InvalidStateMachineTransition(Exception): |
131 | 147 |
pass |
132 | 148 |
|
Also available in: Unified diff
Merged TP2.0/0.9 branch into trunk.