Merge lp:~frankban/juju-quickstart/joyent into lp:juju-quickstart

Proposed by Francesco Banconi
Status: Merged
Merged at revision: 64
Proposed branch: lp:~frankban/juju-quickstart/joyent
Merge into: lp:juju-quickstart
Diff against target: 210 lines (+129/-1)
4 files modified
quickstart/models/envs.py (+60/-1)
quickstart/models/fields.py (+19/-0)
quickstart/tests/models/test_envs.py (+16/-0)
quickstart/tests/models/test_fields.py (+34/-0)
To merge this branch: bzr merge lp:~frankban/juju-quickstart/joyent
Reviewer Review Type Date Requested Status
Juju GUI Hackers Pending
Review via email: mp+214022@code.launchpad.net

Description of the change

Add support for the Joyent provider.

Tests: `make check`.

QA:
QA is not straightforward for this branch, due to the
fact this needs to be tested on a not yet released
juju-core. Sorry about that.
1) Check out the 1.18 juju-core branch (lp:juju-core/1.18),
   and compile it.
2) Edit the quickstart/settings.py file included in this branch:
   set `JUJU_CMD` to point to the juju 1.18 path.
3) Sign up for a Joyent account from http://www.joyent.com/.
4) Run `.venv/bin/python juju-quickstart -i` and create a new
   joyent environment: DO NOT bootstrap it from quickstart, just
   create it and exit (^X).
5) Use juju 1.18 to bootstrap the joyent account, e.g.
   `juju bootstrap -e joyent --upload-tools`. This is required
   because quickstart does not support uploading tools.
6) After a minute, and while the environment is bootstrapping,
   open another terminal and re-run quickstart, select the
   joyent account you created and hit "use"
   (or just invoke quickstart with `-e joyent`).
7) Ensure everything proceeds as expected, and wait
   until the quickstart opens the GUI.
Done, destroy the environment, thank you!

https://codereview.appspot.com/83880044/

To post a comment you must log in.
Revision history for this message
Francesco Banconi (frankban) wrote :

Reviewers: mp+214022_code.launchpad.net,

Message:
Please take a look.

Description:
Add support for the Joyent provider.

Tests: `make check`.

QA:
QA is not straightforward for this branch, due to the
fact this needs to be tested on a not yet released
juju-core. Sorry about that.
1) Check out the 1.18 juju-core branch (lp:juju-core/1.18),
    and compile it.
2) Edit the quickstart/settings.py file included in this branch:
    set `JUJU_CMD` to point to the juju 1.18 path.
3) Sign up for a Joyent account from http://www.joyent.com/.
4) Run `.venv/bin/python juju-quickstart -i` and create a new
    joyent environment: DO NOT bootstrap it from quickstart, just
    create it and exit (^X).
5) Use juju 1.18 to bootstrap the joyent account, e.g.
    `juju bootstrap -e joyent --upload-tools`. This is required
    because quickstart does not support uploading tools.
6) After a minute, and while the environment is bootstrapping,
    open another terminal and re-run quickstart, select the
    joyent account you created and hit "use"
    (or just invoke quickstart with `-e joyent`).
7) Ensure everything proceeds as expected, and wait
    until the quickstart opens the GUI.
Done, destroy the environment, thank you!

https://code.launchpad.net/~frankban/juju-quickstart/joyent/+merge/214022

(do not edit description out of merge proposal)

Please review this at https://codereview.appspot.com/83880044/

Affected files (+117, -4 lines):
   A [revision details]
   M quickstart/models/envs.py
   M quickstart/models/fields.py
   M quickstart/tests/models/test_envs.py
   M quickstart/tests/models/test_fields.py

Revision history for this message
Brad Crittenden (bac) wrote :

Code LGTM. On to QA.

https://codereview.appspot.com/83880044/diff/1/quickstart/tests/models/test_fields.py
File quickstart/tests/models/test_fields.py (right):

https://codereview.appspot.com/83880044/diff/1/quickstart/tests/models/test_fields.py#newcode468
quickstart/tests/models/test_fields.py:468:
field.validate(unicode(__file__))
Nice use of __file__. Nicer then creating a temp file and destroying
it.

https://codereview.appspot.com/83880044/

Revision history for this message
Brad Crittenden (bac) wrote :

When doing QA and bootstrapping the joyent environment I get

http://paste.ubuntu.com/7199671/

https://codereview.appspot.com/83880044/diff/1/quickstart/models/envs.py
File quickstart/models/envs.py (right):

https://codereview.appspot.com/83880044/diff/1/quickstart/models/envs.py#newcode621
quickstart/models/envs.py:621: 'manta-user', required=True,
I'm running quickstart for the first time to set up joyent. I don't
know what the manta username and ssh keys are. Are they the same as my
SDC ones? I only have one Joyent username and ssh key.

