congress.policy_engines.vm_placement module¶
-
class
congress.policy_engines.vm_placement.
ComputePlacementEngine
(name='', keys='', inbox=None, datapath=None, args=None)¶ Bases:
congress.policy_engines.base_driver.PolicyEngineDriver
-
calculate_vm_assignment
()¶ Calculate where VMs should be located in order to minimize warnings.
Returns a dictionary from guest ID to host ID where that guest should be located.
Raises LpProblemUnsolvable if the LP cannot solve the given problem.
Raises LpConversionFailure if self.policy cannot be converted into an LP problem.
-
datalog_to_lp
(query, unknown_table_possibilities)¶ Convert rules defining QUERY in self.policy into a linear program.
@unknowns is the list of tablenames that should become decision variables. @unknown_table_possibilities is the list of all possible instances of the decision variable tables.
-
debug_mode
()¶
-
delete
(formula)¶
-
domain_axioms
()¶ Return a list of all the domain-specific axioms as strings.
Axioms define relationships between LP decision variables that we would not expect the user to write.
-
enforce_policy
()¶ Enforce policy by migrating VMs to minimize warnings.
Raises LpProblemUnsolvable if the LP cannot solve the given problem.
Raises LpConversionFailure if self.policy cannot be converted into an LP problem.
-
get_guests
()¶
-
get_hosts
()¶
-
get_memusage
()¶
-
initialize_table_subscriptions
()¶ Initialize table subscription.
Once policies have all been loaded, this function subscribes to all the necessary tables. See UPDATE_TABLE_SUBSCRIPTIONS as well.
-
insert
(formula)¶
-
parse
(policy)¶
-
parse1
(policy)¶
-
policy_to_lp
()¶ Transform self.policy into a (non-)linear programming problem.
Returns (<optimization criteria>, <hard constraints>) where each are represented using expressions constructed by self.lplang.
-
policy_to_lp_problem
()¶ Return an LP problem representing the state of this engine.
Returns an instance of self.lplang.problem representing the policy and the current data of this engine.
-
production_mode
()¶
-
receive_data
(msg)¶ Event handler for when a dataservice publishes data.
That data can either be the full table (as a list of tuples) or a delta (a list of Events).
-
receive_data_full
(msg)¶ Handler for when dataservice publishes full table.
-
receive_data_update
(msg)¶ Handler for when dataservice publishes a delta.
-
rewrites
= ['ceilometer:mem_consumption(x, y) :- var("hMemUse", x), output(y)']¶
-
select
(query)¶
-
set_bounds
(expr, bounds)¶ Find upper bounds on all variables occurring in expr.
- Param
expr is a LpLang.Expression
- Param
bounds: is a dictionary mapping an Expression’s tuple() to a number.
Modifies bounds to include values for all variables occurring inside expr.
-
set_policy
(policy)¶ Set the policy of this policy engine. POLICY is a datalog string.
-
unknowns
= ['ceilometer:mem_consumption']¶
-
-
exception
congress.policy_engines.vm_placement.
LpProblemUnsolvable
(message=None, **kwargs)¶
-
exception
congress.policy_engines.vm_placement.
NotEnoughData
(message=None, **kwargs)¶
-
class
congress.policy_engines.vm_placement.
VmMigrator
¶ Bases:
object
Code for migrating VMs once we have a LP problem solution.
-
classmethod
check_status
(guest, host, status)¶
-
classmethod
do_migration
(guest, newh, oldh)¶
-
classmethod
do_migrations
(g_h_mapping)¶
-
classmethod
getnext
(mapping, status)¶
-
classmethod
migrate
(guest, host)¶
-
classmethod
-
congress.policy_engines.vm_placement.
d6service
(name, keys, inbox, datapath, args)¶ This method is called by d6cage to create a dataservice instance.