~axwalk/charms/precise/ceph/trunk

« back to all changes in this revision

Viewing changes to hooks/utils.py

  • Committer: james.page at ubuntu
  • Date: 2014-07-29 11:02:32 UTC
  • mfrom: (75.2.14 ceph)
  • Revision ID: james.page@ubuntu.com-20140729110232-pffyutdyiavr66zt
[james-page,r=dosaboy] Add support for ceph public and cluster network configuration.

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
import re
12
12
from charmhelpers.core.hookenv import (
13
13
    unit_get,
14
 
    cached
 
14
    cached,
 
15
    config
15
16
)
16
17
from charmhelpers.fetch import (
17
18
    apt_install,
18
19
    filter_installed_packages
19
20
)
20
21
 
 
22
from charmhelpers.contrib.network import ip
 
23
 
21
24
TEMPLATES_DIR = 'templates'
22
25
 
23
26
try:
72
75
        answers = dns.resolver.query(hostname, 'A')
73
76
        if answers:
74
77
            return answers[0].address
 
78
 
 
79
 
 
80
@cached
 
81
def get_public_addr():
 
82
    return ip.get_address_in_network(config('ceph-public-network'),
 
83
                                     fallback=get_host_ip())