def https(): ''' Determines whether enough data has been provided in configuration or relation data to configure HTTPS . returns: boolean ''' use_https = config_get('use-https') if use_https and bool_from_string(use_https): return True if config_get('ssl_cert') and config_get('ssl_key'): return True for r_id in relation_ids('certificates'): for unit in relation_list(r_id): ca = relation_get('ca', rid=r_id, unit=unit) if ca: return True for r_id in relation_ids('identity-service'): for unit in relation_list(r_id): # TODO - needs fixing for new helper as ssl_cert/key suffixes with CN rel_state = [ relation_get('https_keystone', rid=r_id, unit=unit), relation_get('ca_cert', rid=r_id, unit=unit), ] # NOTE: works around (LP: #1203241) if (None not in rel_state) and ('' not in rel_state): return True return False
def peer_ips(peer_relation='cluster', addr_key='private-address'): '''Return a dict of peers and their private-address''' peers = {} for r_id in relation_ids(peer_relation): for unit in relation_list(r_id): peers[unit] = relation_get(addr_key, rid=r_id, unit=unit) return peers
def is_clustered(): for r_id in (relation_ids('ha') or []): for unit in (relation_list(r_id) or []): clustered = relation_get('clustered', rid=r_id, unit=unit) if clustered: return True return False
def get_ca_cert(): ca_cert = config_get("ssl_ca") if ca_cert is None: log("Inspecting identity-service relations for CA SSL certificate.", level=INFO) for r_id in relation_ids("identity-service"): for unit in relation_list(r_id): if ca_cert is None: ca_cert = relation_get("ca_cert", rid=r_id, unit=unit) return ca_cert
def get_ca_cert(): ca_cert = config_get('ssl_ca') if ca_cert is None: log("Inspecting identity-service relations for CA SSL certificate.", level=INFO) for r_id in relation_ids('identity-service'): for unit in relation_list(r_id): if ca_cert is None: ca_cert = relation_get('ca_cert', rid=r_id, unit=unit) return ca_cert
def get_ca_cert(): ca_cert = config_get('ssl_ca') if ca_cert is None: log("Inspecting identity-service relations for CA SSL certificate.", level=INFO) for r_id in (relation_ids('identity-service') + relation_ids('identity-credentials')): for unit in relation_list(r_id): if ca_cert is None: ca_cert = relation_get('ca_cert', rid=r_id, unit=unit) return ca_cert
def get_cert(): cert = config_get('ssl_cert') key = config_get('ssl_key') if not (cert and key): log("Inspecting identity-service relations for SSL certificate.", level=INFO) cert = key = None for r_id in relation_ids('identity-service'): for unit in relation_list(r_id): if not cert: cert = relation_get('ssl_cert', rid=r_id, unit=unit) if not key: key = relation_get('ssl_key', rid=r_id, unit=unit) return (cert, key)
def get_cert(cn=None): # TODO: deal with multiple https endpoints via charm config cert = config_get("ssl_cert") key = config_get("ssl_key") if not (cert and key): log("Inspecting identity-service relations for SSL certificate.", level=INFO) cert = key = None if cn: ssl_cert_attr = "ssl_cert_{}".format(cn) ssl_key_attr = "ssl_key_{}".format(cn) else: ssl_cert_attr = "ssl_cert" ssl_key_attr = "ssl_key" for r_id in relation_ids("identity-service"): for unit in relation_list(r_id): if not cert: cert = relation_get(ssl_cert_attr, rid=r_id, unit=unit) if not key: key = relation_get(ssl_key_attr, rid=r_id, unit=unit) return (cert, key)
def get_cert(cn=None): # TODO: deal with multiple https endpoints via charm config cert = config_get('ssl_cert') key = config_get('ssl_key') if not (cert and key): log("Inspecting identity-service relations for SSL certificate.", level=INFO) cert = key = None if cn: ssl_cert_attr = 'ssl_cert_{}'.format(cn) ssl_key_attr = 'ssl_key_{}'.format(cn) else: ssl_cert_attr = 'ssl_cert' ssl_key_attr = 'ssl_key' for r_id in relation_ids('identity-service'): for unit in relation_list(r_id): if not cert: cert = relation_get(ssl_cert_attr, rid=r_id, unit=unit) if not key: key = relation_get(ssl_key_attr, rid=r_id, unit=unit) return (cert, key)
def https(): ''' Determines whether enough data has been provided in configuration or relation data to configure HTTPS . returns: boolean ''' if config_get('use-https') == "yes": return True if config_get('ssl_cert') and config_get('ssl_key'): return True for r_id in relation_ids('identity-service'): for unit in relation_list(r_id): # TODO - needs fixing for new helper as ssl_cert/key suffixes with CN rel_state = [ relation_get('https_keystone', rid=r_id, unit=unit), relation_get('ca_cert', rid=r_id, unit=unit), ] # NOTE: works around (LP: #1203241) if (None not in rel_state) and ('' not in rel_state): return True return False
def https(): ''' Determines whether enough data has been provided in configuration or relation data to configure HTTPS . returns: boolean ''' if config_get('use-https') == "yes": return True if config_get('ssl_cert') and config_get('ssl_key'): return True for r_id in relation_ids('identity-service'): for unit in relation_list(r_id): rel_state = [ relation_get('https_keystone', rid=r_id, unit=unit), relation_get('ssl_cert', rid=r_id, unit=unit), relation_get('ssl_key', rid=r_id, unit=unit), relation_get('ca_cert', rid=r_id, unit=unit), ] # NOTE: works around (LP: #1203241) if (None not in rel_state) and ('' not in rel_state): return True return False
def peer_units(peer_relation="cluster"): peers = [] for r_id in (relation_ids(peer_relation) or []): for unit in (relation_list(r_id) or []): peers.append(unit) return peers
def peer_units(): peers = [] for r_id in (relation_ids('cluster') or []): for unit in (relation_list(r_id) or []): peers.append(unit) return peers
def client_joined(): # Only supports a single scale unit (no scale-out of logstash-indexer) rid = relation_ids('client')[0] unit = relation_list(rid)[0] relation_get('host', rid, unit)