def test_server_connect_to_nat(self): fake_client, fake_ctx = self._server_connect_to_nat_noexternal() with mock.patch('vcloud_plugin_common.VcloudAirClient.get', mock.MagicMock(return_value=fake_client)): public_nat.server_connect_to_nat(ctx=fake_ctx) fake_client._vdc_gateway.add_nat_rule.assert_called_with( 'DNAT', '10.18.1.1', 'any', '1.1.1.1', 'any', 'any') fake_client, fake_ctx = self._server_connect_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_connect_to_nat(ctx=fake_ctx) self.check_retry_realy_called(fake_ctx)
def test_server_connect_to_nat(self): fake_client, fake_ctx = self._server_connect_to_nat_noexternal() with mock.patch( 'vcloud_plugin_common.VcloudAirClient.get', mock.MagicMock(return_value=fake_client) ): public_nat.server_connect_to_nat(ctx=fake_ctx) fake_client._vdc_gateway.add_nat_rule.assert_called_with( 'DNAT', '10.18.1.1', 'any', '1.1.1.1', 'any', 'any' ) fake_client, fake_ctx = self._server_connect_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_connect_to_nat(ctx=fake_ctx) self.check_retry_realy_called(fake_ctx)
def test_server_connect_to_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._source.instance.runtime_properties = { 'gateway_lock': False, 'vcloud_vapp_name': 'vapp' } fake_ctx._source.node.properties = { 'vcloud_config': { 'edge_gateway': 'gateway', 'vdc': 'vdc' } } fake_ctx._target.node.properties = { 'nat': { 'edge_gateway': 'gateway' }, 'rules': [{ 'type': 'DNAT' }] } fake_client._vdc_gateway.get_public_ips = mock.MagicMock( return_value=['10.18.1.1'] ) with mock.patch( 'vcloud_plugin_common.VcloudAirClient.get', mock.MagicMock(return_value=fake_client) ): public_nat.server_connect_to_nat(ctx=fake_ctx) fake_client._vdc_gateway.add_nat_rule.assert_called_with( 'DNAT', '10.18.1.1', 'any', '1.1.1.1', 'any', 'any' )