コード例 #1
0
def configure_maas_stonith_resource(stonith_hostnames):
    """Create stonith resource for the given hostname.

    :param stonith_hostnames: The hostnames that the stonith management system
                             refers to the remote node as.
    :type stonith_hostname: List
    """
    hostnames = []
    for host in stonith_hostnames:
        hostnames.append(host)
        if '.' in host:
            hostnames.append(host.split('.')[0])
    hostnames = list(set(hostnames))
    ctxt = {
        'url': config('maas_url'),
        'apikey': config('maas_credentials'),
        'hostnames': ' '.join(sorted(hostnames))}
    if all(ctxt.values()):
        maas_login_params = "url='{url}' apikey='{apikey}'".format(**ctxt)
        maas_rsc_hash = pcmk.resource_checksum(
            'st',
            'stonith:external/maas',
            res_params=maas_login_params)[:7]
        ctxt['stonith_resource_name'] = 'st-maas-{}'.format(maas_rsc_hash)
        ctxt['resource_params'] = (
            "params url='{url}' apikey='{apikey}' hostnames='{hostnames}' "
            "op monitor interval=25 start-delay=25 "
            "timeout=25").format(**ctxt)
        if pcmk.is_resource_present(ctxt['stonith_resource_name']):
            pcmk.crm_update_resource(
                ctxt['stonith_resource_name'],
                'stonith:external/maas',
                ctxt['resource_params'])
        else:
            cmd = (
                "crm configure primitive {stonith_resource_name} "
                "stonith:external/maas {resource_params}").format(**ctxt)
            pcmk.commit(cmd, failure_is_fatal=True)
        pcmk.commit(
            "crm configure property stonith-enabled=true",
            failure_is_fatal=True)
    else:
        raise ValueError("Missing configuration: {}".format(ctxt))
    return {ctxt['stonith_resource_name']: 'stonith:external/maas'}
コード例 #2
0
ファイル: utils.py プロジェクト: openstack/charm-hacluster
def configure_maas_stonith_resource(stonith_hostnames):
    """Create stonith resource for the given hostname.

    :param stonith_hostnames: The hostnames that the stonith management system
                             refers to the remote node as.
    :type stonith_hostname: List
    """
    hostnames = []
    for host in stonith_hostnames:
        hostnames.append(host)
        if '.' in host:
            hostnames.append(host.split('.')[0])
    hostnames = list(set(hostnames))
    ctxt = {
        'url': config('maas_url'),
        'apikey': config('maas_credentials'),
        'hostnames': ' '.join(sorted(hostnames))}
    if all(ctxt.values()):
        maas_login_params = "url='{url}' apikey='{apikey}'".format(**ctxt)
        maas_rsc_hash = pcmk.resource_checksum(
            'st',
            'stonith:external/maas',
            res_params=maas_login_params)[:7]
        ctxt['stonith_resource_name'] = 'st-maas-{}'.format(maas_rsc_hash)
        ctxt['resource_params'] = (
            "params url='{url}' apikey='{apikey}' hostnames='{hostnames}' "
            "op monitor interval=25 start-delay=25 "
            "timeout=25").format(**ctxt)
        if pcmk.is_resource_present(ctxt['stonith_resource_name']):
            pcmk.crm_update_resource(
                ctxt['stonith_resource_name'],
                'stonith:external/maas',
                ctxt['resource_params'])
        else:
            cmd = (
                "crm configure primitive {stonith_resource_name} "
                "stonith:external/maas {resource_params}").format(**ctxt)
            pcmk.commit(cmd, failure_is_fatal=True)
        pcmk.commit(
            "crm configure property stonith-enabled=true",
            failure_is_fatal=True)
    else:
        raise ValueError("Missing configuration: {}".format(ctxt))
    return {ctxt['stonith_resource_name']: 'stonith:external/maas'}
コード例 #3
0
ファイル: test_pcmk.py プロジェクト: hemanthnakkina/hotsos
 def test_resource_checksum(self):
     r = pcmk.resource_checksum('res_test', 'IPaddr2',
                                'params ip=1.2.3.4 cidr_netmask=255.0.0.0')
     self.assertEqual(r, 'ef395293b1b7c29c5bf1c99774f75cf4')
コード例 #4
0
ファイル: test_pcmk.py プロジェクト: gnuoy/charm-hacluster
 def test_resource_checksum(self):
     r = pcmk.resource_checksum('res_test', 'IPaddr2',
                                'params ip=1.2.3.4 cidr_netmask=255.0.0.0')
     self.assertEqual(r, 'ef395293b1b7c29c5bf1c99774f75cf4')