Merge lp:~corey.bryant/charms/trusty/nova-cloud-controller/git into lp:~openstack-charmers-archive/charms/trusty/nova-cloud-controller/next

Proposed by Corey Bryant
Status: Superseded
Proposed branch: lp:~corey.bryant/charms/trusty/nova-cloud-controller/git
Merge into: lp:~openstack-charmers-archive/charms/trusty/nova-cloud-controller/next
Diff against target: 1382 lines (+956/-74)
23 files modified
.bzrignore (+1/-0)
Makefile (+5/-3)
README.txt (+85/-0)
actions.yaml (+2/-0)
actions/git_reinstall.py (+45/-0)
config.yaml (+16/-0)
hooks/charmhelpers/contrib/openstack/utils.py (+4/-1)
hooks/nova_cc_hooks.py (+17/-6)
hooks/nova_cc_utils.py (+272/-1)
templates/git/nova_sudoers (+4/-0)
tests/10-basic-precise-essex (+0/-10)
tests/11-basic-precise-folsom (+0/-18)
tests/12-basic-precise-grizzly (+0/-12)
tests/13-basic-precise-havana (+0/-12)
tests/16-basic-trusty-icehouse-git (+10/-0)
tests/17-basic-trusty-juno (+12/-0)
tests/18-basic-trusty-juno-git (+13/-0)
tests/basic_deployment.py (+25/-2)
unit_tests/__init__.py (+2/-0)
unit_tests/test_actions_git_reinstall.py (+107/-0)
unit_tests/test_nova_cc_contexts.py (+1/-3)
unit_tests/test_nova_cc_hooks.py (+55/-0)
unit_tests/test_nova_cc_utils.py (+280/-6)
To merge this branch: bzr merge lp:~corey.bryant/charms/trusty/nova-cloud-controller/git
Reviewer Review Type Date Requested Status
OpenStack Charmers Pending
Review via email: mp+256298@code.launchpad.net
To post a comment you must log in.
Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_lint_check #3416 nova-cloud-controller-next for corey.bryant mp256298
    LINT OK: passed

Build: http://10.245.162.77:8080/job/charm_lint_check/3416/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_unit_test #3204 nova-cloud-controller-next for corey.bryant mp256298
    UNIT OK: passed

Build: http://10.245.162.77:8080/job/charm_unit_test/3204/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_amulet_test #3209 nova-cloud-controller-next for corey.bryant mp256298
    AMULET OK: passed

Build: http://10.245.162.77:8080/job/charm_amulet_test/3209/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_lint_check #3448 nova-cloud-controller-next for corey.bryant mp256298
    LINT OK: passed

Build: http://10.245.162.77:8080/job/charm_lint_check/3448/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_unit_test #3236 nova-cloud-controller-next for corey.bryant mp256298
    UNIT OK: passed

Build: http://10.245.162.77:8080/job/charm_unit_test/3236/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_lint_check #3457 nova-cloud-controller-next for corey.bryant mp256298
    LINT OK: passed

Build: http://10.245.162.77:8080/job/charm_lint_check/3457/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_unit_test #3245 nova-cloud-controller-next for corey.bryant mp256298
    UNIT OK: passed

Build: http://10.245.162.77:8080/job/charm_unit_test/3245/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_lint_check #3464 nova-cloud-controller-next for corey.bryant mp256298
    LINT OK: passed

Build: http://10.245.162.77:8080/job/charm_lint_check/3464/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_unit_test #3252 nova-cloud-controller-next for corey.bryant mp256298
    UNIT OK: passed

Build: http://10.245.162.77:8080/job/charm_unit_test/3252/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_amulet_test #3261 nova-cloud-controller-next for corey.bryant mp256298
    AMULET FAIL: amulet-test failed

AMULET Results (max last 2 lines):
make: *** [test] Error 1
ERROR:root:Make target returned non-zero.

Full amulet test output: http://paste.ubuntu.com/10834679/
Build: http://10.245.162.77:8080/job/charm_amulet_test/3261/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_lint_check #3517 nova-cloud-controller-next for corey.bryant mp256298
    LINT OK: passed

Build: http://10.245.162.77:8080/job/charm_lint_check/3517/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_unit_test #3305 nova-cloud-controller-next for corey.bryant mp256298
    UNIT OK: passed

Build: http://10.245.162.77:8080/job/charm_unit_test/3305/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_amulet_test #3272 nova-cloud-controller-next for corey.bryant mp256298
    AMULET FAIL: amulet-test failed

AMULET Results (max last 2 lines):
make: *** [test] Error 124
ERROR:root:Make target returned non-zero.

Full amulet test output: http://paste.ubuntu.com/10835667/
Build: http://10.245.162.77:8080/job/charm_amulet_test/3272/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_lint_check #3541 nova-cloud-controller-next for corey.bryant mp256298
    LINT OK: passed

Build: http://10.245.162.77:8080/job/charm_lint_check/3541/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_unit_test #3329 nova-cloud-controller-next for corey.bryant mp256298
    UNIT OK: passed

Build: http://10.245.162.77:8080/job/charm_unit_test/3329/

158. By Corey Bryant

Sync charm-helpers

159. By Corey Bryant

Add libffi-dev, libssl-dev, and libyaml-dev to base git install packages

160. By Corey Bryant

Add nova serial proxy upstart script

161. By Corey Bryant

Generalize neutron-db-manage and quantum-db-manage executable names as they may come from /usr/local/bin when deploying from source.

162. By Corey Bryant

Merge next branch

163. By Corey Bryant

Put base packages in correct list

164. By Corey Bryant

Sync charm-helpers

165. By Corey Bryant

Sync charm-helpers

166. By Corey Bryant

Install neutorn-common as python-six conflict workaround

167. By Corey Bryant

Sync charm-helpers

168. By Corey Bryant

