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

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

Issue 5752069: Supporting for forcing upgrades when unit not in started state.
Patch Set: Supporting for forcing upgrades when unit not in started state. Created 5 years, 10 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
« no previous file with comments | « juju/control/tests/test_destroy_environment.py ('k') | juju/state/errors.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 """Implementation of charm-upgrade subcommand""" 1 """Implementation of charm-upgrade subcommand"""
2 2
3 from twisted.internet.defer import inlineCallbacks 3 from twisted.internet.defer import inlineCallbacks
4 4
5 from juju.control.utils import get_environment, expand_path 5 from juju.control.utils import get_environment, expand_path
6 6
7 from juju.charm.directory import CharmDirectory 7 from juju.charm.directory import CharmDirectory
8 from juju.charm.errors import NewerCharmNotFound 8 from juju.charm.errors import NewerCharmNotFound
9 from juju.charm.publisher import CharmPublisher 9 from juju.charm.publisher import CharmPublisher
10 from juju.charm.repository import resolve 10 from juju.charm.repository import resolve
11 from juju.charm.url import CharmURL 11 from juju.charm.url import CharmURL
12 12
13 from juju.state.service import ServiceStateManager 13 from juju.state.service import ServiceStateManager
14 from juju.unit.workflow import is_unit_running 14 from juju.unit.workflow import is_unit_running
15 15
16 16
17 def configure_subparser(subparsers): 17 def configure_subparser(subparsers):
18 """Configure charm-upgrade subcommand""" 18 """Configure charm-upgrade subcommand"""
19 sub_parser = subparsers.add_parser("upgrade-charm", help=command.__doc__) 19 sub_parser = subparsers.add_parser("upgrade-charm", help=command.__doc__)
20 sub_parser.add_argument( 20 sub_parser.add_argument(
21 "--dry-run", "-n", action="store_true", 21 "--dry-run", "-n", action="store_true",
22 help="Dry-Run, show which charm would be deployed for upgrade.") 22 help="Dry-Run, show which charm would be deployed for upgrade.")
23 sub_parser.add_argument( 23 sub_parser.add_argument(
24 "--force", action="store_true",
25 help="Force an upgrade, regardless of unit state")
26 sub_parser.add_argument(
24 "--environment", "-e", 27 "--environment", "-e",
25 help="juju environment to operate in.") 28 help="juju environment to operate in.")
26 sub_parser.add_argument( 29 sub_parser.add_argument(
27 "--repository", 30 "--repository",
28 help="Directory for charm lookup and retrieval", 31 help="Directory for charm lookup and retrieval",
29 type=expand_path) 32 type=expand_path)
30 sub_parser.add_argument( 33 sub_parser.add_argument(
31 "service_name", 34 "service_name",
32 help="Name of the service that should be upgraded") 35 help="Name of the service that should be upgraded")
33 return sub_parser 36 return sub_parser
34 37
35 38
36 def command(options): 39 def command(options):
37 """Upgrade a service's charm.""" 40 """Upgrade a service's charm."""
38 environment = get_environment(options) 41 environment = get_environment(options)
39 return upgrade_charm( 42 return upgrade_charm(
40 options.environments, 43 options.environments,
41 environment, 44 environment,
42 options.verbose, 45 options.verbose,
43 options.log, 46 options.log,
44 options.repository, 47 options.repository,
45 options.service_name, 48 options.service_name,
46 options.dry_run) 49 options.dry_run,
50 options.force)
47 51
48 52
49 @inlineCallbacks 53 @inlineCallbacks
50 def upgrade_charm( 54 def upgrade_charm(
51 config, environment, verbose, log, repository_path, service_name, dry_run): 55 config, environment, verbose, log, repository_path, service_name,
56 dry_run, force):
niemeyer 2012/03/19 22:15:45 Isn't there something missing below?
52 """Upgrades a service's charm. 57 """Upgrades a service's charm.
53 58
54 First determines if an upgrade is available, then updates the 59 First determines if an upgrade is available, then updates the
55 service charm reference, and marks the units as needing upgrades. 60 service charm reference, and marks the units as needing upgrades.
56 """ 61 """
57 provider = environment.get_machine_provider() 62 provider = environment.get_machine_provider()
58 client = yield provider.connect() 63 client = yield provider.connect()
59 64
60 service_manager = ServiceStateManager(client) 65 service_manager = ServiceStateManager(client)
61 service_state = yield service_manager.get_service_state(service_name) 66 service_state = yield service_manager.get_service_state(service_name)
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 for unit in units: 121 for unit in units:
117 running, state = yield is_unit_running(client, unit) 122 running, state = yield is_unit_running(client, unit)
118 if not running: 123 if not running:
119 log.info( 124 log.info(
120 "Unit %r is not in a running state (state: %r), won't upgrade", 125 "Unit %r is not in a running state (state: %r), won't upgrade",
121 unit.unit_name, state or "uninitialized") 126 unit.unit_name, state or "uninitialized")
122 continue 127 continue
123 128
124 if not dry_run: 129 if not dry_run:
125 yield unit.set_upgrade_flag() 130 yield unit.set_upgrade_flag()
OLDNEW
« no previous file with comments | « juju/control/tests/test_destroy_environment.py ('k') | juju/state/errors.py » ('j') | no next file with comments »

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