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

Proposed by Corey Bryant
Status: Merged
Merged at revision: 123
Proposed branch: lp:~corey.bryant/charms/trusty/nova-compute/git
Merge into: lp:~openstack-charmers-archive/charms/trusty/nova-compute/next
Diff against target: 1288 lines (+811/-65)
29 files modified
.bzrignore (+1/-0)
Makefile (+4/-2)
README.md (+88/-3)
actions.yaml (+2/-0)
actions/git_reinstall.py (+45/-0)
config.yaml (+16/-0)
hooks/charmhelpers/contrib/openstack/utils.py (+4/-1)
hooks/nova_compute_hooks.py (+12/-2)
hooks/nova_compute_utils.py (+191/-2)
templates/git/nova-compute-kvm.conf (+4/-0)
templates/git/nova-compute-lxc.conf (+4/-0)
templates/git/nova-compute-qemu.conf (+4/-0)
templates/git/nova-compute-vmware.conf (+2/-0)
templates/git/nova-compute-xen.conf (+4/-0)
templates/git/nova_sudoers (+4/-0)
templates/git/nova_tgt.conf (+1/-0)
templates/git/upstart/nova-compute.upstart (+27/-0)
tests/10-basic-precise-essex (+0/-9)
tests/11-basic-precise-folsom (+0/-17)
tests/12-basic-precise-grizzly (+0/-11)
tests/13-basic-precise-havana (+0/-11)
tests/16-basic-trusty-icehouse-git (+9/-0)
tests/17-basic-trusty-juno (+11/-0)
tests/18-basic-trusty-juno-git (+12/-0)
tests/basic_deployment.py (+23/-1)
unit_tests/__init__.py (+1/-0)
unit_tests/test_actions_git_reinstall.py (+96/-0)
unit_tests/test_nova_compute_hooks.py (+57/-0)
unit_tests/test_nova_compute_utils.py (+189/-6)
To merge this branch: bzr merge lp:~corey.bryant/charms/trusty/nova-compute/git
Reviewer Review Type Date Requested Status
OpenStack Charmers Pending
Review via email: mp+255945@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 #3331 nova-compute-next for corey.bryant mp255945
    LINT OK: passed

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

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

charm_unit_test #3119 nova-compute-next for corey.bryant mp255945
    UNIT FAIL: unit-test failed

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

Full unit test output: http://paste.ubuntu.com/10823600/
Build: http://10.245.162.77:8080/job/charm_unit_test/3119/

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

charm_lint_check #3334 nova-compute-next for corey.bryant mp255945
    LINT OK: passed

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

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

charm_unit_test #3122 nova-compute-next for corey.bryant mp255945
    UNIT OK: passed

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

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

charm_amulet_test #3153 nova-compute-next for corey.bryant mp255945
    AMULET OK: passed

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

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

charm_amulet_test #3157 nova-compute-next for corey.bryant mp255945
    AMULET OK: passed

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

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

charm_lint_check #3383 nova-compute-next for corey.bryant mp255945
    LINT OK: passed

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

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

charm_unit_test #3171 nova-compute-next for corey.bryant mp255945
    UNIT OK: passed

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

118. By Corey Bryant

Deploy from source

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

charm_lint_check #3387 nova-compute-next for corey.bryant mp255945
    LINT OK: passed

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

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

charm_unit_test #3175 nova-compute-next for corey.bryant mp255945
    UNIT OK: passed

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

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

charm_amulet_test #3171 nova-compute-next for corey.bryant mp255945
    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/10827143/
Build: http://10.245.162.77:8080/job/charm_amulet_test/3171/

119. By Corey Bryant

Fixup test_git_reinstall_exception()

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

charm_amulet_test #3177 nova-compute-next for corey.bryant mp255945
    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/10827232/
Build: http://10.245.162.77:8080/job/charm_amulet_test/3177/

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

charm_lint_check #3399 nova-compute-next for corey.bryant mp255945
    LINT OK: passed

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

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

charm_unit_test #3187 nova-compute-next for corey.bryant mp255945
    UNIT OK: passed

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

120. By Corey Bryant

Sync charm-helpers

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

charm_lint_check #3406 nova-compute-next for corey.bryant mp255945
    LINT OK: passed

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

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

charm_unit_test #3194 nova-compute-next for corey.bryant mp255945
    UNIT OK: passed

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

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

charm_amulet_test #3189 nova-compute-next for corey.bryant mp255945
    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/10827681/
Build: http://10.245.162.77:8080/job/charm_amulet_test/3189/

121. By Corey Bryant

Move config_changed into try block

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

charm_lint_check #3415 nova-compute-next for corey.bryant mp255945
    LINT OK: passed

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

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

charm_unit_test #3203 nova-compute-next for corey.bryant mp255945
    UNIT OK: passed

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

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

charm_amulet_test #3199 nova-compute-next for corey.bryant mp255945
    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/10828002/
Build: http://10.245.162.77:8080/job/charm_amulet_test/3199/

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

charm_amulet_test #3208 nova-compute-next for corey.bryant mp255945
    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/10828279/
Build: http://10.245.162.77:8080/job/charm_amulet_test/3208/

122. By Corey Bryant

Fix nova_conf path

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

charm_lint_check #3418 nova-compute-next for corey.bryant mp255945
    LINT OK: passed

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

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

charm_unit_test #3206 nova-compute-next for corey.bryant mp255945
    UNIT OK: passed

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

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

charm_amulet_test #3212 nova-compute-next for corey.bryant mp255945
    AMULET OK: passed

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

123. By Corey Bryant

Sync charm-helpers

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

charm_lint_check #3456 nova-compute-next for corey.bryant mp255945
    LINT OK: passed

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

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

charm_unit_test #3244 nova-compute-next for corey.bryant mp255945
    UNIT OK: passed

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

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

