Resync helpers
This commit is contained in:
parent
8132d4a8a5
commit
62dd6aa7dd
@ -145,12 +145,16 @@ class SharedDBContext(OSContextGenerator):
|
||||
# with the service units local address and defer execution
|
||||
access_network = relation_get('access-network')
|
||||
if access_network is not None:
|
||||
if self.relation_prefix is not None:
|
||||
hostname_key = "{}_hostname".format(self.relation_prefix)
|
||||
else:
|
||||
hostname_key = "hostname"
|
||||
access_hostname = get_address_in_network(access_network,
|
||||
unit_get('private-address'))
|
||||
set_hostname = relation_get(attribute='hostname',
|
||||
set_hostname = relation_get(attribute=hostname_key,
|
||||
unit=local_unit())
|
||||
if set_hostname != access_hostname:
|
||||
relation_set(hostname=access_hostname)
|
||||
relation_set(relation_settings={hostname_key: access_hostname})
|
||||
return ctxt # Defer any further hook execution for now....
|
||||
|
||||
password_setting = 'password'
|
||||
|
25
hooks/charmhelpers/contrib/openstack/vip.py
Normal file
25
hooks/charmhelpers/contrib/openstack/vip.py
Normal file
@ -0,0 +1,25 @@
|
||||
|
||||
from netaddr import IPAddress, IPNetwork
|
||||
|
||||
class VIPConfiguration():
|
||||
|
||||
def __init__(self, configuration):
|
||||
self.vip = []
|
||||
for vip in configuration.split():
|
||||
self.vips.append(IPAddress(vip))
|
||||
|
||||
def getVIP(self, network):
|
||||
''' Determine the VIP for the provided network
|
||||
:network str: CIDR presented network, e.g. 192.168.1.1/24
|
||||
:returns str: IP address of VIP in provided network or None
|
||||
'''
|
||||
network = IPNetwork(network)
|
||||
for vip in self.vips:
|
||||
if vip in network:
|
||||
return str(vip)
|
||||
return None
|
||||
|
||||
def getNIC(self, network):
|
||||
''' Determine the physical network interface in use
|
||||
for the specified network'''
|
||||
|
Loading…
x
Reference in New Issue
Block a user