~ajkavanagh/openstack-mojo-specs/remove-cinder-from-vrrp-ha

« back to all changes in this revision

Viewing changes to helper/tests/checksum_keystone_certs.py

  • Committer: Liam Young
  • Date: 2015-02-10 07:40:20 UTC
  • mto: This revision was merged to the branch mainline in revision 205.
  • Revision ID: liam.young@canonical.com-20150210074020-iorzsdum2q817wfy
More detail to readme

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
         '/usr/local/share/ca-certificates',
14
14
         '/etc/apache2/ssl/keystone']
15
15
 
16
 
 
17
16
def update_hash_from_path(hash, path, recurse_depth=10):
18
17
    """Recurse through path and update the provided hash for every file found.
19
18
    """
23
22
        raise msg
24
23
 
25
24
    if not os.path.isdir(path):
26
 
        print("WARNING: {} does not exist".format(path))
 
25
        print "WARNING: %s does not exist" % (path)
27
26
 
28
27
    for p in glob.glob("%s/*" % path):
29
28
        if os.path.isdir(p):
31
30
        else:
32
31
            with open(p, 'r') as fd:
33
32
                data = fd.read()
34
 
                print("Found: {} - {}".format(
35
 
                    p, hashlib.sha256(data).hexdigest()))
 
33
                print "Found: %s - %s" % (p, hashlib.sha256(data).hexdigest())
36
34
                hash.update(data)
37
35
 
38
 
 
39
36
for path in paths:
40
37
    update_hash_from_path(sha, path)
41
38
 
42
39
# Check CA
43
40
with tempfile.NamedTemporaryFile(delete=False) as tmpfile:
44
41
    name = tmpfile.name
45
 
    for path in [root + '/ubuntu_cloud_intermediate_ca/cacert.pem',
46
 
                 root + '/ubuntu_cloud_root_ca/cacert.pem']:
 
42
    for path in ['/var/lib/keystone/juju_ssl/ubuntu_cloud_intermediate_ca/cacert.pem',
 
43
                 '/var/lib/keystone/juju_ssl/ubuntu_cloud_root_ca/cacert.pem']:
47
44
        if not os.path.exists(path):
48
 
            print("WARNING: {} does not exist".format(path))
 
45
            print "WARNING: %s does not exist" % (path)
49
46
            continue
50
47
 
51
48
        with open(path, 'r') as fd:
53
50
 
54
51
ca = '/usr/local/share/ca-certificates/keystone_juju_ca_cert.crt'
55
52
if not os.path.exists(ca):
56
 
    print("WARNING: {} does not exist".format(ca))
 
53
    print "WARNING: %s does not exist" % (ca)
57
54
elif not filecmp.cmp(ca, name):
58
 
    print("{} not consistent with root and intermediate ca .pems".format(ca))
59
 
    print(name)
 
55
    print "%s not consistent with root and intermediate ca .pems" % (ca)
 
56
    print name
60
57
 
61
58
os.unlink(tmpfile.name)
62
59
 
63
 
print("TOTAL: {}".format(sha.hexdigest()))
 
60
print "TOTAL: %s" % sha.hexdigest()
64
61
sys.exit(0)
 
62