Drop libffi-dev, libssl-dev, and libyaml-dev.

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file '.bzrignore'
--- .bzrignore 2014-07-02 08:22:25 +0000
+++ .bzrignore 2015-04-16 19:34:57 +0000
@@ -1,2 +1,3 @@
1bin1bin
2.coverage2.coverage
3tags
34
=== modified file 'Makefile'
--- Makefile 2014-09-29 21:03:48 +0000
+++ Makefile 2015-04-16 19:34:57 +0000
@@ -2,7 +2,7 @@
2PYTHON := /usr/bin/env python2PYTHON := /usr/bin/env python
33
4lint:4lint:
5 @flake8 --exclude hooks/charmhelpers hooks unit_tests tests5 @flake8 --exclude hooks/charmhelpers actions hooks unit_tests tests
6 @charm proof6 @charm proof
77
8unit_test:8unit_test:
@@ -18,8 +18,10 @@
18 # coreycb note: The -v should only be temporary until Amulet sends18 # coreycb note: The -v should only be temporary until Amulet sends
19 # raise_status() messages to stderr:19 # raise_status() messages to stderr:
20 # https://bugs.launchpad.net/amulet/+bug/132035720 # https://bugs.launchpad.net/amulet/+bug/1320357
21 @juju test -v -p AMULET_HTTP_PROXY --timeout 900 \21 @juju test -v -p AMULET_HTTP_PROXY --timeout 1200 \
22 00-setup 14-basic-precise-icehouse 15-basic-trusty-icehouse22 00-setup 14-basic-precise-icehouse 15-basic-trusty-icehouse \
23 16-basic-trusty-icehouse-git 17-basic-trusty-juno \
24 18-basic-trusty-juno-git
2325
24sync: bin/charm_helpers_sync.py26sync: bin/charm_helpers_sync.py
25 @$(PYTHON) bin/charm_helpers_sync.py -c charm-helpers-hooks.yaml27 @$(PYTHON) bin/charm_helpers_sync.py -c charm-helpers-hooks.yaml
2628
=== modified file 'README.txt'
--- README.txt 2014-07-30 10:49:59 +0000
+++ README.txt 2015-04-16 19:34:57 +0000
@@ -23,3 +23,88 @@
2323
24juju add-relation "nova-cloud-controller:pgsql-nova-db" "postgresql:db"24juju add-relation "nova-cloud-controller:pgsql-nova-db" "postgresql:db"
25juju add-relation "nova-cloud-controller:pgsql-neutron-db" "postgresql:db"25juju add-relation "nova-cloud-controller:pgsql-neutron-db" "postgresql:db"
26
27Deploying from source
28=====================
29
30The minimum openstack-origin-git config required to deploy from source is:
31
32 openstack-origin-git:
33 "repositories:
34 - {name: requirements,
35 repository: 'git://git.openstack.org/openstack/requirements',
36 branch: stable/juno}
37 - {name: nova,
38 repository: 'git://git.openstack.org/openstack/nova',
39 branch: stable/juno}"
40
41Note that there are only two 'name' values the charm knows about: 'requirements'
42and 'nova'. These repositories must correspond to these 'name' values.
43Additionally, the requirements repository must be specified first and the
44nova repository must be specified last. All other repostories are installed
45in the order in which they are specified.
46
47The following is a full list of current tip repos (may not be up-to-date):
48
49 openstack-origin-git:
50 "repositories:
51 - {name: requirements,
52 repository: 'git://git.openstack.org/openstack/requirements',
53 branch: master}
54 - {name: oslo-concurrency,
55 repository: 'git://git.openstack.org/openstack/oslo.concurrency',
56 branch: master}
57 - {name: oslo-config,
58 repository: 'git://git.openstack.org/openstack/oslo.config',
59 branch: master}
60 - {name: oslo-context,
61 repository: 'git://git.openstack.org/openstack/oslo.context.git',
62 branch: master}
63 - {name: oslo-db,
64 repository: 'git://git.openstack.org/openstack/oslo.db',
65 branch: master}
66 - {name: oslo-i18n,
67 repository: 'git://git.openstack.org/openstack/oslo.i18n',
68 branch: master}
69 - {name: oslo-log,
70 repository: 'git://git.openstack.org/openstack/oslo.log',
71 branch: master}
72 - {name: oslo-messaging,
73 repository: 'git://git.openstack.org/openstack/oslo.messaging.git',
74 branch: master}
75 - {name: oslo-middleware,
76 repository': 'git://git.openstack.org/openstack/oslo.middleware.git',
77 branch: master}
78 - {name: oslo-rootwrap',
79 repository: 'git://git.openstack.org/openstack/oslo.rootwrap.git',
80 branch: master}
81 - {name: oslo-serialization,
82 repository: 'git://git.openstack.org/openstack/oslo.serialization',
83 branch: master}
84 - {name: oslo-utils,
85 repository: 'git://git.openstack.org/openstack/oslo.utils',
86 branch: master}
87 - {name: pbr,
88 repository: 'git://git.openstack.org/openstack-dev/pbr',
89 branch: master}
90 - {name: stevedore,
91 repository: 'git://git.openstack.org/openstack/stevedore.git',
92 branch: 'master'}
93 - {name: sqlalchemy-migrate,
94 repository: 'git://git.openstack.org/stackforge/sqlalchemy-migrate',
95 branch: master}
96 - {name: python-cinderclient,
97 repository: 'git://git.openstack.org/openstack/python-cinderclient.git',
98 branch: master}
99 - {name: python-glanceclient,
100 repository': 'git://git.openstack.org/openstack/python-glanceclient.git',
101 branch: master}
102 - {name: python-neutronlient,
103 repository': 'git://git.openstack.org/openstack/python-neutronclient.git',
104 branch: master}
105 - {name: keystonemiddleware,
106 repository: 'git://git.openstack.org/openstack/keystonemiddleware',
107 branch: master}
108 - {name: nova,
109 repository: 'git://git.openstack.org/openstack/nova',
110 branch: master}"
26111
=== added directory 'actions'
=== added file 'actions.yaml'
--- actions.yaml 1970-01-01 00:00:00 +0000
+++ actions.yaml 2015-04-16 19:34:57 +0000
@@ -0,0 +1,2 @@
1git-reinstall:
2 description: Reinstall nova-cloud-controller from the openstack-origin-git repositories.
03
=== added symlink 'actions/git-reinstall'
=== target is u'git_reinstall.py'
=== added file 'actions/git_reinstall.py'
--- actions/git_reinstall.py 1970-01-01 00:00:00 +0000
+++ actions/git_reinstall.py 2015-04-16 19:34:57 +0000
@@ -0,0 +1,45 @@
1#!/usr/bin/python
2import sys
3import traceback
4
5sys.path.append('hooks/')
6
7from charmhelpers.contrib.openstack.utils import (
8 git_install_requested,
9)
10
11from charmhelpers.core.hookenv import (
12 action_set,
13 action_fail,
14 config,
15)
16
17from nova_cc_utils import (
18 git_install,
19)
20
21from nova_cc_hooks import (
22 config_changed,
23)
24
25
26def git_reinstall():
27 """Reinstall from source and restart services.
28
29 If the openstack-origin-git config option was used to install openstack
30 from source git repositories, then this action can be used to reinstall
31 from updated git repositories, followed by a restart of services."""
32 if not git_install_requested():
33 action_fail('openstack-origin-git is not configured')
34 return
35
36 try:
37 git_install(config('openstack-origin-git'))
38 config_changed()
39 except:
40 action_set({'traceback': traceback.format_exc()})
41 action_fail('git-reinstall resulted in an unexpected error')
42
43
44if __name__ == '__main__':
45 git_reinstall()
046
=== modified file 'config.yaml'
--- config.yaml 2015-04-13 08:49:59 +0000
+++ config.yaml 2015-04-16 19:34:57 +0000
@@ -14,6 +14,22 @@
14 Note that updating this setting to a source that is known to14 Note that updating this setting to a source that is known to
15 provide a later version of OpenStack will trigger a software15 provide a later version of OpenStack will trigger a software
16 upgrade.16 upgrade.
17
18 Note that when openstack-origin-git is specified, openstack
19 specific packages will be installed from source rather than
20 from the openstack-origin repository.
21 openstack-origin-git:
22 default:
23 type: string
24 description: |
25 Specifies a YAML-formatted dictionary listing the git
26 repositories and branches from which to install OpenStack and
27 its dependencies.
28
29 Note that the installed config files will be determined based on
30 the OpenStack release of the openstack-origin option.
31
32 For more details see README.md.
17 rabbit-user:33 rabbit-user:
18 default: nova34 default: nova
19 type: string35 type: string
2036
=== modified file 'hooks/charmhelpers/contrib/openstack/utils.py'
--- hooks/charmhelpers/contrib/openstack/utils.py 2015-04-13 08:51:41 +0000
+++ hooks/charmhelpers/contrib/openstack/utils.py 2015-04-16 19:34:57 +0000
@@ -524,9 +524,10 @@
524 projects = yaml.load(projects_yaml)524 projects = yaml.load(projects_yaml)
525 _git_validate_projects_yaml(projects, core_project)525 _git_validate_projects_yaml(projects, core_project)
526526
527 old_environ = dict(os.environ)
528
527 if 'http_proxy' in projects.keys():529 if 'http_proxy' in projects.keys():
528 os.environ['http_proxy'] = projects['http_proxy']530 os.environ['http_proxy'] = projects['http_proxy']
529
530 if 'https_proxy' in projects.keys():531 if 'https_proxy' in projects.keys():
531 os.environ['https_proxy'] = projects['https_proxy']532 os.environ['https_proxy'] = projects['https_proxy']
532533
@@ -544,6 +545,8 @@
544 repo_dir = _git_clone_and_install_single(repo, branch, parent_dir,545 repo_dir = _git_clone_and_install_single(repo, branch, parent_dir,
545 update_requirements=True)546 update_requirements=True)
546547
548 os.environ = old_environ
549
547550
548def _git_validate_projects_yaml(projects, core_project):551def _git_validate_projects_yaml(projects, core_project):
549 """552 """
550553
=== modified file 'hooks/nova_cc_hooks.py'
--- hooks/nova_cc_hooks.py 2015-03-31 14:56:11 +0000
+++ hooks/nova_cc_hooks.py 2015-04-16 19:34:57 +0000
@@ -43,7 +43,9 @@
43)43)
4444
45from charmhelpers.contrib.openstack.utils import (45from charmhelpers.contrib.openstack.utils import (
46 config_value_changed,
46 configure_installation_source,47 configure_installation_source,
48 git_install_requested,
47 openstack_upgrade_available,49 openstack_upgrade_available,
48 os_release,50 os_release,
49 os_requires_version,51 os_requires_version,
@@ -75,6 +77,7 @@
75 disable_services,77 disable_services,
76 do_openstack_upgrade,78 do_openstack_upgrade,
77 enable_services,79 enable_services,
80 git_install,
78 keystone_ca_cert_b64,81 keystone_ca_cert_b64,
79 migrate_neutron_database,82 migrate_neutron_database,
80 migrate_nova_database,83 migrate_nova_database,
@@ -132,9 +135,12 @@
132def install():135def install():
133 execd_preinstall()136 execd_preinstall()
134 configure_installation_source(config('openstack-origin'))137 configure_installation_source(config('openstack-origin'))
138
135 apt_update()139 apt_update()
136 apt_install(determine_packages(), fatal=True)140 apt_install(determine_packages(), fatal=True)
137141
142 git_install(config('openstack-origin-git'))
143
138 _files = os.path.join(charm_dir(), 'files')144 _files = os.path.join(charm_dir(), 'files')
139 if os.path.isdir(_files):145 if os.path.isdir(_files):
140 for f in os.listdir(_files):146 for f in os.listdir(_files):
@@ -160,16 +166,21 @@
160 relation_prefix='nova')166 relation_prefix='nova')
161167
162 global CONFIGS168 global CONFIGS
163 if openstack_upgrade_available('nova-common'):169 if git_install_requested():
164 CONFIGS = do_openstack_upgrade()170 if config_value_changed('openstack-origin-git'):
165 [neutron_api_relation_joined(rid=rid, remote_restart=True)171 git_install(config('openstack-origin-git'))
166 for rid in relation_ids('neutron-api')]172 else:
173 if openstack_upgrade_available('nova-common'):
174 CONFIGS = do_openstack_upgrade()
175 [neutron_api_relation_joined(rid=rid, remote_restart=True)
176 for rid in relation_ids('neutron-api')]
167 save_script_rc()177 save_script_rc()
168 configure_https()178 configure_https()
169 CONFIGS.write_all()179 CONFIGS.write_all()
170 if console_attributes('protocol'):180 if console_attributes('protocol'):
171 apt_update()181 if not git_install_requested():
172 apt_install(console_attributes('packages'), fatal=True)182 apt_update()
183 apt_install(console_attributes('packages'), fatal=True)
173 [compute_joined(rid=rid)184 [compute_joined(rid=rid)
174 for rid in relation_ids('cloud-compute')]185 for rid in relation_ids('cloud-compute')]
175 for r_id in relation_ids('identity-service'):186 for r_id in relation_ids('identity-service'):
176187
=== modified file 'hooks/nova_cc_utils.py'
--- hooks/nova_cc_utils.py 2015-03-31 14:56:11 +0000
+++ hooks/nova_cc_utils.py 2015-04-16 19:34:57 +0000
@@ -1,4 +1,5 @@
1import os1import os
2import shutil
2import subprocess3import subprocess
3import ConfigParser4import ConfigParser
45
@@ -19,6 +20,9 @@
19 get_host_ip,20 get_host_ip,
20 get_hostname,21 get_hostname,
21 get_os_codename_install_source,22 get_os_codename_install_source,
23 git_install_requested,
24 git_clone_and_install,
25 git_src_dir,
22 is_ip,26 is_ip,
23 os_release,27 os_release,
24 save_script_rc as _save_script_rc)28 save_script_rc as _save_script_rc)
@@ -31,6 +35,7 @@
31)35)
3236
33from charmhelpers.core.hookenv import (37from charmhelpers.core.hookenv import (
38 charm_dir,
34 config,39 config,
35 log,40 log,
36 relation_get,41 relation_get,
@@ -42,13 +47,19 @@
42)47)
4348
44from charmhelpers.core.host import (49from charmhelpers.core.host import (
50 adduser,
51 add_group,
52 add_user_to_group,
53 mkdir,
45 service,54 service,
46 service_start,55 service_start,
47 service_stop,56 service_stop,
48 service_running,57 service_running,
49 lsb_release58 lsb_release,
50)59)
5160
61from charmhelpers.core.templating import render
62
52from charmhelpers.contrib.network.ip import (63from charmhelpers.contrib.network.ip import (
53 is_ipv664 is_ipv6
54)65)
@@ -72,6 +83,41 @@
72 'python-memcache',83 'python-memcache',
73]84]
7485
86BASE_GIT_PACKAGES = [
87 'libxml2-dev',
88 'libxslt1-dev',
89 'python-dev',
90 'python-pip',
91 'python-setuptools',
92 'zlib1g-dev',
93]
94
95LATE_GIT_PACKAGES = [
96 'novnc',
97 'spice-html5',
98 'websockify',
99]
100
101# ubuntu packages that should not be installed when deploying from git
102GIT_PACKAGE_BLACKLIST = [
103 'neutron-server',
104 'neutron-plugin-ml2',
105 'nova-api-ec2',
106 'nova-api-os-compute',
107 'nova-api-os-volume',
108 'nova-cert',
109 'nova-conductor',
110 'nova-consoleauth',
111 'nova-novncproxy',
112 'nova-objectstore',
113 'nova-scheduler',
114 'nova-spiceproxy',
115 'nova-xvpvncproxy',
116 'python-keystoneclient',
117 'python-six',
118 'quantum-server',
119]
120
75BASE_SERVICES = [121BASE_SERVICES = [
76 'nova-api-ec2',122 'nova-api-ec2',
77 'nova-api-os-compute',123 'nova-api-os-compute',
@@ -377,6 +423,15 @@
377 packages.extend(pkgs)423 packages.extend(pkgs)
378 if console_attributes('packages'):424 if console_attributes('packages'):
379 packages.extend(console_attributes('packages'))425 packages.extend(console_attributes('packages'))
426
427 if git_install_requested():
428 packages = list(set(packages))
429 packages.extend(BASE_GIT_PACKAGES)
430 # don't include packages that will be installed from git
431 for p in GIT_PACKAGE_BLACKLIST:
432 if p in packages:
433 packages.remove(p)
434
380 return list(set(packages))435 return list(set(packages))
381436
382437
@@ -974,3 +1029,219 @@
974 ' main')1029 ' main')
975 apt_update()1030 apt_update()
976 apt_install('haproxy/trusty-backports', fatal=True)1031 apt_install('haproxy/trusty-backports', fatal=True)
1032
1033
1034def git_install(projects_yaml):
1035 """Perform setup, and install git repos specified in yaml parameter."""
1036 if git_install_requested():
1037 git_pre_install()
1038 git_clone_and_install(projects_yaml, core_project='nova')
1039 git_post_install(projects_yaml)
1040
1041
1042def git_pre_install():
1043 """Perform pre-install setup."""
1044 dirs = [
1045 '/var/lib/nova',
1046 '/var/lib/nova/buckets',
1047 '/var/lib/nova/CA',
1048 '/var/lib/nova/CA/INTER',
1049 '/var/lib/nova/CA/newcerts',
1050 '/var/lib/nova/CA/private',
1051 '/var/lib/nova/CA/reqs',
1052 '/var/lib/nova/images',
1053 '/var/lib/nova/instances',
1054 '/var/lib/nova/keys',
1055 '/var/lib/nova/networks',
1056 '/var/lib/nova/tmp',
1057 '/var/lib/neutron',
1058 '/var/lib/neutron/lock',
1059 '/var/log/nova',
1060 '/etc/neutron',
1061 '/etc/neutron/plugins',
1062 '/etc/neutron/plugins/ml2',
1063 ]
1064
1065 adduser('nova', shell='/bin/bash', system_user=True)
1066 subprocess.check_call(['usermod', '--home', '/var/lib/nova', 'nova'])
1067 add_group('nova', system_group=True)
1068 add_user_to_group('nova', 'nova')
1069
1070 adduser('neutron', shell='/bin/bash', system_user=True)
1071 add_group('neutron', system_group=True)
1072 add_user_to_group('neutron', 'neutron')
1073
1074 for d in dirs:
1075 mkdir(d, owner='nova', group='nova', perms=0755, force=False)
1076
1077
1078def git_post_install(projects_yaml):
1079 """Perform post-install setup."""
1080 src_etc = os.path.join(git_src_dir(projects_yaml, 'nova'), 'etc/nova')
1081 configs = [
1082 {'src': src_etc,
1083 'dest': '/etc/nova'},
1084 ]
1085
1086 for c in configs:
1087 if os.path.exists(c['dest']):
1088 shutil.rmtree(c['dest'])
1089 shutil.copytree(c['src'], c['dest'])
1090
1091 render('git/nova_sudoers', '/etc/sudoers.d/nova_sudoers', {}, perms=0o440)
1092
1093 nova_cc = 'nova-cloud-controller'
1094 nova_user = 'nova'
1095 start_dir = '/var/lib/nova'
1096 nova_conf = '/etc/nova/nova.conf'
1097 nova_ec2_api_context = {
1098 'service_description': 'Nova EC2 API server',
1099 'service_name': nova_cc,
1100 'user_name': nova_user,
1101 'start_dir': start_dir,
1102 'process_name': 'nova-api-ec2',
1103 'executable_name': '/usr/local/bin/nova-api-ec2',
1104 'config_files': [nova_conf],
1105 }
1106 nova_api_os_compute_context = {
1107 'service_description': 'Nova OpenStack Compute API server',
1108 'service_name': nova_cc,
1109 'user_name': nova_user,
1110 'start_dir': start_dir,
1111 'process_name': 'nova-api-os-compute',
1112 'executable_name': '/usr/local/bin/nova-api-os-compute',
1113 'config_files': [nova_conf],
1114 }
1115 nova_cells_context = {
1116 'service_description': 'Nova cells',
1117 'service_name': nova_cc,
1118 'user_name': nova_user,
1119 'start_dir': start_dir,
1120 'process_name': 'nova-cells',
1121 'executable_name': '/usr/local/bin/nova-cells',
1122 'config_files': [nova_conf],
1123 }
1124 nova_cert_context = {
1125 'service_description': 'Nova cert',
1126 'service_name': nova_cc,
1127 'user_name': nova_user,
1128 'start_dir': start_dir,
1129 'process_name': 'nova-cert',
1130 'executable_name': '/usr/local/bin/nova-cert',
1131 'config_files': [nova_conf],
1132 }
1133 nova_conductor_context = {
1134 'service_description': 'Nova conductor',
1135 'service_name': nova_cc,
1136 'user_name': nova_user,
1137 'start_dir': start_dir,
1138 'process_name': 'nova-conductor',
1139 'executable_name': '/usr/local/bin/nova-conductor',
1140 'config_files': [nova_conf],
1141 }
1142 nova_consoleauth_context = {
1143 'service_description': 'Nova console auth',
1144 'service_name': nova_cc,
1145 'user_name': nova_user,
1146 'start_dir': start_dir,
1147 'process_name': 'nova-consoleauth',
1148 'executable_name': '/usr/local/bin/nova-consoleauth',
1149 'config_files': [nova_conf],
1150 }
1151 nova_console_context = {
1152 'service_description': 'Nova console',
1153 'service_name': nova_cc,
1154 'user_name': nova_user,
1155 'start_dir': start_dir,
1156 'process_name': 'nova-console',
1157 'executable_name': '/usr/local/bin/nova-console',
1158 'config_files': [nova_conf],
1159 }
1160 nova_novncproxy_context = {
1161 'service_description': 'Nova NoVNC proxy',
1162 'service_name': nova_cc,
1163 'user_name': nova_user,
1164 'start_dir': start_dir,
1165 'process_name': 'nova-novncproxy',
1166 'executable_name': '/usr/local/bin/nova-novncproxy',
1167 'config_files': [nova_conf],
1168 }
1169 nova_objectstore_context = {
1170 'service_description': 'Nova object store',
1171 'service_name': nova_cc,
1172 'user_name': nova_user,
1173 'start_dir': start_dir,
1174 'process_name': 'nova-objectstore',
1175 'executable_name': '/usr/local/bin/nova-objectstore',
1176 'config_files': [nova_conf],
1177 }
1178 nova_scheduler_context = {
1179 'service_description': 'Nova scheduler',
1180 'service_name': nova_cc,
1181 'user_name': nova_user,
1182 'start_dir': start_dir,
1183 'process_name': 'nova-scheduler',
1184 'executable_name': '/usr/local/bin/nova-scheduler',
1185 'config_files': [nova_conf],
1186 }
1187 nova_spiceproxy_context = {
1188 'service_description': 'Nova spice proxy',
1189 'service_name': nova_cc,
1190 'user_name': nova_user,
1191 'start_dir': start_dir,
1192 'process_name': 'nova-spicehtml5proxy',
1193 'executable_name': '/usr/local/bin/nova-spicehtml5proxy',
1194 'config_files': [nova_conf],
1195 }
1196 nova_xvpvncproxy_context = {
1197 'service_description': 'Nova XVPVNC proxy',
1198 'service_name': nova_cc,
1199 'user_name': nova_user,
1200 'start_dir': start_dir,
1201 'process_name': 'nova-xvpvncproxy',
1202 'executable_name': '/usr/local/bin/nova-xvpvncproxy',
1203 'config_files': [nova_conf],
1204 }
1205
1206 # NOTE(coreycb): Needs systemd support
1207 templates_dir = 'hooks/charmhelpers/contrib/openstack/templates'
1208 templates_dir = os.path.join(charm_dir(), templates_dir)
1209 render('git.upstart', '/etc/init/nova-api-ec2.conf',
1210 nova_ec2_api_context, perms=0o644,
1211 templates_dir=templates_dir)
1212 render('git.upstart', '/etc/init/nova-api-os-compute.conf',
1213 nova_api_os_compute_context, perms=0o644,
1214 templates_dir=templates_dir)
1215 render('git.upstart', '/etc/init/nova-cells.conf',
1216 nova_cells_context, perms=0o644,
1217 templates_dir=templates_dir)
1218 render('git.upstart', '/etc/init/nova-cert.conf',
1219 nova_cert_context, perms=0o644,
1220 templates_dir=templates_dir)
1221 render('git.upstart', '/etc/init/nova-conductor.conf',
1222 nova_conductor_context, perms=0o644,
1223 templates_dir=templates_dir)
1224 render('git.upstart', '/etc/init/nova-consoleauth.conf',
1225 nova_consoleauth_context, perms=0o644,
1226 templates_dir=templates_dir)
1227 render('git.upstart', '/etc/init/nova-console.conf',
1228 nova_console_context, perms=0o644,
1229 templates_dir=templates_dir)
1230 render('git.upstart', '/etc/init/nova-novncproxy.conf',
1231 nova_novncproxy_context, perms=0o644,
1232 templates_dir=templates_dir)
1233 render('git.upstart', '/etc/init/nova-objectstore.conf',
1234 nova_objectstore_context, perms=0o644,
1235 templates_dir=templates_dir)
1236 render('git.upstart', '/etc/init/nova-scheduler.conf',
1237 nova_scheduler_context, perms=0o644,
1238 templates_dir=templates_dir)
1239 render('git.upstart', '/etc/init/nova-spiceproxy.conf',
1240 nova_spiceproxy_context, perms=0o644,
1241 templates_dir=templates_dir)
1242 render('git.upstart', '/etc/init/nova-xvpvncproxy.conf',
1243 nova_xvpvncproxy_context, perms=0o644,
1244 templates_dir=templates_dir)
1245
1246 apt_update()
1247 apt_install(LATE_GIT_PACKAGES, fatal=True)
9771248
=== added directory 'templates/git'
=== added file 'templates/git/nova_sudoers'
--- templates/git/nova_sudoers 1970-01-01 00:00:00 +0000
+++ templates/git/nova_sudoers 2015-04-16 19:34:57 +0000
@@ -0,0 +1,4 @@
1Defaults:nova !requiretty
2
3nova ALL = (root) NOPASSWD: /usr/local/bin/nova-rootwrap /etc/nova/rootwrap.conf *
4
05
=== removed file 'tests/10-basic-precise-essex'
--- tests/10-basic-precise-essex 2014-07-11 17:34:39 +0000
+++ tests/10-basic-precise-essex 1970-01-01 00:00:00 +0000
@@ -1,10 +0,0 @@
1#!/usr/bin/python
2
3"""Amulet tests on a basic nova cloud controller deployment on
4 precise-essex."""
5
6from basic_deployment import NovaCCBasicDeployment
7
8if __name__ == '__main__':
9 deployment = NovaCCBasicDeployment(series='precise')
10 deployment.run_tests()
110
=== removed file 'tests/11-basic-precise-folsom'
--- tests/11-basic-precise-folsom 2014-07-11 17:34:39 +0000
+++ tests/11-basic-precise-folsom 1970-01-01 00:00:00 +0000
@@ -1,18 +0,0 @@
1#!/usr/bin/python
2
3"""Amulet tests on a basic nova cloud controller deployment on
4 precise-folsom."""
5
6import amulet
7from basic_deployment import NovaCCBasicDeployment
8
9if __name__ == '__main__':
10 # NOTE(coreycb): Skipping failing test until resolved. 'nova-manage db sync'
11 # fails in shared-db-relation-changed (only fails on folsom)
12 message = "Skipping failing test until resolved"
13 amulet.raise_status(amulet.SKIP, msg=message)
14
15 deployment = NovaCCBasicDeployment(series='precise',
16 openstack='cloud:precise-folsom',
17 source='cloud:precise-updates/folsom')
18 deployment.run_tests()
190
=== removed file 'tests/12-basic-precise-grizzly'
--- tests/12-basic-precise-grizzly 2014-07-11 17:34:39 +0000
+++ tests/12-basic-precise-grizzly 1970-01-01 00:00:00 +0000
@@ -1,12 +0,0 @@
1#!/usr/bin/python
2
3"""Amulet tests on a basic nova cloud controller deployment on
4 precise-grizzly."""
5
6from basic_deployment import NovaCCBasicDeployment
7
8if __name__ == '__main__':
9 deployment = NovaCCBasicDeployment(series='precise',
10 openstack='cloud:precise-grizzly',
11 source='cloud:precise-updates/grizzly')
12 deployment.run_tests()
130
=== removed file 'tests/13-basic-precise-havana'
--- tests/13-basic-precise-havana 2014-07-11 17:34:39 +0000
+++ tests/13-basic-precise-havana 1970-01-01 00:00:00 +0000
@@ -1,12 +0,0 @@
1#!/usr/bin/python
2
3"""Amulet tests on a basic nova cloud controller deployment on
4 precise-havana."""
5
6from basic_deployment import NovaCCBasicDeployment
7
8if __name__ == '__main__':
9 deployment = NovaCCBasicDeployment(series='precise',
10 openstack='cloud:precise-havana',
11 source='cloud:precise-updates/havana')
12 deployment.run_tests()
130
=== added file 'tests/16-basic-trusty-icehouse-git'
--- tests/16-basic-trusty-icehouse-git 1970-01-01 00:00:00 +0000
+++ tests/16-basic-trusty-icehouse-git 2015-04-16 19:34:57 +0000
@@ -0,0 +1,10 @@
1#!/usr/bin/python
2
3"""Amulet tests on a basic nova cloud controller git deployment on
4 trusty-icehouse."""
5
6from basic_deployment import NovaCCBasicDeployment
7
8if __name__ == '__main__':
9 deployment = NovaCCBasicDeployment(series='trusty', git=True)
10 deployment.run_tests()
011
=== added file 'tests/17-basic-trusty-juno'
--- tests/17-basic-trusty-juno 1970-01-01 00:00:00 +0000
+++ tests/17-basic-trusty-juno 2015-04-16 19:34:57 +0000
@@ -0,0 +1,12 @@
1#!/usr/bin/python
2
3"""Amulet tests on a basic nova cloud controller deployment on
4 trusty-juno."""
5
6from basic_deployment import NovaCCBasicDeployment
7
8if __name__ == '__main__':
9 deployment = NovaCCBasicDeployment(series='trusty',
10 openstack='cloud:trusty-juno',
11 source='cloud:trusty-updates/juno')
12 deployment.run_tests()
013
=== added file 'tests/18-basic-trusty-juno-git'
--- tests/18-basic-trusty-juno-git 1970-01-01 00:00:00 +0000
+++ tests/18-basic-trusty-juno-git 2015-04-16 19:34:57 +0000
@@ -0,0 +1,13 @@
1#!/usr/bin/python
2
3"""Amulet tests on a basic nova cloud controller git deployment on
4 trusty-juno."""
5
6from basic_deployment import NovaCCBasicDeployment
7
8if __name__ == '__main__':
9 deployment = NovaCCBasicDeployment(series='trusty',
10 openstack='cloud:trusty-juno',
11 source='cloud:trusty-updates/juno',
12 git=True)
13 deployment.run_tests()
014
=== modified file 'tests/basic_deployment.py'
--- tests/basic_deployment.py 2015-04-14 01:14:46 +0000
+++ tests/basic_deployment.py 2015-04-16 19:34:57 +0000
@@ -1,6 +1,8 @@
1#!/usr/bin/python1#!/usr/bin/python
22
3import amulet3import amulet
4import os
5import yaml
46
5from charmhelpers.contrib.openstack.amulet.deployment import (7from charmhelpers.contrib.openstack.amulet.deployment import (
6 OpenStackAmuletDeployment8 OpenStackAmuletDeployment
@@ -19,9 +21,11 @@
19class NovaCCBasicDeployment(OpenStackAmuletDeployment):21class NovaCCBasicDeployment(OpenStackAmuletDeployment):
20 """Amulet tests on a basic nova cloud controller deployment."""22 """Amulet tests on a basic nova cloud controller deployment."""
2123
22 def __init__(self, series=None, openstack=None, source=None, stable=False):24 def __init__(self, series=None, openstack=None, source=None, git=False,
25 stable=False):
23 """Deploy the entire test environment."""26 """Deploy the entire test environment."""
24 super(NovaCCBasicDeployment, self).__init__(series, openstack, source, stable)27 super(NovaCCBasicDeployment, self).__init__(series, openstack, source, stable)
28 self.git = git
25 self._add_services()29 self._add_services()
26 self._add_relations()30 self._add_relations()
27 self._configure_services()31 self._configure_services()
@@ -62,9 +66,28 @@
6266
63 def _configure_services(self):67 def _configure_services(self):
64 """Configure all of the services."""68 """Configure all of the services."""
69 nova_cc_config = {}
70 if self.git:
71 branch = 'stable/' + self._get_openstack_release_string()
72 amulet_http_proxy = os.environ.get('AMULET_HTTP_PROXY')
73 openstack_origin_git = {
74 'repositories': [
75 {'name': 'requirements',
76 'repository': 'git://git.openstack.org/openstack/requirements',
77 'branch': branch},
78 {'name': 'nova',
79 'repository': 'git://git.openstack.org/openstack/nova',
80 'branch': branch},
81 ],
82 'directory': '/mnt/openstack-git',
83 'http_proxy': amulet_http_proxy,
84 'https_proxy': amulet_http_proxy,
85 }
86 nova_cc_config['openstack-origin-git'] = yaml.dump(openstack_origin_git)
65 keystone_config = {'admin-password': 'openstack',87 keystone_config = {'admin-password': 'openstack',
66 'admin-token': 'ubuntutesting'}88 'admin-token': 'ubuntutesting'}
67 configs = {'keystone': keystone_config}89 configs = {'nova-cloud-controller': nova_cc_config,
90 'keystone': keystone_config}
68 super(NovaCCBasicDeployment, self)._configure_services(configs)91 super(NovaCCBasicDeployment, self)._configure_services(configs)
6992
70 def _initialize_tests(self):93 def _initialize_tests(self):
7194
=== modified file 'unit_tests/__init__.py'
--- unit_tests/__init__.py 2013-08-02 03:42:16 +0000
+++ unit_tests/__init__.py 2015-04-16 19:34:57 +0000
@@ -1,2 +1,4 @@
1import sys1import sys
2
3sys.path.append('actions/')
2sys.path.append('hooks/')4sys.path.append('hooks/')
35
=== added file 'unit_tests/test_actions_git_reinstall.py'
--- unit_tests/test_actions_git_reinstall.py 1970-01-01 00:00:00 +0000
+++ unit_tests/test_actions_git_reinstall.py 2015-04-16 19:34:57 +0000
@@ -0,0 +1,107 @@
1from mock import patch, MagicMock
2
3with patch('charmhelpers.core.hookenv.config') as config:
4 config.return_value = 'nova'
5 import nova_cc_utils as utils # noqa
6
7_reg = utils.register_configs
8_map = utils.restart_map
9
10utils.register_configs = MagicMock()
11utils.restart_map = MagicMock()
12
13with patch('nova_cc_utils.guard_map') as gmap:
14 with patch('charmhelpers.core.hookenv.config') as config:
15 config.return_value = False
16 gmap.return_value = {}
17 import git_reinstall
18
19utils.register_configs = _reg
20utils.restart_map = _map
21
22from test_utils import (
23 CharmTestCase
24)
25
26TO_PATCH = [
27 'config',
28]
29
30
31openstack_origin_git = \
32 """repositories:
33 - {name: requirements,
34 repository: 'git://git.openstack.org/openstack/requirements',
35 branch: stable/juno}
36 - {name: nova,
37 repository: 'git://git.openstack.org/openstack/nova',
38 branch: stable/juno}"""
39
40
41class TestnovaAPIActions(CharmTestCase):
42
43 def setUp(self):
44 super(TestnovaAPIActions, self).setUp(git_reinstall, TO_PATCH)
45 self.config.side_effect = self.test_config.get
46
47 @patch.object(git_reinstall, 'action_set')
48 @patch.object(git_reinstall, 'action_fail')
49 @patch.object(git_reinstall, 'git_install')
50 @patch.object(git_reinstall, 'config_changed')
51 def test_git_reinstall(self, config_changed, git_install, action_fail,
52 action_set):
53 self.test_config.set('openstack-origin-git', openstack_origin_git)
54
55 git_reinstall.git_reinstall()
56
57 git_install.assert_called_with(openstack_origin_git)
58 self.assertTrue(git_install.called)
59 self.assertTrue(config_changed.called)
60 self.assertFalse(action_set.called)
61 self.assertFalse(action_fail.called)
62
63 @patch.object(git_reinstall, 'action_set')
64 @patch.object(git_reinstall, 'action_fail')
65 @patch.object(git_reinstall, 'git_install')
66 @patch.object(git_reinstall, 'config_changed')
67 @patch('charmhelpers.contrib.openstack.utils.config')
68 def test_git_reinstall_not_configured(self, _config, config_changed,
69 git_install, action_fail,
70 action_set):
71 _config.return_value = None
72
73 git_reinstall.git_reinstall()
74
75 msg = 'openstack-origin-git is not configured'
76 action_fail.assert_called_with(msg)
77 self.assertFalse(git_install.called)
78 self.assertFalse(action_set.called)
79
80 @patch.object(git_reinstall, 'action_set')
81 @patch.object(git_reinstall, 'action_fail')
82 @patch.object(git_reinstall, 'git_install')
83 @patch.object(git_reinstall, 'config_changed')
84 @patch('traceback.format_exc')
85 @patch('charmhelpers.contrib.openstack.utils.config')
86 def test_git_reinstall_exception(self, _config, format_exc,
87 config_changed, git_install, action_fail,
88 action_set):
89 _config.return_value = openstack_origin_git
90 e = OSError('something bad happened')
91 git_install.side_effect = e
92 traceback = (
93 "Traceback (most recent call last):\n"
94 " File \"actions/git_reinstall.py\", line 37, in git_reinstall\n"
95 " git_install(config(\'openstack-origin-git\'))\n"
96 " File \"/usr/lib/python2.7/dist-packages/mock.py\", line 964, in __call__\n" # noqa
97 " return _mock_self._mock_call(*args, **kwargs)\n"
98 " File \"/usr/lib/python2.7/dist-packages/mock.py\", line 1019, in _mock_call\n" # noqa
99 " raise effect\n"
100 "OSError: something bad happened\n")
101 format_exc.return_value = traceback
102
103 git_reinstall.git_reinstall()
104
105 msg = 'git-reinstall resulted in an unexpected error'
106 action_fail.assert_called_with(msg)
107 action_set.assert_called_with({'traceback': traceback})
0108
=== modified file 'unit_tests/test_nova_cc_contexts.py'
--- unit_tests/test_nova_cc_contexts.py 2015-04-08 12:10:09 +0000
+++ unit_tests/test_nova_cc_contexts.py 2015-04-16 19:34:57 +0000
@@ -9,9 +9,7 @@
9from charmhelpers.core import hookenv9from charmhelpers.core import hookenv
10_conf = hookenv.config10_conf = hookenv.config
11hookenv.config = mock.MagicMock()11hookenv.config = mock.MagicMock()
12import nova_cc_utils as _utils12import nova_cc_utils as _utils # noqa
13# this assert is a double check + to avoid pep8 warning
14assert _utils.config == hookenv.config
15hookenv.config = _conf13hookenv.config = _conf
16#####14#####
1715
1816
=== modified file 'unit_tests/test_nova_cc_hooks.py'
--- unit_tests/test_nova_cc_hooks.py 2015-03-31 14:56:11 +0000
+++ unit_tests/test_nova_cc_hooks.py 2015-04-16 19:34:57 +0000
@@ -1,6 +1,7 @@
1from mock import MagicMock, patch, call1from mock import MagicMock, patch, call
2from test_utils import CharmTestCase, patch_open2from test_utils import CharmTestCase, patch_open
3import os3import os
4import yaml
45
5with patch('charmhelpers.core.hookenv.config') as config:6with patch('charmhelpers.core.hookenv.config') as config:
6 config.return_value = 'neutron'7 config.return_value = 'neutron'
@@ -69,6 +70,8 @@
69 'get_iface_for_address',70 'get_iface_for_address',
70 'get_netmask_for_address',71 'get_netmask_for_address',
71 'update_nrpe_config',72 'update_nrpe_config',
73 'git_install',
74 'git_install_requested',
72]75]
7376
7477
@@ -106,18 +109,70 @@
106 self.disable_services.assert_called()109 self.disable_services.assert_called()
107 self.cmd_all_services.assert_called_with('stop')110 self.cmd_all_services.assert_called_with('stop')
108111
112 def test_install_hook_git(self):
113 self.git_install_requested.return_value = True
114 self.determine_packages.return_value = ['foo', 'bar']
115 self.determine_ports.return_value = [80, 81, 82]
116 repo = 'cloud:trusty-juno'
117 openstack_origin_git = {
118 'repositories': [
119 {'name': 'requirements',
120 'repository': 'git://git.openstack.org/openstack/requirements', # noqa
121 'branch': 'stable/juno'},
122 {'name': 'nova',
123 'repository': 'git://git.openstack.org/openstack/nova',
124 'branch': 'stable/juno'}
125 ],
126 'directory': '/mnt/openstack-git',
127 }
128 projects_yaml = yaml.dump(openstack_origin_git)
129 self.test_config.set('openstack-origin', repo)
130 self.test_config.set('openstack-origin-git', projects_yaml)
131 hooks.install()
132 self.git_install.assert_called_with(projects_yaml)
133 self.apt_install.assert_called_with(['foo', 'bar'], fatal=True)
134 self.execd_preinstall.assert_called()
135 self.disable_services.assert_called()
136 self.cmd_all_services.assert_called_with('stop')
137
109 @patch.object(hooks, 'configure_https')138 @patch.object(hooks, 'configure_https')
110 def test_config_changed_no_upgrade(self, conf_https):139 def test_config_changed_no_upgrade(self, conf_https):
140 self.git_install_requested.return_value = False
111 self.openstack_upgrade_available.return_value = False141 self.openstack_upgrade_available.return_value = False
112 hooks.config_changed()142 hooks.config_changed()
113 self.assertTrue(self.save_script_rc.called)143 self.assertTrue(self.save_script_rc.called)
114144
145 @patch.object(hooks, 'config_value_changed')
146 @patch.object(hooks, 'configure_https')
147 def test_config_changed_git(self, configure_https, config_val_changed):
148 self.git_install_requested.return_value = True
149 repo = 'cloud:trusty-juno'
150 openstack_origin_git = {
151 'repositories': [
152 {'name': 'requirements',
153 'repository':
154 'git://git.openstack.org/openstack/requirements',
155 'branch': 'stable/juno'},
156 {'name': 'nova',
157 'repository': 'git://git.openstack.org/openstack/nova',
158 'branch': 'stable/juno'}
159 ],
160 'directory': '/mnt/openstack-git',
161 }
162 projects_yaml = yaml.dump(openstack_origin_git)
163 self.test_config.set('openstack-origin', repo)
164 self.test_config.set('openstack-origin-git', projects_yaml)
165 hooks.config_changed()
166 self.git_install.assert_called_with(projects_yaml)
167 self.assertFalse(self.do_openstack_upgrade.called)
168
115 @patch.object(hooks, 'cluster_joined')169 @patch.object(hooks, 'cluster_joined')
116 @patch.object(hooks, 'identity_joined')170 @patch.object(hooks, 'identity_joined')
117 @patch.object(hooks, 'neutron_api_relation_joined')171 @patch.object(hooks, 'neutron_api_relation_joined')
118 @patch.object(hooks, 'configure_https')172 @patch.object(hooks, 'configure_https')
119 def test_config_changed_with_upgrade(self, conf_https, neutron_api_joined,173 def test_config_changed_with_upgrade(self, conf_https, neutron_api_joined,
120 identity_joined, cluster_joined):174 identity_joined, cluster_joined):
175 self.git_install_requested.return_value = False
121 self.openstack_upgrade_available.return_value = True176 self.openstack_upgrade_available.return_value = True
122 self.relation_ids.return_value = ['generic_rid']177 self.relation_ids.return_value = ['generic_rid']
123 _zmq_joined = self.patch('zeromq_configuration_relation_joined')178 _zmq_joined = self.patch('zeromq_configuration_relation_joined')
124179
=== modified file 'unit_tests/test_nova_cc_utils.py'
--- unit_tests/test_nova_cc_utils.py 2014-11-20 16:59:00 +0000
+++ unit_tests/test_nova_cc_utils.py 2015-04-16 19:34:57 +0000
@@ -127,6 +127,15 @@
127 '--option', 'Dpkg::Options::=--force-confdef',127 '--option', 'Dpkg::Options::=--force-confdef',
128]128]
129129
130openstack_origin_git = \
131 """repositories:
132 - {name: requirements,
133 repository: 'git://git.openstack.org/openstack/requirements',
134 branch: stable/juno}
135 - {name: nova,
136 repository: 'git://git.openstack.org/openstack/nova',
137 branch: stable/juno}"""
138
130139
131def fake_plugin_attribute(plugin, attr, net_manager):140def fake_plugin_attribute(plugin, attr, net_manager):
132 if plugin in PLUGIN_ATTRIBUTES:141 if plugin in PLUGIN_ATTRIBUTES:
@@ -298,26 +307,34 @@
298 self.assertEquals(_proxy_page, None)307 self.assertEquals(_proxy_page, None)
299308
300 @patch('charmhelpers.contrib.openstack.context.SubordinateConfigContext')309 @patch('charmhelpers.contrib.openstack.context.SubordinateConfigContext')
301 def test_determine_packages_quantum(self, subcontext):310 @patch.object(utils, 'git_install_requested')
311 def test_determine_packages_quantum(self, git_requested, subcontext):
312 git_requested.return_value = False
302 self._resource_map(network_manager='quantum')313 self._resource_map(network_manager='quantum')
303 pkgs = utils.determine_packages()314 pkgs = utils.determine_packages()
304 self.assertIn('quantum-server', pkgs)315 self.assertIn('quantum-server', pkgs)
305316
306 @patch('charmhelpers.contrib.openstack.context.SubordinateConfigContext')317 @patch('charmhelpers.contrib.openstack.context.SubordinateConfigContext')
307 def test_determine_packages_neutron(self, subcontext):318 @patch.object(utils, 'git_install_requested')
319 def test_determine_packages_neutron(self, git_requested, subcontext):
320 git_requested.return_value = False
308 self.is_relation_made.return_value = False321 self.is_relation_made.return_value = False
309 self._resource_map(network_manager='neutron')322 self._resource_map(network_manager='neutron')
310 pkgs = utils.determine_packages()323 pkgs = utils.determine_packages()
311 self.assertIn('neutron-server', pkgs)324 self.assertIn('neutron-server', pkgs)
312325
313 @patch('charmhelpers.contrib.openstack.context.SubordinateConfigContext')326 @patch('charmhelpers.contrib.openstack.context.SubordinateConfigContext')
314 def test_determine_packages_nova_volume(self, subcontext):327 @patch.object(utils, 'git_install_requested')
328 def test_determine_packages_nova_volume(self, git_requested, subcontext):
329 git_requested.return_value = False
315 self.relation_ids.return_value = ['nova-volume-service:0']330 self.relation_ids.return_value = ['nova-volume-service:0']
316 pkgs = utils.determine_packages()331 pkgs = utils.determine_packages()
317 self.assertIn('nova-api-os-volume', pkgs)332 self.assertIn('nova-api-os-volume', pkgs)
318333
319 @patch('charmhelpers.contrib.openstack.context.SubordinateConfigContext')334 @patch('charmhelpers.contrib.openstack.context.SubordinateConfigContext')
320 def test_determine_packages_console(self, subcontext):335 @patch.object(utils, 'git_install_requested')
336 def test_determine_packages_console(self, git_requested, subcontext):
337 git_requested.return_value = False
321 self.test_config.set('console-access-protocol', 'spice')338 self.test_config.set('console-access-protocol', 'spice')
322 self.relation_ids.return_value = []339 self.relation_ids.return_value = []
323 pkgs = utils.determine_packages()340 pkgs = utils.determine_packages()
@@ -326,7 +343,9 @@
326 self.assertIn(console_pkg, pkgs)343 self.assertIn(console_pkg, pkgs)
327344
328 @patch('charmhelpers.contrib.openstack.context.SubordinateConfigContext')345 @patch('charmhelpers.contrib.openstack.context.SubordinateConfigContext')
329 def test_determine_packages_base(self, subcontext):346 @patch.object(utils, 'git_install_requested')
347 def test_determine_packages_base(self, git_requested, subcontext):
348 git_requested.return_value = False
330 self.relation_ids.return_value = []349 self.relation_ids.return_value = []
331 self.os_release.return_value = 'folsom'350 self.os_release.return_value = 'folsom'
332 pkgs = utils.determine_packages()351 pkgs = utils.determine_packages()
@@ -334,7 +353,10 @@
334 self.assertEquals(ex, pkgs)353 self.assertEquals(ex, pkgs)
335354
336 @patch('charmhelpers.contrib.openstack.context.SubordinateConfigContext')355 @patch('charmhelpers.contrib.openstack.context.SubordinateConfigContext')
337 def test_determine_packages_base_grizzly_beyond(self, subcontext):356 @patch.object(utils, 'git_install_requested')
357 def test_determine_packages_base_grizzly_beyond(self, git_requested,
358 subcontext):
359 git_requested.return_value = False
338 self.relation_ids.return_value = []360 self.relation_ids.return_value = []
339 self.os_release.return_value = 'grizzly'361 self.os_release.return_value = 'grizzly'
340 pkgs = utils.determine_packages()362 pkgs = utils.determine_packages()
@@ -824,3 +846,255 @@
824 self.assertFalse(self.service_running.called)846 self.assertFalse(self.service_running.called)
825 self.assertFalse(self.service_stop.called)847 self.assertFalse(self.service_stop.called)
826 self.assertTrue(contexts.complete_contexts.called)848 self.assertTrue(contexts.complete_contexts.called)
849
850 @patch.object(utils, 'git_install_requested')
851 @patch.object(utils, 'git_clone_and_install')
852 @patch.object(utils, 'git_post_install')
853 @patch.object(utils, 'git_pre_install')
854 def test_git_install(self, git_pre, git_post, git_clone_and_install,
855 git_requested):
856 projects_yaml = openstack_origin_git
857 git_requested.return_value = True
858 utils.git_install(projects_yaml)
859 self.assertTrue(git_pre.called)
860 git_clone_and_install.assert_called_with(openstack_origin_git,
861 core_project='nova')
862 self.assertTrue(git_post.called)
863
864 @patch.object(utils, 'mkdir')
865 @patch.object(utils, 'add_user_to_group')
866 @patch.object(utils, 'add_group')
867 @patch.object(utils, 'adduser')
868 @patch('subprocess.check_call')
869 def test_git_pre_install(self, check_call, adduser, add_group,
870 add_user_to_group, mkdir):
871 utils.git_pre_install()
872 expected = [
873 call('nova', shell='/bin/bash', system_user=True),
874 call('neutron', shell='/bin/bash', system_user=True),
875 ]
876 self.assertEquals(adduser.call_args_list, expected)
877 check_call.assert_called_with(['usermod', '--home', '/var/lib/nova',
878 'nova'])
879 expected = [
880 call('nova', system_group=True),
881 call('neutron', system_group=True),
882 ]
883 self.assertEquals(add_group.call_args_list, expected)
884 expected = [
885 call('nova', 'nova'),
886 call('neutron', 'neutron'),
887 ]
888 self.assertEquals(add_user_to_group.call_args_list, expected)
889 expected = [
890 call('/var/lib/nova', owner='nova',
891 group='nova', perms=0755, force=False),
892 call('/var/lib/nova/buckets', owner='nova',
893 group='nova', perms=0755, force=False),
894 call('/var/lib/nova/CA', owner='nova',
895 group='nova', perms=0755, force=False),
896 call('/var/lib/nova/CA/INTER', owner='nova',
897 group='nova', perms=0755, force=False),
898 call('/var/lib/nova/CA/newcerts', owner='nova',
899 group='nova', perms=0755, force=False),
900 call('/var/lib/nova/CA/private', owner='nova',
901 group='nova', perms=0755, force=False),
902 call('/var/lib/nova/CA/reqs', owner='nova',
903 group='nova', perms=0755, force=False),
904 call('/var/lib/nova/images', owner='nova',
905 group='nova', perms=0755, force=False),
906 call('/var/lib/nova/instances', owner='nova',
907 group='nova', perms=0755, force=False),
908 call('/var/lib/nova/keys', owner='nova',
909 group='nova', perms=0755, force=False),
910 call('/var/lib/nova/networks', owner='nova',
911 group='nova', perms=0755, force=False),
912 call('/var/lib/nova/tmp', owner='nova',
913 group='nova', perms=0755, force=False),
914 call('/var/lib/neutron', owner='nova',
915 group='nova', perms=0755, force=False),
916 call('/var/lib/neutron/lock', owner='nova',
917 group='nova', perms=0755, force=False),
918 call('/var/log/nova', owner='nova',
919 group='nova', perms=0755, force=False),
920 call('/etc/neutron', owner='nova',
921 group='nova', perms=0755, force=False),
922 call('/etc/neutron/plugins', owner='nova',
923 group='nova', perms=0755, force=False),
924 call('/etc/neutron/plugins/ml2', owner='nova',
925 group='nova', perms=0755, force=False),
926 ]
927 self.assertEquals(mkdir.call_args_list, expected)
928
929 @patch.object(utils, 'git_src_dir')
930 @patch.object(utils, 'render')
931 @patch('os.path.join')
932 @patch('os.path.exists')
933 @patch('shutil.copytree')
934 @patch('shutil.rmtree')
935 def test_git_post_install(self, rmtree, copytree, exists, join, render,
936 git_src_dir):
937 projects_yaml = openstack_origin_git
938 join.return_value = 'joined-string'
939 utils.git_post_install(projects_yaml)
940 expected = [
941 call('joined-string', '/etc/nova'),
942 ]
943 copytree.assert_has_calls(expected)
944
945 nova_cc = 'nova-cloud-controller'
946 nova_user = 'nova'
947 start_dir = '/var/lib/nova'
948 nova_conf = '/etc/nova/nova.conf'
949 nova_ec2_api_context = {
950 'service_description': 'Nova EC2 API server',
951 'service_name': nova_cc,
952 'user_name': nova_user,
953 'start_dir': start_dir,
954 'process_name': 'nova-api-ec2',
955 'executable_name': '/usr/local/bin/nova-api-ec2',
956 'config_files': [nova_conf],
957 }
958 nova_api_os_compute_context = {
959 'service_description': 'Nova OpenStack Compute API server',
960 'service_name': nova_cc,
961 'user_name': nova_user,
962 'start_dir': start_dir,
963 'process_name': 'nova-api-os-compute',
964 'executable_name': '/usr/local/bin/nova-api-os-compute',
965 'config_files': [nova_conf],
966 }
967 nova_cells_context = {
968 'service_description': 'Nova cells',
969 'service_name': nova_cc,
970 'user_name': nova_user,
971 'start_dir': start_dir,
972 'process_name': 'nova-cells',
973 'executable_name': '/usr/local/bin/nova-cells',
974 'config_files': [nova_conf],
975 }
976 nova_cert_context = {
977 'service_description': 'Nova cert',
978 'service_name': nova_cc,
979 'user_name': nova_user,
980 'start_dir': start_dir,
981 'process_name': 'nova-cert',
982 'executable_name': '/usr/local/bin/nova-cert',
983 'config_files': [nova_conf],
984 }
985 nova_conductor_context = {
986 'service_description': 'Nova conductor',
987 'service_name': nova_cc,
988 'user_name': nova_user,
989 'start_dir': start_dir,
990 'process_name': 'nova-conductor',
991 'executable_name': '/usr/local/bin/nova-conductor',
992 'config_files': [nova_conf],
993 }
994 nova_consoleauth_context = {
995 'service_description': 'Nova console auth',
996 'service_name': nova_cc,
997 'user_name': nova_user,
998 'start_dir': start_dir,
999 'process_name': 'nova-consoleauth',
1000 'executable_name': '/usr/local/bin/nova-consoleauth',
1001 'config_files': [nova_conf],
1002 }
1003 nova_console_context = {
1004 'service_description': 'Nova console',
1005 'service_name': nova_cc,
1006 'user_name': nova_user,
1007 'start_dir': start_dir,
1008 'process_name': 'nova-console',
1009 'executable_name': '/usr/local/bin/nova-console',
1010 'config_files': [nova_conf],
1011 }
1012 nova_novncproxy_context = {
1013 'service_description': 'Nova NoVNC proxy',
1014 'service_name': nova_cc,
1015 'user_name': nova_user,
1016 'start_dir': start_dir,
1017 'process_name': 'nova-novncproxy',
1018 'executable_name': '/usr/local/bin/nova-novncproxy',
1019 'config_files': [nova_conf],
1020 }
1021 nova_objectstore_context = {
1022 'service_description': 'Nova object store',
1023 'service_name': nova_cc,
1024 'user_name': nova_user,
1025 'start_dir': start_dir,
1026 'process_name': 'nova-objectstore',
1027 'executable_name': '/usr/local/bin/nova-objectstore',
1028 'config_files': [nova_conf],
1029 }
1030 nova_scheduler_context = {
1031 'service_description': 'Nova scheduler',
1032 'service_name': nova_cc,
1033 'user_name': nova_user,
1034 'start_dir': start_dir,
1035 'process_name': 'nova-scheduler',
1036 'executable_name': '/usr/local/bin/nova-scheduler',
1037 'config_files': [nova_conf],
1038 }
1039 nova_spiceproxy_context = {
1040 'service_description': 'Nova spice proxy',
1041 'service_name': nova_cc,
1042 'user_name': nova_user,
1043 'start_dir': start_dir,
1044 'process_name': 'nova-spicehtml5proxy',
1045 'executable_name': '/usr/local/bin/nova-spicehtml5proxy',
1046 'config_files': [nova_conf],
1047 }
1048 nova_xvpvncproxy_context = {
1049 'service_description': 'Nova XVPVNC proxy',
1050 'service_name': nova_cc,
1051 'user_name': nova_user,
1052 'start_dir': start_dir,
1053 'process_name': 'nova-xvpvncproxy',
1054 'executable_name': '/usr/local/bin/nova-xvpvncproxy',
1055 'config_files': [nova_conf],
1056 }
1057 expected = [
1058 call('git/nova_sudoers', '/etc/sudoers.d/nova_sudoers',
1059 {}, perms=0o440),
1060 call('git.upstart', '/etc/init/nova-api-ec2.conf',
1061 nova_ec2_api_context, perms=0o644,
1062 templates_dir='joined-string'),
1063 call('git.upstart', '/etc/init/nova-api-os-compute.conf',
1064 nova_api_os_compute_context, perms=0o644,
1065 templates_dir='joined-string'),
1066 call('git.upstart', '/etc/init/nova-cells.conf',
1067 nova_cells_context, perms=0o644,
1068 templates_dir='joined-string'),
1069 call('git.upstart', '/etc/init/nova-cert.conf',
1070 nova_cert_context, perms=0o644,
1071 templates_dir='joined-string'),
1072 call('git.upstart', '/etc/init/nova-conductor.conf',
1073 nova_conductor_context, perms=0o644,
1074 templates_dir='joined-string'),
1075 call('git.upstart', '/etc/init/nova-consoleauth.conf',
1076 nova_consoleauth_context, perms=0o644,
1077 templates_dir='joined-string'),
1078 call('git.upstart', '/etc/init/nova-console.conf',
1079 nova_console_context, perms=0o644,
1080 templates_dir='joined-string'),
1081 call('git.upstart', '/etc/init/nova-novncproxy.conf',
1082 nova_novncproxy_context, perms=0o644,
1083 templates_dir='joined-string'),
1084 call('git.upstart', '/etc/init/nova-objectstore.conf',
1085 nova_objectstore_context, perms=0o644,
1086 templates_dir='joined-string'),
1087 call('git.upstart', '/etc/init/nova-scheduler.conf',
1088 nova_scheduler_context, perms=0o644,
1089 templates_dir='joined-string'),
1090 call('git.upstart', '/etc/init/nova-spiceproxy.conf',
1091 nova_spiceproxy_context, perms=0o644,
1092 templates_dir='joined-string'),
1093 call('git.upstart', '/etc/init/nova-xvpvncproxy.conf',
1094 nova_xvpvncproxy_context, perms=0o644,
1095 templates_dir='joined-string'),
1096 ]
1097 self.assertEquals(render.call_args_list, expected)
1098 self.assertTrue(self.apt_update.called)
1099 self.apt_install.assert_called_with(['novnc', 'spice-html5',
1100 'websockify'], fatal=True)

Subscribers

People subscribed via source and target branches