~aisrael/charms/trusty/apache-hadoop-client/benchmarks

« back to all changes in this revision

Viewing changes to hooks/resourcemanager-relation-changed

  • Committer: Adam Israel
  • Date: 2015-05-28 20:03:27 UTC
  • mfrom: (75.1.21 apache-hadoop-client)
  • Revision ID: adam.israel@gmail.com-20150528200327-3x16mmo1onh18lsj
merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/env python
2
 
# Licensed under the Apache License, Version 2.0 (the "License");
3
 
# you may not use this file except in compliance with the License.
4
 
# You may obtain a copy of the License at
5
 
#
6
 
#     http://www.apache.org/licenses/LICENSE-2.0
7
 
#
8
 
# Unless required by applicable law or agreed to in writing, software
9
 
# distributed under the License is distributed on an "AS IS" BASIS,
10
 
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
 
# See the License for the specific language governing permissions and
12
 
# limitations under the License.
13
 
 
14
 
import common
15
 
from charmhelpers.contrib.bigdata import utils
16
 
from charmhelpers.core import hookenv
17
 
common.manage()
18
 
 
19
 
# send our hostname info on the relation
20
 
host, fqdn = utils.get_hostname_data()
21
 
hookenv.relation_set(hostfqdn=fqdn)
22
 
hookenv.relation_set(hostname=host)
23
 
 
24
 
# get the hostname attributes from our remote unit
25
 
remote_ip = hookenv.relation_get('private-address')
26
 
remote_fqdn = hookenv.relation_get('hostfqdn') or ""
27
 
remote_host = hookenv.relation_get('hostname') or ""
28
 
 
29
 
# onyl update if we have at least one valid hostname
30
 
if remote_fqdn or remote_host:
31
 
    hookenv.log('Updating /etc/hosts with yarn-master hostname data',
32
 
                hookenv.INFO)
33
 
    host_entry = "{'%s': {'private-address': '%s', 'hostfqdn': '%s', 'hostname': '%s'}}" % (remote_ip, remote_ip, remote_fqdn, remote_host)
34
 
    utils.update_etc_hosts(host_entry)
35
 
else:
36
 
    hookenv.log('Incomplete hostname data; not updating /etc/hosts',
37
 
                hookenv.INFO)