Kind of confusing.

https://codereview.appspot.com/83880044/diff/1/quickstart/models/envs.py#newcode634
quickstart/models/envs.py:634: 'private-key-path', label='provate key
path', required=False,
typo: provate

https://codereview.appspot.com/83880044/

lp:~frankban/juju-quickstart/joyent updated
67. By Francesco Banconi

Fix typo.

Revision history for this message
Brad Crittenden (bac) wrote :

For the private key file path, the default is listed as ~/.ssh/id_rsa

If you try to enter '~/.ssh/id_rsa_joyent', quickstart does not properly
expand the path and gives an error. Using
'/home/bac/.ssh/id_rsa_joyent' was accepted.

https://codereview.appspot.com/83880044/

Revision history for this message
Brad Crittenden (bac) wrote :

QA-OK after lots of struggles, mainly the issue with
passphrase-protected ssh key, which is not quickstart's problem.

Though if juju doesn't screen for it perhaps we should?

https://codereview.appspot.com/83880044/

Revision history for this message
Francesco Banconi (frankban) wrote :

On 2014/04/03 20:06:11, bac wrote:
> For the private key file path, the default is listed as ~/.ssh/id_rsa

> If you try to enter '~/.ssh/id_rsa_joyent', quickstart does not
properly expand
> the path and gives an error. Using '/home/bac/.ssh/id_rsa_joyent' was
accepted.

Good catch. Fixed the FilePathField validation to use expanduser.

https://codereview.appspot.com/83880044/

Revision history for this message
Francesco Banconi (frankban) wrote :

On 2014/04/03 20:22:37, bac wrote:
> QA-OK after lots of struggles, mainly the issue with
passphrase-protected ssh
> key, which is not quickstart's problem.

> Though if juju doesn't screen for it perhaps we should?

Thanks a lot Brad, and sorry again for the difficult QA.
As you mentioned, this is something that must be handled by juju-core,
so, given this will land later, I'd be inclined to wait for the core
fix.

https://codereview.appspot.com/83880044/

lp:~frankban/juju-quickstart/joyent updated
68. By Francesco Banconi

Changes as per review.

Revision history for this message
Francesco Banconi (frankban) wrote :

Please take a look.

https://codereview.appspot.com/83880044/diff/1/quickstart/models/envs.py
File quickstart/models/envs.py (right):

https://codereview.appspot.com/83880044/diff/1/quickstart/models/envs.py#newcode621
quickstart/models/envs.py:621: 'manta-user', required=True,
On 2014/04/03 17:23:50, bac wrote:
> I'm running quickstart for the first time to set up joyent. I don't
know what
> the manta username and ssh keys are. Are they the same as my SDC
ones? I only
> have one Joyent username and ssh key.

> Kind of confusing.

Good point Brad, updated the fields description.

https://codereview.appspot.com/83880044/diff/1/quickstart/models/envs.py#newcode634
quickstart/models/envs.py:634: 'private-key-path', label='provate key
path', required=False,
On 2014/04/03 17:23:50, bac wrote:
> typo: provate

Done.

https://codereview.appspot.com/83880044/

Revision history for this message
Brad Crittenden (bac) wrote :
lp:~frankban/juju-quickstart/joyent updated
69. By Francesco Banconi

Merged trunk.

Revision history for this message
Francesco Banconi (frankban) wrote :

*** Submitted:

Add support for the Joyent provider.

Tests: `make check`.

QA:
QA is not straightforward for this branch, due to the
fact this needs to be tested on a not yet released
juju-core. Sorry about that.
1) Check out the 1.18 juju-core branch (lp:juju-core/1.18),
    and compile it.
2) Edit the quickstart/settings.py file included in this branch:
    set `JUJU_CMD` to point to the juju 1.18 path.
3) Sign up for a Joyent account from http://www.joyent.com/.
4) Run `.venv/bin/python juju-quickstart -i` and create a new
    joyent environment: DO NOT bootstrap it from quickstart, just
    create it and exit (^X).
5) Use juju 1.18 to bootstrap the joyent account, e.g.
    `juju bootstrap -e joyent --upload-tools`. This is required
    because quickstart does not support uploading tools.
6) After a minute, and while the environment is bootstrapping,
    open another terminal and re-run quickstart, select the
    joyent account you created and hit "use"
    (or just invoke quickstart with `-e joyent`).
7) Ensure everything proceeds as expected, and wait
    until the quickstart opens the GUI.
Done, destroy the environment, thank you!

R=bac
CC=
https://codereview.appspot.com/83880044

