예제 #1
0
 def test_delete_object_positive(self):
     """Check nsx_common.attempt_with_rerun func: success"""
     self._regen_ctx()
     self.fake_ctx.instance.runtime_properties['resource_id'] = 'r_id'
     kwargs = {
         'a': {'b': 'c'},
         'nsx_auth': {
             'username': '******',
             'password': '******',
             'host': 'host',
             'raml': 'raml'
         }
     }
     fake_client_result = mock.MagicMock()
     fake_client = mock.MagicMock(
         return_value=fake_client_result
     )
     fake_func_for_call = mock.MagicMock()
     with mock.patch(
         'cloudify_nsx.library.nsx_common.NsxClient',
         fake_client
     ):
         common.delete_object(fake_func_for_call, 'a', kwargs, ['d', 'm'])
         fake_client.assert_called_with(
             'raml', 'host', 'username', 'password'
         )
         fake_func_for_call.assert_called_with(
             client_session=fake_client_result, resource_id='r_id'
         )
         self.assertEqual(self.fake_ctx.instance.runtime_properties, {})
예제 #2
0
 def test_delete_object_not_fully(self):
     """Check nsx_common.attempt_with_rerun func: not fully created"""
     self._regen_ctx()
     fake_client = mock.MagicMock()
     with mock.patch(
         'cloudify_nsx.library.nsx_common.NsxClient',
         fake_client
     ):
         self.fake_ctx.instance.runtime_properties['resource_id'] = None
         self.fake_ctx.instance.runtime_properties['d'] = None
         self.fake_ctx.instance.runtime_properties['m'] = None
         common.delete_object(None, 'a', {'a': {'b': 'c'}}, ['d', 'm'])
         self.assertEqual(self.fake_ctx.instance.runtime_properties, {})
예제 #3
0
 def test_delete_object_use_external(self):
     """Check nsx_common.attempt_with_rerun func: use external"""
     self._regen_ctx()
     fake_client = mock.MagicMock()
     with mock.patch(
         'cloudify_nsx.library.nsx_common.NsxClient',
         fake_client
     ):
         self.fake_ctx.instance.runtime_properties['resource_id'] = '!'
         self.fake_ctx.node.properties['use_external_resource'] = True
         self.fake_ctx.instance.runtime_properties['d'] = 'f'
         self.fake_ctx.instance.runtime_properties['m'] = 'g'
         common.delete_object(None, 'a', {'a': {'b': 'c'}}, ['d', 'm'])
         self.assertEqual(self.fake_ctx.instance.runtime_properties, {})
예제 #4
0
    def test_delete_object_call_with_exception(self):
        """Check nsx_common.attempt_with_rerun func: call with exception"""
        self._regen_ctx()
        self.fake_ctx.instance.runtime_properties['resource_id'] = 'r_id'
        kwargs = {
            'a': {'b': 'c'},
            'nsx_auth': {
                'username': '******',
                'password': '******',
                'host': 'host',
                'raml': 'raml'
            }
        }
        fake_client = mock.MagicMock(
            side_effect=cfy_exc.NonRecoverableError()
        )
        with mock.patch(
            'cloudify_nsx.library.nsx_common.NsxClient',
            fake_client
        ):

            with self.assertRaises(cfy_exc.NonRecoverableError):
                common.delete_object(None, 'a', kwargs, ['d', 'm'])

            fake_client.assert_called_with(
                'raml', 'host', 'username', 'password'
            )
            runtime = self.fake_ctx.instance.runtime_properties
            self.assertEqual(runtime['resource_id'], 'r_id')
            self.assertEqual(
                runtime['nsx_auth'], {
                    'username': '******',
                    'password': '******',
                    'host': 'host',
                    'raml': 'raml'
                }
            )
예제 #5
0
def delete(**kwargs):
    common.delete_object(cfy_dlr.del_dhcp_relay, 'relay', kwargs)
예제 #6
0
def delete(**kwargs):
    common.delete_object(nsx_security_policy.del_policy, 'policy', kwargs)
예제 #7
0
def delete(**kwargs):
    common.delete_object(nsx_security_policy.del_policy_group_bind,
                         'policy_group_bind', kwargs)
예제 #8
0
def delete(**kwargs):
    common.delete_object(nsx_security_group.del_group_member, 'group_member',
                         kwargs)
예제 #9
0
def delete(**kwargs):
    common.delete_object(nsx_nat.delete_nat_rule, 'rule', kwargs)
예제 #10
0
def delete(**kwargs):
    common.delete_object(cfy_dlr.del_bgp_neighbour, 'neighbour', kwargs)
예제 #11
0
def delete(**kwargs):
    common.delete_object(nsx_lswitch.del_logical_switch, 'switch', kwargs,
                         ['vsphere_network_id', 'name'])
예제 #12
0
def delete(**kwargs):
    common.delete_object(nsx_security_tag.delete_tag, 'tag', kwargs)
예제 #13
0
def delete(**kwargs):
    common.delete_object(nsx_firewall.delete_firewall_rule, 'rule', kwargs,
                         ['rule_id'])