Пример #1
0
    def configure_namenode(self, secondary_host=None, secondary_port=None):
        dc = self.hadoop_base.dist_config
        host = hookenv.local_unit().replace('/', '-')
        port = dc.port('namenode')
        self.configure_hdfs_base(host, port)
        cfg = self.hadoop_base.charm_config
        hdfs_site = dc.path('hadoop_conf') / 'hdfs-site.xml'
        with utils.xmlpropmap_edit_in_place(hdfs_site) as props:
            props['dfs.replication'] = cfg['dfs_replication']
            props['dfs.blocksize'] = int(cfg['dfs_blocksize'])
            props['dfs.namenode.datanode.registration.ip-hostname-check'] = 'true'
            props['dfs.namenode.http-address'] = '0.0.0.0:{}'.format(dc.port('nn_webapp_http'))
            # TODO: support SSL
            # props['dfs.namenode.https-address'] = '0.0.0.0:{}'.format(dc.port('nn_webapp_https'))

            # FIXME hack-around until transition to layers is complete
            if not (secondary_host and secondary_port) and helpers:
                unit, secondary = helpers.any_ready_unit('secondary')
                if unit:
                    secondary_host = secondary['hostname']
                    secondary_port = secondary['port']
            if secondary_host and secondary_port:
                props['dfs.secondary.http.address'] = '{host}:{port}'.format(
                    host=secondary_host,
                    port=secondary_port,
                )
Пример #2
0
 def am_i_registered(self):
     my_ip = utils.resolve_private_address(
         hookenv.unit_get('private-address'))
     my_hostname = hookenv.local_unit().replace('/', '-')
     unit, data = any_ready_unit(self.relation_name)
     etc_hosts = json.loads((data or {}).get('etc_hosts', '{}'))
     return etc_hosts.get(my_ip, None) == my_hostname
Пример #3
0
 def provide(self, remote_service, all_ready):
     """
     Used by the endpoint to provide the :attr:`required_keys`.
     """
     if not all_ready:
         return {}
     _, namenode = any_ready_unit(NameNode.relation_name)
     _, resourcemanager = any_ready_unit(ResourceManager.relation_name)
     return {
         'namenode-host': namenode['private-address'],
         'hdfs-port': namenode['port'],
         'webhdfs-port': namenode['webhdfs-port'],
         'resourcemanager-host': resourcemanager['private-address'],
         'resourcemanager-port': resourcemanager['port'],
         'historyserver-host': resourcemanager['private-address'],
         'historyserver-port': resourcemanager['historyserver-port'],
     }
Пример #4
0
 def provide(self, remote_service, all_ready):
     """
     Used by the endpoint to provide the :attr:`required_keys`.
     """
     if not all_ready:
         return {}
     _, namenode = any_ready_unit(NameNode.relation_name)
     _, resourcemanager = any_ready_unit(ResourceManager.relation_name)
     return {
         'namenode-host': namenode['private-address'],
         'hdfs-port': namenode['port'],
         'webhdfs-port': namenode['webhdfs-port'],
         'resourcemanager-host': resourcemanager['private-address'],
         'resourcemanager-port': resourcemanager['port'],
         'historyserver-host': resourcemanager['private-address'],
         'historyserver-port': resourcemanager['historyserver-port'],
     }
Пример #5
0
 def _remote(self, relation):
     """
     Return the hostname of the unit on the other end of the given
     relation (derived from that unit's name) and the port used to talk
     to that unit.
     :param str relation: Name of the relation, e.g. "datanode" or "namenode"
     """
     # FIXME delete when transition to layers is complete
     unit, data = helpers.any_ready_unit(relation)
     if not unit:
         return None, None
     host = unit.replace('/', '-')
     return host, data['port']
Пример #6
0
 def _remote(self, relation):
     """
     Return the hostname of the unit on the other end of the given
     relation (derived from that unit's name) and the port used to talk
     to that unit.
     :param str relation: Name of the relation, e.g. "resourcemanager" or "nodemanager"
     """
     # FIXME delete when transition to layers is complete
     unit, data = helpers.any_ready_unit(relation)
     if not unit:
         return None, None
     host = unit.replace('/', '-')
     port = data['port']
     history_http = data['historyserver-http']
     history_ipc = data['historyserver-ipc']
     return host, port, history_http, history_ipc
Пример #7
0
 def am_i_registered(self):
     my_ip = utils.resolve_private_address(hookenv.unit_get('private-address'))
     my_hostname = hookenv.local_unit().replace('/', '-')
     unit, data = any_ready_unit(self.relation_name)
     etc_hosts = json.loads((data or {}).get('etc_hosts', '{}'))
     return etc_hosts.get(my_ip, None) == my_hostname
Пример #8
0
 def register_provided_hosts(self):
     unit, data = any_ready_unit(self.relation_name)
     provided_hosts = json.loads(data['etc_hosts'])
     hookenv.log('Registering hosts from %s: %s' % (unit, provided_hosts))
     for ip, name in provided_hosts.items():
         utils.update_kv_host(ip, name)
Пример #9
0
 def install_ssh_keys(self):
     unit, data = any_ready_unit(self.relation_name)
     ssh_key = data['ssh-key']
     utils.install_ssh_key(self.ssh_user, ssh_key)
Пример #10
0
 def register_provided_hosts(self):
     unit, data = any_ready_unit(self.relation_name)
     provided_hosts = json.loads(data['etc_hosts'])
     hookenv.log('Registering hosts from %s: %s' % (unit, provided_hosts))
     for ip, name in provided_hosts.items():
         utils.update_kv_host(ip, name)
Пример #11
0
 def install_ssh_keys(self):
     unit, data = any_ready_unit(self.relation_name)
     ssh_key = data['ssh-key']
     utils.install_ssh_key(self.ssh_user, ssh_key)