Merge lp:~freyes/charms/trusty/nova-cloud-controller/bug-989337 into lp:~openstack-charmers-archive/charms/trusty/nova-cloud-controller/next

Proposed by Felipe Reyes
Status: Superseded
Proposed branch: lp:~freyes/charms/trusty/nova-cloud-controller/bug-989337
Merge into: lp:~openstack-charmers-archive/charms/trusty/nova-cloud-controller/next
Diff against target: 249 lines (+126/-2)
10 files modified
hooks/nova_cc_context.py (+21/-1)
hooks/nova_cc_hooks.py (+9/-0)
hooks/nova_cc_utils.py (+3/-1)
metadata.yaml (+2/-0)
templates/folsom/nova.conf (+5/-0)
templates/grizzly/nova.conf (+5/-0)
templates/havana/nova.conf (+4/-0)
templates/icehouse/nova.conf (+4/-0)
unit_tests/test_nova_cc_contexts.py (+72/-0)
unit_tests/test_nova_cc_hooks.py (+1/-0)
To merge this branch: bzr merge lp:~freyes/charms/trusty/nova-cloud-controller/bug-989337
Reviewer Review Type Date Requested Status
Felipe Reyes Abstain
Edward Hope-Morley Needs Fixing
OpenStack Charmers Pending
Review via email: mp+241318@code.launchpad.net

This proposal supersedes a proposal from 2014-10-26.

This proposal has been superseded by a proposal from 2014-11-20.

Description of the change

This branch extends the charm to install python-memcache, and configure nova.conf adding the key memcached_servers when a relationship with memcached service is established.

If multiple units of memcached are available, all of them are used (memcached_servers = host1:port1,host2:port,host3:port3)

To post a comment you must log in.
Revision history for this message
Ryan Beisner (1chb1n) wrote : Posted in a previous version of this proposal

UOSCI bot says:
charm_lint_check #771 nova-cloud-controller-next for freyes mp239671
    LINT OK: believed to pass, but you should confirm results

LINT Results (max last 4 lines) from
/var/lib/jenkins/workspace/charm_lint_check/make-lint.771:
I: config.yaml: option haproxy-client-timeout has no default value
I: config.yaml: option ssl_cert has no default value
I: config.yaml: option nvp-l3-uuid has no default value
I: config.yaml: option os-internal-network has no default value

Full lint output: http://paste.ubuntu.com/8694351/
Build: http://10.98.191.181:8080/job/charm_lint_check/771/

Revision history for this message
Ryan Beisner (1chb1n) wrote : Posted in a previous version of this proposal

UOSCI bot says:
charm_unit_test #579 nova-cloud-controller-next for freyes mp239671
    UNIT FAIL: unit-test failed

UNIT Results (max last 4 lines) from
/var/lib/jenkins/workspace/charm_unit_test/unit-test.579:
Ran 4 tests in 0.150s

FAILED (errors=2)
make: *** [unit_test] Error 1

Full unit output: http://paste.ubuntu.com/8694352/
Build: http://10.98.191.181:8080/job/charm_unit_test/579/

Revision history for this message
Ryan Beisner (1chb1n) wrote : Posted in a previous version of this proposal

UOSCI bot says:
charm_amulet_test #304 nova-cloud-controller-next for freyes mp239671
    AMULET OK: believed to pass, but you should confirm results

AMULET Results (max last 4 lines) from
/var/lib/jenkins/workspace/charm_amulet_test/make-test.304:
juju-test.conductor DEBUG : Tearing down osci-sv05 juju environment
juju-test.conductor DEBUG : Calling "juju destroy-environment -y osci-sv05"
WARNING cannot delete security group "juju-osci-sv05-0". Used by another environment?
juju-test INFO : Results: 3 passed, 0 failed, 0 errored

Full amulet output: http://paste.ubuntu.com/8694683/
Build: http://10.98.191.181:8080/job/charm_amulet_test/304/

Revision history for this message
Ryan Beisner (1chb1n) wrote : Posted in a previous version of this proposal

