def test_server_disconnect_from_nat(self):
     fake_client, fake_ctx = self.generate_client_and_context_server()
     fake_ctx._target.instance.runtime_properties = {
         vcloud_network_plugin.PUBLIC_IP: '192.168.1.1'
     }
     fake_ctx._target.node.properties = {
         'nat': {
             'edge_gateway': 'gateway'
         },
         'rules': [{
             'type': 'DNAT'
         }]
     }
     fake_ctx._source.node.properties = {
         'vcloud_config':
         {
             'edge_gateway': 'gateway',
             'vdc': 'vdc'
         }
     }
     fake_ctx._source.instance.runtime_properties = {
         'gateway_lock': False,
         'vcloud_vapp_name': 'vapp'
     }
     with mock.patch(
         'vcloud_plugin_common.VcloudAirClient.get',
         mock.MagicMock(return_value=fake_client)
     ):
         public_nat.server_disconnect_from_nat(ctx=fake_ctx)
     fake_client._vdc_gateway.del_nat_rule.assert_called_with(
         'DNAT', '192.168.1.1', 'any', '1.1.1.1', 'any', 'any'
     )
Beispiel #2
0
 def test_server_disconnect_from_nat(self):
     # successful
     fake_client, fake_ctx = self._server_disconnect_to_nat_noexternal()
     with mock.patch('vcloud_plugin_common.VcloudAirClient.get',
                     mock.MagicMock(return_value=fake_client)):
         public_nat.server_disconnect_from_nat(ctx=fake_ctx)
     fake_client._vdc_gateway.del_nat_rule.assert_called_with(
         'DNAT', '192.168.1.1', 'any', '1.1.1.1', 'any', 'any')
     # check retry
     fake_client, fake_ctx = self._server_disconnect_to_nat_noexternal()
     with mock.patch('vcloud_plugin_common.VcloudAirClient.get',
                     mock.MagicMock(return_value=fake_client)):
         self.prepere_gatway_busy_retry(fake_client, fake_ctx)
         public_nat.server_disconnect_from_nat(ctx=fake_ctx)
         self.check_retry_realy_called(fake_ctx)
 def test_server_disconnect_from_nat(self):
     # successful
     fake_client, fake_ctx = self._server_disconnect_to_nat_noexternal()
     with mock.patch(
         'vcloud_plugin_common.VcloudAirClient.get',
         mock.MagicMock(return_value=fake_client)
     ):
         public_nat.server_disconnect_from_nat(ctx=fake_ctx)
     fake_client._vdc_gateway.del_nat_rule.assert_called_with(
         'DNAT', '192.168.1.1', 'any', '1.1.1.1', 'any', 'any'
     )
     # check retry
     fake_client, fake_ctx = self._server_disconnect_to_nat_noexternal()
     with mock.patch(
         'vcloud_plugin_common.VcloudAirClient.get',
         mock.MagicMock(return_value=fake_client)
     ):
         self.prepere_gatway_busy_retry(fake_client, fake_ctx)
         public_nat.server_disconnect_from_nat(ctx=fake_ctx)
         self.check_retry_realy_called(fake_ctx)