https://codereview.appspot.com/83880044/

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'quickstart/models/envs.py'
--- quickstart/models/envs.py 2014-04-04 14:03:16 +0000
+++ quickstart/models/envs.py 2014-04-10 09:23:37 +0000
@@ -418,6 +418,13 @@
418 azure_locations = (418 azure_locations = (
419 'East US', 'West US', 'West Europe', 'North Europe',419 'East US', 'West US', 'West Europe', 'North Europe',
420 'Southeast Asia', 'East Asia')420 'Southeast Asia', 'East Asia')
421 # The first URL is used as the default one.
422 joyent_sdc_urls = (
423 'https://us-west-1.api.joyentcloud.com',
424 'https://us-east-1.api.joyentcloud.com',
425 'https://us-sw-1.api.joyentcloud.com',
426 'https://us-ams-1.api.joyentcloud.com',
427 )
421 # Define the env_type_db dictionary: this is done inside this function in428 # Define the env_type_db dictionary: this is done inside this function in
422 # order to avoid instantiating fields at import time.429 # order to avoid instantiating fields at import time.
423 # This is an ordered dict so that views can expose options to create new430 # This is an ordered dict so that views can expose options to create new
@@ -566,7 +573,7 @@
566 label='management subscription ID',573 label='management subscription ID',
567 help='this information can be retrieved from '574 help='this information can be retrieved from '
568 'https://manage.windowsazure.com (Settings)'),575 'https://manage.windowsazure.com (Settings)'),
569 fields.StringField(576 fields.FilePathField(
570 'management-certificate-path', required=True,577 'management-certificate-path', required=True,
571 label='management certificate path',578 label='management certificate path',
572 help='the path to the pem file associated to the certificate '579 help='the path to the pem file associated to the certificate '
@@ -584,6 +591,58 @@
584 is_default_field,591 is_default_field,
585 ),592 ),
586 }593 }
594 env_type_db['joyent'] = {
595 'label': 'Joyent',
596 'description': (
597 'The joyent provider enables you to run Juju on the Joyent cloud. '
598 'This process requires you to have a Joyent account. If you have '
599 'not signed up for one yet, it can obtained at '
600 'http://www.joyent.com/.'
601 ),
602 'fields': (
603 provider_field,
604 name_field,
605 admin_secret_field,
606 default_series_field,
607 fields.StringField(
608 'sdc-user', required=True,
609 label='SDC user name',
610 help='The Smart Data Center account name. '
611 'This is usually your Joyent user name.'),
612 fields.StringField(
613 'sdc-key-id', required=True,
614 label='SDC key id',
615 help='the SSH public key fingerprint used to connect to the '
616 'Smart Data Center'),
617 fields.ChoiceField(
618 'sdc-url', choices=joyent_sdc_urls, label='SDC URL',
619 required=False, default=joyent_sdc_urls[0],
620 help='the region URL to use for SDC'),
621 fields.StringField(
622 'manta-user', required=True,
623 label='manta user name',
624 help='The Manta Storage Service account name. '
625 'This is usually your Joyent user name.'),
626 fields.StringField(
627 'manta-key-id', required=True,
628 label='manta key id',
629 help='The SSH public key fingerprint used to connect to the '
630 'Manta Storage Service. This is usually the same SSH '
631 'fingerprint provided as SDC key id.'),
632 fields.StringField(
633 'manta-url', label='manta URL', required=False,
634 default='https://us-east.manta.joyent.com',
635 help='the region URL to use for manta'),
636 fields.FilePathField(
637 'private-key-path', label='private key path', required=False,
638 default='~/.ssh/id_rsa',
639 help='the path to the SSH private key'),
640 fields.StringField(
641 'algorithm', label='SSH algorithm', required=False,
642 default='rsa-sha256'),
643 is_default_field,
644 ),
645 }
587 env_type_db['local'] = {646 env_type_db['local'] = {
588 'label': 'local (LXC)',647 'label': 'local (LXC)',
589 'description': (648 'description': (
590649
=== modified file 'quickstart/models/fields.py'
--- quickstart/models/fields.py 2014-01-14 14:42:20 +0000
+++ quickstart/models/fields.py 2014-04-10 09:23:37 +0000
@@ -30,6 +30,7 @@
3030
31from __future__ import unicode_literals31from __future__ import unicode_literals
3232
33import os
33import uuid34import uuid
3435
3536
@@ -293,6 +294,24 @@
293 )294 )
294295
295296
297class FilePathField(StringField):
298 """A string field storing a path to an existing file."""
299
300 def validate(self, value):
301 """Check the field is set if required.
302
303 If the field is set, also check that the file exists.
304 """
305 # The parent field ensures the value is set if required.
306 super(FilePathField, self).validate(value)
307 value = self.normalize(value)
308 # If the value is not set, just return without validating the path.
309 if value is None:
310 return
311 if not os.path.isfile(os.path.expanduser(value)):
312 raise ValueError('file not found in the specified path')
313
314
296class SuggestionsStringField(StringField):315class SuggestionsStringField(StringField):
297 """A string field storing possible value suggestions."""316 """A string field storing possible value suggestions."""
298317
299318
=== modified file 'quickstart/tests/models/test_envs.py'
--- quickstart/tests/models/test_envs.py 2014-01-28 20:35:42 +0000
+++ quickstart/tests/models/test_envs.py 2014-04-10 09:23:37 +0000
@@ -780,6 +780,21 @@
780 self.assert_fields(expected, env_metadata)780 self.assert_fields(expected, env_metadata)
781 self.assert_required_fields(expected_required, env_metadata)781 self.assert_required_fields(expected_required, env_metadata)
782782
783 def test_joyent_environment(self):
784 # The joyent environment metadata includes the expected fields.
785 self.assertIn('joyent', self.env_type_db)
786 env_metadata = self.env_type_db['joyent']
787 expected = [
788 'type', 'name', 'admin-secret', 'default-series',
789 'sdc-user', 'sdc-key-id', 'sdc-url',
790 'manta-user', 'manta-key-id', 'manta-url',
791 'private-key-path', 'algorithm', 'is-default']
792 expected_required = [
793 'type', 'name', 'sdc-user', 'sdc-key-id', 'manta-user',
794 'manta-key-id', 'is-default']
795 self.assert_fields(expected, env_metadata)
796 self.assert_required_fields(expected_required, env_metadata)
797
783798
784class TestGetSupportedEnvTypes(unittest.TestCase):799class TestGetSupportedEnvTypes(unittest.TestCase):
785800
@@ -790,6 +805,7 @@
790 ('ec2', 'Amazon EC2'),805 ('ec2', 'Amazon EC2'),
791 ('openstack', 'OpenStack (or HP Public Cloud)'),806 ('openstack', 'OpenStack (or HP Public Cloud)'),
792 ('azure', 'Windows Azure'),807 ('azure', 'Windows Azure'),
808 ('joyent', 'Joyent'),
793 ('local', 'local (LXC)'),809 ('local', 'local (LXC)'),
794 ]810 ]
795 obtained_env_types = envs.get_supported_env_types(env_type_db)811 obtained_env_types = envs.get_supported_env_types(env_type_db)
796812
=== modified file 'quickstart/tests/models/test_fields.py'
--- quickstart/tests/models/test_fields.py 2014-01-14 15:46:08 +0000
+++ quickstart/tests/models/test_fields.py 2014-04-10 09:23:37 +0000
@@ -19,8 +19,11 @@
19from __future__ import unicode_literals19from __future__ import unicode_literals
2020
21from contextlib import contextmanager21from contextlib import contextmanager
22import os
22import unittest23import unittest
2324
25import mock
26
24from quickstart.models import fields27from quickstart.models import fields
25from quickstart.tests import helpers28from quickstart.tests import helpers
2629
@@ -457,6 +460,37 @@
457 field.validate(None)460 field.validate(None)
458461
459462
463class TestFilePathField(TestStringField):
464
465 field_class = fields.FilePathField
466
467 def test_validation_success(self):
468 # The validation succeeds if the value is set and the path exists.
469 field = self.field_class('path')
470 with self.assert_not_raises(ValueError):
471 field.validate(unicode(__file__))
472
473 def test_validation_expanduser(self):
474 # The ~ construct is properly expanded.
475 field = self.field_class('path')
476 basename, filename = os.path.split(unicode(__file__))
477 with self.assert_not_raises(ValueError):
478 with mock.patch('os.environ', {'HOME': basename}):
479 field.validate('~/{}'.format(filename))
480
481 def test_validation_error_file_not_found(self):
482 # A ValueError is raised if the path does not exist.
483 field = self.field_class('path')
484 with self.assert_value_error('file not found in the specified path'):
485 field.validate('__no-such-file__')
486
487 def test_validation_error_directory(self):
488 # A ValueError is raised if the path is a directory.
489 field = self.field_class('path')
490 with self.assert_value_error('file not found in the specified path'):
491 field.validate('/tmp')
492
493
460class TestSuggestionsStringField(TestStringField):494class TestSuggestionsStringField(TestStringField):
461495
462 field_class = fields.SuggestionsStringField496 field_class = fields.SuggestionsStringField

Subscribers

People subscribed via source and target branches