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

Proposed by Corey Bryant
Status: Merged
Merged at revision: 166
Proposed branch: lp:~corey.bryant/charms/trusty/nova-cloud-controller/git-ods
Merge into: lp:~openstack-charmers-archive/charms/trusty/nova-cloud-controller/next
Diff against target: 1342 lines (+1001/-21)
17 files modified
.bzrignore (+1/-0)
Makefile (+1/-1)
README.txt (+89/-0)
actions.yaml (+2/-0)
actions/git_reinstall.py (+45/-0)
config.yaml (+16/-0)
hooks/nova_cc_hooks.py (+17/-6)
hooks/nova_cc_utils.py (+323/-3)
templates/git/nova_sudoers (+4/-0)
tests/050-basic-trusty-icehouse-git (+10/-0)
tests/051-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 (+56/-0)
unit_tests/test_nova_cc_utils.py (+289/-6)
To merge this branch: bzr merge lp:~corey.bryant/charms/trusty/nova-cloud-controller/git-ods
Reviewer Review Type Date Requested Status
James Page Needs Fixing
Review via email: mp+258923@code.launchpad.net
To post a comment you must log in.
176. By Corey Bryant

Add libyaml-dev as base git package

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

charm_lint_check #4463 nova-cloud-controller-next for corey.bryant mp258923
    LINT OK: passed

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

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

charm_unit_test #4188 nova-cloud-controller-next for corey.bryant mp258923
    UNIT OK: passed

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

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

charm_amulet_test #4086 nova-cloud-controller-next for corey.bryant mp258923
    AMULET OK: passed

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

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

charm_lint_check #4531 nova-cloud-controller-next for corey.bryant mp258923
    LINT OK: passed

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

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

charm_unit_test #4256 nova-cloud-controller-next for corey.bryant mp258923
    UNIT OK: passed

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

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

charm_amulet_test #4110 nova-cloud-controller-next for corey.bryant mp258923
    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/11118316/
Build: http://10.245.162.77:8080/job/charm_amulet_test/4110/

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

charm_lint_check #4539 nova-cloud-controller-next for corey.bryant mp258923
    LINT OK: passed

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

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

charm_unit_test #4264 nova-cloud-controller-next for corey.bryant mp258923
    UNIT OK: passed

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

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

charm_amulet_test #4118 nova-cloud-controller-next for corey.bryant mp258923
    AMULET OK: passed

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

177. By Corey Bryant

Sync charm-helpers

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

charm_lint_check #4843 nova-cloud-controller-next for corey.bryant mp258923
    LINT OK: passed

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

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

charm_unit_test #4523 nova-cloud-controller-next for corey.bryant mp258923
    UNIT OK: passed

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

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

charm_amulet_test #4334 nova-cloud-controller-next for corey.bryant mp258923
    AMULET OK: passed

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

Revision history for this message
James Page (james-page) wrote :

Looks OK - but see unit test failure on merged branch:

======================================================================
ERROR: test_config_changed_single_consoleauth (unit_tests.test_nova_cc_hooks.NovaCCHooksTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/mock.py", line 1210, in patched
    return func(*args, **keywargs)
  File "/home/jamespage/src/charms/git/nova-cloud-controller/unit_tests/test_nova_cc_hooks.py", line 800, in test_config_changed_single_consoleauth
    hooks.config_changed()
  File "hooks/nova_cc_utils.py", line 1005, in wrapped_f
    f(*args)
  File "hooks/charmhelpers/core/host.py", line 312, in wrapped_f
    f(*args, **kwargs)
  File "hooks/nova_cc_hooks.py", line 180, in config_changed
    if config_value_changed('openstack-origin-git'):
  File "hooks/charmhelpers/contrib/openstack/utils.py", line 346, in config_value_changed
    with hook_data():
  File "/usr/lib/python2.7/contextlib.py", line 17, in __enter__
    return self.gen.next()
  File "hooks/charmhelpers/core/unitdata.py", line 425, in __call__
    self._record_charm_version(hookenv.charm_dir())
  File "hooks/charmhelpers/core/unitdata.py", line 435, in _record_charm_version
    os.path.join(charm_dir, 'revision')).read().strip()
  File "/usr/lib/python2.7/posixpath.py", line 70, in join
    elif path == '' or path.endswith('/'):
AttributeError: 'NoneType' object has no attribute 'endswith'

review: Needs Fixing
178. By Corey Bryant

Merge next branch

179. By Corey Bryant

Update failing unit test

Revision history for this message
Corey Bryant (corey.bryant) wrote :

Thanks for the review! I've merged the latest next branch and updated the failing test.

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

charm_lint_check #5239 nova-cloud-controller-next for corey.bryant mp258923
    LINT OK: passed

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

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

charm_unit_test #4918 nova-cloud-controller-next for corey.bryant mp258923
    UNIT OK: passed

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

180. By Corey Bryant

Merge next branch

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

charm_lint_check #5338 nova-cloud-controller-next for corey.bryant mp258923
    LINT OK: passed

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

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

