~joeborg/charms/trusty/contrail-configuration/rbac-switch

« back to all changes in this revision

Viewing changes to hooks/contrail_configuration_utils.py

  • Committer: Robert Ayres
  • Date: 2017-03-10 12:49:07 UTC
  • mfrom: (63.1.1 contrail-configuration)
  • Revision ID: robert.ayres@canonical.com-20170310124907-w325mry8jegcg418
Merge Ante Karamatic's changes (with modifications)

Show diffs side-by-side

added added

removed removed

Lines of Context:
340
340
def identity_admin_ctx():
341
341
    ctxs = [ { "auth_host": gethostbyname(hostname),
342
342
               "auth_port": relation_get("service_port", unit, rid),
 
343
               "auth_protocol": relation_get("service_protocol", unit, rid),
343
344
               "admin_user": relation_get("service_username", unit, rid),
344
345
               "admin_password": relation_get("service_password", unit, rid),
345
346
               "admin_tenant_name": relation_get("service_tenant_name", unit, rid),
386
387
                                 "169.254.169.254", 80, ip, 8775, "add",
387
388
                                 user, password)
388
389
 
 
390
def remove_ssl_ca_certificate():
 
391
    if os.path.exists("/usr/local/share/ca-certificates/contrail-juju.crt"):
 
392
        os.remove("/usr/local/share/ca-certificates/contrail-juju.crt")
 
393
        check_call(["update-ca-certificates", "-f"])
 
394
        return True
 
395
    else:
 
396
        return False
 
397
 
389
398
def units(relation):
390
399
    """Return a list of units for the specified relation"""
391
400
    return [ unit for rid in relation_ids(relation)
529
538
    render("contrail-config-nodemgr.conf",
530
539
           "/etc/contrail/contrail-config-nodemgr.conf", ctx)
531
540
 
 
541
def write_ssl_ca_certificate(cert):
 
542
    if os.path.exists("/usr/local/share/ca-certificates/contrail-juju.crt"):
 
543
        with open("/usr/local/share/ca-certificates/contrail-juju.crt", "r") as f:
 
544
            c = f.read()
 
545
        if c == cert:
 
546
            return False
 
547
    with open("/usr/local/share/ca-certificates/contrail-juju.crt", "w") as f:
 
548
        f.write(cert)
 
549
    check_call(["update-ca-certificates"])
 
550
    return True
 
551
 
532
552
def write_vnc_api_config():
533
553
    ctx = {}
534
554
    ctx.update(contrail_ctx())