Merge lp:~gz/pyjuju/0.6_default_instance_backport into lp:pyjuju/0.6

Proposed by Martin Packman on 2013-04-02
Status: Merged
Merged at revision: 598
Proposed branch: lp:~gz/pyjuju/0.6_default_instance_backport
Merge into: lp:pyjuju/0.6
Diff against target: 136 lines (+32/-6)
5 files modified
juju/environment/config.py (+3/-2)
juju/environment/tests/test_config.py (+0/-1)
juju/providers/openstack/launch.py (+1/-1)
juju/providers/openstack/tests/__init__.py (+0/-2)
juju/providers/openstack/tests/test_launch.py (+28/-0)
To merge this branch: bzr merge lp:~gz/pyjuju/0.6_default_instance_backport
Reviewer Review Type Date Requested Status
Martin Packman (community) Approve on 2013-04-03
Review via email: mp+156597@code.launchpad.net

Description of the change

Backport correct warning and ignoring behaviour for default-instance-type configuration in openstack.

See the original merge proposal for more details:

<https://code.launchpad.net/~gz/juju/no_default_instance_1069883/+merge/134168>

To post a comment you must log in.
Martin Packman (gz) wrote :

Test suite passes with change.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'juju/environment/config.py'
2--- juju/environment/config.py 2012-09-20 15:11:08 +0000
3+++ juju/environment/config.py 2013-04-02 15:06:25 +0000
4@@ -76,7 +76,7 @@
5 optional=[
6 "access-key", "secret-key", "auth-url", "project-name",
7 "auth-mode", "region", "use-floating-ip",
8- "ssl-hostname-verification"]),
9+ "ssl-hostname-verification", "default-instance-type"]),
10 "openstack_s3": KeyDict({
11 "control-bucket": String(),
12 "admin-secret": String(),
13@@ -96,7 +96,8 @@
14 optional=[
15 "access-key", "secret-key", "combined-key", "auth-url",
16 "s3-uri", "project-name", "auth-mode", "region",
17- "use-floating-ip", "ssl-hostname-verification"]),
18+ "use-floating-ip", "ssl-hostname-verification",
19+ "default-instance-type"]),
20 "orchestra": KeyDict({
21 "orchestra-server": String(),
22 "orchestra-user": String(),
23
24=== modified file 'juju/environment/tests/test_config.py'
25--- juju/environment/tests/test_config.py 2012-09-27 04:36:51 +0000
26+++ juju/environment/tests/test_config.py 2013-04-02 15:06:25 +0000
27@@ -67,7 +67,6 @@
28 admin-secret: sekret
29 control-bucket: container
30 default-image-id: 42
31- default-instance-type: m1-sample
32 default-series: precise
33 """
34
35
36=== modified file 'juju/providers/openstack/launch.py'
37--- juju/providers/openstack/launch.py 2012-08-21 16:30:17 +0000
38+++ juju/providers/openstack/launch.py 2013-04-02 15:06:25 +0000
39@@ -86,7 +86,7 @@
40 # Find appropriate instance type for the given constraints. Warn
41 # if deprecated is instance-type is being used.
42 flavor_name = self._provider.config.get("default-instance-type")
43- if flavor_name is None:
44+ if flavor_name is not None:
45 log.warning(
46 "default-instance-type is deprecated, use cli --constraints")
47 flavors = yield self._provider.nova.list_flavor_details()
48
49=== modified file 'juju/providers/openstack/tests/__init__.py'
50--- juju/providers/openstack/tests/__init__.py 2012-08-24 19:22:13 +0000
51+++ juju/providers/openstack/tests/__init__.py 2013-04-02 15:06:25 +0000
52@@ -100,7 +100,6 @@
53 "auth-url": self.api_url,
54 "project-name": "test_project",
55 "control-bucket": self.environment_name,
56- "default-instance-type": "standard.xsmall",
57 "default-image-id": 42,
58 "use-floating-ip": True,
59 "ssl-hostname-verification": True,
60@@ -189,7 +188,6 @@
61 "auth-url": api_url,
62 "project-name": "aproject",
63 "control-bucket": environment_name,
64- "default-instance-type": "standard.xsmall",
65 "default-image-id": 42,
66 "ssl-hostname-verification": True,
67 }
68
69=== modified file 'juju/providers/openstack/tests/test_launch.py'
70--- juju/providers/openstack/tests/test_launch.py 2012-09-10 03:20:20 +0000
71+++ juju/providers/openstack/tests/test_launch.py 2013-04-02 15:06:25 +0000
72@@ -113,6 +113,13 @@
73 def get_cc_matcher(self, machine_id, provider, is_master=False):
74 return _CloudConfigMatcher(self, machine_id, provider, is_master).match
75
76+ def _check_log(self, log, pattern):
77+ self.assertRegexpMatches(log.getvalue(), pattern)
78+
79+ def capture_and_check_log(self, pattern="^$", logname="juju.openstack"):
80+ log = self.capture_logging(logname)
81+ self.addCleanup(self._check_log, log, pattern)
82+
83 def test_start_machine_with_constraints(self):
84 provider = MockedLaunchProvider(self.mocker)
85 provider.expect_zookeeper_machines(1000, "master.invalid")
86@@ -126,8 +133,26 @@
87 },
88 flavor_id=2)
89 self.mocker.replay()
90+ self.capture_and_check_log()
91 return provider.launch("1", constraints=["cpu=2", "mem=3G"])
92
93+ def test_start_machine_with_default_instance_type(self):
94+ config = dict(MockedLaunchProvider.default_config)
95+ config['default-instance-type'] = "m1.sample"
96+ provider = MockedLaunchProvider(self.mocker, config)
97+ provider.expect_zookeeper_machines(1000, "master.invalid")
98+ provider.expect_launch_setup("1")
99+ provider.expect_run_server("1",
100+ self.get_cc_matcher("1", provider),
101+ response={
102+ 'id': 1001,
103+ 'addresses': {'public': []},
104+ })
105+ self.mocker.replay()
106+ self.capture_and_check_log(
107+ "^default-instance-type is deprecated.*constraints")
108+ return provider.launch("1")
109+
110 def test_start_machine(self):
111 provider = MockedLaunchProvider(self.mocker)
112 provider.expect_zookeeper_machines(1000, "master.invalid")
113@@ -139,6 +164,7 @@
114 'addresses': {'public': []},
115 })
116 self.mocker.replay()
117+ self.capture_and_check_log()
118 return provider.launch("1")
119
120 def test_start_machine_delay(self):
121@@ -159,6 +185,7 @@
122 provider.expect_available_floating_ip(1001)
123 self.mocker.result(succeed(None))
124 self.mocker.replay()
125+ self.capture_and_check_log()
126 self.patch(NovaLaunchMachine, "_DELAY_FOR_ADDRESSES", 0)
127 return provider.launch("1")
128
129@@ -175,6 +202,7 @@
130 provider.provider_actions.save_state({'zookeeper-instances': [1000]})
131 self.mocker.result(succeed(None))
132 self.mocker.replay()
133+ self.capture_and_check_log()
134 return provider.launch("0", master=True)
135
136 def test_start_machine_master(self):

Subscribers

People subscribed via source and target branches