charm_unit_test #4971 nova-cloud-controller-next for corey.bryant mp258923
    UNIT OK: passed

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

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file '.bzrignore'
--- .bzrignore 2015-04-20 10:21:36 +0000
+++ .bzrignore 2015-06-11 13:34:00 +0000
@@ -1,2 +1,3 @@
1bin1bin
2.coverage2.coverage
3tags
34
=== modified file 'Makefile'
--- Makefile 2015-04-20 10:21:36 +0000
+++ Makefile 2015-06-11 13:34:00 +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:
99
=== modified file 'README.txt'
--- README.txt 2015-04-20 10:21:36 +0000
+++ README.txt 2015-06-11 13:34:00 +0000
@@ -23,3 +23,92 @@
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: include-file://nova-juno.yaml
33
34 nova-juno.yaml
35 repositories:
36 - {name: requirements,
37 repository: 'git://github.com/openstack/requirements',
38 branch: stable/juno}
39 - {name: nova,
40 repository: 'git://github.com/openstack/nova',
41 branch: stable/juno}
42
43Note that there are only two 'name' values the charm knows about: 'requirements'
44and 'nova'. These repositories must correspond to these 'name' values.
45Additionally, the requirements repository must be specified first and the
46nova repository must be specified last. All other repostories are installed
47in the order in which they are specified.
48
49The following is a full list of current tip repos (may not be up-to-date):
50
51 openstack-origin-git: include-file://nova-master.yaml
52
53 nova-master.yaml
54 repositories:
55 - {name: requirements,
56 repository: 'git://github.com/openstack/requirements',
57 branch: master}
58 - {name: oslo-concurrency,
59 repository: 'git://github.com/openstack/oslo.concurrency',
60 branch: master}
61 - {name: oslo-config,
62 repository: 'git://github.com/openstack/oslo.config',
63 branch: master}
64 - {name: oslo-context,
65 repository: 'git://github.com/openstack/oslo.context',
66 branch: master}
67 - {name: oslo-db,
68 repository: 'git://github.com/openstack/oslo.db',
69 branch: master}
70 - {name: oslo-i18n,
71 repository: 'git://github.com/openstack/oslo.i18n',
72 branch: master}
73 - {name: oslo-log,
74 repository: 'git://github.com/openstack/oslo.log',
75 branch: master}
76 - {name: oslo-messaging,
77 repository: 'git://github.com/openstack/oslo.messaging',
78 branch: master}
79 - {name: oslo-middleware,
80 repository': 'git://github.com/openstack/oslo.middleware',
81 branch: master}
82 - {name: oslo-rootwrap',
83 repository: 'git://github.com/openstack/oslo.rootwrap',
84 branch: master}
85 - {name: oslo-serialization,
86 repository: 'git://github.com/openstack/oslo.serialization',
87 branch: master}
88 - {name: oslo-utils,
89 repository: 'git://github.com/openstack/oslo.utils',
90 branch: master}
91 - {name: pbr,
92 repository: 'git://github.com/openstack-dev/pbr',
93 branch: master}
94 - {name: stevedore,
95 repository: 'git://github.com/openstack/stevedore',
96 branch: 'master'}
97 - {name: sqlalchemy-migrate,
98 repository: 'git://github.com/stackforge/sqlalchemy-migrate',
99 branch: master}
100 - {name: python-cinderclient,
101 repository: 'git://github.com/openstack/python-cinderclient',
102 branch: master}
103 - {name: python-glanceclient,
104 repository': 'git://github.com/openstack/python-glanceclient',
105 branch: master}
106 - {name: python-neutronlient,
107 repository': 'git://github.com/openstack/python-neutronclient',
108 branch: master}
109 - {name: keystonemiddleware,
110 repository: 'git://github.com/openstack/keystonemiddleware',
111 branch: master}
112 - {name: nova,
113 repository: 'git://github.com/openstack/nova',
114 branch: master}
26115
=== added directory 'actions'
=== added file 'actions.yaml'
--- actions.yaml 1970-01-01 00:00:00 +0000
+++ actions.yaml 2015-06-11 13:34:00 +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-06-11 13:34:00 +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-06-10 20:32:48 +0000
+++ config.yaml 2015-06-11 13:34:00 +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/nova_cc_hooks.py'
--- hooks/nova_cc_hooks.py 2015-06-04 08:45:01 +0000
+++ hooks/nova_cc_hooks.py 2015-06-11 13:34:00 +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,
@@ -142,9 +145,12 @@
142def install():145def install():
143 execd_preinstall()146 execd_preinstall()
144 configure_installation_source(config('openstack-origin'))147 configure_installation_source(config('openstack-origin'))
148
145 apt_update()149 apt_update()
146 apt_install(determine_packages(), fatal=True)150 apt_install(determine_packages(), fatal=True)
147151
152 git_install(config('openstack-origin-git'))
153
148 _files = os.path.join(charm_dir(), 'files')154 _files = os.path.join(charm_dir(), 'files')
149 if os.path.isdir(_files):155 if os.path.isdir(_files):
150 for f in os.listdir(_files):156 for f in os.listdir(_files):
@@ -170,16 +176,21 @@
170 relation_prefix='nova')176 relation_prefix='nova')
171177
172 global CONFIGS178 global CONFIGS
173 if openstack_upgrade_available('nova-common'):179 if git_install_requested():
174 CONFIGS = do_openstack_upgrade()180 if config_value_changed('openstack-origin-git'):
175 [neutron_api_relation_joined(rid=rid, remote_restart=True)181 git_install(config('openstack-origin-git'))
176 for rid in relation_ids('neutron-api')]182 else:
183 if openstack_upgrade_available('nova-common'):
184 CONFIGS = do_openstack_upgrade()
185 [neutron_api_relation_joined(rid=rid, remote_restart=True)
186 for rid in relation_ids('neutron-api')]
177 save_script_rc()187 save_script_rc()
178 configure_https()188 configure_https()
179 CONFIGS.write_all()189 CONFIGS.write_all()
180 if console_attributes('protocol'):190 if console_attributes('protocol'):
181 apt_update()191 if not git_install_requested():
182 apt_install(console_attributes('packages'), fatal=True)192 apt_update()
193 apt_install(console_attributes('packages'), fatal=True)
183 [compute_joined(rid=rid)194 [compute_joined(rid=rid)
184 for rid in relation_ids('cloud-compute')]195 for rid in relation_ids('cloud-compute')]
185 for r_id in relation_ids('identity-service'):196 for r_id in relation_ids('identity-service'):
186197
=== modified file 'hooks/nova_cc_utils.py'
--- hooks/nova_cc_utils.py 2015-05-11 07:38:35 +0000
+++ hooks/nova_cc_utils.py 2015-06-11 13:34:00 +0000
@@ -1,4 +1,5 @@
1import os1import os
2import shutil
2import subprocess3import subprocess
3import ConfigParser4import ConfigParser
45
@@ -14,11 +15,20 @@
1415
15from charmhelpers.contrib.peerstorage import peer_store16from charmhelpers.contrib.peerstorage import peer_store
1617
18from charmhelpers.contrib.python.packages import (
19 pip_install,
20)
21
17from charmhelpers.contrib.openstack.utils import (22from charmhelpers.contrib.openstack.utils import (
18 configure_installation_source,23 configure_installation_source,
19 get_host_ip,24 get_host_ip,
20 get_hostname,25 get_hostname,
21 get_os_codename_install_source,26 get_os_codename_install_source,
27 git_install_requested,
28 git_clone_and_install,
29 git_src_dir,
30 git_pip_venv_dir,
31 git_yaml_value,
22 is_ip,32 is_ip,
23 os_release,33 os_release,
24 save_script_rc as _save_script_rc)34 save_script_rc as _save_script_rc)
@@ -31,6 +41,7 @@
31)41)
3242
33from charmhelpers.core.hookenv import (43from charmhelpers.core.hookenv import (
44 charm_dir,
34 config,45 config,
35 log,46 log,
36 relation_get,47 relation_get,
@@ -42,13 +53,19 @@
42)53)
4354
44from charmhelpers.core.host import (55from charmhelpers.core.host import (
56 adduser,
57 add_group,
58 add_user_to_group,
59 mkdir,
45 service,60 service,
46 service_start,61 service_start,
47 service_stop,62 service_stop,
48 service_running,63 service_running,
49 lsb_release64 lsb_release,
50)65)
5166
67from charmhelpers.core.templating import render
68
52from charmhelpers.contrib.network.ip import (69from charmhelpers.contrib.network.ip import (
53 is_ipv670 is_ipv6
54)71)
@@ -76,6 +93,46 @@
76 'python-memcache',93 'python-memcache',
77]94]
7895
96BASE_GIT_PACKAGES = [
97 'libffi-dev',
98 'libmysqlclient-dev',
99 'libssl-dev',
100 'libxml2-dev',
101 'libxslt1-dev',
102 'libyaml-dev',
103 'python-dev',
104 'python-pip',
105 'python-setuptools',
106 'zlib1g-dev',
107]
108
109LATE_GIT_PACKAGES = [
110 'novnc',
111 'spice-html5',
112 'websockify',
113]
114
115# ubuntu packages that should not be installed when deploying from git
116GIT_PACKAGE_BLACKLIST = [
117 'neutron-common',
118 'neutron-server',
119 'neutron-plugin-ml2',
120 'nova-api-ec2',
121 'nova-api-os-compute',
122 'nova-api-os-volume',
123 'nova-cert',
124 'nova-conductor',
125 'nova-consoleauth',
126 'nova-novncproxy',
127 'nova-objectstore',
128 'nova-scheduler',
129 'nova-spiceproxy',
130 'nova-xvpvncproxy',
131 'python-keystoneclient',
132 'python-six',
133 'quantum-server',
134]
135
79BASE_SERVICES = [136BASE_SERVICES = [
80 'nova-api-ec2',137 'nova-api-ec2',
81 'nova-api-os-compute',138 'nova-api-os-compute',
@@ -381,6 +438,15 @@
381 packages.extend(pkgs)438 packages.extend(pkgs)
382 if console_attributes('packages'):439 if console_attributes('packages'):
383 packages.extend(console_attributes('packages'))440 packages.extend(console_attributes('packages'))
441
442 if git_install_requested():
443 packages = list(set(packages))
444 packages.extend(BASE_GIT_PACKAGES)
445 # don't include packages that will be installed from git
446 for p in GIT_PACKAGE_BLACKLIST:
447 if p in packages:
448 packages.remove(p)
449
384 return list(set(packages))450 return list(set(packages))
385451
386452
@@ -454,8 +520,8 @@
454 os.unlink('/usr/sbin/policy-rc.d')520 os.unlink('/usr/sbin/policy-rc.d')
455521
456522
457QUANTUM_DB_MANAGE = "/usr/bin/quantum-db-manage"523QUANTUM_DB_MANAGE = "quantum-db-manage"
458NEUTRON_DB_MANAGE = "/usr/bin/neutron-db-manage"524NEUTRON_DB_MANAGE = "neutron-db-manage"
459525
460526
461def reset_os_release():527def reset_os_release():
@@ -985,3 +1051,257 @@
985 ' main')1051 ' main')
986 apt_update()1052 apt_update()
987 apt_install('haproxy/trusty-backports', fatal=True)1053 apt_install('haproxy/trusty-backports', fatal=True)
1054
1055
1056def git_install(projects_yaml):
1057 """Perform setup, and install git repos specified in yaml parameter."""
1058 if git_install_requested():
1059 git_pre_install()
1060 git_clone_and_install(projects_yaml, core_project='nova')
1061 git_post_install(projects_yaml)
1062
1063
1064def git_pre_install():
1065 """Perform pre-install setup."""
1066 dirs = [
1067 '/var/lib/nova',
1068 '/var/lib/nova/buckets',
1069 '/var/lib/nova/CA',
1070 '/var/lib/nova/CA/INTER',
1071 '/var/lib/nova/CA/newcerts',
1072 '/var/lib/nova/CA/private',
1073 '/var/lib/nova/CA/reqs',
1074 '/var/lib/nova/images',
1075 '/var/lib/nova/instances',
1076 '/var/lib/nova/keys',
1077 '/var/lib/nova/networks',
1078 '/var/lib/nova/tmp',
1079 '/var/lib/neutron',
1080 '/var/lib/neutron/lock',
1081 '/var/log/nova',
1082 '/etc/neutron',
1083 '/etc/neutron/plugins',
1084 '/etc/neutron/plugins/ml2',
1085 ]
1086
1087 adduser('nova', shell='/bin/bash', system_user=True)
1088 subprocess.check_call(['usermod', '--home', '/var/lib/nova', 'nova'])
1089 add_group('nova', system_group=True)
1090 add_user_to_group('nova', 'nova')
1091
1092 adduser('neutron', shell='/bin/bash', system_user=True)
1093 add_group('neutron', system_group=True)
1094 add_user_to_group('neutron', 'neutron')
1095
1096 for d in dirs:
1097 mkdir(d, owner='nova', group='nova', perms=0755, force=False)
1098
1099
1100def git_post_install(projects_yaml):
1101 """Perform post-install setup."""
1102 http_proxy = git_yaml_value(projects_yaml, 'http_proxy')
1103 if http_proxy:
1104 pip_install('mysql-python', proxy=http_proxy,
1105 venv=git_pip_venv_dir(projects_yaml))
1106 else:
1107 pip_install('mysql-python',
1108 venv=git_pip_venv_dir(projects_yaml))
1109
1110 src_etc = os.path.join(git_src_dir(projects_yaml, 'nova'), 'etc/nova')
1111 configs = [
1112 {'src': src_etc,
1113 'dest': '/etc/nova'},
1114 ]
1115
1116 for c in configs:
1117 if os.path.exists(c['dest']):
1118 shutil.rmtree(c['dest'])
1119 shutil.copytree(c['src'], c['dest'])
1120
1121 # NOTE(coreycb): Need to find better solution than bin symlinks.
1122 symlinks = [
1123 {'src': os.path.join(git_pip_venv_dir(projects_yaml),
1124 'bin/nova-manage'),
1125 'link': '/usr/local/bin/nova-manage'},
1126 {'src': os.path.join(git_pip_venv_dir(projects_yaml),
1127 'bin/nova-rootwrap'),
1128 'link': '/usr/local/bin/nova-rootwrap'},
1129 ]
1130
1131 for s in symlinks:
1132 if os.path.lexists(s['link']):
1133 os.remove(s['link'])
1134 os.symlink(s['src'], s['link'])
1135
1136 render('git/nova_sudoers', '/etc/sudoers.d/nova_sudoers', {}, perms=0o440)
1137
1138 nova_cc = 'nova-cloud-controller'
1139 nova_user = 'nova'
1140 start_dir = '/var/lib/nova'
1141 bin_dir = os.path.join(git_pip_venv_dir(projects_yaml), 'bin')
1142 nova_conf = '/etc/nova/nova.conf'
1143 nova_ec2_api_context = {
1144 'service_description': 'Nova EC2 API server',
1145 'service_name': nova_cc,
1146 'user_name': nova_user,
1147 'start_dir': start_dir,
1148 'process_name': 'nova-api-ec2',
1149 'executable_name': os.path.join(bin_dir, 'nova-api-ec2'),
1150 'config_files': [nova_conf],
1151 }
1152 nova_api_os_compute_context = {
1153 'service_description': 'Nova OpenStack Compute API server',
1154 'service_name': nova_cc,
1155 'user_name': nova_user,
1156 'start_dir': start_dir,
1157 'process_name': 'nova-api-os-compute',
1158 'executable_name': os.path.join(bin_dir, 'nova-api-os-compute'),
1159 'config_files': [nova_conf],
1160 }
1161 nova_cells_context = {
1162 'service_description': 'Nova cells',
1163 'service_name': nova_cc,
1164 'user_name': nova_user,
1165 'start_dir': start_dir,
1166 'process_name': 'nova-cells',
1167 'executable_name': os.path.join(bin_dir, 'nova-cells'),
1168 'config_files': [nova_conf],
1169 }
1170 nova_cert_context = {
1171 'service_description': 'Nova cert',
1172 'service_name': nova_cc,
1173 'user_name': nova_user,
1174 'start_dir': start_dir,
1175 'process_name': 'nova-cert',
1176 'executable_name': os.path.join(bin_dir, 'nova-cert'),
1177 'config_files': [nova_conf],
1178 }
1179 nova_conductor_context = {
1180 'service_description': 'Nova conductor',
1181 'service_name': nova_cc,
1182 'user_name': nova_user,
1183 'start_dir': start_dir,
1184 'process_name': 'nova-conductor',
1185 'executable_name': os.path.join(bin_dir, 'nova-conductor'),
1186 'config_files': [nova_conf],
1187 }
1188 nova_consoleauth_context = {
1189 'service_description': 'Nova console auth',
1190 'service_name': nova_cc,
1191 'user_name': nova_user,
1192 'start_dir': start_dir,
1193 'process_name': 'nova-consoleauth',
1194 'executable_name': os.path.join(bin_dir, 'nova-consoleauth'),
1195 'config_files': [nova_conf],
1196 }
1197 nova_console_context = {
1198 'service_description': 'Nova console',
1199 'service_name': nova_cc,
1200 'user_name': nova_user,
1201 'start_dir': start_dir,
1202 'process_name': 'nova-console',
1203 'executable_name': os.path.join(bin_dir, 'nova-console'),
1204 'config_files': [nova_conf],
1205 }
1206 nova_novncproxy_context = {
1207 'service_description': 'Nova NoVNC proxy',
1208 'service_name': nova_cc,
1209 'user_name': nova_user,
1210 'start_dir': start_dir,
1211 'process_name': 'nova-novncproxy',
1212 'executable_name': os.path.join(bin_dir, 'nova-novncproxy'),
1213 'config_files': [nova_conf],
1214 }
1215 nova_objectstore_context = {
1216 'service_description': 'Nova object store',
1217 'service_name': nova_cc,
1218 'user_name': nova_user,
1219 'start_dir': start_dir,
1220 'process_name': 'nova-objectstore',
1221 'executable_name': os.path.join(bin_dir, 'nova-objectstore'),
1222 'config_files': [nova_conf],
1223 }
1224 nova_scheduler_context = {
1225 'service_description': 'Nova scheduler',
1226 'service_name': nova_cc,
1227 'user_name': nova_user,
1228 'start_dir': start_dir,
1229 'process_name': 'nova-scheduler',
1230 'executable_name': os.path.join(bin_dir, 'nova-scheduler'),
1231 'config_files': [nova_conf],
1232 }
1233 nova_serialproxy_context = {
1234 'service_description': 'Nova serial proxy',
1235 'service_name': nova_cc,
1236 'user_name': nova_user,
1237 'start_dir': start_dir,
1238 'process_name': 'nova-serialproxy',
1239 'executable_name': os.path.join(bin_dir, 'nova-serialproxy'),
1240 'config_files': [nova_conf],
1241 }
1242 nova_spiceproxy_context = {
1243 'service_description': 'Nova spice proxy',
1244 'service_name': nova_cc,
1245 'user_name': nova_user,
1246 'start_dir': start_dir,
1247 'process_name': 'nova-spicehtml5proxy',
1248 'executable_name': os.path.join(bin_dir, 'nova-spicehtml5proxy'),
1249 'config_files': [nova_conf],
1250 }
1251 nova_xvpvncproxy_context = {
1252 'service_description': 'Nova XVPVNC proxy',
1253 'service_name': nova_cc,
1254 'user_name': nova_user,
1255 'start_dir': start_dir,
1256 'process_name': 'nova-xvpvncproxy',
1257 'executable_name': os.path.join(bin_dir, 'nova-xvpvncproxy'),
1258 'config_files': [nova_conf],
1259 }
1260
1261 # NOTE(coreycb): Needs systemd support
1262 templates_dir = 'hooks/charmhelpers/contrib/openstack/templates'
1263 templates_dir = os.path.join(charm_dir(), templates_dir)
1264 os_rel = os_release('nova-common')
1265 render('git.upstart', '/etc/init/nova-api-ec2.conf',
1266 nova_ec2_api_context, perms=0o644,
1267 templates_dir=templates_dir)
1268 render('git.upstart', '/etc/init/nova-api-os-compute.conf',
1269 nova_api_os_compute_context, perms=0o644,
1270 templates_dir=templates_dir)
1271 render('git.upstart', '/etc/init/nova-cells.conf',
1272 nova_cells_context, perms=0o644,
1273 templates_dir=templates_dir)
1274 render('git.upstart', '/etc/init/nova-cert.conf',
1275 nova_cert_context, perms=0o644,
1276 templates_dir=templates_dir)
1277 render('git.upstart', '/etc/init/nova-conductor.conf',
1278 nova_conductor_context, perms=0o644,
1279 templates_dir=templates_dir)
1280 render('git.upstart', '/etc/init/nova-consoleauth.conf',
1281 nova_consoleauth_context, perms=0o644,
1282 templates_dir=templates_dir)
1283 render('git.upstart', '/etc/init/nova-console.conf',
1284 nova_console_context, perms=0o644,
1285 templates_dir=templates_dir)
1286 render('git.upstart', '/etc/init/nova-novncproxy.conf',
1287 nova_novncproxy_context, perms=0o644,
1288 templates_dir=templates_dir)
1289 render('git.upstart', '/etc/init/nova-objectstore.conf',
1290 nova_objectstore_context, perms=0o644,
1291 templates_dir=templates_dir)
1292 render('git.upstart', '/etc/init/nova-scheduler.conf',
1293 nova_scheduler_context, perms=0o644,
1294 templates_dir=templates_dir)
1295 if os_rel >= 'juno':
1296 render('git.upstart', '/etc/init/nova-serialproxy.conf',
1297 nova_serialproxy_context, perms=0o644,
1298 templates_dir=templates_dir)
1299 render('git.upstart', '/etc/init/nova-spiceproxy.conf',
1300 nova_spiceproxy_context, perms=0o644,
1301 templates_dir=templates_dir)
1302 render('git.upstart', '/etc/init/nova-xvpvncproxy.conf',
1303 nova_xvpvncproxy_context, perms=0o644,
1304 templates_dir=templates_dir)
1305
1306 apt_update()
1307 apt_install(LATE_GIT_PACKAGES, fatal=True)
9881308
=== 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-06-11 13:34:00 +0000
@@ -0,0 +1,4 @@
1Defaults:nova !requiretty
2
3nova ALL = (root) NOPASSWD: /usr/local/bin/nova-rootwrap /etc/nova/rootwrap.conf *
4
05
=== added file 'tests/050-basic-trusty-icehouse-git'
--- tests/050-basic-trusty-icehouse-git 1970-01-01 00:00:00 +0000
+++ tests/050-basic-trusty-icehouse-git 2015-06-11 13:34:00 +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/051-basic-trusty-juno-git'
--- tests/051-basic-trusty-juno-git 1970-01-01 00:00:00 +0000
+++ tests/051-basic-trusty-juno-git 2015-06-11 13:34:00 +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-20 10:21:36 +0000
+++ tests/basic_deployment.py 2015-06-11 13:34:00 +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://github.com/openstack/requirements',
77 'branch': branch},
78 {'name': 'nova',
79 'repository': 'git://github.com/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 2015-04-20 10:21:36 +0000
+++ unit_tests/__init__.py 2015-06-11 13:34:00 +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-06-11 13:34:00 +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-06-03 00:06:30 +0000
+++ unit_tests/test_nova_cc_contexts.py 2015-06-11 13:34:00 +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-06-10 20:32:48 +0000
+++ unit_tests/test_nova_cc_hooks.py 2015-06-11 13:34:00 +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
4import tempfile5import tempfile
56
6with patch('charmhelpers.core.hookenv.config') as config:7with patch('charmhelpers.core.hookenv.config') as config:
@@ -70,6 +71,8 @@
70 'get_iface_for_address',71 'get_iface_for_address',
71 'get_netmask_for_address',72 'get_netmask_for_address',
72 'update_nrpe_config',73 'update_nrpe_config',
74 'git_install',
75 'git_install_requested',
73]76]
7477
7578
@@ -116,12 +119,63 @@
116 self.disable_services.assert_called()119 self.disable_services.assert_called()
117 self.cmd_all_services.assert_called_with('stop')120 self.cmd_all_services.assert_called_with('stop')
118121
122 def test_install_hook_git(self):
123 self.git_install_requested.return_value = True
124 self.determine_packages.return_value = ['foo', 'bar']
125 self.determine_ports.return_value = [80, 81, 82]
126 repo = 'cloud:trusty-juno'
127 openstack_origin_git = {
128 'repositories': [
129 {'name': 'requirements',
130 'repository': 'git://git.openstack.org/openstack/requirements', # noqa
131 'branch': 'stable/juno'},
132 {'name': 'nova',
133 'repository': 'git://git.openstack.org/openstack/nova',
134 'branch': 'stable/juno'}
135 ],
136 'directory': '/mnt/openstack-git',
137 }
138 projects_yaml = yaml.dump(openstack_origin_git)
139 self.test_config.set('openstack-origin', repo)
140 self.test_config.set('openstack-origin-git', projects_yaml)
141 hooks.install()
142 self.git_install.assert_called_with(projects_yaml)
143 self.apt_install.assert_called_with(['foo', 'bar'], fatal=True)
144 self.execd_preinstall.assert_called()
145 self.disable_services.assert_called()
146 self.cmd_all_services.assert_called_with('stop')
147
119 @patch.object(hooks, 'configure_https')148 @patch.object(hooks, 'configure_https')
120 def test_config_changed_no_upgrade(self, conf_https):149 def test_config_changed_no_upgrade(self, conf_https):
150 self.git_install_requested.return_value = False
121 self.openstack_upgrade_available.return_value = False151 self.openstack_upgrade_available.return_value = False
122 hooks.config_changed()152 hooks.config_changed()
123 self.assertTrue(self.save_script_rc.called)153 self.assertTrue(self.save_script_rc.called)
124154
155 @patch.object(hooks, 'config_value_changed')
156 @patch.object(hooks, 'configure_https')
157 def test_config_changed_git(self, configure_https, config_val_changed):
158 self.git_install_requested.return_value = True
159 repo = 'cloud:trusty-juno'
160 openstack_origin_git = {
161 'repositories': [
162 {'name': 'requirements',
163 'repository':
164 'git://git.openstack.org/openstack/requirements',
165 'branch': 'stable/juno'},
166 {'name': 'nova',
167 'repository': 'git://git.openstack.org/openstack/nova',
168 'branch': 'stable/juno'}
169 ],
170 'directory': '/mnt/openstack-git',
171 }
172 projects_yaml = yaml.dump(openstack_origin_git)
173 self.test_config.set('openstack-origin', repo)
174 self.test_config.set('openstack-origin-git', projects_yaml)
175 hooks.config_changed()
176 self.git_install.assert_called_with(projects_yaml)
177 self.assertFalse(self.do_openstack_upgrade.called)
178
125 @patch('charmhelpers.contrib.openstack.ip.service_name',179 @patch('charmhelpers.contrib.openstack.ip.service_name',
126 lambda *args: 'nova-cloud-controller')180 lambda *args: 'nova-cloud-controller')
127 @patch.object(hooks, 'cluster_joined')181 @patch.object(hooks, 'cluster_joined')
@@ -130,6 +184,7 @@
130 @patch.object(hooks, 'configure_https')184 @patch.object(hooks, 'configure_https')
131 def test_config_changed_with_upgrade(self, conf_https, neutron_api_joined,185 def test_config_changed_with_upgrade(self, conf_https, neutron_api_joined,
132 identity_joined, cluster_joined):186 identity_joined, cluster_joined):
187 self.git_install_requested.return_value = False
133 self.openstack_upgrade_available.return_value = True188 self.openstack_upgrade_available.return_value = True
134 self.relation_ids.return_value = ['generic_rid']189 self.relation_ids.return_value = ['generic_rid']
135 _zmq_joined = self.patch('zeromq_configuration_relation_joined')190 _zmq_joined = self.patch('zeromq_configuration_relation_joined')
@@ -768,6 +823,7 @@
768 @patch('nova_cc_hooks.configure_https')823 @patch('nova_cc_hooks.configure_https')
769 @patch('nova_cc_utils.config')824 @patch('nova_cc_utils.config')
770 def test_config_changed_single_consoleauth(self, config, *args):825 def test_config_changed_single_consoleauth(self, config, *args):
826 self.git_install_requested.return_value = False
771 config.return_value = 'novnc'827 config.return_value = 'novnc'
772 rids = {'ha': ['ha:1']}828 rids = {'ha': ['ha:1']}
773829
774830
=== modified file 'unit_tests/test_nova_cc_utils.py'
--- unit_tests/test_nova_cc_utils.py 2015-05-11 09:51:21 +0000
+++ unit_tests/test_nova_cc_utils.py 2015-06-11 13:34:00 +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()
@@ -847,3 +869,264 @@
847 self.assertFalse(self.service_running.called)869 self.assertFalse(self.service_running.called)
848 self.assertFalse(self.service_stop.called)870 self.assertFalse(self.service_stop.called)
849 self.assertTrue(contexts.complete_contexts.called)871 self.assertTrue(contexts.complete_contexts.called)
872
873 @patch.object(utils, 'git_install_requested')
874 @patch.object(utils, 'git_clone_and_install')
875 @patch.object(utils, 'git_post_install')
876 @patch.object(utils, 'git_pre_install')
877 def test_git_install(self, git_pre, git_post, git_clone_and_install,
878 git_requested):
879 projects_yaml = openstack_origin_git
880 git_requested.return_value = True
881 utils.git_install(projects_yaml)
882 self.assertTrue(git_pre.called)
883 git_clone_and_install.assert_called_with(openstack_origin_git,
884 core_project='nova')
885 self.assertTrue(git_post.called)
886
887 @patch.object(utils, 'mkdir')
888 @patch.object(utils, 'add_user_to_group')
889 @patch.object(utils, 'add_group')
890 @patch.object(utils, 'adduser')
891 @patch('subprocess.check_call')
892 def test_git_pre_install(self, check_call, adduser, add_group,
893 add_user_to_group, mkdir):
894 utils.git_pre_install()
895 expected = [
896 call('nova', shell='/bin/bash', system_user=True),
897 call('neutron', shell='/bin/bash', system_user=True),
898 ]
899 self.assertEquals(adduser.call_args_list, expected)
900 check_call.assert_called_with(['usermod', '--home', '/var/lib/nova',
901 'nova'])
902 expected = [
903 call('nova', system_group=True),
904 call('neutron', system_group=True),
905 ]
906 self.assertEquals(add_group.call_args_list, expected)
907 expected = [
908 call('nova', 'nova'),
909 call('neutron', 'neutron'),
910 ]
911 self.assertEquals(add_user_to_group.call_args_list, expected)
912 expected = [
913 call('/var/lib/nova', owner='nova',
914 group='nova', perms=0755, force=False),
915 call('/var/lib/nova/buckets', owner='nova',
916 group='nova', perms=0755, force=False),
917 call('/var/lib/nova/CA', owner='nova',
918 group='nova', perms=0755, force=False),
919 call('/var/lib/nova/CA/INTER', owner='nova',
920 group='nova', perms=0755, force=False),
921 call('/var/lib/nova/CA/newcerts', owner='nova',
922 group='nova', perms=0755, force=False),
923 call('/var/lib/nova/CA/private', owner='nova',
924 group='nova', perms=0755, force=False),
925 call('/var/lib/nova/CA/reqs', owner='nova',
926 group='nova', perms=0755, force=False),
927 call('/var/lib/nova/images', owner='nova',
928 group='nova', perms=0755, force=False),
929 call('/var/lib/nova/instances', owner='nova',
930 group='nova', perms=0755, force=False),
931 call('/var/lib/nova/keys', owner='nova',
932 group='nova', perms=0755, force=False),
933 call('/var/lib/nova/networks', owner='nova',
934 group='nova', perms=0755, force=False),
935 call('/var/lib/nova/tmp', owner='nova',
936 group='nova', perms=0755, force=False),
937 call('/var/lib/neutron', owner='nova',
938 group='nova', perms=0755, force=False),
939 call('/var/lib/neutron/lock', owner='nova',
940 group='nova', perms=0755, force=False),
941 call('/var/log/nova', owner='nova',
942 group='nova', perms=0755, force=False),
943 call('/etc/neutron', owner='nova',
944 group='nova', perms=0755, force=False),
945 call('/etc/neutron/plugins', owner='nova',
946 group='nova', perms=0755, force=False),
947 call('/etc/neutron/plugins/ml2', owner='nova',
948 group='nova', perms=0755, force=False),
949 ]
950 self.assertEquals(mkdir.call_args_list, expected)
951
952 @patch.object(utils, 'git_src_dir')
953 @patch.object(utils, 'render')
954 @patch.object(utils, 'git_pip_venv_dir')
955 @patch.object(utils, 'pip_install')
956 @patch('os.path.join')
957 @patch('os.path.exists')
958 @patch('os.symlink')
959 @patch('shutil.copytree')
960 @patch('shutil.rmtree')
961 def test_git_post_install(self, rmtree, copytree, symlink,
962 exists, join, pip_install, venv, render,
963 git_src_dir):
964 projects_yaml = openstack_origin_git
965 join.return_value = 'joined-string'
966 venv.return_value = '/mnt/openstack-git/venv'
967 utils.git_post_install(projects_yaml)
968 expected = [
969 call('joined-string', '/etc/nova'),
970 ]
971 copytree.assert_has_calls(expected)
972 expected = [
973 call('joined-string', '/usr/local/bin/nova-manage'),
974 call('joined-string', '/usr/local/bin/nova-rootwrap'),
975 ]
976
977 nova_cc = 'nova-cloud-controller'
978 nova_user = 'nova'
979 start_dir = '/var/lib/nova'
980 nova_conf = '/etc/nova/nova.conf'
981 nova_ec2_api_context = {
982 'service_description': 'Nova EC2 API server',
983 'service_name': nova_cc,
984 'user_name': nova_user,
985 'start_dir': start_dir,
986 'process_name': 'nova-api-ec2',
987 'executable_name': 'joined-string',
988 'config_files': [nova_conf],
989 }
990 nova_api_os_compute_context = {
991 'service_description': 'Nova OpenStack Compute API server',
992 'service_name': nova_cc,
993 'user_name': nova_user,
994 'start_dir': start_dir,
995 'process_name': 'nova-api-os-compute',
996 'executable_name': 'joined-string',
997 'config_files': [nova_conf],
998 }
999 nova_cells_context = {
1000 'service_description': 'Nova cells',
1001 'service_name': nova_cc,
1002 'user_name': nova_user,
1003 'start_dir': start_dir,
1004 'process_name': 'nova-cells',
1005 'executable_name': 'joined-string',
1006 'config_files': [nova_conf],
1007 }
1008 nova_cert_context = {
1009 'service_description': 'Nova cert',
1010 'service_name': nova_cc,
1011 'user_name': nova_user,
1012 'start_dir': start_dir,
1013 'process_name': 'nova-cert',
1014 'executable_name': 'joined-string',
1015 'config_files': [nova_conf],
1016 }
1017 nova_conductor_context = {
1018 'service_description': 'Nova conductor',
1019 'service_name': nova_cc,
1020 'user_name': nova_user,
1021 'start_dir': start_dir,
1022 'process_name': 'nova-conductor',
1023 'executable_name': 'joined-string',
1024 'config_files': [nova_conf],
1025 }
1026 nova_consoleauth_context = {
1027 'service_description': 'Nova console auth',
1028 'service_name': nova_cc,
1029 'user_name': nova_user,
1030 'start_dir': start_dir,
1031 'process_name': 'nova-consoleauth',
1032 'executable_name': 'joined-string',
1033 'config_files': [nova_conf],
1034 }
1035 nova_console_context = {
1036 'service_description': 'Nova console',
1037 'service_name': nova_cc,
1038 'user_name': nova_user,
1039 'start_dir': start_dir,
1040 'process_name': 'nova-console',
1041 'executable_name': 'joined-string',
1042 'config_files': [nova_conf],
1043 }
1044 nova_novncproxy_context = {
1045 'service_description': 'Nova NoVNC proxy',
1046 'service_name': nova_cc,
1047 'user_name': nova_user,
1048 'start_dir': start_dir,
1049 'process_name': 'nova-novncproxy',
1050 'executable_name': 'joined-string',
1051 'config_files': [nova_conf],
1052 }
1053 nova_objectstore_context = {
1054 'service_description': 'Nova object store',
1055 'service_name': nova_cc,
1056 'user_name': nova_user,
1057 'start_dir': start_dir,
1058 'process_name': 'nova-objectstore',
1059 'executable_name': 'joined-string',
1060 'config_files': [nova_conf],
1061 }
1062 nova_scheduler_context = {
1063 'service_description': 'Nova scheduler',
1064 'service_name': nova_cc,
1065 'user_name': nova_user,
1066 'start_dir': start_dir,
1067 'process_name': 'nova-scheduler',
1068 'executable_name': 'joined-string',
1069 'config_files': [nova_conf],
1070 }
1071 nova_spiceproxy_context = {
1072 'service_description': 'Nova spice proxy',
1073 'service_name': nova_cc,
1074 'user_name': nova_user,
1075 'start_dir': start_dir,
1076 'process_name': 'nova-spicehtml5proxy',
1077 'executable_name': 'joined-string',
1078 'config_files': [nova_conf],
1079 }
1080 nova_xvpvncproxy_context = {
1081 'service_description': 'Nova XVPVNC proxy',
1082 'service_name': nova_cc,
1083 'user_name': nova_user,
1084 'start_dir': start_dir,
1085 'process_name': 'nova-xvpvncproxy',
1086 'executable_name': 'joined-string',
1087 'config_files': [nova_conf],
1088 }
1089 expected = [
1090 call('git/nova_sudoers', '/etc/sudoers.d/nova_sudoers',
1091 {}, perms=0o440),
1092 call('git.upstart', '/etc/init/nova-api-ec2.conf',
1093 nova_ec2_api_context, perms=0o644,
1094 templates_dir='joined-string'),
1095 call('git.upstart', '/etc/init/nova-api-os-compute.conf',
1096 nova_api_os_compute_context, perms=0o644,
1097 templates_dir='joined-string'),
1098 call('git.upstart', '/etc/init/nova-cells.conf',
1099 nova_cells_context, perms=0o644,
1100 templates_dir='joined-string'),
1101 call('git.upstart', '/etc/init/nova-cert.conf',
1102 nova_cert_context, perms=0o644,
1103 templates_dir='joined-string'),
1104 call('git.upstart', '/etc/init/nova-conductor.conf',
1105 nova_conductor_context, perms=0o644,
1106 templates_dir='joined-string'),
1107 call('git.upstart', '/etc/init/nova-consoleauth.conf',
1108 nova_consoleauth_context, perms=0o644,
1109 templates_dir='joined-string'),
1110 call('git.upstart', '/etc/init/nova-console.conf',
1111 nova_console_context, perms=0o644,
1112 templates_dir='joined-string'),
1113 call('git.upstart', '/etc/init/nova-novncproxy.conf',
1114 nova_novncproxy_context, perms=0o644,
1115 templates_dir='joined-string'),
1116 call('git.upstart', '/etc/init/nova-objectstore.conf',
1117 nova_objectstore_context, perms=0o644,
1118 templates_dir='joined-string'),
1119 call('git.upstart', '/etc/init/nova-scheduler.conf',
1120 nova_scheduler_context, perms=0o644,
1121 templates_dir='joined-string'),
1122 call('git.upstart', '/etc/init/nova-spiceproxy.conf',
1123 nova_spiceproxy_context, perms=0o644,
1124 templates_dir='joined-string'),
1125 call('git.upstart', '/etc/init/nova-xvpvncproxy.conf',
1126 nova_xvpvncproxy_context, perms=0o644,
1127 templates_dir='joined-string'),
1128 ]
1129 self.assertEquals(render.call_args_list, expected)
1130 self.assertTrue(self.apt_update.called)
1131 self.apt_install.assert_called_with(['novnc', 'spice-html5',
1132 'websockify'], fatal=True)

Subscribers

People subscribed via source and target branches