UOSCI bot says:
charm_unit_test #582 nova-cloud-controller-next for freyes mp239671
    UNIT FAIL: unit-test failed

UNIT Results (max last 4 lines) from
/var/lib/jenkins/workspace/charm_unit_test/unit-test.582:
Ran 4 tests in 0.153s

FAILED (errors=2)
make: *** [unit_test] Error 1

Full unit output: http://paste.ubuntu.com/8705925/
Build: http://10.98.191.181:8080/job/charm_unit_test/582/

Revision history for this message
Ryan Beisner (1chb1n) wrote : Posted in a previous version of this proposal

UOSCI bot says:
charm_lint_check #774 nova-cloud-controller-next for freyes mp239671
    LINT OK: believed to pass, but you should confirm results

LINT Results (max last 4 lines) from
/var/lib/jenkins/workspace/charm_lint_check/make-lint.774:
I: config.yaml: option haproxy-client-timeout has no default value
I: config.yaml: option ssl_cert has no default value
I: config.yaml: option nvp-l3-uuid has no default value
I: config.yaml: option os-internal-network has no default value

Full lint output: http://paste.ubuntu.com/8705924/
Build: http://10.98.191.181:8080/job/charm_lint_check/774/

Revision history for this message
Ryan Beisner (1chb1n) wrote : Posted in a previous version of this proposal

UOSCI bot says:
charm_amulet_test #307 nova-cloud-controller-next for freyes mp239671
    AMULET FAIL: amulet-test failed

AMULET Results (max last 4 lines) from
/var/lib/jenkins/workspace/charm_amulet_test/make-test.307:
    return self.read(buflen)
  File "/usr/lib/python2.7/ssl.py", line 260, in read
    return self._sslobj.read(len)
socket.error: [Errno 110] Connection timed out

Full amulet output: http://paste.ubuntu.com/8706467/
Build: http://10.98.191.181:8080/job/charm_amulet_test/307/

Revision history for this message
Edward Hope-Morley (hopem) wrote : Posted in a previous version of this proposal

I'm getting a couple of unit test failures here. Looks like a couple of extra mocks needed - see attached u/t output.

review: Needs Fixing
Revision history for this message
Edward Hope-Morley (hopem) wrote : Posted in a previous version of this proposal
Download full text (3.7 KiB)

Hmm can't attach so pasting:

$ make unit_test
Starting unit tests...
nose.plugins.cover: ERROR: Coverage not available: unable to import coverage module
test_instance_console_context_with_memcache (unit_tests.test_nova_cc_contexts.NovaComputeContextTests) ... ok
test_instance_console_context_without_memcache (unit_tests.test_nova_cc_contexts.NovaComputeContextTests) ... ok
Failure: OSError ([Errno 2] No such file or directory) ... ERROR
Failure: OSError ([Errno 2] No such file or directory) ... ERROR

======================================================================
ERROR: Failure: OSError ([Errno 2] No such file or directory)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/nose/loader.py", line 411, in loadTestsFromName
    addr.filename, addr.module)
  File "/usr/lib/python2.7/dist-packages/nose/importer.py", line 47, in importFromPath
    return self.importFromDir(dir_path, fqname)
  File "/usr/lib/python2.7/dist-packages/nose/importer.py", line 94, in importFromDir
    mod = load_module(part_fqname, fh, filename, desc)
  File "/home/gizmo/Documents/reviews/nova-cloud-controller/bug-989337/unit_tests/test_nova_cc_hooks.py", line 6, in <module>
    import nova_cc_utils as utils
  File "hooks/nova_cc_utils.py", line 142, in <module>
    nova_cc_context.NeutronPostgresqlDBContext(),
  File "hooks/nova_cc_context.py", line 268, in __init__
    self).__init__(config('neutron-database'))
  File "hooks/charmhelpers/core/hookenv.py", line 44, in wrapper
    res = func(*args, **kwargs)
  File "hooks/charmhelpers/core/hookenv.py", line 281, in config
    config_data = json.loads(subprocess.check_output(config_cmd_line))
  File "/usr/lib/python2.7/subprocess.py", line 566, in check_output
    process = Popen(stdout=PIPE, *popenargs, **kwargs)
  File "/usr/lib/python2.7/subprocess.py", line 710, in __init__
    errread, errwrite)
  File "/usr/lib/python2.7/subprocess.py", line 1327, in _execute_child
    raise child_exception
