Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(1170)

Side by Side Diff: juju/control/constraints_set.py

Issue 5946047: Documentation fixes
Patch Set: Documentation fixes Created 12 years, 11 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
OLDNEW
1 import argparse 1 import argparse
2 2
3 from twisted.internet.defer import inlineCallbacks 3 from twisted.internet.defer import inlineCallbacks
4 4
5 from juju.control import legacy 5 from juju.control import legacy
6 from juju.control.utils import get_environment 6 from juju.control.utils import get_environment, sync_environment_state
7 from juju.state.environment import EnvironmentStateManager 7 from juju.state.environment import EnvironmentStateManager
8 from juju.state.service import ServiceStateManager 8 from juju.state.service import ServiceStateManager
9 9
10 10
11 def configure_subparser(subparsers): 11 def configure_subparser(subparsers):
12 sub_parser = subparsers.add_parser( 12 sub_parser = subparsers.add_parser(
13 "set-constraints", 13 "set-constraints",
14 help=command.__doc__, 14 help=command.__doc__,
15 formatter_class=argparse.RawDescriptionHelpFormatter, 15 formatter_class=argparse.RawDescriptionHelpFormatter,
16 description=constraints_set.__doc__) 16 description=constraints_set.__doc__)
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 On Amazon EC2: 57 On Amazon EC2:
58 58
59 * arch (CPU architecture: i386/amd64/arm; amd64 by default) 59 * arch (CPU architecture: i386/amd64/arm; amd64 by default)
60 * cpu (processing power in Amazon ECU; 1 by default) 60 * cpu (processing power in Amazon ECU; 1 by default)
61 * mem (memory in [MGT]iB; 512M by default) 61 * mem (memory in [MGT]iB; 512M by default)
62 * instance-type (unset by default) 62 * instance-type (unset by default)
63 * ec2-zone (unset by default) 63 * ec2-zone (unset by default)
64 64
65 On Orchestra: 65 On Orchestra:
66 66
67 * orchestra-classes (unset by default) 67 * orchestra-classes (Cobbler management classes; unset by default)
68 68
69 On MAAS: 69 On MAAS:
70 70
71 * maas-name (unset by default) 71 * maas-name (MAAS system name; unset by default)
72 72
73 Service settings, if specified, will override environment settings, which 73 Service settings, if specified, will override environment settings, which
74 will in turn override the juju defaults of mem=512M, cpu=1, arch=amd64. 74 will in turn override the juju defaults.
75 75
76 New constraints set on an entity will completely replace that entity's 76 New constraints set on an entity will completely replace that entity's
77 pre-existing constraints. 77 pre-existing constraints; constraints left unspecified in new service
78 constraints will inherit from the environment constraints when units are
79 added.
78 80
79 To override an environment constraint with the juju default when setting 81 To override an environment constraint with the juju default when setting
80 service constraints, just specify "name=" (rather than just not specifying 82 service constraints, just specify "name=" (rather than just not specifying
81 the constraint at all, which will cause it to inherit the environment's 83 the constraint at all, which will cause it to inherit the environment's
82 value). 84 value).
83 85
84 To entirely unset a constraint, specify "name=any". 86 To entirely unset a constraint, specify "name=any".
85 """ 87 """
86 provider = environment.get_machine_provider() 88 provider = environment.get_machine_provider()
87 constraint_set = yield provider.get_constraint_set() 89 constraint_set = yield provider.get_constraint_set()
88 constraints = constraint_set.parse(constraint_strs) 90 constraints = constraint_set.parse(constraint_strs)
89 client = yield provider.connect() 91 client = yield provider.connect()
90 try: 92 try:
91 yield legacy.check_constraints(client, constraint_strs) 93 yield legacy.check_constraints(client, constraint_strs)
92 esm = EnvironmentStateManager(client) 94 yield sync_environment_state(client, env_config, environment.name)
93 yield esm.set_config_state(env_config, environment.name)
94 if service_name is None: 95 if service_name is None:
96 esm = EnvironmentStateManager(client)
95 yield esm.set_constraints(constraints) 97 yield esm.set_constraints(constraints)
96 else: 98 else:
97 ssm = ServiceStateManager(client) 99 ssm = ServiceStateManager(client)
98 service = yield ssm.get_service_state(service_name) 100 service = yield ssm.get_service_state(service_name)
99 yield service.set_constraints(constraints) 101 yield service.set_constraints(constraints)
100 finally: 102 finally:
101 yield client.close() 103 yield client.close()
OLDNEW

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b