Merged next in
This commit is contained in:
@@ -1,19 +1,36 @@
|
||||
from charmhelpers.core.hookenv import (
|
||||
config, relation_ids, relation_set, log, ERROR,
|
||||
unit_get, related_units, relation_get)
|
||||
|
||||
from charmhelpers.fetch import apt_install, filter_installed_packages
|
||||
from charmhelpers.contrib.openstack import context, neutron, utils
|
||||
|
||||
config,
|
||||
relation_ids,
|
||||
relation_set,
|
||||
log,
|
||||
ERROR,
|
||||
unit_get,
|
||||
related_units,
|
||||
relations_for_id,
|
||||
relation_get,
|
||||
)
|
||||
from charmhelpers.fetch import (
|
||||
apt_install,
|
||||
filter_installed_packages,
|
||||
)
|
||||
from charmhelpers.contrib.openstack import (
|
||||
context,
|
||||
neutron,
|
||||
utils,
|
||||
)
|
||||
from charmhelpers.contrib.hahelpers.cluster import (
|
||||
determine_apache_port,
|
||||
determine_api_port,
|
||||
https,
|
||||
is_clustered
|
||||
is_clustered,
|
||||
)
|
||||
|
||||
from charmhelpers.contrib.network.ip import (
|
||||
get_ipv6_addr
|
||||
get_ipv6_addr,
|
||||
format_ipv6_addr,
|
||||
)
|
||||
from charmhelpers.contrib.openstack.ip import (
|
||||
resolve_address,
|
||||
INTERNAL,
|
||||
)
|
||||
|
||||
|
||||
@@ -283,6 +300,8 @@ class NovaConfigContext(context.WorkerConfigContext):
|
||||
ctxt = super(NovaConfigContext, self).__call__()
|
||||
ctxt['cpu_allocation_ratio'] = config('cpu-allocation-ratio')
|
||||
ctxt['ram_allocation_ratio'] = config('ram-allocation-ratio')
|
||||
addr = resolve_address(INTERNAL)
|
||||
ctxt['host_ip'] = format_ipv6_addr(addr) or addr
|
||||
return ctxt
|
||||
|
||||
|
||||
@@ -291,3 +310,24 @@ class NovaIPv6Context(context.BindHostContext):
|
||||
ctxt = super(NovaIPv6Context, self).__call__()
|
||||
ctxt['use_ipv6'] = config('prefer-ipv6')
|
||||
return ctxt
|
||||
|
||||
|
||||
class InstanceConsoleContext(context.OSContextGenerator):
|
||||
interfaces = []
|
||||
|
||||
def __call__(self):
|
||||
ctxt = {}
|
||||
servers = []
|
||||
try:
|
||||
for rid in relation_ids('memcache'):
|
||||
for rel in relations_for_id(rid):
|
||||
priv_addr = rel['private-address']
|
||||
# Format it as IPv6 address if needed
|
||||
priv_addr = format_ipv6_addr(priv_addr) or priv_addr
|
||||
servers.append("%s:%s" % (priv_addr, rel['port']))
|
||||
except Exception as ex:
|
||||
log("Could not get memcache servers: %s" % (ex), level='WARNING')
|
||||
servers = []
|
||||
|
||||
ctxt['memcached_servers'] = ','.join(servers)
|
||||
return ctxt
|
||||
|
||||
Reference in New Issue
Block a user