charm_amulet_test #3254 nova-compute-next for corey.bryant mp255945
    AMULET OK: passed

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

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:23:51 +0000
+++ .bzrignore 2015-04-16 14:46:17 +0000
@@ -1,2 +1,3 @@
1bin1bin
2.coverage2.coverage
3tags
34
=== modified file 'Makefile'
--- Makefile 2015-03-31 08:46:52 +0000
+++ Makefile 2015-04-16 14:46:17 +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:
@@ -24,7 +24,9 @@
24 # raise_status() messages to stderr:24 # raise_status() messages to stderr:
25 # https://bugs.launchpad.net/amulet/+bug/132035725 # https://bugs.launchpad.net/amulet/+bug/1320357
26 @juju test -v -p AMULET_HTTP_PROXY --timeout 900 \26 @juju test -v -p AMULET_HTTP_PROXY --timeout 900 \
27 00-setup 14-basic-precise-icehouse 15-basic-trusty-icehouse27 00-setup 14-basic-precise-icehouse 15-basic-trusty-icehouse \
28 16-basic-trusty-icehouse-git 17-basic-trusty-juno \
29 18-basic-trusty-juno-git
2830
29publish: lint unit_test31publish: lint unit_test
30 bzr push lp:charms/nova-compute32 bzr push lp:charms/nova-compute
3133
=== modified file 'README.md'
--- README.md 2015-02-09 15:39:23 +0000
+++ README.md 2015-04-16 14:46:17 +0000
@@ -16,17 +16,102 @@
16 - nrpe-external-master - Used to generate Nagios checks.16 - nrpe-external-master - Used to generate Nagios checks.
1717
18Database18Database
19--------19========
2020
21Nova compute only requires database access if using nova-network. If using21Nova compute only requires database access if using nova-network. If using
22Neutron, no direct database access is required and the shared-db relation need22Neutron, no direct database access is required and the shared-db relation need
23not be added.23not be added.
2424
25Networking25Networking
26----------26==========
27This charm support nova-network (legacy) and Neutron networking.27This charm support nova-network (legacy) and Neutron networking.
2828
29Storage29Storage
30-------30=======
31This charm supports a number of different storage backends depending on31This charm supports a number of different storage backends depending on
32your hypervisor type and storage relations.32your hypervisor type and storage relations.
33
34Deploying from source
35=====================
36
37The minimum openstack-origin-git config required to deploy from source is:
38
39 openstack-origin-git:
40 "repositories:
41 - {name: requirements,
42 repository: 'git://git.openstack.org/openstack/requirements',
43 branch: stable/juno}
44 - {name: nova,
45 repository: 'git://git.openstack.org/openstack/nova',
46 branch: stable/juno}"
47
48Note that there are only two 'name' values the charm knows about: 'requirements'
49and 'nova'. These repositories must correspond to these 'name' values.
50Additionally, the requirements repository must be specified first and the
51nova repository must be specified last. All other repostories are installed
52in the order in which they are specified.
53
54The following is a full list of current tip repos (may not be up-to-date):
55
56 openstack-origin-git:
57 "repositories:
58 - {name: requirements,
59 repository: 'git://git.openstack.org/openstack/requirements',
60 branch: master}
61 - {name: oslo-concurrency,
62 repository: 'git://git.openstack.org/openstack/oslo.concurrency',
63 branch: master}
64 - {name: oslo-config,
65 repository: 'git://git.openstack.org/openstack/oslo.config',
66 branch: master}
67 - {name: oslo-context,
68 repository: 'git://git.openstack.org/openstack/oslo.context.git',
69 branch: master}
70 - {name: oslo-db,
71 repository: 'git://git.openstack.org/openstack/oslo.db',
72 branch: master}
73 - {name: oslo-i18n,
74 repository: 'git://git.openstack.org/openstack/oslo.i18n',
75 branch: master}
76 - {name: oslo-log,
77 repository: 'git://git.openstack.org/openstack/oslo.log',
78 branch: master}
79 - {name: oslo-messaging,
80 repository: 'git://git.openstack.org/openstack/oslo.messaging.git',
81 branch: master}
82 - {name: oslo-middleware,
83 repository': 'git://git.openstack.org/openstack/oslo.middleware.git',
84 branch: master}
85 - {name: oslo-rootwrap',
86 repository: 'git://git.openstack.org/openstack/oslo.rootwrap.git',
87 branch: master}
88 - {name: oslo-serialization,
89 repository: 'git://git.openstack.org/openstack/oslo.serialization',
90 branch: master}
91 - {name: oslo-utils,
92 repository: 'git://git.openstack.org/openstack/oslo.utils',
93 branch: master}
94 - {name: pbr,
95 repository: 'git://git.openstack.org/openstack-dev/pbr',
96 branch: master}
97 - {name: stevedore,
98 repository: 'git://git.openstack.org/openstack/stevedore.git',
99 branch: 'master'}
100 - {name: sqlalchemy-migrate,
101 repository: 'git://git.openstack.org/stackforge/sqlalchemy-migrate',
102 branch: master}
103 - {name: python-cinderclient,
104 repository: 'git://git.openstack.org/openstack/python-cinderclient.git',
105 branch: master}
106 - {name: python-glanceclient,
107 repository': 'git://git.openstack.org/openstack/python-glanceclient.git',
108 branch: master}
109 - {name: python-neutronlient,
110 repository': 'git://git.openstack.org/openstack/python-neutronclient.git',
111 branch: master}
112 - {name: keystonemiddleware,
113 repository: 'git://git.openstack.org/openstack/keystonemiddleware',
114 branch: master}
115 - {name: nova,
116 repository: 'git://git.openstack.org/openstack/nova',
117 branch: master}"
33118
=== added directory 'actions'
=== added file 'actions.yaml'
--- actions.yaml 1970-01-01 00:00:00 +0000
+++ actions.yaml 2015-04-16 14:46:17 +0000
@@ -0,0 +1,2 @@
1git-reinstall:
2 description: Reinstall nova-compute 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 14:46:17 +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_compute_utils import (
18 git_install,
19)
20
21from nova_compute_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 12:22:05 +0000
+++ config.yaml 2015-04-16 14:46:17 +0000
@@ -22,6 +22,22 @@
22 Note that updating this setting to a source that is known to22 Note that updating this setting to a source that is known to
23 provide a later version of OpenStack will trigger a software23 provide a later version of OpenStack will trigger a software
24 upgrade.24 upgrade.
25
26 Note that when openstack-origin-git is specified, openstack
27 specific packages will be installed from source rather than
28 from the openstack-origin repository.
29 openstack-origin-git:
30 default:
31 type: string
32 description: |
33 Specifies a YAML-formatted dictionary listing the git
34 repositories and branches from which to install OpenStack and
35 its dependencies.
36
37 Note that the installed config files will be determined based on
38 the OpenStack release of the openstack-origin option.
39
40 For more details see README.md.
25 nova-config:41 nova-config:
26 default: /etc/nova/nova.conf42 default: /etc/nova/nova.conf
27 type: string43 type: string
2844
=== modified file 'hooks/charmhelpers/contrib/openstack/utils.py'
--- hooks/charmhelpers/contrib/openstack/utils.py 2015-04-13 08:57:13 +0000
+++ hooks/charmhelpers/contrib/openstack/utils.py 2015-04-16 14:46:17 +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_compute_hooks.py'
--- hooks/nova_compute_hooks.py 2015-03-31 15:01:48 +0000
+++ hooks/nova_compute_hooks.py 2015-04-16 14:46:17 +0000
@@ -28,7 +28,9 @@
28)28)
2929
30from charmhelpers.contrib.openstack.utils import (30from charmhelpers.contrib.openstack.utils import (
31 config_value_changed,
31 configure_installation_source,32 configure_installation_source,
33 git_install_requested,
32 openstack_upgrade_available,34 openstack_upgrade_available,
33 os_requires_version,35 os_requires_version,
34)36)
@@ -43,6 +45,7 @@
43from nova_compute_utils import (45from nova_compute_utils import (
44 create_libvirt_secret,46 create_libvirt_secret,
45 determine_packages,47 determine_packages,
48 git_install,
46 import_authorized_keys,49 import_authorized_keys,
47 import_keystone_ca_cert,50 import_keystone_ca_cert,
48 initialize_ssh_keys,51 initialize_ssh_keys,
@@ -84,9 +87,12 @@
84def install():87def install():
85 execd_preinstall()88 execd_preinstall()
86 configure_installation_source(config('openstack-origin'))89 configure_installation_source(config('openstack-origin'))
90
87 apt_update()91 apt_update()
88 apt_install(determine_packages(), fatal=True)92 apt_install(determine_packages(), fatal=True)
8993
94 git_install(config('openstack-origin-git'))
95
9096
91@hooks.hook('config-changed')97@hooks.hook('config-changed')
92@restart_on_change(restart_map())98@restart_on_change(restart_map())
@@ -95,8 +101,12 @@
95 assert_charm_supports_ipv6()101 assert_charm_supports_ipv6()
96102
97 global CONFIGS103 global CONFIGS
98 if openstack_upgrade_available('nova-common'):104 if git_install_requested():
99 CONFIGS = do_openstack_upgrade()105 if config_value_changed('openstack-origin-git'):
106 git_install(config('openstack-origin-git'))
107 else:
108 if openstack_upgrade_available('nova-common'):
109 CONFIGS = do_openstack_upgrade()
100110
101 sysctl_dict = config('sysctl')111 sysctl_dict = config('sysctl')
102 if sysctl_dict:112 if sysctl_dict:
103113
=== modified file 'hooks/nova_compute_utils.py'
--- hooks/nova_compute_utils.py 2015-04-14 05:26:04 +0000
+++ hooks/nova_compute_utils.py 2015-04-16 14:46:17 +0000
@@ -1,4 +1,5 @@
1import os1import os
2import shutil
2import pwd3import pwd
34
4from base64 import b64decode5from base64 import b64decode
@@ -8,16 +9,21 @@
8from charmhelpers.fetch import (9from charmhelpers.fetch import (
9 apt_update,10 apt_update,
10 apt_upgrade,11 apt_upgrade,
11 apt_install12 apt_install,
12)13)
1314
14from charmhelpers.core.host import (15from charmhelpers.core.host import (
16 adduser,
17 add_group,
18 add_user_to_group,
15 mkdir,19 mkdir,
16 service_restart,20 service_restart,
17 lsb_release21 lsb_release,
22 write_file,
18)23)
1924
20from charmhelpers.core.hookenv import (25from charmhelpers.core.hookenv import (
26 charm_dir,
21 config,27 config,
22 log,28 log,
23 related_units,29 related_units,
@@ -27,6 +33,7 @@
27 INFO,33 INFO,
28)34)
2935
36from charmhelpers.core.templating import render
30from charmhelpers.contrib.openstack.neutron import neutron_plugin_attribute37from charmhelpers.contrib.openstack.neutron import neutron_plugin_attribute
31from charmhelpers.contrib.openstack import templating, context38from charmhelpers.contrib.openstack import templating, context
32from charmhelpers.contrib.openstack.alternatives import install_alternative39from charmhelpers.contrib.openstack.alternatives import install_alternative
@@ -34,6 +41,9 @@
34from charmhelpers.contrib.openstack.utils import (41from charmhelpers.contrib.openstack.utils import (
35 configure_installation_source,42 configure_installation_source,
36 get_os_codename_install_source,43 get_os_codename_install_source,
44 git_install_requested,
45 git_clone_and_install,
46 git_src_dir,
37 os_release47 os_release
38)48)
3949
@@ -61,6 +71,57 @@
61 'python-six',71 'python-six',
62]72]
6373
74BASE_GIT_PACKAGES = [
75 'libvirt-bin',
76 'libxml2-dev',
77 'libxslt1-dev',
78 'python-dev',
79 'python-pip',
80 'python-setuptools',
81 'zlib1g-dev',
82]
83
84LATE_GIT_PACKAGES = [
85 'bridge-utils',
86 'dnsmasq-base',
87 'dnsmasq-utils',
88 'ebtables',
89 'genisoimage',
90 'iptables',
91 'iputils-arping',
92 'kpartx',
93 'kvm',
94 'netcat',
95 'open-iscsi',
96 'parted',
97 'python-libvirt',
98 'qemu',
99 'qemu-system',
100 'qemu-utils',
101 'vlan',
102 'xen-system-amd64',
103]
104
105# ubuntu packages that should not be installed when deploying from git
106GIT_PACKAGE_BLACKLIST = [
107 'neutron-plugin-openvswitch',
108 'neutron-plugin-openvswitch-agent',
109 'neutron-server',
110 'nova-api',
111 'nova-api-metadata',
112 'nova-compute',
113 'nova-compute-kvm',
114 'nova-compute-lxc',
115 'nova-compute-qemu',
116 'nova-compute-uml',
117 'nova-compute-xen',
118 'nova-network',
119 'python-six',
120 'quantum-plugin-openvswitch',
121 'quantum-plugin-openvswitch-agent',
122 'quantum-server',
123]
124
64NOVA_CONF_DIR = "/etc/nova"125NOVA_CONF_DIR = "/etc/nova"
65QEMU_CONF = '/etc/libvirt/qemu.conf'126QEMU_CONF = '/etc/libvirt/qemu.conf'
66LIBVIRTD_CONF = '/etc/libvirt/libvirtd.conf'127LIBVIRTD_CONF = '/etc/libvirt/libvirtd.conf'
@@ -289,6 +350,14 @@
289 if enable_nova_metadata():350 if enable_nova_metadata():
290 packages.append('nova-api-metadata')351 packages.append('nova-api-metadata')
291352
353 if git_install_requested():
354 packages = list(set(packages))
355 packages.extend(BASE_GIT_PACKAGES)
356 # don't include packages that will be installed from git
357 for p in GIT_PACKAGE_BLACKLIST:
358 if p in packages:
359 packages.remove(p)
360
292 return packages361 return packages
293362
294363
@@ -527,3 +596,123 @@
527596
528def manage_ovs():597def manage_ovs():
529 return neutron_plugin_legacy_mode() and neutron_plugin() == 'ovs'598 return neutron_plugin_legacy_mode() and neutron_plugin() == 'ovs'
599
600
601def git_install(projects_yaml):
602 """Perform setup, and install git repos specified in yaml parameter."""
603 if git_install_requested():
604 git_pre_install()
605 git_clone_and_install(projects_yaml, core_project='nova')
606 git_post_install(projects_yaml)
607
608
609def git_pre_install():
610 """Perform pre-install setup."""
611 dirs = [
612 '/var/lib/nova',
613 '/var/lib/nova/buckets',
614 '/var/lib/nova/CA',
615 '/var/lib/nova/CA/INTER',
616 '/var/lib/nova/CA/newcerts',
617 '/var/lib/nova/CA/private',
618 '/var/lib/nova/CA/reqs',
619 '/var/lib/nova/images',
620 '/var/lib/nova/instances',
621 '/var/lib/nova/keys',
622 '/var/lib/nova/networks',
623 '/var/lib/nova/tmp',
624 '/var/log/nova',
625 ]
626
627 logs = [
628 '/var/log/nova/nova-api.log',
629 '/var/log/nova/nova-compute.log',
630 '/var/log/nova/nova-manage.log',
631 '/var/log/nova/nova-network.log',
632 ]
633
634 adduser('nova', shell='/bin/bash', system_user=True)
635 check_call(['usermod', '--home', '/var/lib/nova', 'nova'])
636 add_group('nova', system_group=True)
637 add_user_to_group('nova', 'nova')
638 add_user_to_group('nova', 'libvirtd')
639
640 for d in dirs:
641 mkdir(d, owner='nova', group='nova', perms=0755, force=False)
642
643 for l in logs:
644 write_file(l, '', owner='nova', group='nova', perms=0644)
645
646
647def git_post_install(projects_yaml):
648 """Perform post-install setup."""
649 src_etc = os.path.join(git_src_dir(projects_yaml, 'nova'), 'etc/nova')
650 configs = [
651 {'src': src_etc,
652 'dest': '/etc/nova'},
653 ]
654
655 for c in configs:
656 if os.path.exists(c['dest']):
657 shutil.rmtree(c['dest'])
658 shutil.copytree(c['src'], c['dest'])
659
660 virt_type = VIRT_TYPES[config('virt-type')][0]
661 nova_compute_conf = 'git/{}.conf'.format(virt_type)
662 render(nova_compute_conf, '/etc/nova/nova-compute.conf', {}, perms=0o644)
663 render('git/nova_sudoers', '/etc/sudoers.d/nova_sudoers', {}, perms=0o440)
664
665 service_name = 'nova-compute'
666 nova_user = 'nova'
667 start_dir = '/var/lib/nova'
668 nova_conf = '/etc/nova/nova.conf'
669 nova_api_metadata_context = {
670 'service_description': 'Nova Metadata API server',
671 'service_name': service_name,
672 'user_name': nova_user,
673 'start_dir': start_dir,
674 'process_name': 'nova-api-metadata',
675 'executable_name': '/usr/local/bin/nova-api-metadata',
676 'config_files': [nova_conf],
677 }
678 nova_api_context = {
679 'service_description': 'Nova API server',
680 'service_name': service_name,
681 'user_name': nova_user,
682 'start_dir': start_dir,
683 'process_name': 'nova-api',
684 'executable_name': '/usr/local/bin/nova-api',
685 'config_files': [nova_conf],
686 }
687 nova_compute_context = {
688 'service_description': 'Nova compute worker',
689 'service_name': service_name,
690 'user_name': nova_user,
691 'process_name': 'nova-compute',
692 'executable_name': '/usr/local/bin/nova-compute',
693 'config_files': [nova_conf, '/etc/nova/nova-compute.conf'],
694 }
695 nova_network_context = {
696 'service_description': 'Nova network worker',
697 'service_name': service_name,
698 'user_name': nova_user,
699 'start_dir': start_dir,
700 'process_name': 'nova-network',
701 'executable_name': '/usr/local/bin/nova-network',
702 'config_files': [nova_conf],
703 }
704
705 # NOTE(coreycb): Needs systemd support
706 templates_dir = 'hooks/charmhelpers/contrib/openstack/templates'
707 templates_dir = os.path.join(charm_dir(), templates_dir)
708 render('git.upstart', '/etc/init/nova-api-metadata.conf',
709 nova_api_metadata_context, perms=0o644, templates_dir=templates_dir)
710 render('git.upstart', '/etc/init/nova-api.conf',
711 nova_api_context, perms=0o644, templates_dir=templates_dir)
712 render('git/upstart/nova-compute.upstart', '/etc/init/nova-compute.conf',
713 nova_compute_context, perms=0o644)
714 render('git.upstart', '/etc/init/nova-network.conf',
715 nova_network_context, perms=0o644, templates_dir=templates_dir)
716
717 apt_update()
718 apt_install(LATE_GIT_PACKAGES, fatal=True)
530719
=== added directory 'templates/git'
=== added file 'templates/git/nova-compute-kvm.conf'
--- templates/git/nova-compute-kvm.conf 1970-01-01 00:00:00 +0000
+++ templates/git/nova-compute-kvm.conf 2015-04-16 14:46:17 +0000
@@ -0,0 +1,4 @@
1[DEFAULT]
2compute_driver=libvirt.LibvirtDriver
3[libvirt]
4virt_type=kvm
05
=== added file 'templates/git/nova-compute-lxc.conf'
--- templates/git/nova-compute-lxc.conf 1970-01-01 00:00:00 +0000
+++ templates/git/nova-compute-lxc.conf 2015-04-16 14:46:17 +0000
@@ -0,0 +1,4 @@
1[DEFAULT]
2compute_driver=libvirt.LibvirtDriver
3[libvirt]
4virt_type=lxc
05
=== added file 'templates/git/nova-compute-qemu.conf'
--- templates/git/nova-compute-qemu.conf 1970-01-01 00:00:00 +0000
+++ templates/git/nova-compute-qemu.conf 2015-04-16 14:46:17 +0000
@@ -0,0 +1,4 @@
1[DEFAULT]
2compute_driver=libvirt.LibvirtDriver
3[libvirt]
4virt_type=qemu
05
=== added file 'templates/git/nova-compute-vmware.conf'
--- templates/git/nova-compute-vmware.conf 1970-01-01 00:00:00 +0000
+++ templates/git/nova-compute-vmware.conf 2015-04-16 14:46:17 +0000
@@ -0,0 +1,2 @@
1[DEFAULT]
2compute_driver=vmwareapi.VMwareVCDriver
03
=== added file 'templates/git/nova-compute-xen.conf'
--- templates/git/nova-compute-xen.conf 1970-01-01 00:00:00 +0000
+++ templates/git/nova-compute-xen.conf 2015-04-16 14:46:17 +0000
@@ -0,0 +1,4 @@
1[DEFAULT]
2compute_driver=libvirt.LibvirtDriver
3[libvirt]
4virt_type=xen
05
=== added file 'templates/git/nova_sudoers'
--- templates/git/nova_sudoers 1970-01-01 00:00:00 +0000
+++ templates/git/nova_sudoers 2015-04-16 14:46:17 +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 'templates/git/nova_tgt.conf'
--- templates/git/nova_tgt.conf 1970-01-01 00:00:00 +0000
+++ templates/git/nova_tgt.conf 2015-04-16 14:46:17 +0000
@@ -0,0 +1,1 @@
1include /var/lib/nova/volumes/*
02
=== added directory 'templates/git/upstart'
=== added file 'templates/git/upstart/nova-compute.upstart'
--- templates/git/upstart/nova-compute.upstart 1970-01-01 00:00:00 +0000
+++ templates/git/upstart/nova-compute.upstart 2015-04-16 14:46:17 +0000
@@ -0,0 +1,27 @@
1description "{{ service_description }}"
2author "Juju {{ service_name }} Charm <juju@localhost>"
3
4start on runlevel [2345]
5stop on runlevel [!2345]
6
7chdir /var/run
8
9pre-start script
10 mkdir -p /var/run/nova
11 chown nova:root /var/run/nova/
12
13 mkdir -p /var/lock/nova
14 chown nova:root /var/lock/nova/
15
16 modprobe nbd
17
18 # If libvirt-bin is installed, always wait for it to start first
19 if status libvirt-bin; then
20 start wait-for-state WAIT_FOR=libvirt-bin WAIT_STATE=running WAITER={{ process_name }}
21 fi
22end script
23
24exec start-stop-daemon --start --chuid {{ user_name }} --exec {{ executable_name }} -- \
25 {% for config_file in config_files -%}
26 --config-file={{ config_file }} \
27 {% endfor -%}
028
=== removed file 'tests/10-basic-precise-essex'
--- tests/10-basic-precise-essex 2014-07-11 14:09:08 +0000
+++ tests/10-basic-precise-essex 1970-01-01 00:00:00 +0000
@@ -1,9 +0,0 @@
1#!/usr/bin/python
2
3"""Amulet tests on a basic nova compute deployment on precise-essex."""
4
5from basic_deployment import NovaBasicDeployment
6
7if __name__ == '__main__':
8 deployment = NovaBasicDeployment(series='precise')
9 deployment.run_tests()
100
=== removed file 'tests/11-basic-precise-folsom'
--- tests/11-basic-precise-folsom 2014-07-11 14:09:08 +0000
+++ tests/11-basic-precise-folsom 1970-01-01 00:00:00 +0000
@@ -1,17 +0,0 @@
1#!/usr/bin/python
2
3"""Amulet tests on a basic nova compute deployment on precise-folsom."""
4
5import amulet
6from basic_deployment import NovaBasicDeployment
7
8if __name__ == '__main__':
9 # NOTE(coreycb): Skipping failing test until resolved. 'nova-manage db sync'
10 # fails in shared-db-relation-changed (only fails on folsom)
11 message = "Skipping failing test until resolved"
12 amulet.raise_status(amulet.SKIP, msg=message)
13
14 deployment = NovaBasicDeployment(series='precise',
15 openstack='cloud:precise-folsom',
16 source='cloud:precise-updates/folsom')
17 deployment.run_tests()
180
=== removed file 'tests/12-basic-precise-grizzly'
--- tests/12-basic-precise-grizzly 2014-07-11 14:09:08 +0000
+++ tests/12-basic-precise-grizzly 1970-01-01 00:00:00 +0000
@@ -1,11 +0,0 @@
1#!/usr/bin/python
2
3"""Amulet tests on a basic nova compute deployment on precise-grizzly."""
4
5from basic_deployment import NovaBasicDeployment
6
7if __name__ == '__main__':
8 deployment = NovaBasicDeployment(series='precise',
9 openstack='cloud:precise-grizzly',
10 source='cloud:precise-updates/grizzly')
11 deployment.run_tests()
120
=== removed file 'tests/13-basic-precise-havana'
--- tests/13-basic-precise-havana 2014-07-11 14:09:08 +0000
+++ tests/13-basic-precise-havana 1970-01-01 00:00:00 +0000
@@ -1,11 +0,0 @@
1#!/usr/bin/python
2
3"""Amulet tests on a basic nova compute deployment on precise-havana."""
4
5from basic_deployment import NovaBasicDeployment
6
7if __name__ == '__main__':
8 deployment = NovaBasicDeployment(series='precise',
9 openstack='cloud:precise-havana',
10 source='cloud:precise-updates/havana')
11 deployment.run_tests()
120
=== 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 14:46:17 +0000
@@ -0,0 +1,9 @@
1#!/usr/bin/python
2
3"""Amulet tests on a basic nova compute git deployment on trusty-icehouse."""
4
5from basic_deployment import NovaBasicDeployment
6
7if __name__ == '__main__':
8 deployment = NovaBasicDeployment(series='trusty', git=True)
9 deployment.run_tests()
010
=== 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 14:46:17 +0000
@@ -0,0 +1,11 @@
1#!/usr/bin/python
2
3"""Amulet tests on a basic nova compute deployment on trusty-juno."""
4
5from basic_deployment import NovaBasicDeployment
6
7if __name__ == '__main__':
8 deployment = NovaBasicDeployment(series='trusty',
9 openstack='cloud:trusty-juno',
10 source='cloud:trusty-updates/juno')
11 deployment.run_tests()
012
=== 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 14:46:17 +0000
@@ -0,0 +1,12 @@
1#!/usr/bin/python
2
3"""Amulet tests on a basic nova compute git deployment on trusty-juno."""
4
5from basic_deployment import NovaBasicDeployment
6
7if __name__ == '__main__':
8 deployment = NovaBasicDeployment(series='trusty',
9 openstack='cloud:trusty-juno',
10 source='cloud:trusty-updates/juno',
11 git=True)
12 deployment.run_tests()
013
=== modified file 'tests/basic_deployment.py'
--- tests/basic_deployment.py 2015-04-14 09:02:53 +0000
+++ tests/basic_deployment.py 2015-04-16 14:46:17 +0000
@@ -1,7 +1,9 @@
1#!/usr/bin/python1#!/usr/bin/python
22
3import amulet3import amulet
4import os
4import time5import time
6import yaml
57
6from charmhelpers.contrib.openstack.amulet.deployment import (8from charmhelpers.contrib.openstack.amulet.deployment import (
7 OpenStackAmuletDeployment9 OpenStackAmuletDeployment
@@ -20,9 +22,11 @@
20class NovaBasicDeployment(OpenStackAmuletDeployment):22class NovaBasicDeployment(OpenStackAmuletDeployment):
21 """Amulet tests on a basic nova compute deployment."""23 """Amulet tests on a basic nova compute deployment."""
2224
23 def __init__(self, series=None, openstack=None, source=None, stable=False):25 def __init__(self, series=None, openstack=None, source=None, git=False,
26 stable=True):
24 """Deploy the entire test environment."""27 """Deploy the entire test environment."""
25 super(NovaBasicDeployment, self).__init__(series, openstack, source, stable)28 super(NovaBasicDeployment, self).__init__(series, openstack, source, stable)
29 self.git = git
26 self._add_services()30 self._add_services()
27 self._add_relations()31 self._add_relations()
28 self._configure_services()32 self._configure_services()
@@ -65,6 +69,24 @@
65 """Configure all of the services."""69 """Configure all of the services."""
66 nova_config = {'config-flags': 'auto_assign_floating_ip=False',70 nova_config = {'config-flags': 'auto_assign_floating_ip=False',
67 'enable-live-migration': 'False'}71 'enable-live-migration': 'False'}
72 if self.git:
73 branch = 'stable/' + self._get_openstack_release_string()
74 amulet_http_proxy = os.environ.get('AMULET_HTTP_PROXY')
75 openstack_origin_git = {
76 'repositories': [
77 {'name': 'requirements',
78 'repository': 'git://git.openstack.org/openstack/requirements',
79 'branch': branch},
80 {'name': 'nova',
81 'repository': 'git://git.openstack.org/openstack/nova',
82 'branch': branch},
83 ],
84 'directory': '/mnt/openstack-git',
85 'http_proxy': amulet_http_proxy,
86 'https_proxy': amulet_http_proxy,
87 }
88 nova_config['openstack-origin-git'] = yaml.dump(openstack_origin_git)
89
68 keystone_config = {'admin-password': 'openstack',90 keystone_config = {'admin-password': 'openstack',
69 'admin-token': 'ubuntutesting'}91 'admin-token': 'ubuntutesting'}
70 configs = {'nova-compute': nova_config, 'keystone': keystone_config}92 configs = {'nova-compute': nova_config, 'keystone': keystone_config}
7193
=== modified file 'unit_tests/__init__.py'
--- unit_tests/__init__.py 2013-07-26 21:22:44 +0000
+++ unit_tests/__init__.py 2015-04-16 14:46:17 +0000
@@ -1,3 +1,4 @@
1import sys1import sys
22
3sys.path.append('actions/')
3sys.path.append('hooks/')4sys.path.append('hooks/')
45
=== 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 14:46:17 +0000
@@ -0,0 +1,96 @@
1from mock import patch
2
3with patch('charmhelpers.core.hookenv.config') as config:
4 config.return_value = 'nova'
5 import nova_compute_utils as utils # noqa
6
7with patch('nova_compute_utils.restart_map'):
8 with patch('nova_compute_utils.register_configs'):
9 import git_reinstall
10
11from test_utils import (
12 CharmTestCase
13)
14
15TO_PATCH = [
16 'config',
17]
18
19
20openstack_origin_git = \
21 """repositories:
22 - {name: requirements,
23 repository: 'git://git.openstack.org/openstack/requirements',
24 branch: stable/juno}
25 - {name: nova,
26 repository: 'git://git.openstack.org/openstack/nova',
27 branch: stable/juno}"""
28
29
30class TestnovaAPIActions(CharmTestCase):
31
32 def setUp(self):
33 super(TestnovaAPIActions, self).setUp(git_reinstall, TO_PATCH)
34 self.config.side_effect = self.test_config.get
35
36 @patch.object(git_reinstall, 'action_set')
37 @patch.object(git_reinstall, 'action_fail')
38 @patch.object(git_reinstall, 'git_install')
39 @patch.object(git_reinstall, 'config_changed')
40 def test_git_reinstall(self, config_changed, git_install, action_fail,
41 action_set):
42 self.test_config.set('openstack-origin-git', openstack_origin_git)
43
44 git_reinstall.git_reinstall()
45
46 git_install.assert_called_with(openstack_origin_git)
47 self.assertTrue(git_install.called)
48 self.assertTrue(config_changed.called)
49 self.assertFalse(action_set.called)
50 self.assertFalse(action_fail.called)
51
52 @patch.object(git_reinstall, 'action_set')
53 @patch.object(git_reinstall, 'action_fail')
54 @patch.object(git_reinstall, 'git_install')
55 @patch.object(git_reinstall, 'config_changed')
56 @patch('charmhelpers.contrib.openstack.utils.config')
57 def test_git_reinstall_not_configured(self, _config, config_changed,
58 git_install, action_fail,
59 action_set):
60 _config.return_value = None
61
62 git_reinstall.git_reinstall()
63
64 msg = 'openstack-origin-git is not configured'
65 action_fail.assert_called_with(msg)
66 self.assertFalse(git_install.called)
67 self.assertFalse(action_set.called)
68
69 @patch.object(git_reinstall, 'action_set')
70 @patch.object(git_reinstall, 'action_fail')
71 @patch.object(git_reinstall, 'git_install')
72 @patch.object(git_reinstall, 'config_changed')
73 @patch('traceback.format_exc')
74 @patch('charmhelpers.contrib.openstack.utils.config')
75 def test_git_reinstall_exception(self, _config, format_exc,
76 config_changed, git_install, action_fail,
77 action_set):
78 _config.return_value = openstack_origin_git
79 e = OSError('something bad happened')
80 git_install.side_effect = e
81 traceback = (
82 "Traceback (most recent call last):\n"
83 " File \"actions/git_reinstall.py\", line 37, in git_reinstall\n"
84 " git_install(config(\'openstack-origin-git\'))\n"
85 " File \"/usr/lib/python2.7/dist-packages/mock.py\", line 964, in __call__\n" # noqa
86 " return _mock_self._mock_call(*args, **kwargs)\n"
87 " File \"/usr/lib/python2.7/dist-packages/mock.py\", line 1019, in _mock_call\n" # noqa
88 " raise effect\n"
89 "OSError: something bad happened\n")
90 format_exc.return_value = traceback
91
92 git_reinstall.git_reinstall()
93
94 msg = 'git-reinstall resulted in an unexpected error'
95 action_fail.assert_called_with(msg)
96 action_set.assert_called_with({'traceback': traceback})
097
=== modified file 'unit_tests/test_nova_compute_hooks.py'
--- unit_tests/test_nova_compute_hooks.py 2015-03-31 15:01:48 +0000
+++ unit_tests/test_nova_compute_hooks.py 2015-04-16 14:46:17 +0000
@@ -3,6 +3,7 @@
3 patch,3 patch,
4 MagicMock4 MagicMock
5)5)
6import yaml
67
7from test_utils import CharmTestCase8from test_utils import CharmTestCase
89
@@ -48,6 +49,8 @@
48 'disable_shell',49 'disable_shell',
49 'enable_shell',50 'enable_shell',
50 'update_nrpe_config',51 'update_nrpe_config',
52 'git_install',
53 'git_install_requested',
51 # misc_utils54 # misc_utils
52 'ensure_ceph_keyring',55 'ensure_ceph_keyring',
53 'execd_preinstall',56 'execd_preinstall',
@@ -77,13 +80,40 @@
77 self.apt_install.assert_called_with(['foo', 'bar'], fatal=True)80 self.apt_install.assert_called_with(['foo', 'bar'], fatal=True)
78 self.execd_preinstall.assert_called()81 self.execd_preinstall.assert_called()
7982
83 def test_install_hook_git(self):
84 self.git_install_requested.return_value = True
85 self.determine_packages.return_value = ['foo', 'bar']
86 repo = 'cloud:trusty-juno'
87 openstack_origin_git = {
88 'repositories': [
89 {'name': 'requirements',
90 'repository': 'git://git.openstack.org/openstack/requirements', # noqa
91 'branch': 'stable/juno'},
92 {'name': 'nova',
93 'repository': 'git://git.openstack.org/openstack/nova',
94 'branch': 'stable/juno'}
95 ],
96 'directory': '/mnt/openstack-git',
97 }
98 projects_yaml = yaml.dump(openstack_origin_git)
99 self.test_config.set('openstack-origin', repo)
100 self.test_config.set('openstack-origin-git', projects_yaml)
101 hooks.install()
102 self.configure_installation_source.assert_called_with(repo)
103 self.assertTrue(self.apt_update.called)
104 self.apt_install.assert_called_with(['foo', 'bar'], fatal=True)
105 self.git_install.assert_called_with(projects_yaml)
106 self.execd_preinstall.assert_called()
107
80 def test_config_changed_with_upgrade(self):108 def test_config_changed_with_upgrade(self):
109 self.git_install_requested.return_value = False
81 self.openstack_upgrade_available.return_value = True110 self.openstack_upgrade_available.return_value = True
82 hooks.config_changed()111 hooks.config_changed()
83 self.assertTrue(self.do_openstack_upgrade.called)112 self.assertTrue(self.do_openstack_upgrade.called)
84113
85 @patch.object(hooks, 'compute_joined')114 @patch.object(hooks, 'compute_joined')
86 def test_config_changed_with_migration(self, compute_joined):115 def test_config_changed_with_migration(self, compute_joined):
116 self.git_install_requested.return_value = False
87 self.migration_enabled.return_value = True117 self.migration_enabled.return_value = True
88 _zmq_joined = self.patch('zeromq_configuration_relation_joined')118 _zmq_joined = self.patch('zeromq_configuration_relation_joined')
89 self.test_config.set('migration-auth-type', 'ssh')119 self.test_config.set('migration-auth-type', 'ssh')
@@ -102,6 +132,7 @@
102132
103 @patch.object(hooks, 'compute_joined')133 @patch.object(hooks, 'compute_joined')
104 def test_config_changed_with_resize(self, compute_joined):134 def test_config_changed_with_resize(self, compute_joined):
135 self.git_install_requested.return_value = False
105 self.test_config.set('enable-resize', True)136 self.test_config.set('enable-resize', True)
106 _zmq_joined = self.patch('zeromq_configuration_relation_joined')137 _zmq_joined = self.patch('zeromq_configuration_relation_joined')
107 self.relation_ids.return_value = [138 self.relation_ids.return_value = [
@@ -120,6 +151,7 @@
120151
121 @patch.object(hooks, 'compute_joined')152 @patch.object(hooks, 'compute_joined')
122 def test_config_changed_without_resize(self, compute_joined):153 def test_config_changed_without_resize(self, compute_joined):
154 self.git_install_requested.return_value = False
123 self.test_config.set('enable-resize', False)155 self.test_config.set('enable-resize', False)
124 _zmq_joined = self.patch('zeromq_configuration_relation_joined')156 _zmq_joined = self.patch('zeromq_configuration_relation_joined')
125 self.relation_ids.return_value = [157 self.relation_ids.return_value = [
@@ -137,6 +169,7 @@
137169
138 @patch.object(hooks, 'compute_joined')170 @patch.object(hooks, 'compute_joined')
139 def test_config_changed_no_upgrade_no_migration(self, compute_joined):171 def test_config_changed_no_upgrade_no_migration(self, compute_joined):
172 self.git_install_requested.return_value = False
140 self.openstack_upgrade_available.return_value = False173 self.openstack_upgrade_available.return_value = False
141 self.migration_enabled.return_value = False174 self.migration_enabled.return_value = False
142 hooks.config_changed()175 hooks.config_changed()
@@ -145,10 +178,34 @@
145178
146 @patch.object(hooks, 'compute_joined')179 @patch.object(hooks, 'compute_joined')
147 def test_config_changed_with_sysctl(self, compute_joined):180 def test_config_changed_with_sysctl(self, compute_joined):
181 self.git_install_requested.return_value = False
148 self.test_config.set('sysctl', '{ kernel.max_pid : "1337" }')182 self.test_config.set('sysctl', '{ kernel.max_pid : "1337" }')
149 hooks.config_changed()183 hooks.config_changed()
150 self.create_sysctl.assert_called()184 self.create_sysctl.assert_called()
151185
186 @patch.object(hooks, 'config_value_changed')
187 def test_config_changed_git(self, config_val_changed):
188 self.git_install_requested.return_value = True
189 repo = 'cloud:trusty-juno'
190 openstack_origin_git = {
191 'repositories': [
192 {'name': 'requirements',
193 'repository':
194 'git://git.openstack.org/openstack/requirements',
195 'branch': 'stable/juno'},
196 {'name': 'nova',
197 'repository': 'git://git.openstack.org/openstack/nova',
198 'branch': 'stable/juno'}
199 ],
200 'directory': '/mnt/openstack-git',
201 }
202 projects_yaml = yaml.dump(openstack_origin_git)
203 self.test_config.set('openstack-origin', repo)
204 self.test_config.set('openstack-origin-git', projects_yaml)
205 hooks.config_changed()
206 self.git_install.assert_called_with(projects_yaml)
207 self.assertFalse(self.do_openstack_upgrade.called)
208
152 def test_amqp_joined(self):209 def test_amqp_joined(self):
153 hooks.amqp_joined()210 hooks.amqp_joined()
154 self.relation_set.assert_called_with(211 self.relation_set.assert_called_with(
155212
=== modified file 'unit_tests/test_nova_compute_utils.py'
--- unit_tests/test_nova_compute_utils.py 2015-03-31 11:43:21 +0000
+++ unit_tests/test_nova_compute_utils.py 2015-04-16 14:46:17 +0000
@@ -35,6 +35,15 @@
3535
36OVS_PKGS_FLAT = list(itertools.chain.from_iterable(OVS_PKGS))36OVS_PKGS_FLAT = list(itertools.chain.from_iterable(OVS_PKGS))
3737
38openstack_origin_git = \
39 """repositories:
40 - {name: requirements,
41 repository: 'git://git.openstack.org/openstack/requirements',
42 branch: stable/juno}
43 - {name: nova,
44 repository: 'git://git.openstack.org/openstack/nova',
45 branch: stable/juno}"""
46
3847
39class NovaComputeUtilsTests(CharmTestCase):48class NovaComputeUtilsTests(CharmTestCase):
4049
@@ -44,7 +53,10 @@
4453
45 @patch.object(utils, 'enable_nova_metadata')54 @patch.object(utils, 'enable_nova_metadata')
46 @patch.object(utils, 'network_manager')55 @patch.object(utils, 'network_manager')
47 def test_determine_packages_nova_network(self, net_man, en_meta):56 @patch.object(utils, 'git_install_requested')
57 def test_determine_packages_nova_network(self, git_requested, net_man,
58 en_meta):
59 git_requested.return_value = False
48 en_meta.return_value = False60 en_meta.return_value = False
49 net_man.return_value = 'flatdhcpmanager'61 net_man.return_value = 'flatdhcpmanager'
50 self.relation_ids.return_value = []62 self.relation_ids.return_value = []
@@ -59,7 +71,10 @@
59 @patch.object(utils, 'enable_nova_metadata')71 @patch.object(utils, 'enable_nova_metadata')
60 @patch.object(utils, 'neutron_plugin')72 @patch.object(utils, 'neutron_plugin')
61 @patch.object(utils, 'network_manager')73 @patch.object(utils, 'network_manager')
62 def test_determine_packages_quantum(self, net_man, n_plugin, en_meta):74 @patch.object(utils, 'git_install_requested')
75 def test_determine_packages_quantum(self, git_requested, net_man, n_plugin,
76 en_meta):
77 git_requested.return_value = False
63 en_meta.return_value = False78 en_meta.return_value = False
64 self.neutron_plugin_attribute.return_value = OVS_PKGS79 self.neutron_plugin_attribute.return_value = OVS_PKGS
65 net_man.return_value = 'quantum'80 net_man.return_value = 'quantum'
@@ -73,8 +88,11 @@
73 @patch.object(utils, 'enable_nova_metadata')88 @patch.object(utils, 'enable_nova_metadata')
74 @patch.object(utils, 'neutron_plugin')89 @patch.object(utils, 'neutron_plugin')
75 @patch.object(utils, 'network_manager')90 @patch.object(utils, 'network_manager')
76 def test_determine_packages_quantum_legacy_off(self, net_man, n_plugin,91 @patch.object(utils, 'git_install_requested')
92 def test_determine_packages_quantum_legacy_off(self, git_requested,
93 net_man, n_plugin,
77 en_meta, leg_mode):94 en_meta, leg_mode):
95 git_requested.return_value = False
78 en_meta.return_value = False96 en_meta.return_value = False
79 leg_mode.return_value = False97 leg_mode.return_value = False
80 self.neutron_plugin_attribute.return_value = OVS_PKGS98 self.neutron_plugin_attribute.return_value = OVS_PKGS
@@ -89,8 +107,10 @@
89 @patch.object(utils, 'enable_nova_metadata')107 @patch.object(utils, 'enable_nova_metadata')
90 @patch.object(utils, 'neutron_plugin')108 @patch.object(utils, 'neutron_plugin')
91 @patch.object(utils, 'network_manager')109 @patch.object(utils, 'network_manager')
92 def test_determine_packages_quantum_ceph(self, net_man, n_plugin, en_meta,110 @patch.object(utils, 'git_install_requested')
93 leg_mode):111 def test_determine_packages_quantum_ceph(self, git_requested, net_man,
112 n_plugin, en_meta, leg_mode):
113 git_requested.return_value = False
94 en_meta.return_value = False114 en_meta.return_value = False
95 leg_mode.return_value = True115 leg_mode.return_value = True
96 self.neutron_plugin_attribute.return_value = OVS_PKGS116 self.neutron_plugin_attribute.return_value = OVS_PKGS
@@ -105,7 +125,10 @@
105 @patch.object(utils, 'enable_nova_metadata')125 @patch.object(utils, 'enable_nova_metadata')
106 @patch.object(utils, 'neutron_plugin')126 @patch.object(utils, 'neutron_plugin')
107 @patch.object(utils, 'network_manager')127 @patch.object(utils, 'network_manager')
108 def test_determine_packages_metadata(self, net_man, n_plugin, en_meta):128 @patch.object(utils, 'git_install_requested')
129 def test_determine_packages_metadata(self, git_requested, net_man,
130 n_plugin, en_meta):
131 git_requested.return_value = False
109 en_meta.return_value = True132 en_meta.return_value = True
110 self.neutron_plugin_attribute.return_value = OVS_PKGS133 self.neutron_plugin_attribute.return_value = OVS_PKGS
111 net_man.return_value = 'bob'134 net_man.return_value = 'bob'
@@ -475,3 +498,163 @@
475 _neutron_plugin_legacy_mode.return_value = True498 _neutron_plugin_legacy_mode.return_value = True
476 _neutron_plugin.return_value = 'bobvs'499 _neutron_plugin.return_value = 'bobvs'
477 self.assertFalse(utils.manage_ovs())500 self.assertFalse(utils.manage_ovs())
501
502 @patch.object(utils, 'git_install_requested')
503 @patch.object(utils, 'git_clone_and_install')
504 @patch.object(utils, 'git_post_install')
505 @patch.object(utils, 'git_pre_install')
506 def test_git_install(self, git_pre, git_post, git_clone_and_install,
507 git_requested):
508 projects_yaml = openstack_origin_git
509 git_requested.return_value = True
510 utils.git_install(projects_yaml)
511 self.assertTrue(git_pre.called)
512 git_clone_and_install.assert_called_with(openstack_origin_git,
513 core_project='nova')
514 self.assertTrue(git_post.called)
515
516 @patch.object(utils, 'mkdir')
517 @patch.object(utils, 'write_file')
518 @patch.object(utils, 'add_user_to_group')
519 @patch.object(utils, 'add_group')
520 @patch.object(utils, 'adduser')
521 @patch.object(utils, 'check_call')
522 def test_git_pre_install(self, check_call, adduser, add_group,
523 add_user_to_group, write_file, mkdir):
524 utils.git_pre_install()
525 adduser.assert_called_with('nova', shell='/bin/bash',
526 system_user=True)
527 check_call.assert_called_with(['usermod', '--home', '/var/lib/nova',
528 'nova'])
529 add_group.assert_called_with('nova', system_group=True)
530 expected = [
531 call('nova', 'nova'),
532 call('nova', 'libvirtd'),
533 ]
534 self.assertEquals(add_user_to_group.call_args_list, expected)
535 expected = [
536 call('/var/lib/nova', owner='nova',
537 group='nova', perms=0755, force=False),
538 call('/var/lib/nova/buckets', owner='nova',
539 group='nova', perms=0755, force=False),
540 call('/var/lib/nova/CA', owner='nova',
541 group='nova', perms=0755, force=False),
542 call('/var/lib/nova/CA/INTER', owner='nova',
543 group='nova', perms=0755, force=False),
544 call('/var/lib/nova/CA/newcerts', owner='nova',
545 group='nova', perms=0755, force=False),
546 call('/var/lib/nova/CA/private', owner='nova',
547 group='nova', perms=0755, force=False),
548 call('/var/lib/nova/CA/reqs', owner='nova',
549 group='nova', perms=0755, force=False),
550 call('/var/lib/nova/images', owner='nova',
551 group='nova', perms=0755, force=False),
552 call('/var/lib/nova/instances', owner='nova',
553 group='nova', perms=0755, force=False),
554 call('/var/lib/nova/keys', owner='nova',
555 group='nova', perms=0755, force=False),
556 call('/var/lib/nova/networks', owner='nova',
557 group='nova', perms=0755, force=False),
558 call('/var/lib/nova/tmp', owner='nova',
559 group='nova', perms=0755, force=False),
560 call('/var/log/nova', owner='nova',
561 group='nova', perms=0755, force=False),
562 ]
563 self.assertEquals(mkdir.call_args_list, expected)
564 expected = [
565 call('/var/log/nova/nova-api.log', '', owner='nova',
566 group='nova', perms=0644),
567 call('/var/log/nova/nova-compute.log', '', owner='nova',
568 group='nova', perms=0644),
569 call('/var/log/nova/nova-manage.log', '', owner='nova',
570 group='nova', perms=0644),
571 call('/var/log/nova/nova-network.log', '', owner='nova',
572 group='nova', perms=0644),
573 ]
574 self.assertEquals(write_file.call_args_list, expected)
575
576 @patch.object(utils, 'git_src_dir')
577 @patch.object(utils, 'service_restart')
578 @patch.object(utils, 'render')
579 @patch('os.path.join')
580 @patch('os.path.exists')
581 @patch('shutil.copytree')
582 @patch('shutil.rmtree')
583 @patch.object(utils, 'apt_install')
584 @patch.object(utils, 'apt_update')
585 def test_git_post_install(self, apt_update, apt_install, rmtree, copytree,
586 exists, join, render, service_restart,
587 git_src_dir):
588 projects_yaml = openstack_origin_git
589 join.return_value = 'joined-string'
590 utils.git_post_install(projects_yaml)
591 expected = [
592 call('joined-string', '/etc/nova'),
593 ]
594 copytree.assert_has_calls(expected)
595
596 service_name = 'nova-compute'
597 nova_user = 'nova'
598 start_dir = '/var/lib/nova'
599 nova_conf = '/etc/nova/nova.conf'
600 nova_api_metadata_context = {
601 'service_description': 'Nova Metadata API server',
602 'service_name': service_name,
603 'user_name': nova_user,
604 'start_dir': start_dir,
605 'process_name': 'nova-api-metadata',
606 'executable_name': '/usr/local/bin/nova-api-metadata',
607 'config_files': [nova_conf],
608 }
609 nova_api_context = {
610 'service_description': 'Nova API server',
611 'service_name': service_name,
612 'user_name': nova_user,
613 'start_dir': start_dir,
614 'process_name': 'nova-api',
615 'executable_name': '/usr/local/bin/nova-api',
616 'config_files': [nova_conf],
617 }
618 nova_compute_context = {
619 'service_description': 'Nova compute worker',
620 'service_name': service_name,
621 'user_name': nova_user,
622 'process_name': 'nova-compute',
623 'executable_name': '/usr/local/bin/nova-compute',
624 'config_files': [nova_conf, '/etc/nova/nova-compute.conf'],
625 }
626 nova_network_context = {
627 'service_description': 'Nova network worker',
628 'service_name': service_name,
629 'user_name': nova_user,
630 'start_dir': start_dir,
631 'process_name': 'nova-network',
632 'executable_name': '/usr/local/bin/nova-network',
633 'config_files': [nova_conf],
634 }
635 expected = [
636 call('git/nova-compute-kvm.conf', '/etc/nova/nova-compute.conf',
637 {}, perms=0o644),
638 call('git/nova_sudoers', '/etc/sudoers.d/nova_sudoers',
639 {}, perms=0o440),
640 call('git.upstart', '/etc/init/nova-api-metadata.conf',
641 nova_api_metadata_context, perms=0o644,
642 templates_dir='joined-string'),
643 call('git.upstart', '/etc/init/nova-api.conf',
644 nova_api_context, perms=0o644,
645 templates_dir='joined-string'),
646 call('git/upstart/nova-compute.upstart',
647 '/etc/init/nova-compute.conf',
648 nova_compute_context, perms=0o644),
649 call('git.upstart', '/etc/init/nova-network.conf',
650 nova_network_context, perms=0o644,
651 templates_dir='joined-string'),
652 ]
653 self.assertEquals(render.call_args_list, expected)
654 self.assertTrue(apt_update.called)
655 apt_install.assert_called_with(
656 ['bridge-utils', 'dnsmasq-base',
657 'dnsmasq-utils', 'ebtables', 'genisoimage', 'iptables',
658 'iputils-arping', 'kpartx', 'kvm', 'netcat', 'open-iscsi',
659 'parted', 'python-libvirt', 'qemu', 'qemu-system',
660 'qemu-utils', 'vlan', 'xen-system-amd64'], fatal=True)

Subscribers

People subscribed via source and target branches