From b5e6ec5fcd40664e1989eb48a09f756b2827cb25 Mon Sep 17 00:00:00 2001 From: James Page Date: Wed, 27 Feb 2013 16:18:34 +0000 Subject: [PATCH] Fixup missing files --- .project | 17 +++++++++ .pydevproject | 8 ++++ hooks/cluster-relation-changed | 1 + hooks/cluster-relation-joined | 1 + hooks/config-changed | 2 +- hooks/ha-relation-changed | 1 + hooks/ha-relation-joined | 1 + hooks/identity-service-relation-changed | 2 +- hooks/identity-service-relation-joined | 2 +- hooks/install | 2 +- hooks/object-store-relation-joined | 2 +- hooks/swift-storage-relation-broken | 2 +- hooks/swift-storage-relation-changed | 2 +- hooks/{swift-hooks.py => swift_hooks.py} | 48 ++++++++++++------------ templates/haproxy.cfg | 35 +++++++++++++++++ 15 files changed, 96 insertions(+), 30 deletions(-) create mode 100644 .project create mode 100644 .pydevproject create mode 120000 hooks/cluster-relation-changed create mode 120000 hooks/cluster-relation-joined create mode 120000 hooks/ha-relation-changed create mode 120000 hooks/ha-relation-joined rename hooks/{swift-hooks.py => swift_hooks.py} (85%) create mode 100644 templates/haproxy.cfg diff --git a/.project b/.project new file mode 100644 index 0000000..15ac077 --- /dev/null +++ b/.project @@ -0,0 +1,17 @@ + + + swift-proxy + + + + + + org.python.pydev.PyDevBuilder + + + + + + org.python.pydev.pythonNature + + diff --git a/.pydevproject b/.pydevproject new file mode 100644 index 0000000..90f0e6e --- /dev/null +++ b/.pydevproject @@ -0,0 +1,8 @@ + + +python 2.7 +Default + +/swift-proxy/hooks + + diff --git a/hooks/cluster-relation-changed b/hooks/cluster-relation-changed new file mode 120000 index 0000000..8623fba --- /dev/null +++ b/hooks/cluster-relation-changed @@ -0,0 +1 @@ +swift_hooks.py \ No newline at end of file diff --git a/hooks/cluster-relation-joined b/hooks/cluster-relation-joined new file mode 120000 index 0000000..8623fba --- /dev/null +++ b/hooks/cluster-relation-joined @@ -0,0 +1 @@ +swift_hooks.py \ No newline at end of file diff --git a/hooks/config-changed b/hooks/config-changed index fee03fe..8623fba 120000 --- a/hooks/config-changed +++ b/hooks/config-changed @@ -1 +1 @@ -swift-hooks.py \ No newline at end of file +swift_hooks.py \ No newline at end of file diff --git a/hooks/ha-relation-changed b/hooks/ha-relation-changed new file mode 120000 index 0000000..8623fba --- /dev/null +++ b/hooks/ha-relation-changed @@ -0,0 +1 @@ +swift_hooks.py \ No newline at end of file diff --git a/hooks/ha-relation-joined b/hooks/ha-relation-joined new file mode 120000 index 0000000..8623fba --- /dev/null +++ b/hooks/ha-relation-joined @@ -0,0 +1 @@ +swift_hooks.py \ No newline at end of file diff --git a/hooks/identity-service-relation-changed b/hooks/identity-service-relation-changed index fee03fe..8623fba 120000 --- a/hooks/identity-service-relation-changed +++ b/hooks/identity-service-relation-changed @@ -1 +1 @@ -swift-hooks.py \ No newline at end of file +swift_hooks.py \ No newline at end of file diff --git a/hooks/identity-service-relation-joined b/hooks/identity-service-relation-joined index fee03fe..8623fba 120000 --- a/hooks/identity-service-relation-joined +++ b/hooks/identity-service-relation-joined @@ -1 +1 @@ -swift-hooks.py \ No newline at end of file +swift_hooks.py \ No newline at end of file diff --git a/hooks/install b/hooks/install index fee03fe..8623fba 120000 --- a/hooks/install +++ b/hooks/install @@ -1 +1 @@ -swift-hooks.py \ No newline at end of file +swift_hooks.py \ No newline at end of file diff --git a/hooks/object-store-relation-joined b/hooks/object-store-relation-joined index fee03fe..8623fba 120000 --- a/hooks/object-store-relation-joined +++ b/hooks/object-store-relation-joined @@ -1 +1 @@ -swift-hooks.py \ No newline at end of file +swift_hooks.py \ No newline at end of file diff --git a/hooks/swift-storage-relation-broken b/hooks/swift-storage-relation-broken index fee03fe..8623fba 120000 --- a/hooks/swift-storage-relation-broken +++ b/hooks/swift-storage-relation-broken @@ -1 +1 @@ -swift-hooks.py \ No newline at end of file +swift_hooks.py \ No newline at end of file diff --git a/hooks/swift-storage-relation-changed b/hooks/swift-storage-relation-changed index fee03fe..8623fba 120000 --- a/hooks/swift-storage-relation-changed +++ b/hooks/swift-storage-relation-changed @@ -1 +1 @@ -swift-hooks.py \ No newline at end of file +swift_hooks.py \ No newline at end of file diff --git a/hooks/swift-hooks.py b/hooks/swift_hooks.py similarity index 85% rename from hooks/swift-hooks.py rename to hooks/swift_hooks.py index 420fe71..52af806 100755 --- a/hooks/swift-hooks.py +++ b/hooks/swift_hooks.py @@ -63,7 +63,7 @@ def install(): def keystone_joined(relid=None): - if is_clustered(): + if utils.is_clustered(): hostname = utils.config_get('vip') else: hostname = utils.unit_get('private-address') @@ -102,17 +102,17 @@ def balance_rings(): shutil.copyfile(os.path.join(swift.SWIFT_CONF_DIR, f), os.path.join(swift.WWW_DIR, f)) - if eligible_leader(): - msg = 'Broadcasting notification to all storage nodes that new '\ - 'ring is ready for consumption.' - utils.juju_log('INFO', msg) - www_dir = swift.WWW_DIR.split('/var/www/')[1] - trigger = uuid.uuid4() - swift_hash = swift.get_swift_hash() - # notify storage nodes that there is a new ring to fetch. - for relid in utils.relation_ids('swift-storage'): - utils.relation_set(rid=relid, swift_hash=swift_hash, - www_dir=www_dir, trigger=trigger) + if utils.eligible_leader(): + msg = 'Broadcasting notification to all storage nodes that new '\ + 'ring is ready for consumption.' + utils.juju_log('INFO', msg) + www_dir = swift.WWW_DIR.split('/var/www/')[1] + trigger = uuid.uuid4() + swift_hash = swift.get_swift_hash() + # notify storage nodes that there is a new ring to fetch. + for relid in utils.relation_ids('swift-storage'): + utils.relation_set(rid=relid, swift_hash=swift_hash, + www_dir=www_dir, trigger=trigger) swift.proxy_control('restart') @@ -168,29 +168,31 @@ SERVICE_PORTS = { ] } + def cluster_changed(): cluster_hosts = {} - cluster_hosts[os.getenv('JUJU_UNIT_NAME').replace('/','-')] = \ - utils.util_get('private-address') - for r_id in relation_ids('cluster'): - for unit in relation_list(r_id): - cluster_hosts[unit.replace('/','-')] = \ + cluster_hosts[os.getenv('JUJU_UNIT_NAME').replace('/', '-')] = \ + utils.unit_get('private-address') + for r_id in utils.relation_ids('cluster'): + for unit in utils.relation_list(r_id): + cluster_hosts[unit.replace('/', '-')] = \ utils.relation_get(attribute='private-address', rid=r_id, unit=unit) - configure_haproxy(cluster_hosts, - SERVICE_PORTS) + openstack.configure_haproxy(cluster_hosts, + SERVICE_PORTS) utils.restart('haproxy') def ha_relation_changed(): clustered = utils.relation_get('clustered') - if clustered and is_leader(): - juju_log('Cluster configured, notifying other services and updating' - 'keystone endpoint configuration') + if clustered and utils.is_leader(): + utils.juju_log('INFO', + 'Cluster configured, notifying other services and' + 'updating keystone endpoint configuration') # Tell all related services to start using # the VIP and haproxy ports instead - for r_id in relation_ids('identity-service'): + for r_id in utils.relation_ids('identity-service'): keystone_joined(relid=r_id) diff --git a/templates/haproxy.cfg b/templates/haproxy.cfg new file mode 100644 index 0000000..7404000 --- /dev/null +++ b/templates/haproxy.cfg @@ -0,0 +1,35 @@ +global + log 127.0.0.1 local0 + log 127.0.0.1 local1 notice + maxconn 20000 + user haproxy + group haproxy + spread-checks 0 + +defaults + log global + mode http + option httplog + option dontlognull + retries 3 + timeout queue 1000 + timeout connect 1000 + timeout client 30000 + timeout server 30000 + +listen stats :8888 + mode http + stats enable + stats hide-version + stats realm Haproxy\ Statistics + stats uri / + stats auth admin:password + +{% for service, ports in service_ports.iteritems() -%} +listen {{ service }} 0.0.0.0:{{ ports[0] }} + balance roundrobin + option tcplog + {% for unit, address in units.iteritems() -%} + server {{ unit }} {{ address }}:{{ ports[1] }} check + {% endfor %} +{% endfor %}