コード例 #1
0
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
コード例 #2
0
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
コード例 #3
0
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
コード例 #4
0
ファイル: cluster.py プロジェクト: buggtb/sitewhere-juju
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
コード例 #5
0
ファイル: cluster.py プロジェクト: CiscoSystems/juju-cinder
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
コード例 #6
0
ファイル: apache.py プロジェクト: coreycb/keystone
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
コード例 #7
0
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
コード例 #8
0
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
コード例 #9
0
ファイル: apache.py プロジェクト: peterklipfel/firesuit
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():
    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)
コード例 #11
0
ファイル: apache.py プロジェクト: coreycb/keystone
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)
コード例 #12
0
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)
コード例 #13
0
ファイル: cluster.py プロジェクト: thisaintjf/midonet-charms
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
コード例 #14
0
ファイル: cluster.py プロジェクト: CiscoSystems/juju-cinder
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
コード例 #15
0
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
コード例 #16
0
ファイル: cluster.py プロジェクト: CiscoSystems/juju-cinder
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
コード例 #17
0
ファイル: utils.py プロジェクト: chuckbutler/logstash-charm
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)