OSError: [Errno 2] No such file or directory

======================================================================
ERROR: Failure: OSError ([Errno 2] No such file or directory)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/nose/loader.py", line 411, in loadTestsFromName
    addr.filename, addr.module)
  File "/usr/lib/python2.7/dist-packages/nose/importer.py", line 47, in importFromPath
    return self.importFromDir(dir_path, fqname)
  File "/usr/lib/python2.7/dist-packages/nose/importer.py", line 94, in importFromDir
    mod = load_module(part_fqname, fh, filename, desc)
  File "/home/gizmo/Documents/reviews/nova-cloud-controller/bug-989337/unit_tests/test_nova_cc_utils.py", line 11, in <module>
    import nova_cc_utils as utils
  File "hooks/nova_cc_utils.py", line 142, in <module>
    nova_cc_context.NeutronPostgresqlDBContext(),
  File "hooks/nova_cc_context.py", line 268, in __init__
    self).__init__(config('neutron-database'))
  File "hooks/charmhelpers/core/hookenv.py", line 44, in wrapper
    res = func(*args, **kwa...

Read more...

Revision history for this message
Edward Hope-Morley (hopem) wrote : Posted in a previous version of this proposal

FWIW, other than the above this lgtm

Revision history for this message
Felipe Reyes (freyes) wrote : Posted in a previous version of this proposal

Edward, I fixed the broken tests, the patch was a little bit larger than what I expected, but they are working OK now.

Name Stmts Miss Cover Missing
-----------------------------------------------------
hooks/nova_cc_context 166 112 33% 21-28, 39-41, 48-59, 65-79, 86-104, 116-169, 180-195, 203-204, 208, 212-214, 219, 222-236, 242-256, 273-276, 281-283, 297-299
hooks/nova_cc_hooks 447 146 67% 132-135, 148-149, 173, 184-185, 189, 224, 229-234, 245, 325-328, 336-339, 345-348, 358-374, 383-385, 395-409, 413-422, 508, 518, 522-523, 576, 582-592, 597-608, 618-628, 633-672, 682-697, 705-709, 734-743, 767, 772-780, 806, 861, 865-868
hooks/nova_cc_utils 442 111 75% 296-301, 312-315, 325-326, 382, 384, 428-430, 434, 448-456, 463-468, 472-486, 592-594, 599-602, 607, 611, 635-636, 650-652, 673-674, 680-703, 707-713, 717-723, 729, 735, 742, 753-757, 842, 902-908, 912-914, 918-921, 925-937
-----------------------------------------------------
TOTAL 1055 369 65%
----------------------------------------------------------------------
Ran 99 tests in 7.518s

Revision history for this message
Ryan Beisner (1chb1n) wrote : Posted in a previous version of this proposal

UOSCI bot says:
charm_lint_check #922 nova-cloud-controller-next for freyes mp239671
    LINT OK: passed

LINT Results (max last 5 lines):
  I: config.yaml: option os-admin-network has no default value
  I: config.yaml: option haproxy-client-timeout has no default value
  I: config.yaml: option ssl_cert has no default value
  I: config.yaml: option nvp-l3-uuid has no default value
  I: config.yaml: option os-internal-network has no default value

Full lint test output: http://paste.ubuntu.com/8822840/
Build: http://10.98.191.181:8080/job/charm_lint_check/922/

Revision history for this message
Ryan Beisner (1chb1n) wrote : Posted in a previous version of this proposal

UOSCI bot says:
charm_unit_test #757 nova-cloud-controller-next for freyes mp239671
    UNIT OK: passed

UNIT Results (max last 5 lines):
  hooks/nova_cc_hooks 447 146 67% 132-135, 148-149, 173, 184-185, 189, 224, 229-234, 245, 325-328, 336-339, 345-348, 358-374, 383-385, 395-409, 413-422, 508, 518, 522-523, 576, 582-592, 597-608, 618-628, 633-672, 682-697, 705-709, 734-743, 767, 772-780, 806, 861, 865-868
  hooks/nova_cc_utils 442 111 75% 296-301, 312-315, 325-326, 382, 384, 428-430, 434, 448-456, 463-468, 472-486, 592-594, 599-602, 607, 611, 635-636, 650-652, 673-674, 680-703, 707-713, 717-723, 729, 735, 742, 753-757, 842, 902-908, 912-914, 918-921, 925-937
  TOTAL 1055 369 65%
  Ran 99 tests in 8.707s
  OK

Full unit test output: http://paste.ubuntu.com/8822843/
Build: http://10.98.191.181:8080/job/charm_unit_test/757/

Revision history for this message
Ryan Beisner (1chb1n) wrote : Posted in a previous version of this proposal

UOSCI bot says:
charm_amulet_test #340 nova-cloud-controller-next for freyes mp239671
    AMULET OK: passed

AMULET Results (max last 5 lines):
  juju-test.conductor.15-basic-trusty-icehouse RESULT :
  juju-test.conductor DEBUG : Tearing down osci-sv07 juju environment
  juju-test.conductor DEBUG : Calling "juju destroy-environment -y osci-sv07"
  WARNING cannot delete security group "juju-osci-sv07-0". Used by another environment?
  juju-test INFO : Results: 3 passed, 0 failed, 0 errored

Full amulet test output: http://paste.ubuntu.com/8823194/
Build: http://10.98.191.181:8080/job/charm_amulet_test/340/

Revision history for this message
Ryan Beisner (1chb1n) wrote :

UOSCI bot says:
charm_lint_check #979 nova-cloud-controller-next for freyes mp241318
    LINT OK: passed

LINT Results (max last 5 lines):
  I: config.yaml: option os-admin-network has no default value
  I: config.yaml: option haproxy-client-timeout has no default value
  I: config.yaml: option ssl_cert has no default value
  I: config.yaml: option nvp-l3-uuid has no default value
  I: config.yaml: option os-internal-network has no default value

Full lint test output: http://paste.ubuntu.com/8925102/
Build: http://10.98.191.181:8080/job/charm_lint_check/979/

Revision history for this message
Ryan Beisner (1chb1n) wrote :

UOSCI bot says:
charm_unit_test #814 nova-cloud-controller-next for freyes mp241318
    UNIT OK: passed

UNIT Results (max last 5 lines):
  hooks/nova_cc_hooks 447 146 67% 132-135, 148-149, 173, 184-185, 189, 224, 229-234, 245, 325-328, 336-339, 345-348, 358-374, 383-385, 395-409, 413-422, 508, 518, 522-523, 576, 582-592, 597-608, 618-628, 633-672, 682-697, 705-709, 734-743, 767, 772-780, 806, 861, 865-868
  hooks/nova_cc_utils 442 111 75% 296-301, 312-315, 325-326, 382, 384, 428-430, 434, 448-456, 463-468, 472-486, 592-594, 599-602, 607, 611, 635-636, 650-652, 673-674, 680-703, 707-713, 717-723, 729, 735, 742, 753-757, 842, 902-908, 912-914, 918-921, 925-937
  TOTAL 1055 369 65%
  Ran 99 tests in 8.712s
  OK

Full unit test output: http://paste.ubuntu.com/8925116/
Build: http://10.98.191.181:8080/job/charm_unit_test/814/

Revision history for this message
Ryan Beisner (1chb1n) wrote :

UOSCI bot says:
charm_amulet_test #359 nova-cloud-controller-next for freyes mp241318
    AMULET OK: passed

AMULET Results (max last 5 lines):
  juju-test.conductor.15-basic-trusty-icehouse RESULT :
  juju-test.conductor DEBUG : Tearing down osci-sv07 juju environment
  juju-test.conductor DEBUG : Calling "juju destroy-environment -y osci-sv07"
  WARNING cannot delete security group "juju-osci-sv07-0". Used by another environment?
  juju-test INFO : Results: 3 passed, 0 failed, 0 errored

Full amulet test output: http://paste.ubuntu.com/8925544/
Build: http://10.98.191.181:8080/job/charm_amulet_test/359/

Revision history for this message
Edward Hope-Morley (hopem) wrote :

Felipe, thanks for working on this it is much needed.

So some initial comments;

  * could you please rename the cache-relation-* to memcache-relation-*
  * is there are reason for replacing config() with hookenv.config()? I know it is not the nicest coding style but it is the same across all charms so to do it differently here would be breaking convention.
  * some more comments inline

review: Needs Fixing
Revision history for this message
Felipe Reyes (freyes) wrote :

Hi,

> * could you please rename the cache-relation-* to memcache-relation-*
I initially used memcache-relation-* hooks, but they weren't triggered, a quick look to mediawiki charm also uses cache-relation-* for memcache, I'll give it another try to double check this.

> * is there are reason for replacing config() with hookenv.config()? I know
> it is not the nicest coding style but it is the same across all charms so to
> do it differently here would be breaking convention.
I know, but importing config() function made fail the mocking due to the way the modules are imported, if this is a blocker I totally understand and I can revisit this to find a way to make the tests happy.

Best,

125. By Felipe Reyes

Revert "Changed the way charmhelpers.core.hookenv.config is imported"

126. By Felipe Reyes

Patch nova_cc_utils config() before it's imported by nova_cc_context

127. By Felipe Reyes

Format message, set proper level and include exception

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

UOSCI bot says:
charm_lint_check #1151 nova-cloud-controller-next for freyes mp241318
    LINT OK: passed

LINT Results (max last 5 lines):
  I: config.yaml: option os-admin-network has no default value
  I: config.yaml: option haproxy-client-timeout has no default value
  I: config.yaml: option ssl_cert has no default value
  I: config.yaml: option nvp-l3-uuid has no default value
  I: config.yaml: option os-internal-network has no default value

Full lint test output: http://paste.ubuntu.com/9125387/
Build: http://10.98.191.181:8080/job/charm_lint_check/1151/

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

UOSCI bot says:
charm_unit_test #985 nova-cloud-controller-next for freyes mp241318
    UNIT OK: passed

UNIT Results (max last 5 lines):
  hooks/nova_cc_hooks 447 146 67% 132-135, 148-149, 173, 184-185, 189, 224, 229-234, 245, 325-328, 336-339, 345-348, 358-374, 383-385, 395-409, 413-422, 508, 518, 522-523, 576, 582-592, 597-608, 618-628, 633-672, 682-697, 705-709, 734-743, 767, 772-780, 806, 861, 865-868
  hooks/nova_cc_utils 442 111 75% 296-301, 312-315, 325-326, 382, 384, 428-430, 434, 448-456, 463-468, 472-486, 592-594, 599-602, 607, 611, 635-636, 650-652, 673-674, 680-703, 707-713, 717-723, 729, 735, 742, 753-757, 842, 902-908, 912-914, 918-921, 925-937
  TOTAL 1054 369 65%
  Ran 99 tests in 9.596s
  OK

Full unit test output: http://paste.ubuntu.com/9125402/
Build: http://10.98.191.181:8080/job/charm_unit_test/985/

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

UOSCI bot says:
charm_amulet_test #493 nova-cloud-controller-next for freyes mp241318
    AMULET FAIL: amulet-test failed

AMULET Results (max last 5 lines):
"
  WARNING cannot delete security group "juju-osci-sv07-0". Used by another environment?
  juju-test INFO : Results: 2 passed, 0 failed, 1 errored
  ERROR subprocess encountered error code 124
  make: *** [test] Error 124

Full amulet test output: http://paste.ubuntu.com/9125932/
Build: http://10.98.191.181:8080/job/charm_amulet_test/493/

128. By Felipe Reyes

Renamed relation from 'cache' to 'memcache'

129. By Felipe Reyes

Commit after merge

130. By Felipe Reyes

Commit after pulling changes from upstream

Revision history for this message
Felipe Reyes (freyes) wrote :

> juju-test.conductor.15-basic-trusty-icehouse RESULT : ✔
> juju-test.conductor DEBUG : Tearing down osci-sv07 juju environment
> juju-test.conductor DEBUG : Calling "juju destroy-environment -y osci-sv07ERROR:root:Make target returned non-zero.
> "
> WARNING cannot delete security group "juju-osci-sv07-0". Used by another environment?
> juju-test INFO : Results: 2 passed, 0 failed, 1 errored
> ERROR subprocess encountered error code 124

Should I do something with this error?

review: Needs Resubmitting
Revision history for this message
Felipe Reyes (freyes) :
review: Abstain
131. By Felipe Reyes

Added IPv6 support

Added test to check that IPv6 addresses are properly formatted.

132. By Felipe Reyes

Commit after merge

133. By Felipe Reyes

Replace "Couldn't get caching servers" with "Couldn't get memcache servers"

134. By Felipe Reyes

Refactor the way memcached_servers config is put in the templates

Instead of formatting the string with Jinja2, it's formatted with python
and passed to the template as a string.

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added symlink 'hooks/memcache-relation-broken'
2=== target is u'nova_cc_hooks.py'
3=== added symlink 'hooks/memcache-relation-changed'
4=== target is u'nova_cc_hooks.py'
5=== added symlink 'hooks/memcache-relation-departed'
6=== target is u'nova_cc_hooks.py'
7=== added symlink 'hooks/memcache-relation-joined'
8=== target is u'nova_cc_hooks.py'
9=== modified file 'hooks/nova_cc_context.py'
10--- hooks/nova_cc_context.py 2014-10-13 16:18:58 +0000
11+++ hooks/nova_cc_context.py 2014-11-20 16:59:41 +0000
12@@ -1,6 +1,6 @@
13 from charmhelpers.core.hookenv import (
14 config, relation_ids, relation_set, log, ERROR,
15- unit_get, related_units, relation_get)
16+ unit_get, related_units, relation_get, relations_for_id)
17
18 from charmhelpers.fetch import apt_install, filter_installed_packages
19 from charmhelpers.contrib.openstack import context, neutron, utils
20@@ -281,3 +281,23 @@
21 ctxt = super(NovaIPv6Context, self).__call__()
22 ctxt['use_ipv6'] = config('prefer-ipv6')
23 return ctxt
24+
25+
26+class InstanceConsoleContext(context.OSContextGenerator):
27+ interfaces = []
28+
29+ def __call__(self):
30+ ctxt = {}
31+ servers = []
32+ try:
33+ for rid in relation_ids('memcache'):
34+ for rel in relations_for_id(rid):
35+ servers.append({'private-address': rel['private-address'],
36+ 'port': rel['port']})
37+ except Exception as ex:
38+ log("Couldn't get caching servers: {}".format(str(ex)),
39+ level='WARNING')
40+ servers = []
41+
42+ ctxt['memcached_servers'] = servers
43+ return ctxt
44
45=== modified file 'hooks/nova_cc_hooks.py'
46--- hooks/nova_cc_hooks.py 2014-10-23 07:32:45 +0000
47+++ hooks/nova_cc_hooks.py 2014-11-20 16:59:41 +0000
48@@ -849,6 +849,15 @@
49 quantum_joined(rid=rid)
50
51
52+@hooks.hook('memcache-relation-joined',
53+ 'memcache-relation-departed',
54+ 'memcache-relation-changed',
55+ 'memcache-relation-broken')
56+@restart_on_change(restart_map())
57+def memcached_joined():
58+ CONFIGS.write(NOVA_CONF)
59+
60+
61 def main():
62 try:
63 hooks.execute(sys.argv)
64
65=== modified file 'hooks/nova_cc_utils.py'
66--- hooks/nova_cc_utils.py 2014-11-14 09:55:10 +0000
67+++ hooks/nova_cc_utils.py 2014-11-20 16:59:41 +0000
68@@ -68,6 +68,7 @@
69 'python-psycopg2',
70 'python-psutil',
71 'uuid',
72+ 'python-memcache',
73 ]
74
75 BASE_SERVICES = [
76@@ -123,7 +124,8 @@
77 nova_cc_context.VolumeServiceContext(),
78 nova_cc_context.NovaIPv6Context(),
79 nova_cc_context.NeutronCCContext(),
80- nova_cc_context.NovaConfigContext()],
81+ nova_cc_context.NovaConfigContext(),
82+ nova_cc_context.InstanceConsoleContext()],
83 }),
84 (NOVA_API_PASTE, {
85 'services': [s for s in BASE_SERVICES if 'api' in s],
86
87=== modified file 'metadata.yaml'
88--- metadata.yaml 2014-07-11 09:14:57 +0000
89+++ metadata.yaml 2014-11-20 16:59:41 +0000
90@@ -40,6 +40,8 @@
91 nova-vmware:
92 interface: nova-vmware
93 scope: container
94+ memcache:
95+ interface: memcache
96 peers:
97 cluster:
98 interface: nova-ha
99
100=== modified file 'templates/folsom/nova.conf'
101--- templates/folsom/nova.conf 2014-04-16 08:25:14 +0000
102+++ templates/folsom/nova.conf 2014-11-20 16:59:41 +0000
103@@ -21,6 +21,11 @@
104 enabled_apis=ec2,osapi_compute,metadata
105 auth_strategy=keystone
106 compute_driver=libvirt.LibvirtDriver
107+
108+{% if memcached_servers %}
109+memcached_servers = {%for s in memcached_servers %}{% if loop.index0 != 0 %},{% endif %}{{s['private-address']}}:{{s['port']}}{% endfor %}
110+{% endif %}
111+
112 {% if keystone_ec2_url -%}
113 keystone_ec2_url = {{ keystone_ec2_url }}
114 {% endif -%}
115
116=== modified file 'templates/grizzly/nova.conf'
117--- templates/grizzly/nova.conf 2014-03-31 11:56:09 +0000
118+++ templates/grizzly/nova.conf 2014-11-20 16:59:41 +0000
119@@ -20,6 +20,11 @@
120 enabled_apis=ec2,osapi_compute,metadata
121 auth_strategy=keystone
122 compute_driver=libvirt.LibvirtDriver
123+
124+{% if memcached_servers %}
125+memcached_servers = {%for s in memcached_servers %}{% if loop.index0 != 0 %},{% endif %}{{s['private-address']}}:{{s['port']}}{% endfor %}
126+{% endif %}
127+
128 {% if keystone_ec2_url -%}
129 keystone_ec2_url = {{ keystone_ec2_url }}
130 {% endif -%}
131
132=== modified file 'templates/havana/nova.conf'
133--- templates/havana/nova.conf 2014-08-08 09:31:32 +0000
134+++ templates/havana/nova.conf 2014-11-20 16:59:41 +0000
135@@ -26,6 +26,10 @@
136 cpu_allocation_ratio = {{ cpu_allocation_ratio }}
137 use_syslog={{ use_syslog }}
138
139+{% if memcached_servers %}
140+memcached_servers = {%for s in memcached_servers %}{% if loop.index0 != 0 %},{% endif %}{{s['private-address']}}:{{s['port']}}{% endfor %}
141+{% endif %}
142+
143 {% if keystone_ec2_url -%}
144 keystone_ec2_url = {{ keystone_ec2_url }}
145 {% endif -%}
146
147=== modified file 'templates/icehouse/nova.conf'
148--- templates/icehouse/nova.conf 2014-10-07 11:37:20 +0000
149+++ templates/icehouse/nova.conf 2014-11-20 16:59:41 +0000
150@@ -38,6 +38,10 @@
151
152 use_syslog={{ use_syslog }}
153
154+{% if memcached_servers %}
155+memcached_servers = {%for s in memcached_servers %}{% if loop.index0 != 0 %},{% endif %}{{s['private-address']}}:{{s['port']}}{% endfor %}
156+{% endif %}
157+
158 {% if keystone_ec2_url -%}
159 keystone_ec2_url = {{ keystone_ec2_url }}
160 {% endif -%}
161
162=== added file 'unit_tests/test_nova_cc_contexts.py'
163--- unit_tests/test_nova_cc_contexts.py 1970-01-01 00:00:00 +0000
164+++ unit_tests/test_nova_cc_contexts.py 2014-11-20 16:59:41 +0000
165@@ -0,0 +1,72 @@
166+from __future__ import print_function
167+
168+import mock
169+
170+#####
171+# NOTE(freyes): this is a workaround to patch config() function imported by
172+# nova_cc_utils before it gets a reference to the actual config() provided by
173+# hookenv module.
174+from charmhelpers.core import hookenv
175+_conf = hookenv.config
176+hookenv.config = mock.MagicMock()
177+import nova_cc_utils as _utils
178+# this assert is a double check + to avoid pep8 warning
179+assert _utils.config == hookenv.config
180+hookenv.config = _conf
181+#####
182+
183+import nova_cc_context as context
184+
185+from charmhelpers.contrib.openstack import utils
186+
187+from test_utils import CharmTestCase
188+
189+
190+TO_PATCH = [
191+ 'apt_install',
192+ 'filter_installed_packages',
193+ 'relation_ids',
194+ 'relation_get',
195+ 'related_units',
196+ 'config',
197+ 'log',
198+ 'unit_get',
199+ 'relations_for_id',
200+]
201+
202+
203+def fake_log(msg, level=None):
204+ level = level or 'INFO'
205+ print('[juju test log (%s)] %s' % (level, msg))
206+
207+
208+class NovaComputeContextTests(CharmTestCase):
209+ def setUp(self):
210+ super(NovaComputeContextTests, self).setUp(context, TO_PATCH)
211+ self.relation_get.side_effect = self.test_relation.get
212+ self.config.side_effect = self.test_config.get
213+ self.log.side_effect = fake_log
214+
215+ @mock.patch.object(utils, 'os_release')
216+ def test_instance_console_context_without_memcache(self, os_release):
217+ self.unit_get.return_value = '127.0.0.1'
218+ self.relation_ids.return_value = 'cache:0'
219+ self.related_units.return_value = 'memcached/0'
220+ instance_console = context.InstanceConsoleContext()
221+ os_release.return_value = 'icehouse'
222+ self.assertEqual({'memcached_servers': []},
223+ instance_console())
224+
225+ @mock.patch.object(utils, 'os_release')
226+ def test_instance_console_context_with_memcache(self, os_release):
227+ memcached_servers = [{'private-address': '127.0.1.1',
228+ 'port': '11211'}]
229+ self.unit_get.return_value = '127.0.0.1'
230+ self.relation_ids.return_value = ['cache:0']
231+ self.relations_for_id.return_value = memcached_servers
232+ self.related_units.return_value = 'memcached/0'
233+ instance_console = context.InstanceConsoleContext()
234+ os_release.return_value = 'icehouse'
235+ self.maxDiff = None
236+ self.assertEqual({'memcached_servers': memcached_servers},
237+ instance_console())
238
239=== modified file 'unit_tests/test_nova_cc_hooks.py'
240--- unit_tests/test_nova_cc_hooks.py 2014-10-21 13:18:47 +0000
241+++ unit_tests/test_nova_cc_hooks.py 2014-11-20 16:59:41 +0000
242@@ -1,6 +1,7 @@
243 from mock import MagicMock, patch, call
244 from test_utils import CharmTestCase, patch_open
245 import os
246+
247 with patch('charmhelpers.core.hookenv.config') as config:
248 config.return_value = 'neutron'
249 import nova_cc_utils as utils

Subscribers

People subscribed via source and target branches