Beispiel #1
0
 def test_get_existing_rccg(self, svc_authorize_mock, svc_obj_info_mock):
     set_module_args({
         'clustername': 'test_remotecluster',
         'domain': 'domain',
         'username': '******',
         'password': '******',
         'name': 'test_name',
         'state': 'present',
     })
     svc_obj_info_mock.return_value = {
         "id": "11",
         "name": "test_name",
         "master_cluster_id": "0000020321E04566",
         "master_cluster_name": "test_remotecluster",
         "aux_cluster_id": "0000020321E04566",
         "aux_cluster_name": "test_remotecluster",
         "primary": "",
         "state": "empty",
         "relationship_count": "0",
         "freeze_time": "",
         "status": "",
         "sync": "",
         "copy_type": "metro",
         "cycling_mode": "",
         "cycle_period_seconds": "0"
     }
     obj = IBMSVCRCCG()
     return_data = obj.get_existing_rccg()
     self.assertEqual('test_name', return_data['name'])
Beispiel #2
0
 def test_create_existing(self, svc_authorize_mock, svc_run_command_mock,
                          get_existing_rccg_mock):
     set_module_args({
         'clustername': 'test_remotecluster',
         'domain': 'domain',
         'username': '******',
         'password': '******',
         'name': 'test_name',
         'state': 'present',
         'copytype': 'metro'
     })
     get_existing_rccg_mock.return_value = {
         "id": "11",
         "name": "test_name",
         "master_cluster_id": "0000020321E04566",
         "master_cluster_name": "test_remotecluster",
         "aux_cluster_id": "0000020321E04566",
         "aux_cluster_name": "test_remotecluster",
         "primary": "",
         "state": "empty",
         "relationship_count": "0",
         "freeze_time": "",
         "status": "",
         "sync": "",
         "copy_type": "metro",
         "cycling_mode": "",
         "cycle_period_seconds": "0"
     }
     with pytest.raises(AnsibleExitJson) as exc:
         obj = IBMSVCRCCG()
         obj.apply()
     self.assertFalse(exc.value.args[0]['changed'])
Beispiel #3
0
 def test_rccg_probe_failure_when_invalid_input(self, svc_authorize_mock,
                                                svc_obj_info_mock):
     set_module_args({
         'clustername': 'test_remotecluster',
         'domain': 'domain',
         'username': '******',
         'password': '******',
         'name': 'test_name',
         'state': 'present',
         'copytype': 'invalid_input'
     })
     arg_data = {
         "id": "11",
         "name": "test_name",
         "master_cluster_id": "0000020321E04566",
         "master_cluster_name": "test_remotecluster",
         "aux_cluster_id": "0000020321E04566",
         "aux_cluster_name": "test_remotecluster",
         "primary": "",
         "state": "empty",
         "relationship_count": "0",
         "freeze_time": "",
         "status": "",
         "sync": "",
         "copy_type": "global",
         "cycling_mode": "",
         "cycle_period_seconds": "0"
     }
     with pytest.raises(AnsibleFailJson) as exc:
         obj = IBMSVCRCCG()
         obj.rccg_probe(arg_data)
     self.assertTrue(exc.value.args[0]["failed"])
Beispiel #4
0
 def test_rccg_probe(self, svc_authorize_mock, svc_obj_info_mock):
     set_module_args({
         'clustername': 'test_remotecluster',
         'domain': 'domain',
         'username': '******',
         'password': '******',
         'name': 'test_name',
         'state': 'present',
         'copytype': 'metro',
     })
     arg_data = {
         "id": "11",
         "name": "test_name",
         "master_cluster_id": "0000020321E04566",
         "master_cluster_name": "test_remotecluster",
         "aux_cluster_id": "0000020321E04566",
         "aux_cluster_name": "test_remotecluster",
         "primary": "",
         "state": "empty",
         "relationship_count": "0",
         "freeze_time": "",
         "status": "",
         "sync": "",
         "copy_type": "global",
         "cycling_mode": "",
         "cycle_period_seconds": "0"
     }
     obj = IBMSVCRCCG()
     return_data = obj.rccg_probe(arg_data)
     self.assertIn('metro', return_data[0])
     self.assertTrue(return_data[0]["metro"])
Beispiel #5
0
 def test_delete_non_existing(self, svc_authorize_mock,
                              svc_run_command_mock, get_existing_rccg_mock):
     set_module_args({
         'clustername': 'test_remotecluster',
         'domain': 'domain',
         'username': '******',
         'password': '******',
         'name': 'test_name',
         'state': 'absent',
         'copytype': 'metro'
     })
     get_existing_rccg_mock.return_value = {}
     with pytest.raises(AnsibleExitJson) as exc:
         obj = IBMSVCRCCG()
         obj.apply()
     self.assertFalse(exc.value.args[0]['changed'])
Beispiel #6
0
 def test_rccg_update(self, svc_authorize_mock, svc_run_command_mock):
     set_module_args({
         'clustername': 'test_remotecluster',
         'domain': 'domain',
         'username': '******',
         'password': '******',
         'name': 'test_name',
         'state': 'present',
         'copytype': 'metro',
         'cyclingperiod': 299
     })
     sample_modify = {'global': True}
     sample_modifycv = {
         'cycleperiodseconds': 300,
     }
     obj = IBMSVCRCCG()
     return_data = obj.rccg_update(sample_modify, sample_modifycv)
     self.assertEqual(None, return_data)
Beispiel #7
0
 def test_creation(self, svc_authorize_mock, svc_run_command_mock,
                   get_existing_rccg_mock):
     set_module_args({
         'clustername': 'test_remotecluster',
         'domain': 'domain',
         'username': '******',
         'password': '******',
         'name': 'test_name',
         'state': 'present'
     })
     get_existing_rccg_mock.return_value = {}
     svc_run_command_mock.return_value = {
         'message': 'RC Consistency Group, id [3], successfully created',
         'id': '3'
     }
     with pytest.raises(AnsibleExitJson) as exc:
         obj = IBMSVCRCCG()
         obj.apply()
     self.assertTrue(exc.value.args[0]['changed'])
Beispiel #8
0
 def test_module_fail_when_required_args_missing(self):
     """ required arguments are reported as errors """
     with pytest.raises(AnsibleFailJson) as exc:
         set_module_args({})
         IBMSVCRCCG()
     print('Info: %s' % exc.value.args[0]['msg'])