Beispiel #1
0
 def test_configure_maas_stonith_resource_no_url(self, is_resource_present,
                                                 commit, config):
     cfg = {'maas_credentials': 'apikey'}
     is_resource_present.return_value = False
     config.side_effect = lambda x: cfg.get(x)
     with self.assertRaises(ValueError):
         utils.configure_maas_stonith_resource('node1')
 def test_configure_maas_stonith_resource_no_url(self,
                                                 is_resource_present,
                                                 commit, config):
     cfg = {
         'maas_credentials': 'apikey'}
     is_resource_present.return_value = False
     config.side_effect = lambda x: cfg.get(x)
     with self.assertRaises(ValueError):
         utils.configure_maas_stonith_resource('node1')
Beispiel #3
0
 def test_configure_maas_stonith_resource_duplicate(self,
                                                    crm_update_resource,
                                                    is_resource_present,
                                                    commit, config):
     cfg = {'maas_url': 'http://maas/2.0', 'maas_credentials': 'apikey'}
     is_resource_present.return_value = True
     config.side_effect = lambda x: cfg.get(x)
     utils.configure_maas_stonith_resource(['node1'])
     crm_update_resource.assert_called_once_with(
         'st-maas-3975c9d', 'stonith:external/maas',
         ("params url='http://maas/2.0' apikey='apikey' hostnames='node1' "
          "op monitor interval=25 start-delay=25 timeout=25"))
     commit.assert_called_once_with(
         'crm configure property stonith-enabled=true',
         failure_is_fatal=True)
Beispiel #4
0
 def test_configure_maas_stonith_resource(self, is_resource_present, commit,
                                          config):
     cfg = {'maas_url': 'http://maas/2.0', 'maas_credentials': 'apikey'}
     is_resource_present.return_value = False
     config.side_effect = lambda x: cfg.get(x)
     utils.configure_maas_stonith_resource(['node1'])
     cmd = ("crm configure primitive st-maas-3975c9d "
            "stonith:external/maas "
            "params url='http://maas/2.0' apikey='apikey' "
            "hostnames='node1' "
            "op monitor interval=25 start-delay=25 "
            "timeout=25")
     commit_calls = [
         mock.call(cmd, failure_is_fatal=True),
         mock.call('crm configure property stonith-enabled=true',
                   failure_is_fatal=True),
     ]
     commit.assert_has_calls(commit_calls)
 def test_configure_maas_stonith_resource_duplicate(self,
                                                    crm_update_resource,
                                                    is_resource_present,
                                                    commit, config):
     cfg = {
         'maas_url': 'http://maas/2.0',
         'maas_credentials': 'apikey'}
     is_resource_present.return_value = True
     config.side_effect = lambda x: cfg.get(x)
     utils.configure_maas_stonith_resource(['node1'])
     crm_update_resource.assert_called_once_with(
         'st-maas-3975c9d',
         'stonith:external/maas',
         ("params url='http://maas/2.0' apikey='apikey' hostnames='node1' "
          "op monitor interval=25 start-delay=25 timeout=25"))
     commit.assert_called_once_with(
         'crm configure property stonith-enabled=true',
         failure_is_fatal=True)
 def test_configure_maas_stonith_resource(self, is_resource_present,
                                          commit, config):
     cfg = {
         'maas_url': 'http://maas/2.0',
         'maas_credentials': 'apikey'}
     is_resource_present.return_value = False
     config.side_effect = lambda x: cfg.get(x)
     utils.configure_maas_stonith_resource(['node1'])
     cmd = (
         "crm configure primitive st-maas-3975c9d "
         "stonith:external/maas "
         "params url='http://maas/2.0' apikey='apikey' "
         "hostnames='node1' "
         "op monitor interval=25 start-delay=25 "
         "timeout=25")
     commit_calls = [
         mock.call(cmd, failure_is_fatal=True),
         mock.call(
             'crm configure property stonith-enabled=true',
             failure_is_fatal=True),
     ]
     commit.assert_has_calls(commit_calls)