52 |
52 |
from haizea.core.rpcserver import RPCServer
|
53 |
53 |
from haizea.common.utils import abstract, round_datetime, Singleton, import_class, OpenNebulaXMLRPCClientSingleton
|
54 |
54 |
from haizea.common.opennebula_xmlrpc import OpenNebulaXMLRPCClient
|
55 |
|
from haizea.pluggable.policies import admission_class_mappings, preemption_class_mappings, host_class_mappings
|
|
55 |
from haizea.pluggable.policies import admission_class_mappings, preemption_class_mappings, host_class_mappings, pricing_mappings
|
56 |
56 |
from haizea.pluggable.accounting import probe_class_mappings
|
57 |
57 |
|
58 |
58 |
import operator
|
... | ... | |
91 |
91 |
pidfile -- When running as a daemon, file to save pid to
|
92 |
92 |
"""
|
93 |
93 |
self.config = config
|
94 |
|
|
|
94 |
self.daemon = daemon
|
|
95 |
self.pidfile = pidfile
|
|
96 |
|
|
97 |
# Has to be in a separate function since some pluggable modules need to
|
|
98 |
# access the Manager singleton
|
|
99 |
def __initialize(self):
|
95 |
100 |
# Create the RM components
|
96 |
101 |
|
97 |
|
mode = config.get("mode")
|
|
102 |
mode = self.config.get("mode")
|
98 |
103 |
|
99 |
|
self.daemon = daemon
|
100 |
|
self.pidfile = pidfile
|
101 |
104 |
|
102 |
105 |
if mode == "simulated":
|
103 |
106 |
# Simulated-time simulations always run in the foreground
|
... | ... | |
157 |
160 |
else:
|
158 |
161 |
site = Site.from_resources_string(resources)
|
159 |
162 |
|
160 |
|
deploy_bandwidth = config.get("imagetransfer-bandwidth")
|
|
163 |
deploy_bandwidth = self.config.get("imagetransfer-bandwidth")
|
161 |
164 |
info_enact = SimulatedResourcePoolInfo(site)
|
162 |
165 |
vm_enact = SimulatedVMEnactment()
|
163 |
166 |
deploy_enact = SimulatedDeploymentEnactment(deploy_bandwidth)
|
... | ... | |
205 |
208 |
host_selection = import_class(host_selection)
|
206 |
209 |
host_selection = host_selection(slottable)
|
207 |
210 |
|
208 |
|
self.policy = PolicyManager(admission, preemption, host_selection)
|
|
211 |
pricing = self.config.get("policy.pricing")
|
|
212 |
pricing = pricing_mappings.get(pricing, pricing)
|
|
213 |
pricing = import_class(pricing)
|
|
214 |
pricing = pricing(slottable)
|
209 |
215 |
|
|
216 |
self.policy = PolicyManager(admission, preemption, host_selection, pricing)
|
|
217 |
|
210 |
218 |
# Preparation scheduler
|
211 |
219 |
if preparation_type == constants.PREPARATION_UNMANAGED:
|
212 |
220 |
preparation_scheduler = UnmanagedPreparationScheduler(slottable, resourcepool, deploy_enact)
|
... | ... | |
339 |
347 |
|
340 |
348 |
def start(self):
|
341 |
349 |
"""Starts the resource manager"""
|
|
350 |
|
|
351 |
self.__initialize()
|
|
352 |
|
342 |
353 |
self.logger.info("Starting resource manager")
|
343 |
354 |
|
344 |
355 |
for frontend in self.frontends:
|
- Separated constructor from initialization code in Manager
- Added dynamic loading of pricing policies