示例#1
0
def register_templates(template_registry, config_opts):
    '''
    Register the common templates.
    Params
    ------
    template_registry : `TemplateRegistry`
        Registry to update.

    config_opts : `hod.mpiservice.ConfigOptsParams`
        Configuration structure holding our config options.
    '''
    workdir = config_opts.workdir
    modules = config_opts.modules
    local_data_network = node.sorted_network(node.get_networks())[0]
    templates = [
        _config_template_stub('masterhostname', 'Hostname bound to the Fully Qualified Domain Name (FQDN) of the master node.'),
        _config_template_stub('masterhostaddress', 'Address bound to the Fully Qualified Domain Name (FQDN) of the master node.'),
        _config_template_stub('masterdataname', 'Hostname bound to the Infiniband adaptor on the master node if available'),
        _config_template_stub('masterdataaddress', 'Address bound to the Infiniband adaptor on the master node if available'),
        ConfigTemplate('hostname', socket.getfqdn, 'Fully Qualified Domain Name (FQDN)'),
        ConfigTemplate('hostaddress', lambda: socket.gethostbyname(socket.getfqdn()), 'IP address registered as the FQDN'),
        ConfigTemplate('dataname', local_data_network.hostname, 'Infiniband hostname if available'),
        ConfigTemplate('dataaddress', local_data_network.addr, 'Infiniband address if available'),
        ConfigTemplate('workdir', workdir, 'Base directory for configuration and logging, e.g. /tmp, or somewhere on a shared file system.'),
        ConfigTemplate('localworkdir', lambda: mklocalworkdir(workdir), 'Subdirectory of workdir with user, host, and pid in the name to make it distinct from other workdirs for use on shared file systems'),
        ConfigTemplate('user', _current_user, 'Current user'),
        ConfigTemplate('pid', os.getpid, 'PID for the current process'),
        ConfigTemplate('modules', lambda: ' '.join(modules), 'Modules listed in the hod.conf'),
        ]

    for ct in templates:
        template_registry.register(ct)
def register_templates(template_registry, config_opts):
    '''
    Register the common templates.
    Params
    ------
    template_registry : `TemplateRegistry`
        Registry to update.

    config_opts : `hod.mpiservice.ConfigOptsParams`
        Configuration structure holding our config options.
    '''
    workdir = config_opts.workdir
    modules = config_opts.modules
    local_data_network = node.sorted_network(node.get_networks())[0]
    templates = [
        _config_template_stub(
            'masterhostname',
            'Hostname bound to the Fully Qualified Domain Name (FQDN) of the master node.'
        ),
        _config_template_stub(
            'masterhostaddress',
            'Address bound to the Fully Qualified Domain Name (FQDN) of the master node.'
        ),
        _config_template_stub(
            'masterdataname',
            'Hostname bound to the Infiniband adaptor on the master node if available'
        ),
        _config_template_stub(
            'masterdataaddress',
            'Address bound to the Infiniband adaptor on the master node if available'
        ),
        ConfigTemplate('hostname', socket.getfqdn,
                       'Fully Qualified Domain Name (FQDN)'),
        ConfigTemplate('hostaddress',
                       lambda: socket.gethostbyname(socket.getfqdn()),
                       'IP address registered as the FQDN'),
        ConfigTemplate('dataname', local_data_network.hostname,
                       'Infiniband hostname if available'),
        ConfigTemplate('dataaddress', local_data_network.addr,
                       'Infiniband address if available'),
        ConfigTemplate(
            'workdir', workdir,
            'Base directory for configuration and logging, e.g. /tmp, or somewhere on a shared file system.'
        ),
        ConfigTemplate(
            'localworkdir', lambda: mklocalworkdir(workdir),
            'Subdirectory of workdir with user, host, and pid in the name to make it distinct from other workdirs for use on shared file systems'
        ),
        ConfigTemplate('user', _current_user, 'Current user'),
        ConfigTemplate('pid', os.getpid, 'PID for the current process'),
        ConfigTemplate('modules', lambda: ' '.join(modules),
                       'Modules listed in the hod.conf'),
    ]

    for ct in templates:
        template_registry.register(ct)
示例#3
0
 def test_sorted_networks_multiple_infiniband(self):
     '''
     We don't want to use infiniband interfaces that haven't had a
     hostname assigned to them.
     '''
     nw = [hn.NetworkInterface('localhost', '127.0.0.1', 'lo', 8),
           hn.NetworkInterface('wibble01.wibble.os', '10.1.1.2', 'em1', 16),
           hn.NetworkInterface('wibble01.sitename.tld', '157.193.16.9', 'em3', 25),
           hn.NetworkInterface('wibble01.wibble.data', '10.143.13.2', 'ib0', 16),
           hn.NetworkInterface('10.143.113.2', '10.143.113.2', 'ib1', 16)]
     sorted_nw = hn.sorted_network(copy.copy(nw))
     print sorted_nw
     self.assertEqual([nw[3], nw[2], nw[1], nw[4], nw[0]], sorted_nw)
def master_template_opts(stub_config_opts=None):
    '''
    Generate template options for the master node.

    If stub_config_opts is given, this function pulls the doctrings from the existing
    configuration
    '''
    data_interface = node.sorted_network(node.get_networks())[0]
    master_dataname = data_interface.hostname
    master_dataaddress = data_interface.addr
    fqdn = socket.getfqdn()
    docs = dict()
    if stub_config_opts is not None:
        docs = dict([(opt.name, opt.doc) for opt in stub_config_opts])
    return [
        ConfigTemplate('masterhostname', fqdn, docs.get('masterhostname', '')),
        ConfigTemplate('masterhostaddress', socket.gethostbyname(fqdn), docs.get('masterhostaddress', '')),
        ConfigTemplate('masterdataname', master_dataname, docs.get('masterdataname', '')),
        ConfigTemplate('masterdataaddress', master_dataaddress, docs.get('masterdataaddress', '')),
        ]
示例#5
0
 def test_node_sorted_network_complex(self):
     '''test sorted_network puts IB before loopback'''
     nw = [hn.NetworkInterface('localhost', '127.0.0.1', 'lo', 8),
           hn.NetworkInterface('localhost', '127.0.0.1', 'ib3', 8)]
     sorted_nw = hn.sorted_network(copy.copy(nw))
     self.assertEqual([nw[1], nw[0]], sorted_nw)
示例#6
0
 def test_node_sorted_network_simple(self):
     '''test node order network'''
     nw = [hn.NetworkInterface('localhost', '127.0.0.1', 'lo', 8)]
     self.assertEqual(nw, hn.sorted_network(nw))