Merge lp:~franciscosouza/pyjuju/juju-vpc into lp:pyjuju
- juju-vpc
- Merge into trunk
Status: | Needs review |
---|---|
Proposed branch: | lp:~franciscosouza/pyjuju/juju-vpc |
Merge into: | lp:pyjuju |
Diff against target: |
1999 lines (+752/-174) 46 files modified
juju/charm/repository.py (+3/-3) juju/lib/http_client.py (+74/-0) juju/machine/__init__.py (+2/-1) juju/machine/tests/data/test_get_container (+1/-1) juju/machine/tests/test_unit_deployment.py (+71/-1) juju/machine/unit.py (+35/-15) juju/providers/common/cloudinit.py (+35/-13) juju/providers/common/launch.py (+10/-0) juju/providers/common/tests/data/cloud_init_bootstrap (+2/-2) juju/providers/common/tests/data/cloud_init_bootstrap_extra_env (+69/-0) juju/providers/common/tests/data/cloud_init_bootstrap_zookeepers (+2/-2) juju/providers/common/tests/data/cloud_init_branch (+1/-1) juju/providers/common/tests/data/cloud_init_branch_trunk (+1/-1) juju/providers/common/tests/data/cloud_init_distro (+1/-2) juju/providers/common/tests/data/cloud_init_image (+35/-0) juju/providers/common/tests/data/cloud_init_image_extra_env (+39/-0) juju/providers/common/tests/data/cloud_init_no_machine_id (+2/-2) juju/providers/common/tests/data/cloud_init_normal (+2/-2) juju/providers/common/tests/data/cloud_init_ppa (+2/-2) juju/providers/common/tests/data/cloud_init_ppa_apt_proxy (+2/-2) juju/providers/common/tests/data/cloud_init_proposed (+1/-1) juju/providers/common/tests/test_cloudinit.py (+36/-0) juju/providers/ec2/__init__.py (+3/-2) juju/providers/ec2/launch.py (+34/-18) juju/providers/ec2/machine.py (+7/-3) juju/providers/ec2/securitygroup.py (+36/-20) juju/providers/ec2/tests/common.py (+13/-12) juju/providers/ec2/tests/data/bootstrap_cloud_init (+2/-2) juju/providers/ec2/tests/data/launch_cloud_init (+1/-1) juju/providers/ec2/tests/data/launch_cloud_init_branch (+1/-1) juju/providers/ec2/tests/data/launch_cloud_init_ip_address (+35/-0) juju/providers/ec2/tests/data/launch_cloud_init_ppa (+1/-1) juju/providers/ec2/tests/test_bootstrap.py (+3/-3) juju/providers/ec2/tests/test_launch.py (+63/-26) juju/providers/ec2/tests/test_machine.py (+18/-1) juju/providers/ec2/tests/test_securitygroup.py (+39/-10) juju/providers/ec2/tests/test_shutdown.py (+15/-10) juju/providers/ec2/utils.py (+2/-2) juju/providers/local/files.py (+2/-2) juju/providers/orchestra/files.py (+2/-2) juju/providers/orchestra/tests/data/bootstrap_user_data (+2/-2) juju/providers/orchestra/tests/data/launch_user_data (+1/-1) juju/unit/address.py (+13/-2) juju/unit/charm.py (+2/-2) juju/unit/deploy.py (+5/-0) juju/unit/tests/test_address.py (+26/-0) |
To merge this branch: | bzr merge lp:~franciscosouza/pyjuju/juju-vpc |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Juju Engineering | Pending | ||
Review via email: mp+134169@code.launchpad.net |
Commit message
Description of the change
providers/ec2: support VPC
To use VPC, all the user need to do is add two new environment settings: vpc_id
and subnet_id.
This CL depends on three other CLs (related to txaws):
- https:/
- https:/
- https:/
** NOT FOR MERGE **
- 605. By Francisco Souza
-
provides/ec2: removed unused import
Chico (franciscossouza) wrote : | # |
Please take a look.
- 606. By Francisco Souza
-
providers/ec2: record machine private_ip_address (for VPC)
- 607. By Francisco Souza
-
machine: support private_ip_address
- 608. By Francisco Souza
-
providers/common: added private mode to cloudinit
In private mode, it uses private_ip_address for zookeeper.
- 609. By Francisco Souza
-
providers/common: use cloudinit's private mode
- 610. By Francisco Souza
-
providers/ec2: update launch with subnet to work in private mode
Chico (franciscossouza) wrote : | # |
Please take a look.
- 611. By Francisco Souza
-
providers/ec2: added private mode
Also adapt to new txaws api.
Chico (franciscossouza) wrote : | # |
Please take a look.
- 612. By Francisco Souza
-
providers/ec2: don't use group_name on describe_
security_ groups I know that sucks, but we need a better solution later.
Chico (franciscossouza) wrote : | # |
Please take a look.
- 613. By Francisco Souza
-
cloudinit: added image source
This source should be used when juju comes pre-installed in the machine image.
Chico (franciscossouza) wrote : | # |
Please take a look.
Kapil Thangavelu (hazmat) wrote : | # |
one comment regarding correctness.
https:/
File juju/providers/
https:/
juju/providers/
This is very suspect, deferred results should not be access directly,
this needs a callback registered or inlineCallbacks syntax.
Chico (franciscossouza) wrote : | # |
https:/
File juju/providers/
https:/
juju/providers/
On 2012/11/22 13:44:07, hazmat wrote:
> This is very suspect, deferred results should not be access directly,
this needs
> a callback registered or inlineCallbacks syntax.
Thanks, I will fix this.
I will also stop updating this CL using lbox, so you guys stop receiving
notifications. There is more than VPC in this CL now (proxy,
pre-installed juju, etc.), and we will probably keep using this fork. I
hope that we will be able to send smaller patchs for merging in the
(near) future.
Kapil Thangavelu (hazmat) wrote : | # |
no worries about using lbox, i don't mind having a look on occasion, i
understood from the merge proposal that it wasn't intended for merge. i've
been going through the txaws branches as well, which look good but i'll
need to rope in one more reviewer for them i think. i'd like to get some
additional functionality there for txaws to be able to create vpc, with a
goal that juju can create the vpc itself. cheers.
On Thu, Nov 22, 2012 at 8:58 AM, <email address hidden> wrote:
>
> https:/
> providers/
> File juju/providers/
>
> https:/
> providers/
> juju/providers/
> On 2012/11/22 13:44:07, hazmat wrote:
>
>> This is very suspect, deferred results should not be access directly,
>>
> this needs
>
>> a callback registered or inlineCallbacks syntax.
>>
>
> Thanks, I will fix this.
>
> I will also stop updating this CL using lbox, so you guys stop receiving
> notifications. There is more than VPC in this CL now (proxy,
> pre-installed juju, etc.), and we will probably keep using this fork. I
> hope that we will be able to send smaller patchs for merging in the
> (near) future.
>
> https:/
>
Chico (franciscossouza) wrote : | # |
On 2012/11/22 14:26:33, hazmat wrote:
> no worries about using lbox, i don't mind having a look on occasion, i
> understood from the merge proposal that it wasn't intended for merge.
i've
> been going through the txaws branches as well, which look good but
i'll
> need to rope in one more reviewer for them i think. i'd like to get
some
> additional functionality there for txaws to be able to create vpc,
with a
> goal that juju can create the vpc itself. cheers.
Indeed. txaws branches are there for merging, I think they're quite
there. Are you able to review and merge them? I'd like to move forward
in getting those branches merged.
Regards,
Francisco
- 614. By Francisco Souza
-
providers/ec2: don't use deferred.result
Chico (franciscossouza) wrote : | # |
Please take a look.
https:/
File juju/providers/
https:/
juju/providers/
On 2012/11/22 13:44:07, hazmat wrote:
> This is very suspect, deferred results should not be access directly,
this needs
> a callback registered or inlineCallbacks syntax.
Done.
- 615. By Francisco Souza
-
providers/common: added extra environment support for cloud init
- 616. By Francisco Souza
-
machine: added support for extra environment variables in unit deployment
- 617. By Francisco Souza
-
providers/common: launching vms with http and https proxy in upstart file
- 618. By Francisco Souza
-
unit/deploy: read http_proxy and https_proxy from os environment
These values are used to add new units, setting http_proxy and https_proxy in
upstart config file.
Chico (franciscossouza) wrote : | # |
Please take a look.
- 619. By Francisco Souza
-
providers/common: set extra environment on provision agent too
Chico (franciscossouza) wrote : | # |
Please take a look.
- 620. By Francisco Souza
-
lib: added http_client
This will wrap getPage and downloadPage from twisted, enabling proxy.
- 621. By Francisco Souza
-
all: use download_page and get_page from lib.http_client
Chico (franciscossouza) wrote : | # |
Please take a look.
- 622. By Francisco Souza
-
lib/http_client: don't use proxy to connect to localhost, 127.0.0.1 and 169.254.169.254
Chico (franciscossouza) wrote : | # |
Please take a look.
- 623. By Francisco Souza
-
lib/http_client: fix stupid error
Chico (franciscossouza) wrote : | # |
Please take a look.
- 624. By Francisco Souza
-
providers, unit: added private mode for address
A VPC instance does not have public DNS name, so the metadata url for this data
returns 404.
Chico (franciscossouza) wrote : | # |
Please take a look.
- 625. By Francisco Souza
-
unit/deploy: set JUJU_PRIVATE on service upstart file
Chico (franciscossouza) wrote : | # |
Please take a look.
Unmerged revisions
- 625. By Francisco Souza
-
unit/deploy: set JUJU_PRIVATE on service upstart file
- 624. By Francisco Souza
-
providers, unit: added private mode for address
A VPC instance does not have public DNS name, so the metadata url for this data
returns 404. - 623. By Francisco Souza
-
lib/http_client: fix stupid error
- 622. By Francisco Souza
-
lib/http_client: don't use proxy to connect to localhost, 127.0.0.1 and 169.254.169.254
- 621. By Francisco Souza
-
all: use download_page and get_page from lib.http_client
- 620. By Francisco Souza
-
lib: added http_client
This will wrap getPage and downloadPage from twisted, enabling proxy.
- 619. By Francisco Souza
-
providers/common: set extra environment on provision agent too
- 618. By Francisco Souza
-
unit/deploy: read http_proxy and https_proxy from os environment
These values are used to add new units, setting http_proxy and https_proxy in
upstart config file. - 617. By Francisco Souza
-
providers/common: launching vms with http and https proxy in upstart file
- 616. By Francisco Souza
-
machine: added support for extra environment variables in unit deployment
Preview Diff
1 | === modified file 'juju/charm/repository.py' | |||
2 | --- juju/charm/repository.py 2012-08-23 23:57:09 +0000 | |||
3 | +++ juju/charm/repository.py 2012-11-23 21:00:27 +0000 | |||
4 | @@ -7,7 +7,6 @@ | |||
5 | 7 | import yaml | 7 | import yaml |
6 | 8 | 8 | ||
7 | 9 | from twisted.internet.defer import fail, inlineCallbacks, returnValue, succeed | 9 | from twisted.internet.defer import fail, inlineCallbacks, returnValue, succeed |
8 | 10 | from twisted.web.client import downloadPage, getPage | ||
9 | 11 | from twisted.web.error import Error | 10 | from twisted.web.error import Error |
10 | 12 | from txaws.client.ssl import VerifyingContextFactory | 11 | from txaws.client.ssl import VerifyingContextFactory |
11 | 13 | 12 | ||
12 | @@ -15,6 +14,7 @@ | |||
13 | 15 | from juju.charm.url import CharmURL | 14 | from juju.charm.url import CharmURL |
14 | 16 | from juju.errors import FileNotFound | 15 | from juju.errors import FileNotFound |
15 | 17 | from juju.lib import under | 16 | from juju.lib import under |
16 | 17 | from juju.lib.http_client import download_page, get_page | ||
17 | 18 | 18 | ||
18 | 19 | from .errors import ( | 19 | from .errors import ( |
19 | 20 | CharmNotFound, CharmError, RepositoryNotFound, ServiceConfigValueError) | 20 | CharmNotFound, CharmError, RepositoryNotFound, ServiceConfigValueError) |
20 | @@ -129,7 +129,7 @@ | |||
21 | 129 | self.url_base, urllib.quote(charm_id)) | 129 | self.url_base, urllib.quote(charm_id)) |
22 | 130 | try: | 130 | try: |
23 | 131 | host = urlparse.urlparse(url).hostname | 131 | host = urlparse.urlparse(url).hostname |
25 | 132 | all_info = json.loads((yield getPage(url, contextFactory=VerifyingContextFactory(host)))) | 132 | all_info = json.loads((yield get_page(url, contextFactory=VerifyingContextFactory(host)))) |
26 | 133 | charm_info = all_info[charm_id] | 133 | charm_info = all_info[charm_id] |
27 | 134 | for warning in charm_info.get("warnings", []): | 134 | for warning in charm_info.get("warnings", []): |
28 | 135 | log.warning("%s: %s", charm_id, warning) | 135 | log.warning("%s: %s", charm_id, warning) |
29 | @@ -152,7 +152,7 @@ | |||
30 | 152 | downloading_path = f.name | 152 | downloading_path = f.name |
31 | 153 | host = urlparse.urlparse(url).hostname | 153 | host = urlparse.urlparse(url).hostname |
32 | 154 | try: | 154 | try: |
34 | 155 | yield downloadPage(url, downloading_path, contextFactory=VerifyingContextFactory(host)) | 155 | yield download_page(url, downloading_path, contextFactory=VerifyingContextFactory(host)) |
35 | 156 | except Error: | 156 | except Error: |
36 | 157 | raise CharmNotFound(self.url_base, charm_url) | 157 | raise CharmNotFound(self.url_base, charm_url) |
37 | 158 | os.rename(downloading_path, cache_path) | 158 | os.rename(downloading_path, cache_path) |
38 | 159 | 159 | ||
39 | === added file 'juju/lib/http_client.py' | |||
40 | --- juju/lib/http_client.py 1970-01-01 00:00:00 +0000 | |||
41 | +++ juju/lib/http_client.py 2012-11-23 21:00:27 +0000 | |||
42 | @@ -0,0 +1,74 @@ | |||
43 | 1 | # -*- coding: utf-8 -*- | ||
44 | 2 | import os | ||
45 | 3 | import urlparse | ||
46 | 4 | |||
47 | 5 | from twisted.internet import reactor | ||
48 | 6 | from twisted.internet.defer import Deferred | ||
49 | 7 | from twisted.internet.endpoints import TCP4ClientEndpoint | ||
50 | 8 | from twisted.internet.protocol import connectionDone, Protocol | ||
51 | 9 | from twisted.web.client import downloadPage, getPage, ProxyAgent, ResponseDone | ||
52 | 10 | from twisted.web.http import PotentialDataLoss | ||
53 | 11 | |||
54 | 12 | |||
55 | 13 | class Receiver(Protocol): | ||
56 | 14 | finished = None | ||
57 | 15 | _filename = None | ||
58 | 16 | |||
59 | 17 | def __init__(self, filename=None): | ||
60 | 18 | self.received = "" | ||
61 | 19 | if filename: | ||
62 | 20 | self._filename = filename | ||
63 | 21 | |||
64 | 22 | def dataReceived(self, data): | ||
65 | 23 | self.received += data | ||
66 | 24 | |||
67 | 25 | def connectionLost(self, reason=connectionDone): | ||
68 | 26 | reason.trap(ResponseDone, PotentialDataLoss, connectionDone) | ||
69 | 27 | d = self.finished | ||
70 | 28 | self.finished = None | ||
71 | 29 | if self._filename: | ||
72 | 30 | file = open(self._filename, "w") | ||
73 | 31 | try: | ||
74 | 32 | file.write(self.received) | ||
75 | 33 | finally: | ||
76 | 34 | file.close() | ||
77 | 35 | d.callback(self.received) | ||
78 | 36 | |||
79 | 37 | |||
80 | 38 | def response_saver(path): | ||
81 | 39 | def save_response(response): | ||
82 | 40 | receiver = Receiver(path) | ||
83 | 41 | receiver.finished = d = Deferred() | ||
84 | 42 | response.deliverBody(receiver) | ||
85 | 43 | return d | ||
86 | 44 | return save_response | ||
87 | 45 | |||
88 | 46 | |||
89 | 47 | def _deferred_get(url, proxy_endpoint): | ||
90 | 48 | proxy_url = urlparse.urlparse(proxy_endpoint) | ||
91 | 49 | endpoint = TCP4ClientEndpoint(reactor, proxy_url.hostname, proxy_url.port) | ||
92 | 50 | agent = ProxyAgent(endpoint) | ||
93 | 51 | return agent.request("GET", url) | ||
94 | 52 | |||
95 | 53 | |||
96 | 54 | def download_page(url, path, *args, **kwargs): | ||
97 | 55 | host = urlparse.urlparse(url).hostname | ||
98 | 56 | proxy_var = url.startswith("https://") and "https_proxy" or "http_proxy" | ||
99 | 57 | proxy_endpoint = os.environ.get(proxy_var) | ||
100 | 58 | if proxy_endpoint and host not in ("localhost", "127.0.0.1", "169.254.169.254"): | ||
101 | 59 | d = _deferred_get(url, proxy_endpoint) | ||
102 | 60 | d.addCallback(response_saver(path)) | ||
103 | 61 | return d | ||
104 | 62 | return downloadPage(url, path, *args, **kwargs) | ||
105 | 63 | |||
106 | 64 | |||
107 | 65 | def get_page(url, *args, **kwargs): | ||
108 | 66 | host = urlparse.urlparse(url).hostname | ||
109 | 67 | proxy_var = url.startswith("https://") and "https_proxy" or "http_proxy" | ||
110 | 68 | proxy_endpoint = os.environ.get(proxy_var) | ||
111 | 69 | if proxy_endpoint and host not in ("localhost", "127.0.0.1", "169.254.169.254"): | ||
112 | 70 | d = _deferred_get(url, proxy_endpoint) | ||
113 | 71 | d.addCallback(response_saver(None)) | ||
114 | 72 | return d | ||
115 | 73 | else: | ||
116 | 74 | return getPage(url, *args, **kwargs) | ||
117 | 0 | 75 | ||
118 | === modified file 'juju/machine/__init__.py' | |||
119 | --- juju/machine/__init__.py 2012-01-31 19:57:53 +0000 | |||
120 | +++ juju/machine/__init__.py 2012-11-23 21:00:27 +0000 | |||
121 | @@ -9,9 +9,10 @@ | |||
122 | 9 | """ | 9 | """ |
123 | 10 | 10 | ||
124 | 11 | def __init__(self, instance_id, dns_name=None, private_dns_name=None, | 11 | def __init__(self, instance_id, dns_name=None, private_dns_name=None, |
126 | 12 | state="unknown"): | 12 | state="unknown", private_ip_address=None): |
127 | 13 | self.instance_id = instance_id | 13 | self.instance_id = instance_id |
128 | 14 | # ideally this would be ip_address, but txaws doesn't expose it. | 14 | # ideally this would be ip_address, but txaws doesn't expose it. |
129 | 15 | self.dns_name = dns_name | 15 | self.dns_name = dns_name |
130 | 16 | self.private_dns_name = private_dns_name | 16 | self.private_dns_name = private_dns_name |
131 | 17 | self.private_ip_address = private_ip_address | ||
132 | 17 | self.state = state | 18 | self.state = state |
133 | 18 | 19 | ||
134 | === modified file 'juju/machine/tests/data/test_get_container' | |||
135 | --- juju/machine/tests/data/test_get_container 2012-10-09 18:55:55 +0000 | |||
136 | +++ juju/machine/tests/data/test_get_container 2012-11-23 21:00:27 +0000 | |||
137 | @@ -7,7 +7,7 @@ | |||
138 | 7 | machine-data: {juju-provider-type: null, juju-zookeeper-hosts: 'localhost:2181', | 7 | machine-data: {juju-provider-type: null, juju-zookeeper-hosts: 'localhost:2181', |
139 | 8 | machine-id: null} | 8 | machine-id: null} |
140 | 9 | output: {all: '| tee -a /var/log/cloud-init-output.log'} | 9 | output: {all: '| tee -a /var/log/cloud-init-output.log'} |
142 | 10 | packages: [bzr, byobu, tmux, python-setuptools, python-twisted, python-txaws, python-zookeeper] | 10 | packages: [bzr, byobu, tmux, python-setuptools, python-twisted, python-zookeeper, python-txaws] |
143 | 11 | runcmd: [sudo apt-get install -y python-txzookeeper, sudo mkdir -p /usr/lib/juju, | 11 | runcmd: [sudo apt-get install -y python-txzookeeper, sudo mkdir -p /usr/lib/juju, |
144 | 12 | 'cd /usr/lib/juju && sudo /usr/bin/bzr co --lightweight lp:juju | 12 | 'cd /usr/lib/juju && sudo /usr/bin/bzr co --lightweight lp:juju |
145 | 13 | juju', cd /usr/lib/juju/juju && sudo python setup.py develop, sudo mkdir -p /var/lib/juju, | 13 | juju', cd /usr/lib/juju/juju && sudo python setup.py develop, sudo mkdir -p /var/lib/juju, |
146 | 14 | 14 | ||
147 | === modified file 'juju/machine/tests/test_unit_deployment.py' | |||
148 | --- juju/machine/tests/test_unit_deployment.py 2012-10-05 13:55:09 +0000 | |||
149 | +++ juju/machine/tests/test_unit_deployment.py 2012-11-23 21:00:27 +0000 | |||
150 | @@ -15,7 +15,7 @@ | |||
151 | 15 | from juju.lib.lxc.tests.test_lxc import uses_sudo | 15 | from juju.lib.lxc.tests.test_lxc import uses_sudo |
152 | 16 | from juju.lib.mocker import ANY, KWARGS, MATCH | 16 | from juju.lib.mocker import ANY, KWARGS, MATCH |
153 | 17 | from juju.lib.upstart import UpstartService | 17 | from juju.lib.upstart import UpstartService |
155 | 18 | from juju.machine.unit import UnitMachineDeployment, UnitContainerDeployment | 18 | from juju.machine.unit import ExtraEnvironmentDeployment, UnitMachineDeployment, UnitContainerDeployment |
156 | 19 | from juju.machine.errors import UnitDeploymentError | 19 | from juju.machine.errors import UnitDeploymentError |
157 | 20 | from juju.machine import tests | 20 | from juju.machine import tests |
158 | 21 | from juju.tests.common import get_test_zookeeper_address | 21 | from juju.tests.common import get_test_zookeeper_address |
159 | @@ -143,6 +143,54 @@ | |||
160 | 143 | d.addCallback(verify_upstart) | 143 | d.addCallback(verify_upstart) |
161 | 144 | return d | 144 | return d |
162 | 145 | 145 | ||
163 | 146 | def test_service_unit_start_with_extra_environment(self): | ||
164 | 147 | """ | ||
165 | 148 | Starting a service unit will result in a unit workspace being created | ||
166 | 149 | if it does not exist and a running service unit agent. | ||
167 | 150 | """ | ||
168 | 151 | self.setup_mock() | ||
169 | 152 | self.mock_install() | ||
170 | 153 | self.mock_is_running(False) | ||
171 | 154 | self.mock_start() | ||
172 | 155 | self.mocker.replay() | ||
173 | 156 | |||
174 | 157 | self.deployment.set_env("http_proxy", "http://myproxy.com:3128/") | ||
175 | 158 | d = self.deployment.start( | ||
176 | 159 | "123", get_test_zookeeper_address(), self.bundle) | ||
177 | 160 | |||
178 | 161 | def verify_upstart(_): | ||
179 | 162 | conf_path = os.path.join(self.init_dir, "juju-wordpress-0.conf") | ||
180 | 163 | with open(conf_path) as f: | ||
181 | 164 | lines = f.readlines() | ||
182 | 165 | |||
183 | 166 | env = [] | ||
184 | 167 | for line in lines: | ||
185 | 168 | if line.startswith("env "): | ||
186 | 169 | env.append(line[4:-1].split("=", 1)) | ||
187 | 170 | if line.startswith("exec "): | ||
188 | 171 | exec_ = line[5:-1] | ||
189 | 172 | |||
190 | 173 | env = dict((k, v.strip('"')) for (k, v) in env) | ||
191 | 174 | env.pop("PYTHONPATH") | ||
192 | 175 | self.assertEquals(env, { | ||
193 | 176 | "JUJU_HOME": self.juju_directory, | ||
194 | 177 | "JUJU_UNIT_NAME": self.unit_name, | ||
195 | 178 | "JUJU_ZOOKEEPER": get_test_zookeeper_address(), | ||
196 | 179 | "JUJU_MACHINE_ID": "123", | ||
197 | 180 | "http_proxy": "http://myproxy.com:3128/"}) | ||
198 | 181 | |||
199 | 182 | log_file = os.path.join( | ||
200 | 183 | self.deployment.directory, "charm.log") | ||
201 | 184 | command = " ".join([ | ||
202 | 185 | "/usr/bin/python", "-m", "juju.agents.dummy", "--nodaemon", | ||
203 | 186 | "--logfile", log_file, "--session-file", | ||
204 | 187 | "/var/run/juju/unit-wordpress-0-agent.zksession", | ||
205 | 188 | ">> /tmp/juju-wordpress-0.output 2>&1"]) | ||
206 | 189 | self.assertEquals(exec_, command) | ||
207 | 190 | d.addCallback(verify_upstart) | ||
208 | 191 | self.deployment.unset_env("http_proxy") | ||
209 | 192 | return d | ||
210 | 193 | |||
211 | 146 | @inlineCallbacks | 194 | @inlineCallbacks |
212 | 147 | def test_service_unit_destroy(self): | 195 | def test_service_unit_destroy(self): |
213 | 148 | """ | 196 | """ |
214 | @@ -426,3 +474,25 @@ | |||
215 | 426 | 474 | ||
216 | 427 | container, rootfs = yield self.unit_deploy._get_container( | 475 | container, rootfs = yield self.unit_deploy._get_container( |
217 | 428 | "0", cloud_init) | 476 | "0", cloud_init) |
218 | 477 | |||
219 | 478 | |||
220 | 479 | class ExtraEnvironmentTest(RepositoryTestBase): | ||
221 | 480 | |||
222 | 481 | def test_set_env(self): | ||
223 | 482 | deploy = ExtraEnvironmentDeployment() | ||
224 | 483 | deploy.set_env("http_proxy", "http://myproxy.com:3128/") | ||
225 | 484 | self.assertEquals(deploy._extra_environment["http_proxy"], "http://myproxy.com:3128/") | ||
226 | 485 | |||
227 | 486 | def test_unset_env(self): | ||
228 | 487 | deploy = ExtraEnvironmentDeployment() | ||
229 | 488 | deploy.set_env("http_proxy", "http://myproxy.com:3128/") | ||
230 | 489 | deploy.unset_env("http_proxy") | ||
231 | 490 | self.assertNotIn("http_proxy", deploy._extra_environment) | ||
232 | 491 | |||
233 | 492 | def test_machine_deployment_extends_extra_environment(self): | ||
234 | 493 | assert issubclass(UnitMachineDeployment, ExtraEnvironmentDeployment), \ | ||
235 | 494 | "UnitMachineDeployment should inherit from ExtraEnvironmentDeployment!" | ||
236 | 495 | |||
237 | 496 | def test_container_deployment_extends_extra_environment(self): | ||
238 | 497 | assert issubclass(UnitContainerDeployment, ExtraEnvironmentDeployment), \ | ||
239 | 498 | "UnitContainerDeployment should inherit from ExtraEnvironmentDeployment!" | ||
240 | 429 | 499 | ||
241 | === modified file 'juju/machine/unit.py' | |||
242 | --- juju/machine/unit.py 2012-09-27 00:42:32 +0000 | |||
243 | +++ juju/machine/unit.py 2012-11-23 21:00:27 +0000 | |||
244 | @@ -8,7 +8,7 @@ | |||
245 | 8 | 8 | ||
246 | 9 | from juju.charm.bundle import CharmBundle | 9 | from juju.charm.bundle import CharmBundle |
247 | 10 | from juju.errors import ServiceError | 10 | from juju.errors import ServiceError |
249 | 11 | from juju.lib.lxc import LXCContainer, get_containers, LXCError | 11 | from juju.lib.lxc import LXCContainer, get_containers |
250 | 12 | from juju.lib.twistutils import get_module_directory | 12 | from juju.lib.twistutils import get_module_directory |
251 | 13 | from juju.lib.upstart import UpstartService | 13 | from juju.lib.upstart import UpstartService |
252 | 14 | from juju.providers.common.cloudinit import CloudInit | 14 | from juju.providers.common.cloudinit import CloudInit |
253 | @@ -27,20 +27,33 @@ | |||
254 | 27 | return UnitMachineDeployment | 27 | return UnitMachineDeployment |
255 | 28 | 28 | ||
256 | 29 | 29 | ||
264 | 30 | def _get_environment(unit_name, juju_home, machine_id, zookeeper_hosts): | 30 | def _get_environment(unit_name, juju_home, machine_id, zookeeper_hosts, base=None): |
265 | 31 | environ = dict() | 31 | if not base: |
266 | 32 | environ["JUJU_MACHINE_ID"] = str(machine_id) | 32 | base = {} |
267 | 33 | environ["JUJU_UNIT_NAME"] = unit_name | 33 | base["JUJU_MACHINE_ID"] = str(machine_id) |
268 | 34 | environ["JUJU_HOME"] = juju_home | 34 | base["JUJU_UNIT_NAME"] = unit_name |
269 | 35 | environ["JUJU_ZOOKEEPER"] = zookeeper_hosts | 35 | base["JUJU_HOME"] = juju_home |
270 | 36 | environ["PYTHONPATH"] = ":".join( | 36 | base["JUJU_ZOOKEEPER"] = zookeeper_hosts |
271 | 37 | base["PYTHONPATH"] = ":".join( | ||
272 | 37 | filter(None, [ | 38 | filter(None, [ |
273 | 38 | os.path.dirname(get_module_directory(juju)), | 39 | os.path.dirname(get_module_directory(juju)), |
274 | 39 | os.environ.get("PYTHONPATH")])) | 40 | os.environ.get("PYTHONPATH")])) |
279 | 40 | return environ | 41 | return base |
280 | 41 | 42 | ||
281 | 42 | 43 | ||
282 | 43 | class UnitMachineDeployment(object): | 44 | class ExtraEnvironmentDeployment(object): |
283 | 45 | |||
284 | 46 | def __init__(self): | ||
285 | 47 | self._extra_environment = {} | ||
286 | 48 | |||
287 | 49 | def set_env(self, name, value): | ||
288 | 50 | self._extra_environment[name] = value | ||
289 | 51 | |||
290 | 52 | def unset_env(self, name): | ||
291 | 53 | del self._extra_environment[name] | ||
292 | 54 | |||
293 | 55 | |||
294 | 56 | class UnitMachineDeployment(ExtraEnvironmentDeployment): | ||
295 | 44 | """ Deploy a unit directly onto a machine. | 57 | """ Deploy a unit directly onto a machine. |
296 | 45 | 58 | ||
297 | 46 | A service unit deployed directly to a machine has full access | 59 | A service unit deployed directly to a machine has full access |
298 | @@ -54,6 +67,7 @@ | |||
299 | 54 | unit_agent_module = "juju.agents.unit" | 67 | unit_agent_module = "juju.agents.unit" |
300 | 55 | 68 | ||
301 | 56 | def __init__(self, unit_name, juju_home): | 69 | def __init__(self, unit_name, juju_home): |
302 | 70 | super(UnitMachineDeployment, self).__init__() | ||
303 | 57 | assert ".." not in unit_name, "Invalid Unit Name" | 71 | assert ".." not in unit_name, "Invalid Unit Name" |
304 | 58 | self.unit_name = unit_name | 72 | self.unit_name = unit_name |
305 | 59 | self.juju_home = juju_home | 73 | self.juju_home = juju_home |
306 | @@ -72,7 +86,7 @@ | |||
307 | 72 | self.service.set_description( | 86 | self.service.set_description( |
308 | 73 | "Juju unit agent for %s" % self.unit_name) | 87 | "Juju unit agent for %s" % self.unit_name) |
309 | 74 | self.service.set_environ(_get_environment( | 88 | self.service.set_environ(_get_environment( |
311 | 75 | self.unit_name, self.juju_home, machine_id, zookeeper_hosts)) | 89 | self.unit_name, self.juju_home, machine_id, zookeeper_hosts, self._extra_environment)) |
312 | 76 | self.service.set_command(" ".join(( | 90 | self.service.set_command(" ".join(( |
313 | 77 | "/usr/bin/python", "-m", self.unit_agent_module, | 91 | "/usr/bin/python", "-m", self.unit_agent_module, |
314 | 78 | "--nodaemon", | 92 | "--nodaemon", |
315 | @@ -130,7 +144,7 @@ | |||
316 | 130 | "juju-%s" % self.unit_path_name, use_sudo=True) | 144 | "juju-%s" % self.unit_path_name, use_sudo=True) |
317 | 131 | 145 | ||
318 | 132 | 146 | ||
320 | 133 | class UnitContainerDeployment(object): | 147 | class UnitContainerDeployment(ExtraEnvironmentDeployment): |
321 | 134 | """Deploy a service unit in a container. | 148 | """Deploy a service unit in a container. |
322 | 135 | 149 | ||
323 | 136 | Units deployed in a container have strong isolation between | 150 | Units deployed in a container have strong isolation between |
324 | @@ -145,6 +159,7 @@ | |||
325 | 145 | """ | 159 | """ |
326 | 146 | 160 | ||
327 | 147 | def __init__(self, unit_name, juju_home): | 161 | def __init__(self, unit_name, juju_home): |
328 | 162 | super(UnitContainerDeployment, self).__init__() | ||
329 | 148 | self.unit_name = unit_name | 163 | self.unit_name = unit_name |
330 | 149 | self.juju_home = juju_home | 164 | self.juju_home = juju_home |
331 | 150 | self.unit_path_name = unit_name.replace("/", "-") | 165 | self.unit_path_name = unit_name.replace("/", "-") |
332 | @@ -189,7 +204,7 @@ | |||
333 | 189 | (zk, port) = zk.split(':') | 204 | (zk, port) = zk.split(':') |
334 | 190 | else: | 205 | else: |
335 | 191 | port = 2181 | 206 | port = 2181 |
337 | 192 | zks.append((zk,port)) | 207 | zks.append((zk, port)) |
338 | 193 | 208 | ||
339 | 194 | cloud_init.set_zookeeper_hosts(zks) | 209 | cloud_init.set_zookeeper_hosts(zks) |
340 | 195 | # XXX Very hard to access the provider's notion of network | 210 | # XXX Very hard to access the provider's notion of network |
341 | @@ -197,6 +212,9 @@ | |||
342 | 197 | # the apt-cacher-ng since this is meant for local provider. | 212 | # the apt-cacher-ng since this is meant for local provider. |
343 | 198 | cloud_init.set_apt_proxy('http://%s:3142' % zks[0][0]) | 213 | cloud_init.set_apt_proxy('http://%s:3142' % zks[0][0]) |
344 | 199 | 214 | ||
345 | 215 | for name, value in self._extra_environment.iteritems(): | ||
346 | 216 | cloud_init.set_env(name, value) | ||
347 | 217 | |||
348 | 200 | if self._juju_origin: | 218 | if self._juju_origin: |
349 | 201 | if self._juju_origin.startswith("lp:"): | 219 | if self._juju_origin.startswith("lp:"): |
350 | 202 | cloud_init.set_juju_source(branch=self._juju_origin) | 220 | cloud_init.set_juju_source(branch=self._juju_origin) |
351 | @@ -204,6 +222,8 @@ | |||
352 | 204 | cloud_init.set_juju_source(ppa=True) | 222 | cloud_init.set_juju_source(ppa=True) |
353 | 205 | elif self._juju_origin == "proposed": | 223 | elif self._juju_origin == "proposed": |
354 | 206 | cloud_init.set_juju_source(proposed=True) | 224 | cloud_init.set_juju_source(proposed=True) |
355 | 225 | elif self._juju_origin == "image": | ||
356 | 226 | cloud_init.set_juju_source(image=True) | ||
357 | 207 | else: | 227 | else: |
358 | 208 | # Ignore other values, just use the distro for sanity | 228 | # Ignore other values, just use the distro for sanity |
359 | 209 | cloud_init.set_juju_source(distro=True) | 229 | cloud_init.set_juju_source(distro=True) |
360 | 210 | 230 | ||
361 | === modified file 'juju/providers/common/cloudinit.py' | |||
362 | --- juju/providers/common/cloudinit.py 2012-10-09 18:55:55 +0000 | |||
363 | +++ juju/providers/common/cloudinit.py 2012-11-23 21:00:27 +0000 | |||
364 | @@ -13,6 +13,7 @@ | |||
365 | 13 | PPA = "ppa" | 13 | PPA = "ppa" |
366 | 14 | BRANCH = "branch" | 14 | BRANCH = "branch" |
367 | 15 | PROPOSED = "proposed" | 15 | PROPOSED = "proposed" |
368 | 16 | IMAGE = "image" | ||
369 | 16 | 17 | ||
370 | 17 | 18 | ||
371 | 18 | def _branch_install_scripts(branch): | 19 | def _branch_install_scripts(branch): |
372 | @@ -45,11 +46,13 @@ | |||
373 | 45 | b64encode(serializer.dump(constraints.data)), provider_type)] | 46 | b64encode(serializer.dump(constraints.data)), provider_type)] |
374 | 46 | 47 | ||
375 | 47 | 48 | ||
377 | 48 | def _machine_scripts(machine_id, zookeeper_hosts): | 49 | def _machine_scripts(machine_id, zookeeper_hosts, extra_env=None): |
378 | 49 | service = UpstartService("juju-machine-agent") | 50 | service = UpstartService("juju-machine-agent") |
379 | 50 | service.set_description("Juju machine agent") | 51 | service.set_description("Juju machine agent") |
382 | 51 | service.set_environ( | 52 | env = {"JUJU_MACHINE_ID": machine_id, "JUJU_ZOOKEEPER": zookeeper_hosts} |
383 | 52 | {"JUJU_MACHINE_ID": machine_id, "JUJU_ZOOKEEPER": zookeeper_hosts}) | 53 | if extra_env: |
384 | 54 | env.update(extra_env) | ||
385 | 55 | service.set_environ(env) | ||
386 | 53 | service.set_command( | 56 | service.set_command( |
387 | 54 | "python -m juju.agents.machine --nodaemon " | 57 | "python -m juju.agents.machine --nodaemon " |
388 | 55 | "--logfile /var/log/juju/machine-agent.log " | 58 | "--logfile /var/log/juju/machine-agent.log " |
389 | @@ -78,10 +81,13 @@ | |||
390 | 78 | "/var/run/juju/unit-%s-agent.zksession" % unit_path_name])) | 81 | "/var/run/juju/unit-%s-agent.zksession" % unit_path_name])) |
391 | 79 | return service.get_cloud_init_commands() | 82 | return service.get_cloud_init_commands() |
392 | 80 | 83 | ||
394 | 81 | def _provision_scripts(zookeeper_hosts): | 84 | def _provision_scripts(zookeeper_hosts, extra_env=None): |
395 | 82 | service = UpstartService("juju-provision-agent") | 85 | service = UpstartService("juju-provision-agent") |
396 | 83 | service.set_description("Juju provisioning agent") | 86 | service.set_description("Juju provisioning agent") |
398 | 84 | service.set_environ({"JUJU_ZOOKEEPER": zookeeper_hosts}) | 87 | env = {"JUJU_ZOOKEEPER": zookeeper_hosts} |
399 | 88 | if extra_env: | ||
400 | 89 | env.update(extra_env) | ||
401 | 90 | service.set_environ(env) | ||
402 | 85 | service.set_command( | 91 | service.set_command( |
403 | 86 | "python -m juju.agents.provision --nodaemon " | 92 | "python -m juju.agents.provision --nodaemon " |
404 | 87 | "--logfile /var/log/juju/provision-agent.log " | 93 | "--logfile /var/log/juju/provision-agent.log " |
405 | @@ -175,6 +181,8 @@ | |||
406 | 175 | self._unit_name = None | 181 | self._unit_name = None |
407 | 176 | self._juju_home = None | 182 | self._juju_home = None |
408 | 177 | self._apt_proxy = None | 183 | self._apt_proxy = None |
409 | 184 | self._extra_environment = {} | ||
410 | 185 | self.private = False | ||
411 | 178 | 186 | ||
412 | 179 | def add_ssh_key(self, key): | 187 | def add_ssh_key(self, key): |
413 | 180 | """Add an SSH public key. | 188 | """Add an SSH public key. |
414 | @@ -190,8 +198,14 @@ | |||
415 | 190 | self._zookeeper = True | 198 | self._zookeeper = True |
416 | 191 | self._provision = True | 199 | self._provision = True |
417 | 192 | 200 | ||
418 | 201 | def set_env(self, name, value): | ||
419 | 202 | self._extra_environment[name] = value | ||
420 | 203 | |||
421 | 204 | def unset_env(self, name): | ||
422 | 205 | del self._extra_environment[name] | ||
423 | 206 | |||
424 | 193 | def set_juju_source( | 207 | def set_juju_source( |
426 | 194 | self, branch=None, ppa=False, distro=False, proposed=False): | 208 | self, branch=None, ppa=False, distro=False, proposed=False, image=False): |
427 | 195 | """Set the version of juju the machine should run. | 209 | """Set the version of juju the machine should run. |
428 | 196 | 210 | ||
429 | 197 | :param branch: location from which to check out juju; for example, | 211 | :param branch: location from which to check out juju; for example, |
430 | @@ -213,9 +227,12 @@ | |||
431 | 213 | Note that you don't need to call this method; the juju source | 227 | Note that you don't need to call this method; the juju source |
432 | 214 | defaults to what is returned by `get_default_origin`. | 228 | defaults to what is returned by `get_default_origin`. |
433 | 215 | """ | 229 | """ |
435 | 216 | if len(filter(None, (branch, ppa, distro, proposed))) != 1: | 230 | if len(filter(None, (branch, ppa, distro, proposed, image))) != 1: |
436 | 217 | raise CloudInitError("Please specify one source") | 231 | raise CloudInitError("Please specify one source") |
438 | 218 | if branch: | 232 | if image: |
439 | 233 | self._origin = IMAGE | ||
440 | 234 | self._origin_url = None | ||
441 | 235 | elif branch: | ||
442 | 219 | self._origin = BRANCH | 236 | self._origin = BRANCH |
443 | 220 | self._origin_url = branch | 237 | self._origin_url = branch |
444 | 221 | elif ppa: | 238 | elif ppa: |
445 | @@ -282,7 +299,10 @@ | |||
446 | 282 | You don't have to set this, so long as the machine you are starting is | 299 | You don't have to set this, so long as the machine you are starting is |
447 | 283 | itself a zookeeper instance. | 300 | itself a zookeeper instance. |
448 | 284 | """ | 301 | """ |
450 | 285 | self._zookeeper_hosts = [m.private_dns_name for m in machines] | 302 | if self.private: |
451 | 303 | self._zookeeper_hosts = [m.private_ip_address for m in machines] | ||
452 | 304 | else: | ||
453 | 305 | self._zookeeper_hosts = [m.private_dns_name for m in machines] | ||
454 | 286 | 306 | ||
455 | 287 | def set_zookeeper_hosts(self, hosts): | 307 | def set_zookeeper_hosts(self, hosts): |
456 | 288 | """Specify master :class:`juju.machine.ProviderMachine` instances. | 308 | """Specify master :class:`juju.machine.ProviderMachine` instances. |
457 | @@ -367,18 +387,20 @@ | |||
458 | 367 | def _collect_packages(self): | 387 | def _collect_packages(self): |
459 | 368 | packages = [ | 388 | packages = [ |
460 | 369 | "bzr", "byobu", "tmux", "python-setuptools", "python-twisted", | 389 | "bzr", "byobu", "tmux", "python-setuptools", "python-twisted", |
462 | 370 | "python-txaws", "python-zookeeper"] | 390 | "python-zookeeper"] |
463 | 371 | if self._zookeeper: | 391 | if self._zookeeper: |
464 | 372 | packages.extend([ | 392 | packages.extend([ |
465 | 373 | "default-jre-headless", "zookeeper", "zookeeperd"]) | 393 | "default-jre-headless", "zookeeper", "zookeeperd"]) |
466 | 374 | if self._origin in (DISTRO, PPA, PROPOSED): | 394 | if self._origin in (DISTRO, PPA, PROPOSED): |
467 | 375 | packages.append("juju") | 395 | packages.append("juju") |
468 | 396 | if self._origin != IMAGE: | ||
469 | 397 | packages.append("python-txaws") | ||
470 | 376 | return packages | 398 | return packages |
471 | 377 | 399 | ||
472 | 378 | def _collect_repositories(self): | 400 | def _collect_repositories(self): |
473 | 379 | if self._origin == PROPOSED: | 401 | if self._origin == PROPOSED: |
474 | 380 | return ["deb $MIRROR $RELEASE-proposed main universe"] | 402 | return ["deb $MIRROR $RELEASE-proposed main universe"] |
476 | 381 | if self._origin != DISTRO: | 403 | if self._origin not in (DISTRO, IMAGE): |
477 | 382 | return ["ppa:juju/pkgs"] | 404 | return ["ppa:juju/pkgs"] |
478 | 383 | return [] | 405 | return [] |
479 | 384 | 406 | ||
480 | @@ -392,7 +414,7 @@ | |||
481 | 392 | self._provider_type)) | 414 | self._provider_type)) |
482 | 393 | if self._machine_id: | 415 | if self._machine_id: |
483 | 394 | scripts.extend(_machine_scripts( | 416 | scripts.extend(_machine_scripts( |
485 | 395 | self._machine_id, self._join_zookeeper_hosts())) | 417 | self._machine_id, self._join_zookeeper_hosts(), self._extra_environment)) |
486 | 396 | if self._unit_name: | 418 | if self._unit_name: |
487 | 397 | scripts.extend(_unit_scripts( | 419 | scripts.extend(_unit_scripts( |
488 | 398 | self._machine_id, | 420 | self._machine_id, |
489 | @@ -400,7 +422,7 @@ | |||
490 | 400 | self._join_zookeeper_hosts(), | 422 | self._join_zookeeper_hosts(), |
491 | 401 | self._juju_home)) | 423 | self._juju_home)) |
492 | 402 | if self._provision: | 424 | if self._provision: |
494 | 403 | scripts.extend(_provision_scripts(self._join_zookeeper_hosts())) | 425 | scripts.extend(_provision_scripts(self._join_zookeeper_hosts(), self._extra_environment)) |
495 | 404 | return scripts | 426 | return scripts |
496 | 405 | 427 | ||
497 | 406 | def _collect_machine_data(self): | 428 | def _collect_machine_data(self): |
498 | 407 | 429 | ||
499 | === modified file 'juju/providers/common/launch.py' | |||
500 | --- juju/providers/common/launch.py 2012-07-18 20:04:16 +0000 | |||
501 | +++ juju/providers/common/launch.py 2012-11-23 21:00:27 +0000 | |||
502 | @@ -92,6 +92,7 @@ | |||
503 | 92 | """ | 92 | """ |
504 | 93 | config = self._provider.config | 93 | config = self._provider.config |
505 | 94 | cloud_init = CloudInit() | 94 | cloud_init = CloudInit() |
506 | 95 | cloud_init.private = config.get("vpc_id") is not None | ||
507 | 95 | cloud_init.add_ssh_key(get_user_authorized_keys(config)) | 96 | cloud_init.add_ssh_key(get_user_authorized_keys(config)) |
508 | 96 | cloud_init.set_machine_id(machine_id) | 97 | cloud_init.set_machine_id(machine_id) |
509 | 97 | cloud_init.set_zookeeper_machines(zookeepers) | 98 | cloud_init.set_zookeeper_machines(zookeepers) |
510 | @@ -103,9 +104,18 @@ | |||
511 | 103 | cloud_init.set_juju_source(ppa=True) | 104 | cloud_init.set_juju_source(ppa=True) |
512 | 104 | elif origin == "proposed": | 105 | elif origin == "proposed": |
513 | 105 | cloud_init.set_juju_source(proposed=True) | 106 | cloud_init.set_juju_source(proposed=True) |
514 | 107 | elif origin == "image": | ||
515 | 108 | cloud_init.set_juju_source(image=True) | ||
516 | 106 | else: | 109 | else: |
517 | 107 | # Ignore other values, just use the distro for sanity | 110 | # Ignore other values, just use the distro for sanity |
518 | 108 | cloud_init.set_juju_source(distro=True) | 111 | cloud_init.set_juju_source(distro=True) |
519 | 112 | proxy = config.get("proxy") | ||
520 | 113 | if proxy: | ||
521 | 114 | cloud_init.set_env("http_proxy", proxy) | ||
522 | 115 | cloud_init.set_env("https_proxy", proxy) | ||
523 | 116 | private = config.get("vpc_id") is not None | ||
524 | 117 | if private: | ||
525 | 118 | cloud_init.set_env("JUJU_PRIVATE", "private") | ||
526 | 109 | if self._master: | 119 | if self._master: |
527 | 110 | cloud_init.enable_bootstrap() | 120 | cloud_init.enable_bootstrap() |
528 | 111 | cloud_init.set_zookeeper_secret(config["admin-secret"]) | 121 | cloud_init.set_zookeeper_secret(config["admin-secret"]) |
529 | 112 | 122 | ||
530 | === modified file 'juju/providers/common/tests/data/cloud_init_bootstrap' | |||
531 | --- juju/providers/common/tests/data/cloud_init_bootstrap 2012-08-23 16:14:42 +0000 | |||
532 | +++ juju/providers/common/tests/data/cloud_init_bootstrap 2012-11-23 21:00:27 +0000 | |||
533 | @@ -4,8 +4,8 @@ | |||
534 | 4 | machine-data: {juju-provider-type: dummy, juju-zookeeper-hosts: 'localhost:2181', | 4 | machine-data: {juju-provider-type: dummy, juju-zookeeper-hosts: 'localhost:2181', |
535 | 5 | machine-id: passport} | 5 | machine-id: passport} |
536 | 6 | output: {all: '| tee -a /var/log/cloud-init-output.log'} | 6 | output: {all: '| tee -a /var/log/cloud-init-output.log'} |
539 | 7 | packages: [bzr, byobu, tmux, python-setuptools, python-twisted, python-txaws, python-zookeeper, | 7 | packages: [bzr, byobu, tmux, python-setuptools, python-twisted, python-zookeeper, |
540 | 8 | default-jre-headless, zookeeper, zookeeperd, juju] | 8 | default-jre-headless, zookeeper, zookeeperd, juju, python-txaws] |
541 | 9 | runcmd: [sudo mkdir -p /var/lib/juju, sudo mkdir -p /var/log/juju, 'juju-admin initialize | 9 | runcmd: [sudo mkdir -p /var/lib/juju, sudo mkdir -p /var/log/juju, 'juju-admin initialize |
542 | 10 | --instance-id=token --admin-identity=admin:19vlzY4Vc3q4Ew5OsCwKYqrq1HI= --constraints-data=e2NwdTogJzIwJywgcHJvdmlkZXItdHlwZTogZHVtbXksIHVidW50dS1zZXJpZXM6IGFzdG9uaXNoaW5nfQo= | 10 | --instance-id=token --admin-identity=admin:19vlzY4Vc3q4Ew5OsCwKYqrq1HI= --constraints-data=e2NwdTogJzIwJywgcHJvdmlkZXItdHlwZTogZHVtbXksIHVidW50dS1zZXJpZXM6IGFzdG9uaXNoaW5nfQo= |
543 | 11 | --provider-type=dummy', 'cat >> /etc/init/juju-machine-agent.conf <<EOF | 11 | --provider-type=dummy', 'cat >> /etc/init/juju-machine-agent.conf <<EOF |
544 | 12 | 12 | ||
545 | === added file 'juju/providers/common/tests/data/cloud_init_bootstrap_extra_env' | |||
546 | --- juju/providers/common/tests/data/cloud_init_bootstrap_extra_env 1970-01-01 00:00:00 +0000 | |||
547 | +++ juju/providers/common/tests/data/cloud_init_bootstrap_extra_env 2012-11-23 21:00:27 +0000 | |||
548 | @@ -0,0 +1,69 @@ | |||
549 | 1 | #cloud-config | ||
550 | 2 | apt_update: true | ||
551 | 3 | apt_upgrade: true | ||
552 | 4 | machine-data: {juju-provider-type: dummy, juju-zookeeper-hosts: 'localhost:2181', | ||
553 | 5 | machine-id: passport} | ||
554 | 6 | output: {all: '| tee -a /var/log/cloud-init-output.log'} | ||
555 | 7 | packages: [bzr, byobu, tmux, python-setuptools, python-twisted, python-zookeeper, | ||
556 | 8 | default-jre-headless, zookeeper, zookeeperd, juju, python-txaws] | ||
557 | 9 | runcmd: [sudo mkdir -p /var/lib/juju, sudo mkdir -p /var/log/juju, 'juju-admin initialize | ||
558 | 10 | --instance-id=token --admin-identity=admin:19vlzY4Vc3q4Ew5OsCwKYqrq1HI= --constraints-data=e2NwdTogJzIwJywgcHJvdmlkZXItdHlwZTogZHVtbXksIHVidW50dS1zZXJpZXM6IGFzdG9uaXNoaW5nfQo= | ||
559 | 11 | --provider-type=dummy', 'cat >> /etc/init/juju-machine-agent.conf <<EOF | ||
560 | 12 | |||
561 | 13 | description "Juju machine agent" | ||
562 | 14 | |||
563 | 15 | author "Juju Team <juju@lists.ubuntu.com>" | ||
564 | 16 | |||
565 | 17 | |||
566 | 18 | start on runlevel [2345] | ||
567 | 19 | |||
568 | 20 | stop on runlevel [!2345] | ||
569 | 21 | |||
570 | 22 | respawn | ||
571 | 23 | |||
572 | 24 | |||
573 | 25 | env JUJU_MACHINE_ID="passport" | ||
574 | 26 | |||
575 | 27 | env JUJU_ZOOKEEPER="localhost:2181" | ||
576 | 28 | |||
577 | 29 | env http_proxy="http://myproxy.com:3128/" | ||
578 | 30 | |||
579 | 31 | env https_proxy="http://myproxy.com:3128/" | ||
580 | 32 | |||
581 | 33 | |||
582 | 34 | exec python -m juju.agents.machine --nodaemon --logfile /var/log/juju/machine-agent.log | ||
583 | 35 | --session-file /var/run/juju/machine-agent.zksession >> /tmp/juju-machine-agent.output | ||
584 | 36 | 2>&1 | ||
585 | 37 | |||
586 | 38 | EOF | ||
587 | 39 | |||
588 | 40 | ', /sbin/start juju-machine-agent, 'cat >> /etc/init/juju-provision-agent.conf | ||
589 | 41 | <<EOF | ||
590 | 42 | |||
591 | 43 | description "Juju provisioning agent" | ||
592 | 44 | |||
593 | 45 | author "Juju Team <juju@lists.ubuntu.com>" | ||
594 | 46 | |||
595 | 47 | |||
596 | 48 | start on runlevel [2345] | ||
597 | 49 | |||
598 | 50 | stop on runlevel [!2345] | ||
599 | 51 | |||
600 | 52 | respawn | ||
601 | 53 | |||
602 | 54 | |||
603 | 55 | env JUJU_ZOOKEEPER="localhost:2181" | ||
604 | 56 | |||
605 | 57 | env http_proxy="http://myproxy.com:3128/" | ||
606 | 58 | |||
607 | 59 | env https_proxy="http://myproxy.com:3128/" | ||
608 | 60 | |||
609 | 61 | |||
610 | 62 | exec python -m juju.agents.provision --nodaemon --logfile /var/log/juju/provision-agent.log | ||
611 | 63 | --session-file /var/run/juju/provision-agent.zksession >> /tmp/juju-provision-agent.output | ||
612 | 64 | 2>&1 | ||
613 | 65 | |||
614 | 66 | EOF | ||
615 | 67 | |||
616 | 68 | ', /sbin/start juju-provision-agent] | ||
617 | 69 | ssh_authorized_keys: [chubb] | ||
618 | 0 | 70 | ||
619 | === modified file 'juju/providers/common/tests/data/cloud_init_bootstrap_zookeepers' | |||
620 | --- juju/providers/common/tests/data/cloud_init_bootstrap_zookeepers 2012-08-23 16:14:42 +0000 | |||
621 | +++ juju/providers/common/tests/data/cloud_init_bootstrap_zookeepers 2012-11-23 21:00:27 +0000 | |||
622 | @@ -4,8 +4,8 @@ | |||
623 | 4 | machine-data: {juju-provider-type: dummy, juju-zookeeper-hosts: 'cotswold:2181,longleat:2181,localhost:2181', | 4 | machine-data: {juju-provider-type: dummy, juju-zookeeper-hosts: 'cotswold:2181,longleat:2181,localhost:2181', |
624 | 5 | machine-id: passport} | 5 | machine-id: passport} |
625 | 6 | output: {all: '| tee -a /var/log/cloud-init-output.log'} | 6 | output: {all: '| tee -a /var/log/cloud-init-output.log'} |
628 | 7 | packages: [bzr, byobu, tmux, python-setuptools, python-twisted, python-txaws, python-zookeeper, | 7 | packages: [bzr, byobu, tmux, python-setuptools, python-twisted, python-zookeeper, |
629 | 8 | default-jre-headless, zookeeper, zookeeperd, juju] | 8 | default-jre-headless, zookeeper, zookeeperd, juju, python-txaws] |
630 | 9 | runcmd: [sudo mkdir -p /var/lib/juju, sudo mkdir -p /var/log/juju, 'juju-admin initialize | 9 | runcmd: [sudo mkdir -p /var/lib/juju, sudo mkdir -p /var/log/juju, 'juju-admin initialize |
631 | 10 | --instance-id=token --admin-identity=admin:19vlzY4Vc3q4Ew5OsCwKYqrq1HI= --constraints-data=e2NwdTogJzIwJywgcHJvdmlkZXItdHlwZTogZHVtbXksIHVidW50dS1zZXJpZXM6IGFzdG9uaXNoaW5nfQo= | 10 | --instance-id=token --admin-identity=admin:19vlzY4Vc3q4Ew5OsCwKYqrq1HI= --constraints-data=e2NwdTogJzIwJywgcHJvdmlkZXItdHlwZTogZHVtbXksIHVidW50dS1zZXJpZXM6IGFzdG9uaXNoaW5nfQo= |
632 | 11 | --provider-type=dummy', 'cat >> /etc/init/juju-machine-agent.conf <<EOF | 11 | --provider-type=dummy', 'cat >> /etc/init/juju-machine-agent.conf <<EOF |
633 | 12 | 12 | ||
634 | === modified file 'juju/providers/common/tests/data/cloud_init_branch' | |||
635 | --- juju/providers/common/tests/data/cloud_init_branch 2012-10-09 18:55:55 +0000 | |||
636 | +++ juju/providers/common/tests/data/cloud_init_branch 2012-11-23 21:00:27 +0000 | |||
637 | @@ -6,7 +6,7 @@ | |||
638 | 6 | machine-data: {juju-provider-type: dummy, juju-zookeeper-hosts: 'cotswold:2181,longleat:2181', | 6 | machine-data: {juju-provider-type: dummy, juju-zookeeper-hosts: 'cotswold:2181,longleat:2181', |
639 | 7 | machine-id: passport} | 7 | machine-id: passport} |
640 | 8 | output: {all: '| tee -a /var/log/cloud-init-output.log'} | 8 | output: {all: '| tee -a /var/log/cloud-init-output.log'} |
642 | 9 | packages: [bzr, byobu, tmux, python-setuptools, python-twisted, python-txaws, python-zookeeper] | 9 | packages: [bzr, byobu, tmux, python-setuptools, python-twisted, python-zookeeper, python-txaws] |
643 | 10 | runcmd: [sudo apt-get install -y python-txzookeeper, sudo mkdir -p /usr/lib/juju, | 10 | runcmd: [sudo apt-get install -y python-txzookeeper, sudo mkdir -p /usr/lib/juju, |
644 | 11 | 'cd /usr/lib/juju && sudo /usr/bin/bzr co --lightweight lp:blah/juju/blah-blah juju', cd /usr/lib/juju/juju | 11 | 'cd /usr/lib/juju && sudo /usr/bin/bzr co --lightweight lp:blah/juju/blah-blah juju', cd /usr/lib/juju/juju |
645 | 12 | && sudo python setup.py develop, sudo mkdir -p /var/lib/juju, sudo mkdir -p /var/log/juju, | 12 | && sudo python setup.py develop, sudo mkdir -p /var/lib/juju, sudo mkdir -p /var/log/juju, |
646 | 13 | 13 | ||
647 | === modified file 'juju/providers/common/tests/data/cloud_init_branch_trunk' | |||
648 | --- juju/providers/common/tests/data/cloud_init_branch_trunk 2012-10-09 18:55:55 +0000 | |||
649 | +++ juju/providers/common/tests/data/cloud_init_branch_trunk 2012-11-23 21:00:27 +0000 | |||
650 | @@ -6,7 +6,7 @@ | |||
651 | 6 | machine-data: {juju-provider-type: dummy, juju-zookeeper-hosts: 'cotswold:2181,longleat:2181', | 6 | machine-data: {juju-provider-type: dummy, juju-zookeeper-hosts: 'cotswold:2181,longleat:2181', |
652 | 7 | machine-id: passport} | 7 | machine-id: passport} |
653 | 8 | output: {all: '| tee -a /var/log/cloud-init-output.log'} | 8 | output: {all: '| tee -a /var/log/cloud-init-output.log'} |
655 | 9 | packages: [bzr, byobu, tmux, python-setuptools, python-twisted, python-txaws, python-zookeeper] | 9 | packages: [bzr, byobu, tmux, python-setuptools, python-twisted, python-zookeeper, python-txaws] |
656 | 10 | runcmd: [sudo apt-get install -y python-txzookeeper, sudo mkdir -p /usr/lib/juju, | 10 | runcmd: [sudo apt-get install -y python-txzookeeper, sudo mkdir -p /usr/lib/juju, |
657 | 11 | 'cd /usr/lib/juju && sudo /usr/bin/bzr co --lightweight lp:juju juju', cd /usr/lib/juju/juju && | 11 | 'cd /usr/lib/juju && sudo /usr/bin/bzr co --lightweight lp:juju juju', cd /usr/lib/juju/juju && |
658 | 12 | sudo python setup.py develop, sudo mkdir -p /var/lib/juju, sudo mkdir -p /var/log/juju, | 12 | sudo python setup.py develop, sudo mkdir -p /var/lib/juju, sudo mkdir -p /var/log/juju, |
659 | 13 | 13 | ||
660 | === modified file 'juju/providers/common/tests/data/cloud_init_distro' | |||
661 | --- juju/providers/common/tests/data/cloud_init_distro 2012-08-23 16:14:42 +0000 | |||
662 | +++ juju/providers/common/tests/data/cloud_init_distro 2012-11-23 21:00:27 +0000 | |||
663 | @@ -4,8 +4,7 @@ | |||
664 | 4 | machine-data: {juju-provider-type: dummy, juju-zookeeper-hosts: 'cotswold:2181,longleat:2181', | 4 | machine-data: {juju-provider-type: dummy, juju-zookeeper-hosts: 'cotswold:2181,longleat:2181', |
665 | 5 | machine-id: passport} | 5 | machine-id: passport} |
666 | 6 | output: {all: '| tee -a /var/log/cloud-init-output.log'} | 6 | output: {all: '| tee -a /var/log/cloud-init-output.log'} |
669 | 7 | packages: [bzr, byobu, tmux, python-setuptools, python-twisted, python-txaws, python-zookeeper, | 7 | packages: [bzr, byobu, tmux, python-setuptools, python-twisted, python-zookeeper, juju, python-txaws] |
668 | 8 | juju] | ||
670 | 9 | runcmd: [sudo mkdir -p /var/lib/juju, sudo mkdir -p /var/log/juju, 'cat >> /etc/init/juju-machine-agent.conf | 8 | runcmd: [sudo mkdir -p /var/lib/juju, sudo mkdir -p /var/log/juju, 'cat >> /etc/init/juju-machine-agent.conf |
671 | 10 | <<EOF | 9 | <<EOF |
672 | 11 | 10 | ||
673 | 12 | 11 | ||
674 | === added file 'juju/providers/common/tests/data/cloud_init_image' | |||
675 | --- juju/providers/common/tests/data/cloud_init_image 1970-01-01 00:00:00 +0000 | |||
676 | +++ juju/providers/common/tests/data/cloud_init_image 2012-11-23 21:00:27 +0000 | |||
677 | @@ -0,0 +1,35 @@ | |||
678 | 1 | #cloud-config | ||
679 | 2 | apt_update: true | ||
680 | 3 | apt_upgrade: true | ||
681 | 4 | machine-data: {juju-provider-type: dummy, juju-zookeeper-hosts: 'cotswold:2181,longleat:2181', | ||
682 | 5 | machine-id: passport} | ||
683 | 6 | output: {all: '| tee -a /var/log/cloud-init-output.log'} | ||
684 | 7 | packages: [bzr, byobu, tmux, python-setuptools, python-twisted, python-zookeeper] | ||
685 | 8 | runcmd: [sudo mkdir -p /var/lib/juju, sudo mkdir -p /var/log/juju, 'cat >> /etc/init/juju-machine-agent.conf | ||
686 | 9 | <<EOF | ||
687 | 10 | |||
688 | 11 | description "Juju machine agent" | ||
689 | 12 | |||
690 | 13 | author "Juju Team <juju@lists.ubuntu.com>" | ||
691 | 14 | |||
692 | 15 | |||
693 | 16 | start on runlevel [2345] | ||
694 | 17 | |||
695 | 18 | stop on runlevel [!2345] | ||
696 | 19 | |||
697 | 20 | respawn | ||
698 | 21 | |||
699 | 22 | |||
700 | 23 | env JUJU_MACHINE_ID="passport" | ||
701 | 24 | |||
702 | 25 | env JUJU_ZOOKEEPER="cotswold:2181,longleat:2181" | ||
703 | 26 | |||
704 | 27 | |||
705 | 28 | exec python -m juju.agents.machine --nodaemon --logfile /var/log/juju/machine-agent.log | ||
706 | 29 | --session-file /var/run/juju/machine-agent.zksession >> /tmp/juju-machine-agent.output | ||
707 | 30 | 2>&1 | ||
708 | 31 | |||
709 | 32 | EOF | ||
710 | 33 | |||
711 | 34 | ', /sbin/start juju-machine-agent] | ||
712 | 35 | ssh_authorized_keys: [chubb] | ||
713 | 0 | 36 | ||
714 | === added file 'juju/providers/common/tests/data/cloud_init_image_extra_env' | |||
715 | --- juju/providers/common/tests/data/cloud_init_image_extra_env 1970-01-01 00:00:00 +0000 | |||
716 | +++ juju/providers/common/tests/data/cloud_init_image_extra_env 2012-11-23 21:00:27 +0000 | |||
717 | @@ -0,0 +1,39 @@ | |||
718 | 1 | #cloud-config | ||
719 | 2 | apt_update: true | ||
720 | 3 | apt_upgrade: true | ||
721 | 4 | machine-data: {juju-provider-type: dummy, juju-zookeeper-hosts: 'cotswold:2181,longleat:2181', | ||
722 | 5 | machine-id: passport} | ||
723 | 6 | output: {all: '| tee -a /var/log/cloud-init-output.log'} | ||
724 | 7 | packages: [bzr, byobu, tmux, python-setuptools, python-twisted, python-zookeeper] | ||
725 | 8 | runcmd: [sudo mkdir -p /var/lib/juju, sudo mkdir -p /var/log/juju, 'cat >> /etc/init/juju-machine-agent.conf | ||
726 | 9 | <<EOF | ||
727 | 10 | |||
728 | 11 | description "Juju machine agent" | ||
729 | 12 | |||
730 | 13 | author "Juju Team <juju@lists.ubuntu.com>" | ||
731 | 14 | |||
732 | 15 | |||
733 | 16 | start on runlevel [2345] | ||
734 | 17 | |||
735 | 18 | stop on runlevel [!2345] | ||
736 | 19 | |||
737 | 20 | respawn | ||
738 | 21 | |||
739 | 22 | |||
740 | 23 | env JUJU_MACHINE_ID="passport" | ||
741 | 24 | |||
742 | 25 | env JUJU_ZOOKEEPER="cotswold:2181,longleat:2181" | ||
743 | 26 | |||
744 | 27 | env http_proxy="http://myproxy.com:3128/" | ||
745 | 28 | |||
746 | 29 | env https_proxy="http://myproxy.com:3128/" | ||
747 | 30 | |||
748 | 31 | |||
749 | 32 | exec python -m juju.agents.machine --nodaemon --logfile /var/log/juju/machine-agent.log | ||
750 | 33 | --session-file /var/run/juju/machine-agent.zksession >> /tmp/juju-machine-agent.output | ||
751 | 34 | 2>&1 | ||
752 | 35 | |||
753 | 36 | EOF | ||
754 | 37 | |||
755 | 38 | ', /sbin/start juju-machine-agent] | ||
756 | 39 | ssh_authorized_keys: [chubb] | ||
757 | 0 | 40 | ||
758 | === modified file 'juju/providers/common/tests/data/cloud_init_no_machine_id' | |||
759 | --- juju/providers/common/tests/data/cloud_init_no_machine_id 2012-09-24 04:04:32 +0000 | |||
760 | +++ juju/providers/common/tests/data/cloud_init_no_machine_id 2012-11-23 21:00:27 +0000 | |||
761 | @@ -4,7 +4,7 @@ | |||
762 | 4 | machine-data: {juju-provider-type: dummy, juju-zookeeper-hosts: 'cotswold:2181,longleat:2181', | 4 | machine-data: {juju-provider-type: dummy, juju-zookeeper-hosts: 'cotswold:2181,longleat:2181', |
763 | 5 | machine-id: } | 5 | machine-id: } |
764 | 6 | output: {all: '| tee -a /var/log/cloud-init-output.log'} | 6 | output: {all: '| tee -a /var/log/cloud-init-output.log'} |
767 | 7 | packages: [bzr, byobu, tmux, python-setuptools, python-twisted, python-txaws, | 7 | packages: [bzr, byobu, tmux, python-setuptools, python-twisted, |
768 | 8 | python-zookeeper, juju] | 8 | python-zookeeper, juju, python-txaws] |
769 | 9 | runcmd: ['sudo mkdir -p /var/lib/juju', 'sudo mkdir -p /var/log/juju'] | 9 | runcmd: ['sudo mkdir -p /var/lib/juju', 'sudo mkdir -p /var/log/juju'] |
770 | 10 | ssh_authorized_keys: [chubb] | 10 | ssh_authorized_keys: [chubb] |
771 | 11 | 11 | ||
772 | === modified file 'juju/providers/common/tests/data/cloud_init_normal' | |||
773 | --- juju/providers/common/tests/data/cloud_init_normal 2012-08-23 16:14:42 +0000 | |||
774 | +++ juju/providers/common/tests/data/cloud_init_normal 2012-11-23 21:00:27 +0000 | |||
775 | @@ -4,8 +4,8 @@ | |||
776 | 4 | machine-data: {juju-provider-type: dummy, juju-zookeeper-hosts: 'cotswold:2181,longleat:2181', | 4 | machine-data: {juju-provider-type: dummy, juju-zookeeper-hosts: 'cotswold:2181,longleat:2181', |
777 | 5 | machine-id: passport} | 5 | machine-id: passport} |
778 | 6 | output: {all: '| tee -a /var/log/cloud-init-output.log'} | 6 | output: {all: '| tee -a /var/log/cloud-init-output.log'} |
781 | 7 | packages: [bzr, byobu, tmux, python-setuptools, python-twisted, python-txaws, | 7 | packages: [bzr, byobu, tmux, python-setuptools, python-twisted, |
782 | 8 | python-zookeeper, juju] | 8 | python-zookeeper, juju, python-txaws] |
783 | 9 | runcmd: [sudo mkdir -p /var/lib/juju, sudo mkdir | 9 | runcmd: [sudo mkdir -p /var/lib/juju, sudo mkdir |
784 | 10 | -p /var/log/juju, 'JUJU_MACHINE_ID=passport JUJU_ZOOKEEPER=cotswold:2181,longleat:2181 | 10 | -p /var/log/juju, 'JUJU_MACHINE_ID=passport JUJU_ZOOKEEPER=cotswold:2181,longleat:2181 |
785 | 11 | python -m juju.agents.machine -n --logfile=/var/log/juju/machine-agent.log | 11 | python -m juju.agents.machine -n --logfile=/var/log/juju/machine-agent.log |
786 | 12 | 12 | ||
787 | === modified file 'juju/providers/common/tests/data/cloud_init_ppa' | |||
788 | --- juju/providers/common/tests/data/cloud_init_ppa 2012-10-09 18:55:55 +0000 | |||
789 | +++ juju/providers/common/tests/data/cloud_init_ppa 2012-11-23 21:00:27 +0000 | |||
790 | @@ -6,8 +6,8 @@ | |||
791 | 6 | machine-data: {juju-provider-type: dummy, juju-zookeeper-hosts: 'cotswold:2181,longleat:2181', | 6 | machine-data: {juju-provider-type: dummy, juju-zookeeper-hosts: 'cotswold:2181,longleat:2181', |
792 | 7 | machine-id: passport} | 7 | machine-id: passport} |
793 | 8 | output: {all: '| tee -a /var/log/cloud-init-output.log'} | 8 | output: {all: '| tee -a /var/log/cloud-init-output.log'} |
796 | 9 | packages: [bzr, byobu, tmux, python-setuptools, python-twisted, python-txaws, python-zookeeper, | 9 | packages: [bzr, byobu, tmux, python-setuptools, python-twisted, python-zookeeper, |
797 | 10 | juju] | 10 | juju, python-txaws] |
798 | 11 | runcmd: [sudo mkdir -p /var/lib/juju, sudo mkdir -p /var/log/juju, 'cat >> /etc/init/juju-machine-agent.conf | 11 | runcmd: [sudo mkdir -p /var/lib/juju, sudo mkdir -p /var/log/juju, 'cat >> /etc/init/juju-machine-agent.conf |
799 | 12 | <<EOF | 12 | <<EOF |
800 | 13 | 13 | ||
801 | 14 | 14 | ||
802 | === modified file 'juju/providers/common/tests/data/cloud_init_ppa_apt_proxy' | |||
803 | --- juju/providers/common/tests/data/cloud_init_ppa_apt_proxy 2012-10-09 18:55:55 +0000 | |||
804 | +++ juju/providers/common/tests/data/cloud_init_ppa_apt_proxy 2012-11-23 21:00:27 +0000 | |||
805 | @@ -7,8 +7,8 @@ | |||
806 | 7 | machine-data: {juju-provider-type: dummy, juju-zookeeper-hosts: 'cotswold:2181,longleat:2181', | 7 | machine-data: {juju-provider-type: dummy, juju-zookeeper-hosts: 'cotswold:2181,longleat:2181', |
807 | 8 | machine-id: passport} | 8 | machine-id: passport} |
808 | 9 | output: {all: '| tee -a /var/log/cloud-init-output.log'} | 9 | output: {all: '| tee -a /var/log/cloud-init-output.log'} |
811 | 10 | packages: [bzr, byobu, tmux, python-setuptools, python-twisted, python-txaws, python-zookeeper, | 10 | packages: [bzr, byobu, tmux, python-setuptools, python-twisted, python-zookeeper, |
812 | 11 | juju] | 11 | juju, python-txaws] |
813 | 12 | runcmd: [sudo mkdir -p /var/lib/juju, sudo mkdir -p /var/log/juju, 'cat >> /etc/init/juju-machine-agent.conf | 12 | runcmd: [sudo mkdir -p /var/lib/juju, sudo mkdir -p /var/log/juju, 'cat >> /etc/init/juju-machine-agent.conf |
814 | 13 | <<EOF | 13 | <<EOF |
815 | 14 | 14 | ||
816 | 15 | 15 | ||
817 | === modified file 'juju/providers/common/tests/data/cloud_init_proposed' | |||
818 | --- juju/providers/common/tests/data/cloud_init_proposed 2012-08-23 16:14:42 +0000 | |||
819 | +++ juju/providers/common/tests/data/cloud_init_proposed 2012-11-23 21:00:27 +0000 | |||
820 | @@ -6,7 +6,7 @@ | |||
821 | 6 | machine-data: {juju-provider-type: dummy, juju-zookeeper-hosts: 'cotswold:2181,longleat:2181', | 6 | machine-data: {juju-provider-type: dummy, juju-zookeeper-hosts: 'cotswold:2181,longleat:2181', |
822 | 7 | machine-id: passport} | 7 | machine-id: passport} |
823 | 8 | output: {all: '| tee -a /var/log/cloud-init-output.log'} | 8 | output: {all: '| tee -a /var/log/cloud-init-output.log'} |
825 | 9 | packages: [bzr, byobu, tmux, python-setuptools, python-twisted, python-txaws, python-zookeeper, juju] | 9 | packages: [bzr, byobu, tmux, python-setuptools, python-twisted, python-zookeeper, juju, python-txaws] |
826 | 10 | runcmd: [sudo mkdir -p /var/lib/juju, sudo mkdir -p | 10 | runcmd: [sudo mkdir -p /var/lib/juju, sudo mkdir -p |
827 | 11 | /var/log/juju, 'cat >> /etc/init/juju-machine-agent.conf <<EOF | 11 | /var/log/juju, 'cat >> /etc/init/juju-machine-agent.conf <<EOF |
828 | 12 | 12 | ||
829 | 13 | 13 | ||
830 | === modified file 'juju/providers/common/tests/test_cloudinit.py' | |||
831 | --- juju/providers/common/tests/test_cloudinit.py 2012-10-09 18:55:55 +0000 | |||
832 | +++ juju/providers/common/tests/test_cloudinit.py 2012-11-23 21:00:27 +0000 | |||
833 | @@ -107,6 +107,18 @@ | |||
834 | 107 | "/usr/lib/pymodules/python2.7/juju/__init__.pyc") | 107 | "/usr/lib/pymodules/python2.7/juju/__init__.pyc") |
835 | 108 | self.assert_render(self.construct_normal(), "cloud_init_distro") | 108 | self.assert_render(self.construct_normal(), "cloud_init_distro") |
836 | 109 | 109 | ||
837 | 110 | def test_render_image_source(self): | ||
838 | 111 | cloud_init = self.construct_normal() | ||
839 | 112 | cloud_init.set_juju_source(image=True) | ||
840 | 113 | self.assert_render(cloud_init, "cloud_init_image") | ||
841 | 114 | |||
842 | 115 | def test_render_extra_environment(self): | ||
843 | 116 | cloud_init = self.construct_normal() | ||
844 | 117 | cloud_init.set_juju_source(image=True) | ||
845 | 118 | cloud_init.set_env("http_proxy", "http://myproxy.com:3128/") | ||
846 | 119 | cloud_init.set_env("https_proxy", "http://myproxy.com:3128/") | ||
847 | 120 | self.assert_render(cloud_init, "cloud_init_image_extra_env") | ||
848 | 121 | |||
849 | 110 | def test_render_ppa_source(self): | 122 | def test_render_ppa_source(self): |
850 | 111 | cloud_init = self.construct_normal() | 123 | cloud_init = self.construct_normal() |
851 | 112 | cloud_init.set_juju_source(ppa=True) | 124 | cloud_init.set_juju_source(ppa=True) |
852 | @@ -135,6 +147,12 @@ | |||
853 | 135 | def test_render_bootstrap(self): | 147 | def test_render_bootstrap(self): |
854 | 136 | self.assert_render(self.construct_bootstrap(), "cloud_init_bootstrap") | 148 | self.assert_render(self.construct_bootstrap(), "cloud_init_bootstrap") |
855 | 137 | 149 | ||
856 | 150 | def test_render_bootstrap_with_extra_environment(self): | ||
857 | 151 | cloud_init = self.construct_bootstrap() | ||
858 | 152 | cloud_init.set_env("http_proxy", "http://myproxy.com:3128/") | ||
859 | 153 | cloud_init.set_env("https_proxy", "http://myproxy.com:3128/") | ||
860 | 154 | self.assert_render(cloud_init, "cloud_init_bootstrap_extra_env") | ||
861 | 155 | |||
862 | 138 | def test_render_bootstrap_with_zookeepers(self): | 156 | def test_render_bootstrap_with_zookeepers(self): |
863 | 139 | self.assert_render( | 157 | self.assert_render( |
864 | 140 | self.construct_bootstrap(True), "cloud_init_bootstrap_zookeepers") | 158 | self.construct_bootstrap(True), "cloud_init_bootstrap_zookeepers") |
865 | @@ -168,6 +186,13 @@ | |||
866 | 168 | cloud_init.set_zookeeper_hosts(['bar1.private', 'bar2.private']) | 186 | cloud_init.set_zookeeper_hosts(['bar1.private', 'bar2.private']) |
867 | 169 | self.assertEqual(['bar1.private', 'bar2.private'], cloud_init._zookeeper_hosts) | 187 | self.assertEqual(['bar1.private', 'bar2.private'], cloud_init._zookeeper_hosts) |
868 | 170 | 188 | ||
869 | 189 | def test_set_zookeeper_machines_in_private_mode(self): | ||
870 | 190 | machine = ProviderMachine('i-100', 'foo1', 'foo1.private', private_ip_address='10.0.1.0') | ||
871 | 191 | cloud_init = CloudInit() | ||
872 | 192 | cloud_init.private = True | ||
873 | 193 | cloud_init.set_zookeeper_machines([machine]) | ||
874 | 194 | self.assertEqual(['10.0.1.0'], cloud_init._zookeeper_hosts) | ||
875 | 195 | |||
876 | 171 | def test_set_zookeeper_hosts_tuple(self): | 196 | def test_set_zookeeper_hosts_tuple(self): |
877 | 172 | cloud_init = CloudInit() | 197 | cloud_init = CloudInit() |
878 | 173 | cloud_init.set_zookeeper_hosts([('bar1.private', 9999)]) | 198 | cloud_init.set_zookeeper_hosts([('bar1.private', 9999)]) |
879 | @@ -330,3 +355,14 @@ | |||
880 | 330 | self.patch(juju, "__file__", | 355 | self.patch(juju, "__file__", |
881 | 331 | "/usr/lib/pymodules/python2.7/juju/__init__.pyc") | 356 | "/usr/lib/pymodules/python2.7/juju/__init__.pyc") |
882 | 332 | self.assertEquals(get_default_origin(), ("distro", None)) | 357 | self.assertEquals(get_default_origin(), ("distro", None)) |
883 | 358 | |||
884 | 359 | def test_set_env(self): | ||
885 | 360 | cloudinit = CloudInit() | ||
886 | 361 | cloudinit.set_env("http_proxy", "http://myproxy.com:3128/") | ||
887 | 362 | self.assertEquals(cloudinit._extra_environment["http_proxy"], "http://myproxy.com:3128/") | ||
888 | 363 | |||
889 | 364 | def test_unset_env(self): | ||
890 | 365 | cloudinit = CloudInit() | ||
891 | 366 | cloudinit.set_env("http_proxy", "http://myproxy.com:3128/") | ||
892 | 367 | cloudinit.unset_env("http_proxy") | ||
893 | 368 | self.assertNotIn("http_proxy", cloudinit._extra_environment) | ||
894 | 333 | 369 | ||
895 | === modified file 'juju/providers/ec2/__init__.py' | |||
896 | --- juju/providers/ec2/__init__.py 2012-08-28 16:11:41 +0000 | |||
897 | +++ juju/providers/ec2/__init__.py 2012-11-23 21:00:27 +0000 | |||
898 | @@ -149,12 +149,13 @@ | |||
899 | 149 | % (", ".join(instance_ids), message)) | 149 | % (", ".join(instance_ids), message)) |
900 | 150 | 150 | ||
901 | 151 | machines = [] | 151 | machines = [] |
902 | 152 | private = self.config.get("vpc_id") is not None | ||
903 | 152 | for instance in instances: | 153 | for instance in instances: |
904 | 153 | if instance.instance_state not in ("running", "pending"): | 154 | if instance.instance_state not in ("running", "pending"): |
905 | 154 | continue | 155 | continue |
907 | 155 | if group_name not in instance.reservation.groups: | 156 | if group_name not in [g[1] for g in instance.reservation.groups]: |
908 | 156 | continue | 157 | continue |
910 | 157 | machines.append(machine_from_instance(instance)) | 158 | machines.append(machine_from_instance(instance, private)) |
911 | 158 | 159 | ||
912 | 159 | if instance_ids: | 160 | if instance_ids: |
913 | 160 | # We were asked for a specific list of machines, and if we can't | 161 | # We were asked for a specific list of machines, and if we can't |
914 | 161 | 162 | ||
915 | === modified file 'juju/providers/ec2/launch.py' | |||
916 | --- juju/providers/ec2/launch.py 2012-07-05 21:49:12 +0000 | |||
917 | +++ juju/providers/ec2/launch.py 2012-11-23 21:00:27 +0000 | |||
918 | @@ -38,15 +38,20 @@ | |||
919 | 38 | spec = yield get_machine_spec(self._provider.config, self._constraints) | 38 | spec = yield get_machine_spec(self._provider.config, self._constraints) |
920 | 39 | security_groups = yield self._ensure_groups(machine_id) | 39 | security_groups = yield self._ensure_groups(machine_id) |
921 | 40 | 40 | ||
922 | 41 | subnet = self._provider.config.get("subnet_id") | ||
923 | 42 | kw = { | ||
924 | 43 | 'min_count': 1, | ||
925 | 44 | 'max_count': 1, | ||
926 | 45 | 'image_id': spec.image_id, | ||
927 | 46 | 'instance_type': spec.instance_type, | ||
928 | 47 | 'availability_zone': availability_zone, | ||
929 | 48 | 'user_data': user_data, | ||
930 | 49 | } | ||
931 | 50 | if subnet: | ||
932 | 51 | kw['subnet_id'] = subnet | ||
933 | 52 | kw['security_group_ids'] = security_groups | ||
934 | 41 | log.debug("Launching with machine spec %s", spec) | 53 | log.debug("Launching with machine spec %s", spec) |
943 | 42 | instances = yield self._provider.ec2.run_instances( | 54 | instances = yield self._provider.ec2.run_instances(**kw) |
936 | 43 | min_count=1, | ||
937 | 44 | max_count=1, | ||
938 | 45 | image_id=spec.image_id, | ||
939 | 46 | instance_type=spec.instance_type, | ||
940 | 47 | security_groups=security_groups, | ||
941 | 48 | availability_zone=availability_zone, | ||
942 | 49 | user_data=user_data) | ||
944 | 50 | 55 | ||
945 | 51 | returnValue([machine_from_instance(i) for i in instances]) | 56 | returnValue([machine_from_instance(i) for i in instances]) |
946 | 52 | 57 | ||
947 | @@ -68,18 +73,24 @@ | |||
948 | 68 | self._provider.environment_name, machine_id) | 73 | self._provider.environment_name, machine_id) |
949 | 69 | 74 | ||
950 | 70 | security_groups = yield self._provider.ec2.describe_security_groups() | 75 | security_groups = yield self._provider.ec2.describe_security_groups() |
952 | 71 | group_ids = [group.name for group in security_groups] | 76 | group_names = [group.name for group in security_groups] |
953 | 77 | vpc_id = self._provider.config.get("vpc_id") | ||
954 | 72 | 78 | ||
955 | 73 | # Create the provider group if doesn't exist. | 79 | # Create the provider group if doesn't exist. |
957 | 74 | if not juju_group in group_ids: | 80 | if juju_group in group_names: |
958 | 81 | for group in security_groups: | ||
959 | 82 | if group.name == juju_group: | ||
960 | 83 | juju_group_id = group.id | ||
961 | 84 | else: | ||
962 | 75 | log.debug("Creating juju provider group %s", juju_group) | 85 | log.debug("Creating juju provider group %s", juju_group) |
964 | 76 | yield self._provider.ec2.create_security_group( | 86 | juju_group_id = yield self._provider.ec2.create_security_group( |
965 | 77 | juju_group, | 87 | juju_group, |
967 | 78 | "juju group for %s" % self._provider.environment_name) | 88 | "juju group for %s" % self._provider.environment_name, |
968 | 89 | vpc_id=vpc_id) | ||
969 | 79 | 90 | ||
970 | 80 | # Authorize SSH. | 91 | # Authorize SSH. |
971 | 81 | yield self._provider.ec2.authorize_security_group( | 92 | yield self._provider.ec2.authorize_security_group( |
973 | 82 | juju_group, | 93 | group_id=juju_group_id, |
974 | 83 | ip_protocol="tcp", | 94 | ip_protocol="tcp", |
975 | 84 | from_port="22", to_port="22", | 95 | from_port="22", to_port="22", |
976 | 85 | cidr_ip="0.0.0.0/0") | 96 | cidr_ip="0.0.0.0/0") |
977 | @@ -90,15 +101,20 @@ | |||
978 | 90 | 101 | ||
979 | 91 | # Authorize Internal ZK Traffic | 102 | # Authorize Internal ZK Traffic |
980 | 92 | yield self._provider.ec2.authorize_security_group( | 103 | yield self._provider.ec2.authorize_security_group( |
982 | 93 | juju_group, | 104 | group_id=juju_group_id, |
983 | 94 | source_group_name=juju_group, | 105 | source_group_name=juju_group, |
984 | 95 | source_group_owner_id=groups_info.pop().owner_id) | 106 | source_group_owner_id=groups_info.pop().owner_id) |
985 | 96 | 107 | ||
986 | 97 | # Create the machine-specific group if it does not already exist | 108 | # Create the machine-specific group if it does not already exist |
989 | 98 | if not juju_machine_group in group_ids: | 109 | if juju_machine_group in group_names: |
990 | 99 | yield self._provider.ec2.create_security_group( | 110 | for group in security_groups: |
991 | 111 | if group.name == juju_machine_group: | ||
992 | 112 | juju_machine_group_id = group.id | ||
993 | 113 | else: | ||
994 | 114 | juju_machine_group_id = yield self._provider.ec2.create_security_group( | ||
995 | 100 | juju_machine_group, | 115 | juju_machine_group, |
996 | 101 | "juju group for %s machine %s" % ( | 116 | "juju group for %s machine %s" % ( |
998 | 102 | self._provider.environment_name, machine_id)) | 117 | self._provider.environment_name, machine_id), |
999 | 118 | vpc_id=vpc_id) | ||
1000 | 103 | 119 | ||
1002 | 104 | returnValue([juju_group, juju_machine_group]) | 120 | returnValue([juju_group_id, juju_machine_group_id]) |
1003 | 105 | 121 | ||
1004 | === modified file 'juju/providers/ec2/machine.py' | |||
1005 | --- juju/providers/ec2/machine.py 2011-10-11 10:59:04 +0000 | |||
1006 | +++ juju/providers/ec2/machine.py 2012-11-23 21:00:27 +0000 | |||
1007 | @@ -8,15 +8,19 @@ | |||
1008 | 8 | """ | 8 | """ |
1009 | 9 | 9 | ||
1010 | 10 | 10 | ||
1012 | 11 | def machine_from_instance(instance): | 11 | def machine_from_instance(instance, private=False): |
1013 | 12 | """Create an :class:`EC2ProviderMachine` from a txaws :class:`Instance` | 12 | """Create an :class:`EC2ProviderMachine` from a txaws :class:`Instance` |
1014 | 13 | 13 | ||
1015 | 14 | :param instance: the EC2 Instance | 14 | :param instance: the EC2 Instance |
1016 | 15 | 15 | ||
1017 | 16 | :return: a matching :class:`EC2ProviderMachine` | 16 | :return: a matching :class:`EC2ProviderMachine` |
1018 | 17 | """ | 17 | """ |
1020 | 18 | return EC2ProviderMachine( | 18 | params = [ |
1021 | 19 | instance.instance_id, | 19 | instance.instance_id, |
1022 | 20 | instance.dns_name, | 20 | instance.dns_name, |
1023 | 21 | instance.private_dns_name, | 21 | instance.private_dns_name, |
1025 | 22 | instance.instance_state) | 22 | instance.instance_state, |
1026 | 23 | instance.private_ip_address] | ||
1027 | 24 | if private: | ||
1028 | 25 | params[1] = params[2] = instance.private_ip_address | ||
1029 | 26 | return EC2ProviderMachine(*params) | ||
1030 | 23 | 27 | ||
1031 | === modified file 'juju/providers/ec2/securitygroup.py' | |||
1032 | --- juju/providers/ec2/securitygroup.py 2012-07-05 21:49:12 +0000 | |||
1033 | +++ juju/providers/ec2/securitygroup.py 2012-11-23 21:00:27 +0000 | |||
1034 | @@ -6,14 +6,32 @@ | |||
1035 | 6 | from .utils import log | 6 | from .utils import log |
1036 | 7 | 7 | ||
1037 | 8 | 8 | ||
1038 | 9 | @inlineCallbacks | ||
1039 | 10 | def _get_security_group_id(group_name, ec2): | ||
1040 | 11 | groups = yield ec2.describe_security_groups() | ||
1041 | 12 | for group in groups: | ||
1042 | 13 | if group.name == group_name: | ||
1043 | 14 | returnValue(group.id) | ||
1044 | 15 | |||
1045 | 16 | |||
1046 | 9 | def _get_juju_security_group(provider): | 17 | def _get_juju_security_group(provider): |
1047 | 10 | """Get EC2 security group name for environment of `provider`.""" | 18 | """Get EC2 security group name for environment of `provider`.""" |
1048 | 11 | return "juju-%s" % provider.environment_name | 19 | return "juju-%s" % provider.environment_name |
1049 | 12 | 20 | ||
1050 | 13 | 21 | ||
1051 | 22 | def _get_juju_security_group_id(provider): | ||
1052 | 23 | name = "juju-%s" % provider.environment_name | ||
1053 | 24 | return _get_security_group_id(name, provider.ec2) | ||
1054 | 25 | |||
1055 | 26 | |||
1056 | 14 | def _get_machine_group_name(provider, machine_id): | 27 | def _get_machine_group_name(provider, machine_id): |
1057 | 28 | return "juju-%s-%s" % (provider.environment_name, machine_id) | ||
1058 | 29 | |||
1059 | 30 | |||
1060 | 31 | def _get_machine_group_id(provider, machine_id): | ||
1061 | 15 | """Get EC2 security group name associated just with `machine_id`.""" | 32 | """Get EC2 security group name associated just with `machine_id`.""" |
1063 | 16 | return "juju-%s-%s" % (provider.environment_name, machine_id) | 33 | name = _get_machine_group_name(provider, machine_id) |
1064 | 34 | return _get_security_group_id(name, provider.ec2) | ||
1065 | 17 | 35 | ||
1066 | 18 | 36 | ||
1067 | 19 | # TODO These security group functions do not handle the eventual | 37 | # TODO These security group functions do not handle the eventual |
1068 | @@ -34,8 +52,9 @@ | |||
1069 | 34 | def open_provider_port(provider, machine, machine_id, port, protocol): | 52 | def open_provider_port(provider, machine, machine_id, port, protocol): |
1070 | 35 | """Authorize `port`/`proto` for the machine security group.""" | 53 | """Authorize `port`/`proto` for the machine security group.""" |
1071 | 36 | try: | 54 | try: |
1072 | 55 | group_id = yield _get_machine_group_id(provider, machine_id) | ||
1073 | 37 | yield provider.ec2.authorize_security_group( | 56 | yield provider.ec2.authorize_security_group( |
1075 | 38 | _get_machine_group_name(provider, machine_id), | 57 | group_id=group_id, |
1076 | 39 | ip_protocol=protocol, | 58 | ip_protocol=protocol, |
1077 | 40 | from_port=str(port), to_port=str(port), | 59 | from_port=str(port), to_port=str(port), |
1078 | 41 | cidr_ip="0.0.0.0/0") | 60 | cidr_ip="0.0.0.0/0") |
1079 | @@ -51,8 +70,9 @@ | |||
1080 | 51 | def close_provider_port(provider, machine, machine_id, port, protocol): | 70 | def close_provider_port(provider, machine, machine_id, port, protocol): |
1081 | 52 | """Revoke `port`/`proto` for the machine security group.""" | 71 | """Revoke `port`/`proto` for the machine security group.""" |
1082 | 53 | try: | 72 | try: |
1083 | 73 | group_id = yield _get_machine_group_id(provider, machine_id) | ||
1084 | 54 | yield provider.ec2.revoke_security_group( | 74 | yield provider.ec2.revoke_security_group( |
1086 | 55 | _get_machine_group_name(provider, machine_id), | 75 | group_id=group_id, |
1087 | 56 | ip_protocol=protocol, | 76 | ip_protocol=protocol, |
1088 | 57 | from_port=str(port), to_port=str(port), | 77 | from_port=str(port), to_port=str(port), |
1089 | 58 | cidr_ip="0.0.0.0/0") | 78 | cidr_ip="0.0.0.0/0") |
1090 | @@ -73,15 +93,20 @@ | |||
1091 | 73 | proto) pairs. | 93 | proto) pairs. |
1092 | 74 | """ | 94 | """ |
1093 | 75 | try: | 95 | try: |
1096 | 76 | security_groups = yield provider.ec2.describe_security_groups( | 96 | security_group = None |
1097 | 77 | _get_machine_group_name(provider, machine_id)) | 97 | security_groups = yield provider.ec2.describe_security_groups() |
1098 | 98 | name = _get_machine_group_name(provider, machine_id) | ||
1099 | 99 | for group in security_groups: | ||
1100 | 100 | if group.name == name: | ||
1101 | 101 | security_group = group | ||
1102 | 102 | break | ||
1103 | 78 | except EC2Error, e: | 103 | except EC2Error, e: |
1104 | 79 | raise ProviderInteractionError( | 104 | raise ProviderInteractionError( |
1105 | 80 | "Unexpected EC2Error getting open ports on machine %s: %s" | 105 | "Unexpected EC2Error getting open ports on machine %s: %s" |
1106 | 81 | % (machine.instance_id, e.get_error_messages())) | 106 | % (machine.instance_id, e.get_error_messages())) |
1107 | 82 | 107 | ||
1108 | 83 | opened_ports = set() # made up of (port, protocol) pairs | 108 | opened_ports = set() # made up of (port, protocol) pairs |
1110 | 84 | for ip_permission in security_groups[0].allowed_ips: | 109 | for ip_permission in security_group.allowed_ips: |
1111 | 85 | if ip_permission.cidr_ip != "0.0.0.0/0": | 110 | if ip_permission.cidr_ip != "0.0.0.0/0": |
1112 | 86 | continue | 111 | continue |
1113 | 87 | from_port = int(ip_permission.from_port) | 112 | from_port = int(ip_permission.from_port) |
1114 | @@ -110,24 +135,15 @@ | |||
1115 | 110 | 135 | ||
1116 | 111 | 136 | ||
1117 | 112 | @inlineCallbacks | 137 | @inlineCallbacks |
1118 | 113 | def _delete_security_group(provider, group): | ||
1119 | 114 | """Wrap EC2 delete_security_group.""" | ||
1120 | 115 | try: | ||
1121 | 116 | yield provider.ec2.delete_security_group(group) | ||
1122 | 117 | log.debug("Deleted security group %r", group) | ||
1123 | 118 | except EC2Error, e: | ||
1124 | 119 | raise ProviderInteractionError( | ||
1125 | 120 | "EC2 error when attempting to delete group %s: %s" % (group, e)) | ||
1126 | 121 | |||
1127 | 122 | |||
1128 | 123 | @inlineCallbacks | ||
1129 | 124 | def destroy_environment_security_group(provider): | 138 | def destroy_environment_security_group(provider): |
1130 | 125 | """Delete the security group for the environment of `provider`""" | 139 | """Delete the security group for the environment of `provider`""" |
1131 | 126 | group = _get_juju_security_group(provider) | 140 | group = _get_juju_security_group(provider) |
1132 | 127 | try: | 141 | try: |
1136 | 128 | yield provider.ec2.delete_security_group(group) | 142 | group_id = yield _get_juju_security_group_id(provider) |
1137 | 129 | log.debug("Deleted environment security group %r", group) | 143 | if group_id: |
1138 | 130 | returnValue(True) | 144 | yield provider.ec2.delete_security_group(id=group_id) |
1139 | 145 | log.debug("Deleted environment security group %r", group) | ||
1140 | 146 | returnValue(True) | ||
1141 | 131 | except EC2Error, e: | 147 | except EC2Error, e: |
1142 | 132 | # Ignore, since this is only attempting to cleanup | 148 | # Ignore, since this is only attempting to cleanup |
1143 | 133 | log.debug( | 149 | log.debug( |
1144 | 134 | 150 | ||
1145 | === modified file 'juju/providers/ec2/tests/common.py' | |||
1146 | --- juju/providers/ec2/tests/common.py 2012-09-10 03:20:20 +0000 | |||
1147 | +++ juju/providers/ec2/tests/common.py 2012-11-23 21:00:27 +0000 | |||
1148 | @@ -49,8 +49,8 @@ | |||
1149 | 49 | def get_instance(self, | 49 | def get_instance(self, |
1150 | 50 | instance_id, state="running", machine_id=42, **kwargs): | 50 | instance_id, state="running", machine_id=42, **kwargs): |
1151 | 51 | groups = kwargs.pop("groups", | 51 | groups = kwargs.pop("groups", |
1154 | 52 | ["juju-%s" % self.env_name, | 52 | [("sg-a1a1a1", "juju-%s" % self.env_name), |
1155 | 53 | "juju-%s-%s" % (self.env_name, machine_id)]) | 53 | ("sg-b2b2b2", "juju-%s-%s" % (self.env_name, machine_id))]) |
1156 | 54 | reservation = Reservation("x", "y", groups=groups) | 54 | reservation = Reservation("x", "y", groups=groups) |
1157 | 55 | return Instance(instance_id, state, reservation=reservation, **kwargs) | 55 | return Instance(instance_id, state, reservation=reservation, **kwargs) |
1158 | 56 | 56 | ||
1159 | @@ -108,32 +108,33 @@ | |||
1160 | 108 | get_ami(*get_ami_args) | 108 | get_ami(*get_ami_args) |
1161 | 109 | self.mocker.result(succeed(ami_name)) | 109 | self.mocker.result(succeed(ami_name)) |
1162 | 110 | 110 | ||
1164 | 111 | def _mock_create_group(self): | 111 | def _mock_create_group(self, vpc_id=None): |
1165 | 112 | group_name = "juju-%s" % self.env_name | 112 | group_name = "juju-%s" % self.env_name |
1166 | 113 | self.ec2.create_security_group( | 113 | self.ec2.create_security_group( |
1169 | 114 | group_name, "juju group for %s" % self.env_name) | 114 | group_name, "juju group for %s" % self.env_name, |
1170 | 115 | self.mocker.result(succeed(True)) | 115 | vpc_id=vpc_id) |
1171 | 116 | self.mocker.result(succeed("sg-a1a1a1a1")) | ||
1172 | 116 | 117 | ||
1173 | 117 | self.ec2.authorize_security_group( | 118 | self.ec2.authorize_security_group( |
1175 | 118 | group_name, ip_protocol="tcp", from_port="22", | 119 | group_id="sg-a1a1a1a1", ip_protocol="tcp", from_port="22", |
1176 | 119 | to_port="22", cidr_ip="0.0.0.0/0") | 120 | to_port="22", cidr_ip="0.0.0.0/0") |
1177 | 120 | self.mocker.result(succeed([self.env_name])) | 121 | self.mocker.result(succeed([self.env_name])) |
1178 | 121 | 122 | ||
1179 | 122 | self.ec2.describe_security_groups(group_name) | 123 | self.ec2.describe_security_groups(group_name) |
1180 | 123 | self.mocker.result(succeed( | 124 | self.mocker.result(succeed( |
1182 | 124 | [SecurityGroup(group_name, "", owner_id="123")])) | 125 | [SecurityGroup("sg-a1a1a1a1", group_name, "", owner_id="123")])) |
1183 | 125 | 126 | ||
1184 | 126 | self.ec2.authorize_security_group( | 127 | self.ec2.authorize_security_group( |
1186 | 127 | group_name, source_group_name=group_name, | 128 | group_id="sg-a1a1a1a1", source_group_name=group_name, |
1187 | 128 | source_group_owner_id="123") | 129 | source_group_owner_id="123") |
1188 | 129 | self.mocker.result(succeed(True)) | 130 | self.mocker.result(succeed(True)) |
1189 | 130 | 131 | ||
1191 | 131 | def _mock_create_machine_group(self, machine_id): | 132 | def _mock_create_machine_group(self, machine_id, vpc_id=None): |
1192 | 132 | machine_group_name = "juju-%s-%s" % (self.env_name, machine_id) | 133 | machine_group_name = "juju-%s-%s" % (self.env_name, machine_id) |
1193 | 133 | self.ec2.create_security_group( | 134 | self.ec2.create_security_group( |
1194 | 134 | machine_group_name, "juju group for %s machine %s" % ( | 135 | machine_group_name, "juju group for %s machine %s" % ( |
1197 | 135 | self.env_name, machine_id)) | 136 | self.env_name, machine_id), vpc_id=vpc_id) |
1198 | 136 | self.mocker.result(succeed(True)) | 137 | self.mocker.result(succeed("sg-b2b2b2b2")) |
1199 | 137 | 138 | ||
1200 | 138 | def _mock_get_zookeeper_hosts(self, hosts=None): | 139 | def _mock_get_zookeeper_hosts(self, hosts=None): |
1201 | 139 | """ | 140 | """ |
1202 | @@ -147,7 +148,7 @@ | |||
1203 | 147 | 148 | ||
1204 | 148 | if hosts is None: | 149 | if hosts is None: |
1205 | 149 | hosts = [self.get_instance( | 150 | hosts = [self.get_instance( |
1207 | 150 | "i-es-zoo", private_dns_name="es.example.internal")] | 151 | "i-es-zoo", private_dns_name="es.example.internal", private_ip_address="1.1.1.1")] |
1208 | 151 | 152 | ||
1209 | 152 | self.s3.get_object(self.env_name, "provider-state") | 153 | self.s3.get_object(self.env_name, "provider-state") |
1210 | 153 | if hosts is False: | 154 | if hosts is False: |
1211 | 154 | 155 | ||
1212 | === modified file 'juju/providers/ec2/tests/data/bootstrap_cloud_init' | |||
1213 | --- juju/providers/ec2/tests/data/bootstrap_cloud_init 2012-08-23 16:14:42 +0000 | |||
1214 | +++ juju/providers/ec2/tests/data/bootstrap_cloud_init 2012-11-23 21:00:27 +0000 | |||
1215 | @@ -3,8 +3,8 @@ | |||
1216 | 3 | apt_upgrade: true | 3 | apt_upgrade: true |
1217 | 4 | machine-data: {juju-provider-type: ec2, juju-zookeeper-hosts: 'localhost:2181', machine-id: '0'} | 4 | machine-data: {juju-provider-type: ec2, juju-zookeeper-hosts: 'localhost:2181', machine-id: '0'} |
1218 | 5 | output: {all: '| tee -a /var/log/cloud-init-output.log'} | 5 | output: {all: '| tee -a /var/log/cloud-init-output.log'} |
1221 | 6 | packages: [bzr, byobu, tmux, python-setuptools, python-twisted, python-txaws, python-zookeeper, | 6 | packages: [bzr, byobu, tmux, python-setuptools, python-twisted, python-zookeeper, |
1222 | 7 | default-jre-headless, zookeeper, zookeeperd, juju] | 7 | default-jre-headless, zookeeper, zookeeperd, juju, python-txaws] |
1223 | 8 | runcmd: [sudo mkdir -p /var/lib/juju, sudo mkdir -p /var/log/juju, 'juju-admin initialize | 8 | runcmd: [sudo mkdir -p /var/lib/juju, sudo mkdir -p /var/log/juju, 'juju-admin initialize |
1224 | 9 | --instance-id=$(curl http://169.254.169.254/1.0/meta-data/instance-id) --admin-identity=admin:JbJ6sDGV37EHzbG9FPvttk64cmg= | 9 | --instance-id=$(curl http://169.254.169.254/1.0/meta-data/instance-id) --admin-identity=admin:JbJ6sDGV37EHzbG9FPvttk64cmg= |
1225 | 10 | --constraints-data=e2NwdTogbnVsbCwgaW5zdGFuY2UtdHlwZTogbTEuc21hbGwsIG1lbTogbnVsbCwgcHJvdmlkZXItdHlwZTogZWMyLCB1YnVudHUtc2VyaWVzOiBzcGxlbmRpZH0K | 10 | --constraints-data=e2NwdTogbnVsbCwgaW5zdGFuY2UtdHlwZTogbTEuc21hbGwsIG1lbTogbnVsbCwgcHJvdmlkZXItdHlwZTogZWMyLCB1YnVudHUtc2VyaWVzOiBzcGxlbmRpZH0K |
1226 | 11 | 11 | ||
1227 | === modified file 'juju/providers/ec2/tests/data/launch_cloud_init' | |||
1228 | --- juju/providers/ec2/tests/data/launch_cloud_init 2012-08-23 16:14:42 +0000 | |||
1229 | +++ juju/providers/ec2/tests/data/launch_cloud_init 2012-11-23 21:00:27 +0000 | |||
1230 | @@ -4,7 +4,7 @@ | |||
1231 | 4 | machine-data: {juju-provider-type: ec2, juju-zookeeper-hosts: 'es.example.internal:2181', | 4 | machine-data: {juju-provider-type: ec2, juju-zookeeper-hosts: 'es.example.internal:2181', |
1232 | 5 | machine-id: '1'} | 5 | machine-id: '1'} |
1233 | 6 | output: {all: '| tee -a /var/log/cloud-init-output.log'} | 6 | output: {all: '| tee -a /var/log/cloud-init-output.log'} |
1235 | 7 | packages: [bzr, byobu, tmux, python-setuptools, python-twisted, python-txaws, python-zookeeper, juju] | 7 | packages: [bzr, byobu, tmux, python-setuptools, python-twisted, python-zookeeper, juju, python-txaws] |
1236 | 8 | runcmd: [sudo mkdir -p /var/lib/juju, sudo mkdir -p | 8 | runcmd: [sudo mkdir -p /var/lib/juju, sudo mkdir -p |
1237 | 9 | /var/log/juju, 'cat >> /etc/init/juju-machine-agent.conf <<EOF | 9 | /var/log/juju, 'cat >> /etc/init/juju-machine-agent.conf <<EOF |
1238 | 10 | 10 | ||
1239 | 11 | 11 | ||
1240 | === modified file 'juju/providers/ec2/tests/data/launch_cloud_init_branch' | |||
1241 | --- juju/providers/ec2/tests/data/launch_cloud_init_branch 2012-10-09 18:55:55 +0000 | |||
1242 | +++ juju/providers/ec2/tests/data/launch_cloud_init_branch 2012-11-23 21:00:27 +0000 | |||
1243 | @@ -6,7 +6,7 @@ | |||
1244 | 6 | machine-data: {juju-provider-type: ec2, juju-zookeeper-hosts: 'es.example.internal:2181', | 6 | machine-data: {juju-provider-type: ec2, juju-zookeeper-hosts: 'es.example.internal:2181', |
1245 | 7 | machine-id: '1'} | 7 | machine-id: '1'} |
1246 | 8 | output: {all: '| tee -a /var/log/cloud-init-output.log'} | 8 | output: {all: '| tee -a /var/log/cloud-init-output.log'} |
1248 | 9 | packages: [bzr, byobu, tmux, python-setuptools, python-twisted, python-txaws, python-zookeeper] | 9 | packages: [bzr, byobu, tmux, python-setuptools, python-twisted, python-zookeeper, python-txaws] |
1249 | 10 | runcmd: [sudo apt-get install -y python-txzookeeper, sudo mkdir -p /usr/lib/juju, | 10 | runcmd: [sudo apt-get install -y python-txzookeeper, sudo mkdir -p /usr/lib/juju, |
1250 | 11 | 'cd /usr/lib/juju && sudo /usr/bin/bzr co --lightweight lp:~wizard/juju-juicebar juju', cd /usr/lib/juju/juju | 11 | 'cd /usr/lib/juju && sudo /usr/bin/bzr co --lightweight lp:~wizard/juju-juicebar juju', cd /usr/lib/juju/juju |
1251 | 12 | && sudo python setup.py develop, sudo mkdir -p /var/lib/juju, sudo mkdir -p /var/log/juju, | 12 | && sudo python setup.py develop, sudo mkdir -p /var/lib/juju, sudo mkdir -p /var/log/juju, |
1252 | 13 | 13 | ||
1253 | === added file 'juju/providers/ec2/tests/data/launch_cloud_init_ip_address' | |||
1254 | --- juju/providers/ec2/tests/data/launch_cloud_init_ip_address 1970-01-01 00:00:00 +0000 | |||
1255 | +++ juju/providers/ec2/tests/data/launch_cloud_init_ip_address 2012-11-23 21:00:27 +0000 | |||
1256 | @@ -0,0 +1,35 @@ | |||
1257 | 1 | #cloud-config | ||
1258 | 2 | apt_update: true | ||
1259 | 3 | apt_upgrade: true | ||
1260 | 4 | machine-data: {juju-provider-type: ec2, juju-zookeeper-hosts: '1.1.1.1:2181', | ||
1261 | 5 | machine-id: '1'} | ||
1262 | 6 | output: {all: '| tee -a /var/log/cloud-init-output.log'} | ||
1263 | 7 | packages: [bzr, byobu, tmux, python-setuptools, python-twisted, python-txaws, python-zookeeper, juju] | ||
1264 | 8 | runcmd: [sudo mkdir -p /var/lib/juju, sudo mkdir -p | ||
1265 | 9 | /var/log/juju, 'cat >> /etc/init/juju-machine-agent.conf <<EOF | ||
1266 | 10 | |||
1267 | 11 | description "Juju machine agent" | ||
1268 | 12 | |||
1269 | 13 | author "Juju Team <juju@lists.ubuntu.com>" | ||
1270 | 14 | |||
1271 | 15 | |||
1272 | 16 | start on runlevel [2345] | ||
1273 | 17 | |||
1274 | 18 | stop on runlevel [!2345] | ||
1275 | 19 | |||
1276 | 20 | respawn | ||
1277 | 21 | |||
1278 | 22 | |||
1279 | 23 | env JUJU_MACHINE_ID="1" | ||
1280 | 24 | |||
1281 | 25 | env JUJU_ZOOKEEPER="1.1.1.1:2181" | ||
1282 | 26 | |||
1283 | 27 | |||
1284 | 28 | exec python -m juju.agents.machine --nodaemon --logfile /var/log/juju/machine-agent.log | ||
1285 | 29 | --session-file /var/run/juju/machine-agent.zksession >> /tmp/juju-machine-agent.output | ||
1286 | 30 | 2>&1 | ||
1287 | 31 | |||
1288 | 32 | EOF | ||
1289 | 33 | |||
1290 | 34 | ', /sbin/start juju-machine-agent] | ||
1291 | 35 | ssh_authorized_keys: [zebra] | ||
1292 | 0 | 36 | ||
1293 | === modified file 'juju/providers/ec2/tests/data/launch_cloud_init_ppa' | |||
1294 | --- juju/providers/ec2/tests/data/launch_cloud_init_ppa 2012-10-09 18:55:55 +0000 | |||
1295 | +++ juju/providers/ec2/tests/data/launch_cloud_init_ppa 2012-11-23 21:00:27 +0000 | |||
1296 | @@ -6,7 +6,7 @@ | |||
1297 | 6 | machine-data: {juju-provider-type: ec2, juju-zookeeper-hosts: 'es.example.internal:2181', | 6 | machine-data: {juju-provider-type: ec2, juju-zookeeper-hosts: 'es.example.internal:2181', |
1298 | 7 | machine-id: '1'} | 7 | machine-id: '1'} |
1299 | 8 | output: {all: '| tee -a /var/log/cloud-init-output.log'} | 8 | output: {all: '| tee -a /var/log/cloud-init-output.log'} |
1301 | 9 | packages: [bzr, byobu, tmux, python-setuptools, python-twisted, python-txaws, python-zookeeper, juju] | 9 | packages: [bzr, byobu, tmux, python-setuptools, python-twisted, python-zookeeper, juju, python-txaws] |
1302 | 10 | runcmd: [sudo mkdir -p /var/lib/juju, sudo mkdir -p | 10 | runcmd: [sudo mkdir -p /var/lib/juju, sudo mkdir -p |
1303 | 11 | /var/log/juju, 'cat >> /etc/init/juju-machine-agent.conf <<EOF | 11 | /var/log/juju, 'cat >> /etc/init/juju-machine-agent.conf <<EOF |
1304 | 12 | 12 | ||
1305 | 13 | 13 | ||
1306 | === modified file 'juju/providers/ec2/tests/test_bootstrap.py' | |||
1307 | --- juju/providers/ec2/tests/test_bootstrap.py 2012-09-10 03:20:20 +0000 | |||
1308 | +++ juju/providers/ec2/tests/test_bootstrap.py 2012-11-23 21:00:27 +0000 | |||
1309 | @@ -48,7 +48,7 @@ | |||
1310 | 48 | instance_type="m1.small", | 48 | instance_type="m1.small", |
1311 | 49 | max_count=1, | 49 | max_count=1, |
1312 | 50 | min_count=1, | 50 | min_count=1, |
1314 | 51 | security_groups=["juju-moon", "juju-moon-0"], | 51 | security_group_ids=["sg-a1a1a1a1", "sg-b2b2b2b2"], |
1315 | 52 | availability_zone=None, | 52 | availability_zone=None, |
1316 | 53 | user_data=MATCH(verify_user_data)) | 53 | user_data=MATCH(verify_user_data)) |
1317 | 54 | 54 | ||
1318 | @@ -90,7 +90,7 @@ | |||
1319 | 90 | self._mock_verify() | 90 | self._mock_verify() |
1320 | 91 | self.ec2.describe_security_groups() | 91 | self.ec2.describe_security_groups() |
1321 | 92 | self.mocker.result(succeed([ | 92 | self.mocker.result(succeed([ |
1323 | 93 | SecurityGroup("juju-%s" % self.env_name, "")])) | 93 | SecurityGroup("sg-a1a1a1a1", "juju-%s" % self.env_name, "")])) |
1324 | 94 | self._mock_create_machine_group(0) | 94 | self._mock_create_machine_group(0) |
1325 | 95 | self._mock_launch_utils() | 95 | self._mock_launch_utils() |
1326 | 96 | self._mock_launch() | 96 | self._mock_launch() |
1327 | @@ -138,7 +138,7 @@ | |||
1328 | 138 | self._mock_verify() | 138 | self._mock_verify() |
1329 | 139 | self.ec2.describe_security_groups() | 139 | self.ec2.describe_security_groups() |
1330 | 140 | self.mocker.result(succeed([ | 140 | self.mocker.result(succeed([ |
1332 | 141 | SecurityGroup("juju-%s" % self.env_name, "")])) | 141 | SecurityGroup("sg-a1a1a1a1", "juju-%s" % self.env_name, "")])) |
1333 | 142 | self._mock_create_machine_group(0) | 142 | self._mock_create_machine_group(0) |
1334 | 143 | self._mock_launch_utils() | 143 | self._mock_launch_utils() |
1335 | 144 | self._mock_launch() | 144 | self._mock_launch() |
1336 | 145 | 145 | ||
1337 | === modified file 'juju/providers/ec2/tests/test_launch.py' | |||
1338 | --- juju/providers/ec2/tests/test_launch.py 2012-09-10 03:20:20 +0000 | |||
1339 | +++ juju/providers/ec2/tests/test_launch.py 2012-11-23 21:00:27 +0000 | |||
1340 | @@ -31,7 +31,7 @@ | |||
1341 | 31 | def _mock_launch(self, instance, expect_ami="ami-default", | 31 | def _mock_launch(self, instance, expect_ami="ami-default", |
1342 | 32 | expect_instance_type="m1.small", | 32 | expect_instance_type="m1.small", |
1343 | 33 | expect_availability_zone=None, | 33 | expect_availability_zone=None, |
1345 | 34 | cloud_init="launch_cloud_init"): | 34 | cloud_init="launch_cloud_init", **extra): |
1346 | 35 | 35 | ||
1347 | 36 | def verify_user_data(data): | 36 | def verify_user_data(data): |
1348 | 37 | expect_path = os.path.join(DATA_DIR, cloud_init) | 37 | expect_path = os.path.join(DATA_DIR, cloud_init) |
1349 | @@ -45,12 +45,26 @@ | |||
1350 | 45 | instance_type=expect_instance_type, | 45 | instance_type=expect_instance_type, |
1351 | 46 | max_count=1, | 46 | max_count=1, |
1352 | 47 | min_count=1, | 47 | min_count=1, |
1353 | 48 | security_groups=["juju-moon", "juju-moon-1"], | ||
1354 | 49 | availability_zone=expect_availability_zone, | 48 | availability_zone=expect_availability_zone, |
1356 | 50 | user_data=MATCH(verify_user_data)) | 49 | user_data=MATCH(verify_user_data), **extra) |
1357 | 51 | 50 | ||
1358 | 52 | self.mocker.result(succeed([instance])) | 51 | self.mocker.result(succeed([instance])) |
1359 | 53 | 52 | ||
1360 | 53 | def _mock_launch_groupname(self, instance, expect_ami="ami-default", | ||
1361 | 54 | expect_instance_type="m1.small", | ||
1362 | 55 | expect_availability_zone=None, | ||
1363 | 56 | cloud_init="launch_cloud_init", **extra): | ||
1364 | 57 | extra["security_group_ids"] = ["sg-a1a1a1a1", "sg-b2b2b2b2"] | ||
1365 | 58 | self._mock_launch(instance, expect_ami, expect_instance_type, expect_availability_zone, cloud_init, **extra) | ||
1366 | 59 | |||
1367 | 60 | def _mock_launch_subnet(self, instance, subnet_id, expect_ami="ami-default", | ||
1368 | 61 | expect_instance_type="m1.small", | ||
1369 | 62 | expect_availability_zone=None, | ||
1370 | 63 | cloud_init="launch_cloud_init", **extra): | ||
1371 | 64 | extra["subnet_id"] = subnet_id | ||
1372 | 65 | extra["security_group_ids"] = ["sg-a1a1a1a1", "sg-b2b2b2b2"] | ||
1373 | 66 | self._mock_launch(instance, expect_ami, expect_instance_type, expect_availability_zone, cloud_init, **extra) | ||
1374 | 67 | |||
1375 | 54 | def test_bad_data(self): | 68 | def test_bad_data(self): |
1376 | 55 | self.mocker.replay() | 69 | self.mocker.replay() |
1377 | 56 | d = self.get_provider().start_machine({}) | 70 | d = self.get_provider().start_machine({}) |
1378 | @@ -74,13 +88,39 @@ | |||
1379 | 74 | self._mock_create_machine_group("1") | 88 | self._mock_create_machine_group("1") |
1380 | 75 | self._mock_launch_utils() | 89 | self._mock_launch_utils() |
1381 | 76 | self._mock_get_zookeeper_hosts() | 90 | self._mock_get_zookeeper_hosts() |
1389 | 77 | self._mock_launch(self.get_instance("i-foobar")) | 91 | self._mock_launch_groupname(self.get_instance("i-foobar")) |
1390 | 78 | self.mocker.replay() | 92 | self.mocker.replay() |
1391 | 79 | 93 | ||
1392 | 80 | def verify_result(result): | 94 | def verify_result(result): |
1393 | 81 | (machine,) = result | 95 | (machine,) = result |
1394 | 82 | self.assert_machine(machine, "i-foobar", "") | 96 | self.assert_machine(machine, "i-foobar", "") |
1395 | 83 | provider = self.get_provider() | 97 | provider = self.get_provider() |
1396 | 98 | d = provider.start_machine({ | ||
1397 | 99 | "machine-id": "1", "constraints": self.constraints}) | ||
1398 | 100 | d.addCallback(verify_result) | ||
1399 | 101 | return d | ||
1400 | 102 | |||
1401 | 103 | def test_provider_launch_with_subnet_and_vpc(self): | ||
1402 | 104 | vpc_id = "vpc-a1d4f2" | ||
1403 | 105 | self.ec2.describe_security_groups() | ||
1404 | 106 | self.mocker.result(succeed([])) | ||
1405 | 107 | self._mock_create_group(vpc_id=vpc_id) | ||
1406 | 108 | self._mock_create_machine_group("1", vpc_id=vpc_id) | ||
1407 | 109 | self._mock_launch_utils() | ||
1408 | 110 | self._mock_get_zookeeper_hosts() | ||
1409 | 111 | self._mock_launch_subnet( | ||
1410 | 112 | self.get_instance("i-foobar", private_ip_address="1.1.1.1"), | ||
1411 | 113 | "subnet-a7f22c3e", | ||
1412 | 114 | cloud_init="launch_cloud_init_ip_address" | ||
1413 | 115 | ) | ||
1414 | 116 | self.mocker.replay() | ||
1415 | 117 | |||
1416 | 118 | def verify_result(result): | ||
1417 | 119 | (machine,) = result | ||
1418 | 120 | self.assert_machine(machine, "i-foobar", "") | ||
1419 | 121 | provider = self.get_provider() | ||
1420 | 122 | provider.config["subnet_id"] = "subnet-a7f22c3e" | ||
1421 | 123 | provider.config["vpc_id"] = vpc_id | ||
1422 | 84 | d = provider.start_machine({ | 124 | d = provider.start_machine({ |
1423 | 85 | "machine-id": "1", "constraints": self.constraints}) | 125 | "machine-id": "1", "constraints": self.constraints}) |
1424 | 86 | d.addCallback(verify_result) | 126 | d.addCallback(verify_result) |
1425 | @@ -104,7 +144,7 @@ | |||
1426 | 104 | self._mock_create_machine_group("1") | 144 | self._mock_create_machine_group("1") |
1427 | 105 | self._mock_launch_utils() | 145 | self._mock_launch_utils() |
1428 | 106 | self._mock_get_zookeeper_hosts() | 146 | self._mock_get_zookeeper_hosts() |
1430 | 107 | self._mock_launch( | 147 | self._mock_launch_groupname( |
1431 | 108 | self.get_instance("i-foobar"), | 148 | self.get_instance("i-foobar"), |
1432 | 109 | cloud_init="launch_cloud_init_branch") | 149 | cloud_init="launch_cloud_init_branch") |
1433 | 110 | self.mocker.replay() | 150 | self.mocker.replay() |
1434 | @@ -124,7 +164,7 @@ | |||
1435 | 124 | self._mock_create_machine_group("1") | 164 | self._mock_create_machine_group("1") |
1436 | 125 | self._mock_launch_utils() | 165 | self._mock_launch_utils() |
1437 | 126 | self._mock_get_zookeeper_hosts() | 166 | self._mock_get_zookeeper_hosts() |
1439 | 127 | self._mock_launch( | 167 | self._mock_launch_groupname( |
1440 | 128 | self.get_instance("i-foobar"), | 168 | self.get_instance("i-foobar"), |
1441 | 129 | cloud_init="launch_cloud_init_ppa") | 169 | cloud_init="launch_cloud_init_ppa") |
1442 | 130 | self.mocker.replay() | 170 | self.mocker.replay() |
1443 | @@ -144,7 +184,7 @@ | |||
1444 | 144 | self._mock_create_machine_group("1") | 184 | self._mock_create_machine_group("1") |
1445 | 145 | self._mock_launch_utils() | 185 | self._mock_launch_utils() |
1446 | 146 | self._mock_get_zookeeper_hosts() | 186 | self._mock_get_zookeeper_hosts() |
1448 | 147 | self._mock_launch( | 187 | self._mock_launch_groupname( |
1449 | 148 | self.get_instance("i-foobar"), | 188 | self.get_instance("i-foobar"), |
1450 | 149 | cloud_init="launch_cloud_init") | 189 | cloud_init="launch_cloud_init") |
1451 | 150 | self.mocker.replay() | 190 | self.mocker.replay() |
1452 | @@ -159,14 +199,15 @@ | |||
1453 | 159 | def test_provider_launch_existing_security_group(self): | 199 | def test_provider_launch_existing_security_group(self): |
1454 | 160 | """Verify that the launch works if the env security group exists""" | 200 | """Verify that the launch works if the env security group exists""" |
1455 | 161 | instance = Instance("i-foobar", "running", dns_name="x1.example.com") | 201 | instance = Instance("i-foobar", "running", dns_name="x1.example.com") |
1457 | 162 | security_group = SecurityGroup("juju-moon", "some description") | 202 | security_group = SecurityGroup("sg-a1a1a1a1", "juju-moon", "some description") |
1458 | 163 | 203 | ||
1459 | 164 | self.ec2.describe_security_groups() | 204 | self.ec2.describe_security_groups() |
1460 | 165 | self.mocker.result(succeed([security_group])) | 205 | self.mocker.result(succeed([security_group])) |
1461 | 206 | self.mocker.count(1) | ||
1462 | 166 | self._mock_create_machine_group("1") | 207 | self._mock_create_machine_group("1") |
1463 | 167 | self._mock_launch_utils() | 208 | self._mock_launch_utils() |
1464 | 168 | self._mock_get_zookeeper_hosts() | 209 | self._mock_get_zookeeper_hosts() |
1466 | 169 | self._mock_launch(instance) | 210 | self._mock_launch_groupname(instance) |
1467 | 170 | self.mocker.replay() | 211 | self.mocker.replay() |
1468 | 171 | 212 | ||
1469 | 172 | provider = self.get_provider() | 213 | provider = self.get_provider() |
1470 | @@ -180,15 +221,13 @@ | |||
1471 | 180 | def test_provider_launch_existing_machine_security_group(self): | 221 | def test_provider_launch_existing_machine_security_group(self): |
1472 | 181 | """Verify that the launch works if the machine security group exists""" | 222 | """Verify that the launch works if the machine security group exists""" |
1473 | 182 | instance = Instance("i-foobar", "running", dns_name="x1.example.com") | 223 | instance = Instance("i-foobar", "running", dns_name="x1.example.com") |
1477 | 183 | machine_group = SecurityGroup( | 224 | machine_group = SecurityGroup("sg-b2b2b2b2", "juju-moon-1", "some description") |
1475 | 184 | "juju-moon-1", "some description") | ||
1476 | 185 | |||
1478 | 186 | self.ec2.describe_security_groups() | 225 | self.ec2.describe_security_groups() |
1479 | 187 | self.mocker.result(succeed([machine_group])) | 226 | self.mocker.result(succeed([machine_group])) |
1480 | 188 | self._mock_create_group() | 227 | self._mock_create_group() |
1481 | 189 | self._mock_launch_utils() | 228 | self._mock_launch_utils() |
1482 | 190 | self._mock_get_zookeeper_hosts() | 229 | self._mock_get_zookeeper_hosts() |
1484 | 191 | self._mock_launch(instance) | 230 | self._mock_launch_groupname(instance) |
1485 | 192 | self.mocker.replay() | 231 | self.mocker.replay() |
1486 | 193 | 232 | ||
1487 | 194 | provider = self.get_provider() | 233 | provider = self.get_provider() |
1488 | @@ -206,15 +245,13 @@ | |||
1489 | 206 | that security group, generally because it is still shutting | 245 | that security group, generally because it is still shutting |
1490 | 207 | down.""" | 246 | down.""" |
1491 | 208 | instance = Instance("i-foobar", "running", dns_name="x1.example.com") | 247 | instance = Instance("i-foobar", "running", dns_name="x1.example.com") |
1495 | 209 | machine_group = SecurityGroup( | 248 | machine_group = SecurityGroup("sg-b2b2b2b2", "juju-moon-1", "some description") |
1493 | 210 | "juju-moon-1", "some description") | ||
1494 | 211 | |||
1496 | 212 | self.ec2.describe_security_groups() | 249 | self.ec2.describe_security_groups() |
1497 | 213 | self.mocker.result(succeed([machine_group])) | 250 | self.mocker.result(succeed([machine_group])) |
1498 | 214 | self._mock_create_group() | 251 | self._mock_create_group() |
1499 | 215 | self._mock_launch_utils() | 252 | self._mock_launch_utils() |
1500 | 216 | self._mock_get_zookeeper_hosts() | 253 | self._mock_get_zookeeper_hosts() |
1502 | 217 | self._mock_launch(instance) | 254 | self._mock_launch_groupname(instance) |
1503 | 218 | self.mocker.replay() | 255 | self.mocker.replay() |
1504 | 219 | 256 | ||
1505 | 220 | provider = self.get_provider() | 257 | provider = self.get_provider() |
1506 | @@ -266,7 +303,7 @@ | |||
1507 | 266 | get_ami_args=( | 303 | get_ami_args=( |
1508 | 267 | "splendid", "amd64", "somewhere-else-1", False, False)) | 304 | "splendid", "amd64", "somewhere-else-1", False, False)) |
1509 | 268 | self._mock_get_zookeeper_hosts() | 305 | self._mock_get_zookeeper_hosts() |
1511 | 269 | self._mock_launch(self.get_instance("i-foobar"), "ami-regional") | 306 | self._mock_launch_groupname(self.get_instance("i-foobar"), "ami-regional") |
1512 | 270 | self.mocker.replay() | 307 | self.mocker.replay() |
1513 | 271 | 308 | ||
1514 | 272 | provider = self.get_provider() | 309 | provider = self.get_provider() |
1515 | @@ -283,7 +320,7 @@ | |||
1516 | 283 | ami_name="ami-fancy-cluster", | 320 | ami_name="ami-fancy-cluster", |
1517 | 284 | get_ami_args=("vast", "amd64", "us-east-1", True, False)) | 321 | get_ami_args=("vast", "amd64", "us-east-1", True, False)) |
1518 | 285 | self._mock_get_zookeeper_hosts() | 322 | self._mock_get_zookeeper_hosts() |
1520 | 286 | self._mock_launch( | 323 | self._mock_launch_groupname( |
1521 | 287 | self.get_instance("i-foobar"), "ami-fancy-cluster", | 324 | self.get_instance("i-foobar"), "ami-fancy-cluster", |
1522 | 288 | expect_instance_type="cc2.8xlarge", | 325 | expect_instance_type="cc2.8xlarge", |
1523 | 289 | expect_availability_zone="us-east-1b") | 326 | expect_availability_zone="us-east-1b") |
1524 | @@ -302,7 +339,7 @@ | |||
1525 | 302 | self._mock_launch_utils( | 339 | self._mock_launch_utils( |
1526 | 303 | get_ami_args=("dribbly", "amd64", "us-east-1", False, False)) | 340 | get_ami_args=("dribbly", "amd64", "us-east-1", False, False)) |
1527 | 304 | self._mock_get_zookeeper_hosts() | 341 | self._mock_get_zookeeper_hosts() |
1529 | 305 | self._mock_launch( | 342 | self._mock_launch_groupname( |
1530 | 306 | self.get_instance("i-foobar"), "ami-default", | 343 | self.get_instance("i-foobar"), "ami-default", |
1531 | 307 | expect_instance_type="c1.xlarge") | 344 | expect_instance_type="c1.xlarge") |
1532 | 308 | self.mocker.replay() | 345 | self.mocker.replay() |
1533 | 309 | 346 | ||
1534 | === modified file 'juju/providers/ec2/tests/test_machine.py' | |||
1535 | --- juju/providers/ec2/tests/test_machine.py 2011-10-11 14:03:11 +0000 | |||
1536 | +++ juju/providers/ec2/tests/test_machine.py 2012-11-23 21:00:27 +0000 | |||
1537 | @@ -11,7 +11,8 @@ | |||
1538 | 11 | instance = Instance( | 11 | instance = Instance( |
1539 | 12 | "i-foobar", "oscillating", | 12 | "i-foobar", "oscillating", |
1540 | 13 | dns_name="public", | 13 | dns_name="public", |
1542 | 14 | private_dns_name="private") | 14 | private_dns_name="private", |
1543 | 15 | private_ip_address="10.0.1.10") | ||
1544 | 15 | 16 | ||
1545 | 16 | machine = machine_from_instance(instance) | 17 | machine = machine_from_instance(instance) |
1546 | 17 | self.assertTrue(isinstance(machine, EC2ProviderMachine)) | 18 | self.assertTrue(isinstance(machine, EC2ProviderMachine)) |
1547 | @@ -19,3 +20,19 @@ | |||
1548 | 19 | self.assertEquals(machine.dns_name, "public") | 20 | self.assertEquals(machine.dns_name, "public") |
1549 | 20 | self.assertEquals(machine.private_dns_name, "private") | 21 | self.assertEquals(machine.private_dns_name, "private") |
1550 | 21 | self.assertEquals(machine.state, "oscillating") | 22 | self.assertEquals(machine.state, "oscillating") |
1551 | 23 | self.assertEquals(machine.private_ip_address, "10.0.1.10") | ||
1552 | 24 | |||
1553 | 25 | def test_machine_from_instance_private_mode(self): | ||
1554 | 26 | instance = Instance( | ||
1555 | 27 | "i-foobar", "oscillating", | ||
1556 | 28 | dns_name="public", | ||
1557 | 29 | private_dns_name="private", | ||
1558 | 30 | private_ip_address="10.0.1.10") | ||
1559 | 31 | |||
1560 | 32 | machine = machine_from_instance(instance, True) | ||
1561 | 33 | self.assertTrue(isinstance(machine, EC2ProviderMachine)) | ||
1562 | 34 | self.assertEquals(machine.instance_id, "i-foobar") | ||
1563 | 35 | self.assertEquals(machine.dns_name, "10.0.1.10") | ||
1564 | 36 | self.assertEquals(machine.private_dns_name, "10.0.1.10") | ||
1565 | 37 | self.assertEquals(machine.state, "oscillating") | ||
1566 | 38 | self.assertEquals(machine.private_ip_address, "10.0.1.10") | ||
1567 | 22 | 39 | ||
1568 | === modified file 'juju/providers/ec2/tests/test_securitygroup.py' | |||
1569 | --- juju/providers/ec2/tests/test_securitygroup.py 2012-07-05 21:49:12 +0000 | |||
1570 | +++ juju/providers/ec2/tests/test_securitygroup.py 2012-11-23 21:00:27 +0000 | |||
1571 | @@ -18,9 +18,12 @@ | |||
1572 | 18 | def test_open_provider_port(self): | 18 | def test_open_provider_port(self): |
1573 | 19 | """Verify open port op will use the correct EC2 API.""" | 19 | """Verify open port op will use the correct EC2 API.""" |
1574 | 20 | log = self.capture_logging("juju.ec2", level=logging.DEBUG) | 20 | log = self.capture_logging("juju.ec2", level=logging.DEBUG) |
1575 | 21 | secgroup = SecurityGroup("sg-a1a1a1", "juju-moon-machine-1", "some description") | ||
1576 | 22 | self.ec2.describe_security_groups() | ||
1577 | 23 | self.mocker.result(succeed([secgroup])) | ||
1578 | 21 | machine = ProviderMachine("i-foobar", "x1.example.com") | 24 | machine = ProviderMachine("i-foobar", "x1.example.com") |
1579 | 22 | self.ec2.authorize_security_group( | 25 | self.ec2.authorize_security_group( |
1581 | 23 | "juju-moon-machine-1", ip_protocol="tcp", from_port="80", | 26 | group_id=secgroup.id, ip_protocol="tcp", from_port="80", |
1582 | 24 | to_port="80", cidr_ip="0.0.0.0/0") | 27 | to_port="80", cidr_ip="0.0.0.0/0") |
1583 | 25 | self.mocker.result(succeed(True)) | 28 | self.mocker.result(succeed(True)) |
1584 | 26 | self.mocker.replay() | 29 | self.mocker.replay() |
1585 | @@ -35,9 +38,12 @@ | |||
1586 | 35 | def test_close_provider_port(self): | 38 | def test_close_provider_port(self): |
1587 | 36 | """Verify close port op will use the correct EC2 API.""" | 39 | """Verify close port op will use the correct EC2 API.""" |
1588 | 37 | log = self.capture_logging("juju.ec2", level=logging.DEBUG) | 40 | log = self.capture_logging("juju.ec2", level=logging.DEBUG) |
1589 | 41 | secgroup = SecurityGroup("sg-b2b2b2", "juju-moon-machine-1", "some description") | ||
1590 | 42 | self.ec2.describe_security_groups() | ||
1591 | 43 | self.mocker.result(succeed([secgroup])) | ||
1592 | 38 | machine = ProviderMachine("i-foobar", "x1.example.com") | 44 | machine = ProviderMachine("i-foobar", "x1.example.com") |
1593 | 39 | self.ec2.revoke_security_group( | 45 | self.ec2.revoke_security_group( |
1595 | 40 | "juju-moon-machine-1", ip_protocol="tcp", from_port="80", | 46 | group_id="sg-b2b2b2", ip_protocol="tcp", from_port="80", |
1596 | 41 | to_port="80", cidr_ip="0.0.0.0/0") | 47 | to_port="80", cidr_ip="0.0.0.0/0") |
1597 | 42 | self.mocker.result(succeed(True)) | 48 | self.mocker.result(succeed(True)) |
1598 | 43 | self.mocker.replay() | 49 | self.mocker.replay() |
1599 | @@ -51,9 +57,10 @@ | |||
1600 | 51 | @inlineCallbacks | 57 | @inlineCallbacks |
1601 | 52 | def test_get_provider_opened_ports(self): | 58 | def test_get_provider_opened_ports(self): |
1602 | 53 | """Verify correct parse of IP perms from describe_security_group.""" | 59 | """Verify correct parse of IP perms from describe_security_group.""" |
1604 | 54 | self.ec2.describe_security_groups("juju-moon-machine-1") | 60 | self.ec2.describe_security_groups() |
1605 | 55 | self.mocker.result(succeed([ | 61 | self.mocker.result(succeed([ |
1606 | 56 | SecurityGroup( | 62 | SecurityGroup( |
1607 | 63 | "sg-a1b2c3d4e5f6", | ||
1608 | 57 | "juju-%s-machine-1" % self.env_name, | 64 | "juju-%s-machine-1" % self.env_name, |
1609 | 58 | "a security group name", | 65 | "a security group name", |
1610 | 59 | ips=[ | 66 | ips=[ |
1611 | @@ -76,9 +83,12 @@ | |||
1612 | 76 | @inlineCallbacks | 83 | @inlineCallbacks |
1613 | 77 | def test_open_provider_port_unknown_instance(self): | 84 | def test_open_provider_port_unknown_instance(self): |
1614 | 78 | """Verify open port op will use the correct EC2 API.""" | 85 | """Verify open port op will use the correct EC2 API.""" |
1615 | 86 | secgroup = SecurityGroup("sg-a1a1a1", "juju-moon-machine-1", "some description") | ||
1616 | 87 | self.ec2.describe_security_groups() | ||
1617 | 88 | self.mocker.result(succeed([secgroup])) | ||
1618 | 79 | machine = ProviderMachine("i-foobar", "x1.example.com") | 89 | machine = ProviderMachine("i-foobar", "x1.example.com") |
1619 | 80 | self.ec2.authorize_security_group( | 90 | self.ec2.authorize_security_group( |
1621 | 81 | "juju-moon-machine-1", ip_protocol="tcp", from_port="80", | 91 | group_id="sg-a1a1a1", ip_protocol="tcp", from_port="80", |
1622 | 82 | to_port="80", cidr_ip="0.0.0.0/0") | 92 | to_port="80", cidr_ip="0.0.0.0/0") |
1623 | 83 | self.mocker.result(fail(self.get_ec2_error("i-foobar"))) | 93 | self.mocker.result(fail(self.get_ec2_error("i-foobar"))) |
1624 | 84 | self.mocker.replay() | 94 | self.mocker.replay() |
1625 | @@ -95,9 +105,12 @@ | |||
1626 | 95 | @inlineCallbacks | 105 | @inlineCallbacks |
1627 | 96 | def test_close_provider_port_unknown_instance(self): | 106 | def test_close_provider_port_unknown_instance(self): |
1628 | 97 | """Verify open port op will use the correct EC2 API.""" | 107 | """Verify open port op will use the correct EC2 API.""" |
1629 | 108 | secgroup = SecurityGroup("sg-b2b2b2", "juju-moon-machine-1", "some description") | ||
1630 | 109 | self.ec2.describe_security_groups() | ||
1631 | 110 | self.mocker.result(succeed([secgroup])) | ||
1632 | 98 | machine = ProviderMachine("i-foobar", "x1.example.com") | 111 | machine = ProviderMachine("i-foobar", "x1.example.com") |
1633 | 99 | self.ec2.revoke_security_group( | 112 | self.ec2.revoke_security_group( |
1635 | 100 | "juju-moon-machine-1", ip_protocol="tcp", from_port="80", | 113 | group_id="sg-b2b2b2", ip_protocol="tcp", from_port="80", |
1636 | 101 | to_port="80", cidr_ip="0.0.0.0/0") | 114 | to_port="80", cidr_ip="0.0.0.0/0") |
1637 | 102 | self.mocker.result(fail(self.get_ec2_error("i-foobar"))) | 115 | self.mocker.result(fail(self.get_ec2_error("i-foobar"))) |
1638 | 103 | self.mocker.replay() | 116 | self.mocker.replay() |
1639 | @@ -114,7 +127,7 @@ | |||
1640 | 114 | @inlineCallbacks | 127 | @inlineCallbacks |
1641 | 115 | def test_get_provider_opened_ports_unknown_instance(self): | 128 | def test_get_provider_opened_ports_unknown_instance(self): |
1642 | 116 | """Verify open port op will use the correct EC2 API.""" | 129 | """Verify open port op will use the correct EC2 API.""" |
1644 | 117 | self.ec2.describe_security_groups("juju-moon-machine-1") | 130 | self.ec2.describe_security_groups() |
1645 | 118 | self.mocker.result(fail(self.get_ec2_error("i-foobar"))) | 131 | self.mocker.result(fail(self.get_ec2_error("i-foobar"))) |
1646 | 119 | self.mocker.replay() | 132 | self.mocker.replay() |
1647 | 120 | 133 | ||
1648 | @@ -134,7 +147,10 @@ | |||
1649 | 134 | @inlineCallbacks | 147 | @inlineCallbacks |
1650 | 135 | def test_destroy_environment_security_group(self): | 148 | def test_destroy_environment_security_group(self): |
1651 | 136 | """Verify the deletion of the security group for the environment""" | 149 | """Verify the deletion of the security group for the environment""" |
1653 | 137 | self.ec2.delete_security_group("juju-moon") | 150 | secgroup = SecurityGroup("sg-0e0e0e", "juju-moon", "some description") |
1654 | 151 | self.ec2.describe_security_groups() | ||
1655 | 152 | self.mocker.result(succeed([secgroup])) | ||
1656 | 153 | self.ec2.delete_security_group(id="sg-0e0e0e") | ||
1657 | 138 | self.mocker.result(succeed(True)) | 154 | self.mocker.result(succeed(True)) |
1658 | 139 | self.mocker.replay() | 155 | self.mocker.replay() |
1659 | 140 | 156 | ||
1660 | @@ -143,10 +159,12 @@ | |||
1661 | 143 | self.assertTrue(destroyed) | 159 | self.assertTrue(destroyed) |
1662 | 144 | 160 | ||
1663 | 145 | @inlineCallbacks | 161 | @inlineCallbacks |
1666 | 146 | def test_destroy_environment_security_group_missing(self): | 162 | def test_destroy_environment_security_group_ignores_failure(self): |
1665 | 147 | """Verify ignores errors in deleting the env security group""" | ||
1667 | 148 | log = self.capture_logging(level=logging.DEBUG) | 163 | log = self.capture_logging(level=logging.DEBUG) |
1669 | 149 | self.ec2.delete_security_group("juju-moon") | 164 | secgroup = SecurityGroup("sg-0e0e0e", "juju-moon", "some description") |
1670 | 165 | self.ec2.describe_security_groups() | ||
1671 | 166 | self.mocker.result(succeed([secgroup])) | ||
1672 | 167 | self.ec2.delete_security_group(id="sg-0e0e0e") | ||
1673 | 150 | self.mocker.result(fail( | 168 | self.mocker.result(fail( |
1674 | 151 | self.get_ec2_error( | 169 | self.get_ec2_error( |
1675 | 152 | "juju-moon", | 170 | "juju-moon", |
1676 | @@ -162,3 +180,14 @@ | |||
1677 | 162 | "juju-moon: Error Message: The security group " | 180 | "juju-moon: Error Message: The security group " |
1678 | 163 | "'juju-moon' does not exist", | 181 | "'juju-moon' does not exist", |
1679 | 164 | log.getvalue()) | 182 | log.getvalue()) |
1680 | 183 | |||
1681 | 184 | @inlineCallbacks | ||
1682 | 185 | def test_destroy_environment_security_group_missing(self): | ||
1683 | 186 | """Verify ignores errors in deleting the env security group""" | ||
1684 | 187 | self.ec2.describe_security_groups() | ||
1685 | 188 | self.mocker.result(succeed([])) | ||
1686 | 189 | self.mocker.replay() | ||
1687 | 190 | |||
1688 | 191 | provider = self.get_provider() | ||
1689 | 192 | destroyed = yield destroy_environment_security_group(provider) | ||
1690 | 193 | self.assertFalse(destroyed) | ||
1691 | 165 | 194 | ||
1692 | === modified file 'juju/providers/ec2/tests/test_shutdown.py' | |||
1693 | --- juju/providers/ec2/tests/test_shutdown.py 2012-07-09 22:59:18 +0000 | |||
1694 | +++ juju/providers/ec2/tests/test_shutdown.py 2012-11-23 21:00:27 +0000 | |||
1695 | @@ -2,12 +2,13 @@ | |||
1696 | 2 | 2 | ||
1697 | 3 | from juju.lib.testing import TestCase | 3 | from juju.lib.testing import TestCase |
1698 | 4 | from juju.providers.ec2.tests.common import ( | 4 | from juju.providers.ec2.tests.common import ( |
1700 | 5 | EC2TestMixin, MATCH_GROUP, Observed, MockInstanceState) | 5 | EC2TestMixin, MATCH_GROUP, MockInstanceState) |
1701 | 6 | 6 | ||
1702 | 7 | from juju.machine import ProviderMachine | 7 | from juju.machine import ProviderMachine |
1703 | 8 | 8 | ||
1704 | 9 | from juju.errors import MachinesNotFound, ProviderError | 9 | from juju.errors import MachinesNotFound, ProviderError |
1705 | 10 | from juju.providers.ec2.machine import EC2ProviderMachine | 10 | from juju.providers.ec2.machine import EC2ProviderMachine |
1706 | 11 | from txaws.ec2.model import SecurityGroup | ||
1707 | 11 | 12 | ||
1708 | 12 | 13 | ||
1709 | 13 | class SomeError(Exception): | 14 | class SomeError(Exception): |
1710 | @@ -156,10 +157,11 @@ | |||
1711 | 156 | ("i-canbekilled", "running", "shutting-down"), | 157 | ("i-canbekilled", "running", "shutting-down"), |
1712 | 157 | ("i-canbekilledtoo", "pending", "shutting-down")])) | 158 | ("i-canbekilledtoo", "pending", "shutting-down")])) |
1713 | 158 | 159 | ||
1718 | 159 | self.ec2.delete_security_group(MATCH_GROUP) | 160 | secgroup = SecurityGroup("sg-0a0a0a", "juju-moon", "some description") |
1719 | 160 | deleted_groups = Observed() | 161 | self.ec2.describe_security_groups() |
1720 | 161 | self.mocker.call(deleted_groups.add) | 162 | self.mocker.result(succeed([secgroup])) |
1721 | 162 | self.mocker.count(1) | 163 | self.ec2.delete_security_group(id="sg-0a0a0a") |
1722 | 164 | self.mocker.result(succeed(True)) | ||
1723 | 163 | 165 | ||
1724 | 164 | self.mocker.replay() | 166 | self.mocker.replay() |
1725 | 165 | 167 | ||
1726 | @@ -169,9 +171,6 @@ | |||
1727 | 169 | self.assertEquals(machine_1.instance_id, "i-canbekilled") | 171 | self.assertEquals(machine_1.instance_id, "i-canbekilled") |
1728 | 170 | self.assertTrue(isinstance(machine_2, EC2ProviderMachine)) | 172 | self.assertTrue(isinstance(machine_2, EC2ProviderMachine)) |
1729 | 171 | self.assertEquals(machine_2.instance_id, "i-canbekilledtoo") | 173 | self.assertEquals(machine_2.instance_id, "i-canbekilledtoo") |
1730 | 172 | self.assertEquals( | ||
1731 | 173 | deleted_groups.items, | ||
1732 | 174 | set(["juju-moon"])) | ||
1733 | 175 | 174 | ||
1734 | 176 | @inlineCallbacks | 175 | @inlineCallbacks |
1735 | 177 | def test_s3_failure(self): | 176 | def test_s3_failure(self): |
1736 | @@ -189,7 +188,10 @@ | |||
1737 | 189 | self.ec2.terminate_instances("i-canbekilled") | 188 | self.ec2.terminate_instances("i-canbekilled") |
1738 | 190 | self.mocker.result(succeed([ | 189 | self.mocker.result(succeed([ |
1739 | 191 | ("i-canbekilled", "running", "shutting-down")])) | 190 | ("i-canbekilled", "running", "shutting-down")])) |
1741 | 192 | self.ec2.delete_security_group("juju-moon") | 191 | secgroup = SecurityGroup("sg-0a0a0a", "juju-moon", "some description") |
1742 | 192 | self.ec2.describe_security_groups() | ||
1743 | 193 | self.mocker.result(succeed([secgroup])) | ||
1744 | 194 | self.ec2.delete_security_group(id="sg-0a0a0a") | ||
1745 | 193 | self.mocker.result(succeed(True)) | 195 | self.mocker.result(succeed(True)) |
1746 | 194 | self.mocker.replay() | 196 | self.mocker.replay() |
1747 | 195 | 197 | ||
1748 | @@ -208,7 +210,10 @@ | |||
1749 | 208 | self.mocker.result(succeed(None)) | 210 | self.mocker.result(succeed(None)) |
1750 | 209 | self.ec2.describe_instances() | 211 | self.ec2.describe_instances() |
1751 | 210 | self.mocker.result(succeed([])) | 212 | self.mocker.result(succeed([])) |
1753 | 211 | self.ec2.delete_security_group("juju-moon") | 213 | secgroup = SecurityGroup("sg-0a0a0a", "juju-moon", "some description") |
1754 | 214 | self.ec2.describe_security_groups() | ||
1755 | 215 | self.mocker.result(succeed([secgroup])) | ||
1756 | 216 | self.ec2.delete_security_group(id="sg-0a0a0a") | ||
1757 | 212 | self.mocker.result(fail( | 217 | self.mocker.result(fail( |
1758 | 213 | self.get_ec2_error( | 218 | self.get_ec2_error( |
1759 | 214 | "juju-moon", | 219 | "juju-moon", |
1760 | 215 | 220 | ||
1761 | === modified file 'juju/providers/ec2/utils.py' | |||
1762 | --- juju/providers/ec2/utils.py 2012-07-05 21:49:12 +0000 | |||
1763 | +++ juju/providers/ec2/utils.py 2012-11-23 21:00:27 +0000 | |||
1764 | @@ -6,10 +6,10 @@ | |||
1765 | 6 | import StringIO | 6 | import StringIO |
1766 | 7 | 7 | ||
1767 | 8 | from twisted.internet.defer import inlineCallbacks, returnValue | 8 | from twisted.internet.defer import inlineCallbacks, returnValue |
1768 | 9 | from twisted.web.client import getPage | ||
1769 | 10 | from twisted.web.error import Error | 9 | from twisted.web.error import Error |
1770 | 11 | 10 | ||
1771 | 12 | from juju.errors import ProviderError | 11 | from juju.errors import ProviderError |
1772 | 12 | from juju.lib.http_client import get_page | ||
1773 | 13 | 13 | ||
1774 | 14 | # We don't actually know what's available in any given region | 14 | # We don't actually know what's available in any given region |
1775 | 15 | _PLAUSIBLE_ZONES = ascii_lowercase | 15 | _PLAUSIBLE_ZONES = ascii_lowercase |
1776 | @@ -102,7 +102,7 @@ | |||
1777 | 102 | contextFactory = VerifyingContextFactory(_CURRENT_IMAGE_HOST) | 102 | contextFactory = VerifyingContextFactory(_CURRENT_IMAGE_HOST) |
1778 | 103 | else: | 103 | else: |
1779 | 104 | contextFactory = None | 104 | contextFactory = None |
1781 | 105 | d = getPage(uri, contextFactory=contextFactory) | 105 | d = get_page(uri, contextFactory=contextFactory) |
1782 | 106 | d.addErrback(handle_404) | 106 | d.addErrback(handle_404) |
1783 | 107 | d.addCallback(extract_ami) | 107 | d.addCallback(extract_ami) |
1784 | 108 | return d | 108 | return d |
1785 | 109 | 109 | ||
1786 | === modified file 'juju/providers/local/files.py' | |||
1787 | --- juju/providers/local/files.py 2012-09-28 06:13:47 +0000 | |||
1788 | +++ juju/providers/local/files.py 2012-11-23 21:00:27 +0000 | |||
1789 | @@ -3,10 +3,10 @@ | |||
1790 | 3 | 3 | ||
1791 | 4 | from twisted.internet.defer import inlineCallbacks, returnValue | 4 | from twisted.internet.defer import inlineCallbacks, returnValue |
1792 | 5 | from twisted.internet.error import ConnectionRefusedError | 5 | from twisted.internet.error import ConnectionRefusedError |
1793 | 6 | from twisted.web.client import getPage | ||
1794 | 7 | 6 | ||
1795 | 8 | from juju.errors import ProviderError, FileNotFound | 7 | from juju.errors import ProviderError, FileNotFound |
1796 | 9 | from juju.lib import serializer | 8 | from juju.lib import serializer |
1797 | 9 | from juju.lib.http_client import get_page | ||
1798 | 10 | from juju.lib.service import TwistedDaemonService | 10 | from juju.lib.service import TwistedDaemonService |
1799 | 11 | from juju.providers.common.files import FileStorage | 11 | from juju.providers.common.files import FileStorage |
1800 | 12 | 12 | ||
1801 | @@ -55,7 +55,7 @@ | |||
1802 | 55 | def is_serving(self): | 55 | def is_serving(self): |
1803 | 56 | try: | 56 | try: |
1804 | 57 | storage = LocalStorage(self._storage_dir) | 57 | storage = LocalStorage(self._storage_dir) |
1806 | 58 | yield getPage((yield storage.get_url(SERVER_URL_KEY))) | 58 | yield get_page((yield storage.get_url(SERVER_URL_KEY))) |
1807 | 59 | returnValue(True) | 59 | returnValue(True) |
1808 | 60 | except ConnectionRefusedError: | 60 | except ConnectionRefusedError: |
1809 | 61 | returnValue(False) | 61 | returnValue(False) |
1810 | 62 | 62 | ||
1811 | === modified file 'juju/providers/orchestra/files.py' | |||
1812 | --- juju/providers/orchestra/files.py 2011-10-17 07:43:09 +0000 | |||
1813 | +++ juju/providers/orchestra/files.py 2012-11-23 21:00:27 +0000 | |||
1814 | @@ -2,10 +2,10 @@ | |||
1815 | 2 | import urllib | 2 | import urllib |
1816 | 3 | import urlparse | 3 | import urlparse |
1817 | 4 | 4 | ||
1818 | 5 | from twisted.web.client import getPage | ||
1819 | 6 | from twisted.web.error import Error | 5 | from twisted.web.error import Error |
1820 | 7 | 6 | ||
1821 | 8 | from juju.errors import FileNotFound, ProviderError | 7 | from juju.errors import FileNotFound, ProviderError |
1822 | 8 | from juju.lib.http_client import get_page | ||
1823 | 9 | from juju.providers.common.utils import convert_unknown_error | 9 | from juju.providers.common.utils import convert_unknown_error |
1824 | 10 | from juju.providers.orchestra.digestauth import ( | 10 | from juju.providers.orchestra.digestauth import ( |
1825 | 11 | DigestAuthenticator, get_page_auth) | 11 | DigestAuthenticator, get_page_auth) |
1826 | @@ -60,7 +60,7 @@ | |||
1827 | 60 | :raises: :exc:`juju.errors.FileNotFound` if the file doesn't exist | 60 | :raises: :exc:`juju.errors.FileNotFound` if the file doesn't exist |
1828 | 61 | """ | 61 | """ |
1829 | 62 | url = self.get_url(name) | 62 | url = self.get_url(name) |
1831 | 63 | d = getPage(url) | 63 | d = get_page(url) |
1832 | 64 | d.addCallback(StringIO) | 64 | d.addCallback(StringIO) |
1833 | 65 | d.addErrback(_convert_error, "GET", url, {404: FileNotFound(url)}) | 65 | d.addErrback(_convert_error, "GET", url, {404: FileNotFound(url)}) |
1834 | 66 | return d | 66 | return d |
1835 | 67 | 67 | ||
1836 | === modified file 'juju/providers/orchestra/tests/data/bootstrap_user_data' | |||
1837 | --- juju/providers/orchestra/tests/data/bootstrap_user_data 2012-08-23 16:14:42 +0000 | |||
1838 | +++ juju/providers/orchestra/tests/data/bootstrap_user_data 2012-11-23 21:00:27 +0000 | |||
1839 | @@ -3,8 +3,8 @@ | |||
1840 | 3 | machine-data: {juju-provider-type: orchestra, juju-zookeeper-hosts: 'localhost:2181', | 3 | machine-data: {juju-provider-type: orchestra, juju-zookeeper-hosts: 'localhost:2181', |
1841 | 4 | machine-id: '0'} | 4 | machine-id: '0'} |
1842 | 5 | output: {all: '| tee -a /var/log/cloud-init-output.log'} | 5 | output: {all: '| tee -a /var/log/cloud-init-output.log'} |
1845 | 6 | packages: [bzr, byobu, tmux, python-setuptools, python-twisted, python-txaws, python-zookeeper, | 6 | packages: [bzr, byobu, tmux, python-setuptools, python-twisted, python-zookeeper, |
1846 | 7 | default-jre-headless, zookeeper, zookeeperd, juju] | 7 | default-jre-headless, zookeeper, zookeeperd, juju, python-txaws] |
1847 | 8 | runcmd: [sudo mkdir -p /var/lib/juju, sudo mkdir -p /var/log/juju, 'juju-admin initialize | 8 | runcmd: [sudo mkdir -p /var/lib/juju, sudo mkdir -p /var/log/juju, 'juju-admin initialize |
1848 | 9 | --instance-id=winston-uid --admin-identity=admin:qRBXC1ubEEUqRL6wcBhgmc9xkaY= | 9 | --instance-id=winston-uid --admin-identity=admin:qRBXC1ubEEUqRL6wcBhgmc9xkaY= |
1849 | 10 | --constraints-data=e29yY2hlc3RyYS1jbGFzc2VzOiAnZm9vLGJhcicsIHByb3ZpZGVyLXR5cGU6IG9yY2hlc3RyYSwgdWJ1bnR1LXNlcmllczogYml6YXJyZX0K | 10 | --constraints-data=e29yY2hlc3RyYS1jbGFzc2VzOiAnZm9vLGJhcicsIHByb3ZpZGVyLXR5cGU6IG9yY2hlc3RyYSwgdWJ1bnR1LXNlcmllczogYml6YXJyZX0K |
1850 | 11 | 11 | ||
1851 | === modified file 'juju/providers/orchestra/tests/data/launch_user_data' | |||
1852 | --- juju/providers/orchestra/tests/data/launch_user_data 2012-08-23 16:14:42 +0000 | |||
1853 | +++ juju/providers/orchestra/tests/data/launch_user_data 2012-11-23 21:00:27 +0000 | |||
1854 | @@ -3,7 +3,7 @@ | |||
1855 | 3 | machine-data: {juju-provider-type: orchestra, juju-zookeeper-hosts: 'jennifer:2181', | 3 | machine-data: {juju-provider-type: orchestra, juju-zookeeper-hosts: 'jennifer:2181', |
1856 | 4 | machine-id: '42'} | 4 | machine-id: '42'} |
1857 | 5 | output: {all: '| tee -a /var/log/cloud-init-output.log'} | 5 | output: {all: '| tee -a /var/log/cloud-init-output.log'} |
1859 | 6 | packages: [bzr, byobu, tmux, python-setuptools, python-twisted, python-txaws, python-zookeeper, juju] | 6 | packages: [bzr, byobu, tmux, python-setuptools, python-twisted, python-zookeeper, juju, python-txaws] |
1860 | 7 | runcmd: [sudo mkdir -p /var/lib/juju, sudo mkdir -p | 7 | runcmd: [sudo mkdir -p /var/lib/juju, sudo mkdir -p |
1861 | 8 | /var/log/juju, 'cat >> /etc/init/juju-machine-agent.conf <<EOF | 8 | /var/log/juju, 'cat >> /etc/init/juju-machine-agent.conf <<EOF |
1862 | 9 | 9 | ||
1863 | 10 | 10 | ||
1864 | === modified file 'juju/unit/address.py' | |||
1865 | --- juju/unit/address.py 2012-10-05 17:49:27 +0000 | |||
1866 | +++ juju/unit/address.py 2012-11-23 21:00:27 +0000 | |||
1867 | @@ -1,5 +1,6 @@ | |||
1868 | 1 | """Service units have both a public and private address. | 1 | """Service units have both a public and private address. |
1869 | 2 | """ | 2 | """ |
1870 | 3 | import os | ||
1871 | 3 | import subprocess | 4 | import subprocess |
1872 | 4 | 5 | ||
1873 | 5 | from twisted.internet.defer import inlineCallbacks, returnValue, succeed | 6 | from twisted.internet.defer import inlineCallbacks, returnValue, succeed |
1874 | @@ -15,7 +16,9 @@ | |||
1875 | 15 | settings = GlobalSettingsStateManager(client) | 16 | settings = GlobalSettingsStateManager(client) |
1876 | 16 | provider_type = yield settings.get_provider_type() | 17 | provider_type = yield settings.get_provider_type() |
1877 | 17 | if provider_type == "ec2": | 18 | if provider_type == "ec2": |
1879 | 18 | returnValue(EC2UnitAddress()) | 19 | address = EC2UnitAddress() |
1880 | 20 | address.private = os.environ.get("JUJU_PRIVATE") is not None | ||
1881 | 21 | returnValue(address) | ||
1882 | 19 | if provider_type in ("openstack", "openstack_s3"): | 22 | if provider_type in ("openstack", "openstack_s3"): |
1883 | 20 | returnValue(OpenStackUnitAddress()) | 23 | returnValue(OpenStackUnitAddress()) |
1884 | 21 | elif provider_type == "local": | 24 | elif provider_type == "local": |
1885 | @@ -50,6 +53,10 @@ | |||
1886 | 50 | 53 | ||
1887 | 51 | class EC2UnitAddress(UnitAddress): | 54 | class EC2UnitAddress(UnitAddress): |
1888 | 52 | 55 | ||
1889 | 56 | def __init__(self, *args, **kwargs): | ||
1890 | 57 | super(EC2UnitAddress, self).__init__(*args, **kwargs) | ||
1891 | 58 | self.private = False | ||
1892 | 59 | |||
1893 | 53 | @inlineCallbacks | 60 | @inlineCallbacks |
1894 | 54 | def get_private_address(self): | 61 | def get_private_address(self): |
1895 | 55 | content = yield client.getPage( | 62 | content = yield client.getPage( |
1896 | @@ -58,8 +65,12 @@ | |||
1897 | 58 | 65 | ||
1898 | 59 | @inlineCallbacks | 66 | @inlineCallbacks |
1899 | 60 | def get_public_address(self): | 67 | def get_public_address(self): |
1900 | 68 | if self.private: | ||
1901 | 69 | field = "local-ipv4" | ||
1902 | 70 | else: | ||
1903 | 71 | field = "public-hostname" | ||
1904 | 61 | content = yield client.getPage( | 72 | content = yield client.getPage( |
1906 | 62 | "http://169.254.169.254/latest/meta-data/public-hostname") | 73 | "http://169.254.169.254/latest/meta-data/%s" % field) |
1907 | 63 | returnValue(content.strip()) | 74 | returnValue(content.strip()) |
1908 | 64 | 75 | ||
1909 | 65 | 76 | ||
1910 | 66 | 77 | ||
1911 | === modified file 'juju/unit/charm.py' | |||
1912 | --- juju/unit/charm.py 2012-03-21 12:54:28 +0000 | |||
1913 | +++ juju/unit/charm.py 2012-11-23 21:00:27 +0000 | |||
1914 | @@ -3,12 +3,12 @@ | |||
1915 | 3 | import shutil | 3 | import shutil |
1916 | 4 | 4 | ||
1917 | 5 | from twisted.internet.defer import inlineCallbacks, returnValue | 5 | from twisted.internet.defer import inlineCallbacks, returnValue |
1918 | 6 | from twisted.web.client import downloadPage | ||
1919 | 7 | from twisted.web.error import Error | 6 | from twisted.web.error import Error |
1920 | 8 | 7 | ||
1921 | 9 | from juju.errors import FileNotFound | 8 | from juju.errors import FileNotFound |
1922 | 10 | from juju.charm.bundle import CharmBundle | 9 | from juju.charm.bundle import CharmBundle |
1923 | 11 | from juju.lib import under | 10 | from juju.lib import under |
1924 | 11 | from juju.lib.http_client import download_page | ||
1925 | 12 | from juju.state.charm import CharmStateManager | 12 | from juju.state.charm import CharmStateManager |
1926 | 13 | 13 | ||
1927 | 14 | 14 | ||
1928 | @@ -33,7 +33,7 @@ | |||
1929 | 33 | shutil.copyfileobj(open(file_path), open(local_charm_path, "w")) | 33 | shutil.copyfileobj(open(file_path), open(local_charm_path, "w")) |
1930 | 34 | else: | 34 | else: |
1931 | 35 | try: | 35 | try: |
1933 | 36 | yield downloadPage(charm_state.bundle_url, local_charm_path) | 36 | yield download_page(charm_state.bundle_url, local_charm_path) |
1934 | 37 | except Error: | 37 | except Error: |
1935 | 38 | raise FileNotFound(charm_state.bundle_url) | 38 | raise FileNotFound(charm_state.bundle_url) |
1936 | 39 | 39 | ||
1937 | 40 | 40 | ||
1938 | === modified file 'juju/unit/deploy.py' | |||
1939 | --- juju/unit/deploy.py 2012-04-04 20:21:44 +0000 | |||
1940 | +++ juju/unit/deploy.py 2012-11-23 21:00:27 +0000 | |||
1941 | @@ -80,6 +80,11 @@ | |||
1942 | 80 | deployment = self.deploy_factory( | 80 | deployment = self.deploy_factory( |
1943 | 81 | service_unit_name, self.juju_directory) | 81 | service_unit_name, self.juju_directory) |
1944 | 82 | 82 | ||
1945 | 83 | for env in ("http_proxy", "https_proxy", "JUJU_PRIVATE"): | ||
1946 | 84 | value = os.environ.get(env) | ||
1947 | 85 | if value: | ||
1948 | 86 | deployment.set_env(env, value) | ||
1949 | 87 | |||
1950 | 83 | log.debug("Using %r for %s in %s", | 88 | log.debug("Using %r for %s in %s", |
1951 | 84 | deployment, | 89 | deployment, |
1952 | 85 | service_unit_name, | 90 | service_unit_name, |
1953 | 86 | 91 | ||
1954 | === modified file 'juju/unit/tests/test_address.py' | |||
1955 | --- juju/unit/tests/test_address.py 2012-10-05 17:49:27 +0000 | |||
1956 | +++ juju/unit/tests/test_address.py 2012-11-23 21:00:27 +0000 | |||
1957 | @@ -1,3 +1,4 @@ | |||
1958 | 1 | import os | ||
1959 | 1 | import subprocess | 2 | import subprocess |
1960 | 2 | import zookeeper | 3 | import zookeeper |
1961 | 3 | 4 | ||
1962 | @@ -30,6 +31,14 @@ | |||
1963 | 30 | def test_get_ec2_address(self): | 31 | def test_get_ec2_address(self): |
1964 | 31 | address = yield self.get_address_for("ec2") | 32 | address = yield self.get_address_for("ec2") |
1965 | 32 | self.assertTrue(isinstance(address, EC2UnitAddress)) | 33 | self.assertTrue(isinstance(address, EC2UnitAddress)) |
1966 | 34 | self.assertFalse(address.private) | ||
1967 | 35 | |||
1968 | 36 | @inlineCallbacks | ||
1969 | 37 | def test_get_ec2_address_private_mode(self): | ||
1970 | 38 | os.environ.setdefault("JUJU_PRIVATE", "private") | ||
1971 | 39 | address = yield self.get_address_for("ec2") | ||
1972 | 40 | self.assertTrue(address.private) | ||
1973 | 41 | del os.environ["JUJU_PRIVATE"] | ||
1974 | 33 | 42 | ||
1975 | 34 | @inlineCallbacks | 43 | @inlineCallbacks |
1976 | 35 | def test_get_openstack_address(self): | 44 | def test_get_openstack_address(self): |
1977 | @@ -118,6 +127,23 @@ | |||
1978 | 118 | self.assertEqual( | 127 | self.assertEqual( |
1979 | 119 | (yield self.address.get_public_address()), "foobar") | 128 | (yield self.address.get_public_address()), "foobar") |
1980 | 120 | 129 | ||
1981 | 130 | @inlineCallbacks | ||
1982 | 131 | def test_get_address_private_mode(self): | ||
1983 | 132 | urls = [ | ||
1984 | 133 | "http://169.254.169.254/latest/meta-data/local-hostname", | ||
1985 | 134 | "http://169.254.169.254/latest/meta-data/local-ipv4"] | ||
1986 | 135 | |||
1987 | 136 | def verify_args(url): | ||
1988 | 137 | self.assertEqual(urls.pop(0), url) | ||
1989 | 138 | return succeed("foobar\n") | ||
1990 | 139 | |||
1991 | 140 | self.address.private = True | ||
1992 | 141 | self.patch(client, "getPage", verify_args) | ||
1993 | 142 | self.assertEqual( | ||
1994 | 143 | (yield self.address.get_private_address()), "foobar") | ||
1995 | 144 | self.assertEqual( | ||
1996 | 145 | (yield self.address.get_public_address()), "foobar") | ||
1997 | 146 | self.address.private = False | ||
1998 | 121 | 147 | ||
1999 | 122 | class OpenStackAddressTest(TestCase): | 148 | class OpenStackAddressTest(TestCase): |
2000 | 123 | 149 |
Reviewers: mp+134169_ code.launchpad. net,
Message:
Please take a look.
Description:
providers/ec2: support VPC
To use VPC, all the user need to do is add two new environment settings:
vpc_id
and subnet_id.
This CL depends on three other CLs (related to txaws):
- https:/ /codereview. appspot. com/6826065/ /codereview. appspot. com/6822097/ /codereview. appspot. com/6814123/
- https:/
- https:/
https:/ /code.launchpad .net/~francisco souza/juju/ juju-vpc/ +merge/ 134169
(do not edit description out of merge proposal)
Please review this at https:/ /codereview. appspot. com/6850044/
Affected files: ec2/launch. py ec2/securitygro up.py ec2/tests/ common. py ec2/tests/ test_bootstrap. py ec2/tests/ test_launch. py ec2/tests/ test_securitygr oup.py ec2/tests/ test_shutdown. py
A [revision details]
M juju/providers/
M juju/providers/
M juju/providers/
M juju/providers/
M juju/providers/
M juju/providers/
M juju/providers/