diff --git a/.travis.yml b/.travis.yml index 6ac11c63..e4f308b5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,6 +16,8 @@ before_deploy: deploy: provider: pypi + edge: + branch: v1.8.45 user: noplay password: secure: Fa66zp8ML4oSGwzkUMZi07MIYfO3tbS5gHFUaLN2mk2MBknhCjDYexmFJqT//sC/+xqv6sSJE6rz1EPoy/THbxj8R96ZgIyiUZIbDCbzgdy92d7J/eusrDoNdpApBLke8NqQqtFETb3addMZZNofQ3IDANFD2m2jY+KECU8z8NI= diff --git a/CHANGELOG b/CHANGELOG index 0c5be506..f7e7cc88 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,37 @@ # Change Log +## 2.1.4 12/03/2018 + +* Add Juniper JunOS space appliance. +* Sync checkpoint gaia appliance template. +* Sync appliance templates. +* Make sure we use an IPv4 address in the remote install script. +* Delete old pcap file when starting a new packet capture. +* Fix bug preventing to export portable projects with IOU images. +* Ignore invalid BPF filters. Ref #1290. +* Different approach to handle no data returned by uBridge hypervisors. Fixes #1289. +* Do not raise exception if Dynamips or uBridge hypervisor don't return data and are still running. Fixes #1289 +* Fix Dynamips private config not loaded into nvram when starting a router. Fixes #1313. +* Make sure we don't try to read when opening a file in binary more. Fixes #1301. +* Compatybility with controller, default_symbol and hover_symbol, Fixes: #2444 +* Filter snapshots directory during the snapshot, Fixes: #1297 +* Handle docker env with last empty line, Fixes: #2420 +* Require uBridge version 0.9.14 on Linux +* Pywin32 instead of pypiwin32, Ref. #1276 +* Fix missing 'locales' package in base image +* Implement a minimum interval between psutil calls. Fixes #2262 +* Fix error when appliance template is broken (missing fields). Fixes #1287. +* Fix "Change of linked base VM doesn't work with templates migrated from 2.0" +* Fix "Unable to override non-custom VMware adapter". +* Let a project be opened when a port cannot be found (can happens if a project is corrupted). +* Add an error message when Docker container is not ready to be started. Ref #1281. +* Update documentation. +* Sync appliance files. +* Fix issue when running multiple project containing IOU nodes on the same server. Ref #1239. +* Set first byte to 52 when generating a random MAC address for a Qemu VM. Ref #1267. +* Update link state and save project when a link is suspended or filters are added/removed (without node properties set). +* More generic dependency for pypiwin32, Ref. #1276 + ## 2.1.3 19/01/2018 * Update appliance files. diff --git a/gns3server/crash_report.py b/gns3server/crash_report.py index 0ea79d21..8303eb05 100644 --- a/gns3server/crash_report.py +++ b/gns3server/crash_report.py @@ -57,7 +57,7 @@ class CrashReport: Report crash to a third party service """ - DSN = "sync+https://9bd029d7f92b48178b01868465532d6e:9f4a6a513bd1452fbfd1771ae2ca8b66@sentry.io/38482" + DSN = "sync+https://6b6c2ce19b8545278f7ee00c333175a6:be17229ec8da460e9a126d02b82de5dc@sentry.io/38482" if hasattr(sys, "frozen"): cacert = get_resource("cacert.pem") if cacert is not None and os.path.isfile(cacert): diff --git a/tests/compute/docker/test_docker_vm.py b/tests/compute/docker/test_docker_vm.py index 0672a313..d48fcc98 100644 --- a/tests/compute/docker/test_docker_vm.py +++ b/tests/compute/docker/test_docker_vm.py @@ -86,7 +86,7 @@ def test_create(loop, project, manager): with asyncio_patch("gns3server.compute.docker.Docker.list_images", return_value=[{"image": "ubuntu"}]) as mock_list_images: with asyncio_patch("gns3server.compute.docker.Docker.query", return_value=response) as mock: vm = DockerVM("test", str(uuid.uuid4()), project, manager, "ubuntu:latest") - loop.run_until_complete(asyncio.ensure_future(vm.create())) + loop.run_until_complete(asyncio.async(vm.create())) mock.assert_called_with("POST", "containers/create", data={ "Tty": True, "OpenStdin": True, @@ -125,7 +125,7 @@ def test_create_with_tag(loop, project, manager): with asyncio_patch("gns3server.compute.docker.Docker.list_images", return_value=[{"image": "ubuntu"}]) as mock_list_images: with asyncio_patch("gns3server.compute.docker.Docker.query", return_value=response) as mock: vm = DockerVM("test", str(uuid.uuid4()), project, manager, "ubuntu:16.04") - loop.run_until_complete(asyncio.ensure_future(vm.create())) + loop.run_until_complete(asyncio.async(vm.create())) mock.assert_called_with("POST", "containers/create", data={ "Tty": True, "OpenStdin": True, @@ -167,7 +167,7 @@ def test_create_vnc(loop, project, manager): vm = DockerVM("test", str(uuid.uuid4()), project, manager, "ubuntu", console_type="vnc", console=5900) vm._start_vnc = MagicMock() vm._display = 42 - loop.run_until_complete(asyncio.ensure_future(vm.create())) + loop.run_until_complete(asyncio.async(vm.create())) mock.assert_called_with("POST", "containers/create", data={ "Tty": True, "OpenStdin": True, @@ -212,7 +212,7 @@ def test_create_start_cmd(loop, project, manager): with asyncio_patch("gns3server.compute.docker.Docker.query", return_value=response) as mock: vm = DockerVM("test", str(uuid.uuid4()), project, manager, "ubuntu:latest") vm._start_command = "/bin/ls" - loop.run_until_complete(asyncio.ensure_future(vm.create())) + loop.run_until_complete(asyncio.async(vm.create())) mock.assert_called_with("POST", "containers/create", data={ "Tty": True, "OpenStdin": True, @@ -256,36 +256,38 @@ def test_create_environment(loop, project, manager): with asyncio_patch("gns3server.compute.docker.Docker.query", return_value=response) as mock: vm = DockerVM("test", str(uuid.uuid4()), project, manager, "ubuntu") vm.environment = "YES=1\nNO=0\nGNS3_MAX_ETHERNET=eth2" - loop.run_until_complete(asyncio.ensure_future(vm.create())) - mock.assert_called_with("POST", "containers/create", data={ - "Tty": True, - "OpenStdin": True, - "StdinOnce": False, - "HostConfig": - { - "CapAdd": ["ALL"], - "Binds": [ - "{}:/gns3:ro".format(get_resource("compute/docker/resources")), - "{}:/gns3volumes/etc/network:rw".format(os.path.join(vm.working_dir, "etc", "network")) - ], - "Privileged": True - }, - "Env": [ - "container=docker", - "GNS3_MAX_ETHERNET=eth0", - "GNS3_VOLUMES=/etc/network", - "YES=1", - "NO=0" - ], - "Volumes": {}, - "NetworkDisabled": True, - "Name": "test", - "Hostname": "test", - "Image": "ubuntu:latest", - "Entrypoint": ["/gns3/init.sh"], - "Cmd": ["/bin/sh"] - }) - assert vm._cid == "e90e34656806" + loop.run_until_complete(asyncio.async(vm.create())) + assert mock.call_args[1]['data']['Env'] == [ + "container=docker", + "GNS3_MAX_ETHERNET=eth0", + "GNS3_VOLUMES=/etc/network", + "YES=1", + "NO=0" + ] + + +def test_create_environment_with_last_new_line_character(loop, project, manager): + """ + Allow user to pass an environnement. User can't override our + internal variables + """ + + response = { + "Id": "e90e34656806", + "Warnings": [] + } + with asyncio_patch("gns3server.compute.docker.Docker.list_images", return_value=[{"image": "ubuntu"}]): + with asyncio_patch("gns3server.compute.docker.Docker.query", return_value=response) as mock: + vm = DockerVM("test", str(uuid.uuid4()), project, manager, "ubuntu") + vm.environment = "YES=1\nNO=0\nGNS3_MAX_ETHERNET=eth2\n" + loop.run_until_complete(asyncio.async(vm.create())) + assert mock.call_args[1]['data']['Env'] == [ + "container=docker", + "GNS3_MAX_ETHERNET=eth0", + "GNS3_VOLUMES=/etc/network", + "YES=1", + "NO=0" + ] def test_create_image_not_available(loop, project, manager): @@ -311,7 +313,7 @@ def test_create_image_not_available(loop, project, manager): vm._get_image_information.side_effect = information with asyncio_patch("gns3server.compute.docker.DockerVM.pull_image", return_value=True) as mock_pull: with asyncio_patch("gns3server.compute.docker.Docker.query", return_value=response) as mock: - loop.run_until_complete(asyncio.ensure_future(vm.create())) + loop.run_until_complete(asyncio.async(vm.create())) mock.assert_called_with("POST", "containers/create", data={ "Tty": True, "OpenStdin": True, @@ -357,17 +359,17 @@ def test_get_container_state(loop, vm): } } with asyncio_patch("gns3server.compute.docker.Docker.query", return_value=response) as mock: - assert loop.run_until_complete(asyncio.ensure_future(vm._get_container_state())) == "running" + assert loop.run_until_complete(asyncio.async(vm._get_container_state())) == "running" response["State"]["Running"] = False response["State"]["Paused"] = True with asyncio_patch("gns3server.compute.docker.Docker.query", return_value=response) as mock: - assert loop.run_until_complete(asyncio.ensure_future(vm._get_container_state())) == "paused" + assert loop.run_until_complete(asyncio.async(vm._get_container_state())) == "paused" response["State"]["Running"] = False response["State"]["Paused"] = False with asyncio_patch("gns3server.compute.docker.Docker.query", return_value=response) as mock: - assert loop.run_until_complete(asyncio.ensure_future(vm._get_container_state())) == "exited" + assert loop.run_until_complete(asyncio.async(vm._get_container_state())) == "exited" def test_is_running(loop, vm): @@ -378,17 +380,17 @@ def test_is_running(loop, vm): } } with asyncio_patch("gns3server.compute.docker.Docker.query", return_value=response) as mock: - assert loop.run_until_complete(asyncio.ensure_future(vm.is_running())) is False + assert loop.run_until_complete(asyncio.async(vm.is_running())) is False response["State"]["Running"] = True with asyncio_patch("gns3server.compute.docker.Docker.query", return_value=response) as mock: - assert loop.run_until_complete(asyncio.ensure_future(vm.is_running())) is True + assert loop.run_until_complete(asyncio.async(vm.is_running())) is True def test_pause(loop, vm): with asyncio_patch("gns3server.compute.docker.Docker.query") as mock: - loop.run_until_complete(asyncio.ensure_future(vm.pause())) + loop.run_until_complete(asyncio.async(vm.pause())) mock.assert_called_with("POST", "containers/e90e34656842/pause") assert vm.status == "suspended" @@ -397,7 +399,7 @@ def test_pause(loop, vm): def test_unpause(loop, vm): with asyncio_patch("gns3server.compute.docker.Docker.query") as mock: - loop.run_until_complete(asyncio.ensure_future(vm.unpause())) + loop.run_until_complete(asyncio.async(vm.unpause())) mock.assert_called_with("POST", "containers/e90e34656842/unpause") @@ -417,10 +419,10 @@ def test_start(loop, vm, manager, free_console_port): vm._start_console = AsyncioMagicMock() nio = manager.create_nio({"type": "nio_udp", "lport": free_console_port, "rport": free_console_port, "rhost": "127.0.0.1"}) - loop.run_until_complete(asyncio.ensure_future(vm.adapter_add_nio_binding(0, nio))) + loop.run_until_complete(asyncio.async(vm.adapter_add_nio_binding(0, nio))) with asyncio_patch("gns3server.compute.docker.Docker.query") as mock_query: - loop.run_until_complete(asyncio.ensure_future(vm.start())) + loop.run_until_complete(asyncio.async(vm.start())) mock_query.assert_called_with("POST", "containers/e90e34656842/start") vm._add_ubridge_connection.assert_called_once_with(nio, 0) @@ -436,7 +438,7 @@ def test_start_namespace_failed(loop, vm, manager, free_console_port): vm.adapters = 1 nio = manager.create_nio({"type": "nio_udp", "lport": free_console_port, "rport": free_console_port, "rhost": "127.0.0.1"}) - loop.run_until_complete(asyncio.ensure_future(vm.adapter_add_nio_binding(0, nio))) + loop.run_until_complete(asyncio.async(vm.adapter_add_nio_binding(0, nio))) with asyncio_patch("gns3server.compute.docker.DockerVM._get_container_state", return_value="stopped"): with asyncio_patch("gns3server.compute.docker.Docker.query") as mock_query: @@ -446,7 +448,7 @@ def test_start_namespace_failed(loop, vm, manager, free_console_port): with asyncio_patch("gns3server.compute.docker.DockerVM._get_log", return_value='Hello not available') as mock_log: with pytest.raises(DockerError): - loop.run_until_complete(asyncio.ensure_future(vm.start())) + loop.run_until_complete(asyncio.async(vm.start())) mock_query.assert_any_call("POST", "containers/e90e34656842/start") mock_add_ubridge_connection.assert_called_once_with(nio, 0) @@ -468,7 +470,7 @@ def test_start_without_nio(loop, vm, manager, free_console_port): with asyncio_patch("gns3server.compute.docker.DockerVM._get_namespace", return_value=42) as mock_namespace: with asyncio_patch("gns3server.compute.docker.DockerVM._add_ubridge_connection") as mock_add_ubridge_connection: with asyncio_patch("gns3server.compute.docker.DockerVM._start_console") as mock_start_console: - loop.run_until_complete(asyncio.ensure_future(vm.start())) + loop.run_until_complete(asyncio.async(vm.start())) mock_query.assert_called_with("POST", "containers/e90e34656842/start") assert mock_add_ubridge_connection.called @@ -481,7 +483,7 @@ def test_start_unpause(loop, vm, manager, free_console_port): with asyncio_patch("gns3server.compute.docker.DockerVM._get_container_state", return_value="paused"): with asyncio_patch("gns3server.compute.docker.DockerVM.unpause", return_value="paused") as mock: - loop.run_until_complete(asyncio.ensure_future(vm.start())) + loop.run_until_complete(asyncio.async(vm.start())) assert mock.called assert vm.status == "started" @@ -489,7 +491,7 @@ def test_start_unpause(loop, vm, manager, free_console_port): def test_restart(loop, vm): with asyncio_patch("gns3server.compute.docker.Docker.query") as mock: - loop.run_until_complete(asyncio.ensure_future(vm.restart())) + loop.run_until_complete(asyncio.async(vm.restart())) mock.assert_called_with("POST", "containers/e90e34656842/restart") @@ -502,7 +504,7 @@ def test_stop(loop, vm): with asyncio_patch("gns3server.compute.docker.DockerVM._get_container_state", return_value="running"): with asyncio_patch("gns3server.compute.docker.Docker.query") as mock_query: - loop.run_until_complete(asyncio.ensure_future(vm.stop())) + loop.run_until_complete(asyncio.async(vm.stop())) mock_query.assert_called_with("POST", "containers/e90e34656842/stop", params={"t": 5}) assert mock.stop.called assert vm._ubridge_hypervisor is None @@ -514,7 +516,7 @@ def test_stop_paused_container(loop, vm): with asyncio_patch("gns3server.compute.docker.DockerVM._get_container_state", return_value="paused"): with asyncio_patch("gns3server.compute.docker.DockerVM.unpause") as mock_unpause: with asyncio_patch("gns3server.compute.docker.Docker.query") as mock_query: - loop.run_until_complete(asyncio.ensure_future(vm.stop())) + loop.run_until_complete(asyncio.async(vm.stop())) mock_query.assert_called_with("POST", "containers/e90e34656842/stop", params={"t": 5}) assert mock_unpause.called @@ -532,7 +534,7 @@ def test_update(loop, vm): with asyncio_patch("gns3server.compute.docker.Docker.list_images", return_value=[{"image": "ubuntu"}]) as mock_list_images: with asyncio_patch("gns3server.compute.docker.DockerVM._get_container_state", return_value="stopped"): with asyncio_patch("gns3server.compute.docker.Docker.query", return_value=response) as mock_query: - loop.run_until_complete(asyncio.ensure_future(vm.update())) + loop.run_until_complete(asyncio.async(vm.update())) mock_query.assert_any_call("DELETE", "containers/e90e34656842", params={"force": 1, "v": 1}) mock_query.assert_any_call("POST", "containers/create", data={ @@ -582,7 +584,7 @@ def test_update_vnc(loop, vm): with asyncio_patch("gns3server.compute.docker.Docker.list_images", return_value=[{"image": "ubuntu"}]) as mock_list_images: with asyncio_patch("gns3server.compute.docker.DockerVM._get_container_state", return_value="stopped"): with asyncio_patch("gns3server.compute.docker.Docker.query", return_value=response) as mock_query: - loop.run_until_complete(asyncio.ensure_future(vm.update())) + loop.run_until_complete(asyncio.async(vm.update())) assert vm.console == original_console assert vm.aux == original_aux @@ -601,7 +603,7 @@ def test_update_running(loop, vm): with asyncio_patch("gns3server.compute.docker.Docker.list_images", return_value=[{"image": "ubuntu"}]) as mock_list_images: with asyncio_patch("gns3server.compute.docker.DockerVM._get_container_state", return_value="running"): with asyncio_patch("gns3server.compute.docker.Docker.query", return_value=response) as mock_query: - loop.run_until_complete(asyncio.ensure_future(vm.update())) + loop.run_until_complete(asyncio.async(vm.update())) mock_query.assert_any_call("DELETE", "containers/e90e34656842", params={"force": 1, "v": 1}) mock_query.assert_any_call("POST", "containers/create", data={ @@ -639,7 +641,7 @@ def test_delete(loop, vm): with asyncio_patch("gns3server.compute.docker.DockerVM._get_container_state", return_value="stopped"): with asyncio_patch("gns3server.compute.docker.Docker.query") as mock_query: - loop.run_until_complete(asyncio.ensure_future(vm.delete())) + loop.run_until_complete(asyncio.async(vm.delete())) mock_query.assert_called_with("DELETE", "containers/e90e34656842", params={"force": 1, "v": 1}) @@ -649,11 +651,11 @@ def test_close(loop, vm, port_manager): "rport": 4343, "rhost": "127.0.0.1"} nio = vm.manager.create_nio(nio) - loop.run_until_complete(asyncio.ensure_future(vm.adapter_add_nio_binding(0, nio))) + loop.run_until_complete(asyncio.async(vm.adapter_add_nio_binding(0, nio))) with asyncio_patch("gns3server.compute.docker.DockerVM._get_container_state", return_value="stopped"): with asyncio_patch("gns3server.compute.docker.Docker.query") as mock_query: - loop.run_until_complete(asyncio.ensure_future(vm.close())) + loop.run_until_complete(asyncio.async(vm.close())) mock_query.assert_called_with("DELETE", "containers/e90e34656842", params={"force": 1, "v": 1}) assert vm._closed is True @@ -668,7 +670,7 @@ def test_close_vnc(loop, vm, port_manager): with asyncio_patch("gns3server.compute.docker.DockerVM._get_container_state", return_value="stopped"): with asyncio_patch("gns3server.compute.docker.Docker.query") as mock_query: - loop.run_until_complete(asyncio.ensure_future(vm.close())) + loop.run_until_complete(asyncio.async(vm.close())) mock_query.assert_called_with("DELETE", "containers/e90e34656842", params={"force": 1, "v": 1}) assert vm._closed is True @@ -682,7 +684,7 @@ def test_get_namespace(loop, vm): } } with asyncio_patch("gns3server.compute.docker.Docker.query", return_value=response) as mock_query: - assert loop.run_until_complete(asyncio.ensure_future(vm._get_namespace())) == 42 + assert loop.run_until_complete(asyncio.async(vm._get_namespace())) == 42 mock_query.assert_called_with("GET", "containers/e90e34656842/json") @@ -697,7 +699,7 @@ def test_add_ubridge_connection(loop, vm): vm._ubridge_hypervisor = MagicMock() vm._namespace = 42 - loop.run_until_complete(asyncio.ensure_future(vm._add_ubridge_connection(nio, 0))) + loop.run_until_complete(asyncio.async(vm._add_ubridge_connection(nio, 0))) calls = [ call.send('bridge create bridge0'), @@ -718,7 +720,7 @@ def test_add_ubridge_connection_none_nio(loop, vm): vm._ubridge_hypervisor = MagicMock() vm._namespace = 42 - loop.run_until_complete(asyncio.ensure_future(vm._add_ubridge_connection(nio, 0))) + loop.run_until_complete(asyncio.async(vm._add_ubridge_connection(nio, 0))) calls = [ call.send('bridge create bridge0'), @@ -739,7 +741,7 @@ def test_add_ubridge_connection_invalid_adapter_number(loop, vm): "rhost": "127.0.0.1"} nio = vm.manager.create_nio(nio) with pytest.raises(DockerError): - loop.run_until_complete(asyncio.ensure_future(vm._add_ubridge_connection(nio, 12))) + loop.run_until_complete(asyncio.async(vm._add_ubridge_connection(nio, 12))) def test_add_ubridge_connection_no_free_interface(loop, vm): @@ -755,7 +757,7 @@ def test_add_ubridge_connection_no_free_interface(loop, vm): interfaces = ["tap-gns3-e{}".format(index) for index in range(4096)] with patch("psutil.net_if_addrs", return_value=interfaces): - loop.run_until_complete(asyncio.ensure_future(vm._add_ubridge_connection(nio, 0))) + loop.run_until_complete(asyncio.async(vm._add_ubridge_connection(nio, 0))) def test_adapter_add_nio_binding(vm, loop): @@ -764,7 +766,7 @@ def test_adapter_add_nio_binding(vm, loop): "rport": 4343, "rhost": "127.0.0.1"} nio = vm.manager.create_nio(nio) - loop.run_until_complete(asyncio.ensure_future(vm.adapter_add_nio_binding(0, nio))) + loop.run_until_complete(asyncio.async(vm.adapter_add_nio_binding(0, nio))) assert vm._ethernet_adapters[0].get_nio(0) == nio @@ -779,9 +781,9 @@ def test_adapter_udpate_nio_binding(vm, loop): "rhost": "127.0.0.1"} nio = vm.manager.create_nio(nio) with asyncio_patch("gns3server.compute.docker.DockerVM._get_container_state", return_value="running"): - loop.run_until_complete(asyncio.ensure_future(vm.adapter_add_nio_binding(0, nio))) + loop.run_until_complete(asyncio.async(vm.adapter_add_nio_binding(0, nio))) - loop.run_until_complete(asyncio.ensure_future(vm.adapter_update_nio_binding(0, nio))) + loop.run_until_complete(asyncio.async(vm.adapter_update_nio_binding(0, nio))) assert vm._ubridge_apply_filters.called @@ -793,9 +795,9 @@ def test_adapter_udpate_nio_binding_bridge_not_started(vm, loop): "rhost": "127.0.0.1"} nio = vm.manager.create_nio(nio) with asyncio_patch("gns3server.compute.docker.DockerVM._get_container_state", return_value="running"): - loop.run_until_complete(asyncio.ensure_future(vm.adapter_add_nio_binding(0, nio))) + loop.run_until_complete(asyncio.async(vm.adapter_add_nio_binding(0, nio))) - loop.run_until_complete(asyncio.ensure_future(vm.adapter_update_nio_binding(0, nio))) + loop.run_until_complete(asyncio.async(vm.adapter_update_nio_binding(0, nio))) assert vm._ubridge_apply_filters.called is False @@ -806,7 +808,7 @@ def test_adapter_add_nio_binding_invalid_adapter(vm, loop): "rhost": "127.0.0.1"} nio = vm.manager.create_nio(nio) with pytest.raises(DockerError): - loop.run_until_complete(asyncio.ensure_future(vm.adapter_add_nio_binding(12, nio))) + loop.run_until_complete(asyncio.async(vm.adapter_add_nio_binding(12, nio))) def test_adapter_remove_nio_binding(vm, loop): @@ -818,10 +820,10 @@ def test_adapter_remove_nio_binding(vm, loop): "rport": 4343, "rhost": "127.0.0.1"} nio = vm.manager.create_nio(nio) - loop.run_until_complete(asyncio.ensure_future(vm.adapter_add_nio_binding(0, nio))) + loop.run_until_complete(asyncio.async(vm.adapter_add_nio_binding(0, nio))) with asyncio_patch("gns3server.compute.docker.DockerVM._ubridge_send") as delete_ubridge_mock: - loop.run_until_complete(asyncio.ensure_future(vm.adapter_remove_nio_binding(0))) + loop.run_until_complete(asyncio.async(vm.adapter_remove_nio_binding(0))) assert vm._ethernet_adapters[0].get_nio(0) is None delete_ubridge_mock.assert_any_call('bridge stop bridge0') delete_ubridge_mock.assert_any_call('bridge remove_nio_udp bridge0 4242 127.0.0.1 4343') @@ -829,15 +831,15 @@ def test_adapter_remove_nio_binding(vm, loop): def test_adapter_remove_nio_binding_invalid_adapter(vm, loop): with pytest.raises(DockerError): - loop.run_until_complete(asyncio.ensure_future(vm.adapter_remove_nio_binding(12))) + loop.run_until_complete(asyncio.async(vm.adapter_remove_nio_binding(12))) def test_start_capture(vm, tmpdir, manager, free_console_port, loop): output_file = str(tmpdir / "test.pcap") nio = manager.create_nio({"type": "nio_udp", "lport": free_console_port, "rport": free_console_port, "rhost": "127.0.0.1"}) - loop.run_until_complete(asyncio.ensure_future(vm.adapter_add_nio_binding(0, nio))) - loop.run_until_complete(asyncio.ensure_future(vm.start_capture(0, output_file))) + loop.run_until_complete(asyncio.async(vm.adapter_add_nio_binding(0, nio))) + loop.run_until_complete(asyncio.async(vm.start_capture(0, output_file))) assert vm._ethernet_adapters[0].get_nio(0).capturing @@ -845,10 +847,10 @@ def test_stop_capture(vm, tmpdir, manager, free_console_port, loop): output_file = str(tmpdir / "test.pcap") nio = manager.create_nio({"type": "nio_udp", "lport": free_console_port, "rport": free_console_port, "rhost": "127.0.0.1"}) - loop.run_until_complete(asyncio.ensure_future(vm.adapter_add_nio_binding(0, nio))) + loop.run_until_complete(asyncio.async(vm.adapter_add_nio_binding(0, nio))) loop.run_until_complete(vm.start_capture(0, output_file)) assert vm._ethernet_adapters[0].get_nio(0).capturing - loop.run_until_complete(asyncio.ensure_future(vm.stop_capture(0))) + loop.run_until_complete(asyncio.async(vm.stop_capture(0))) assert vm._ethernet_adapters[0].get_nio(0).capturing is False @@ -861,7 +863,7 @@ def test_get_log(loop, vm): mock_query.read = read with asyncio_patch("gns3server.compute.docker.Docker.http_query", return_value=mock_query) as mock: - images = loop.run_until_complete(asyncio.ensure_future(vm._get_log())) + images = loop.run_until_complete(asyncio.async(vm._get_log())) mock.assert_called_with("GET", "containers/e90e34656842/logs", params={"stderr": 1, "stdout": 1}, data={}) @@ -870,7 +872,7 @@ def test_get_image_informations(project, manager, loop): } with asyncio_patch("gns3server.compute.docker.Docker.query", return_value=response) as mock: vm = DockerVM("test", str(uuid.uuid4()), project, manager, "ubuntu") - loop.run_until_complete(asyncio.ensure_future(vm._get_image_information())) + loop.run_until_complete(asyncio.async(vm._get_image_information())) mock.assert_called_with("GET", "images/ubuntu:latest/json") @@ -900,7 +902,7 @@ def test_start_vnc(vm, loop): with patch("shutil.which", return_value="/bin/x"): with asyncio_patch("gns3server.compute.docker.docker_vm.wait_for_file_creation") as mock_wait: with asyncio_patch("asyncio.create_subprocess_exec") as mock_exec: - loop.run_until_complete(asyncio.ensure_future(vm._start_vnc())) + loop.run_until_complete(asyncio.async(vm._start_vnc())) assert vm._display is not None mock_exec.assert_any_call("Xvfb", "-nolisten", "tcp", ":{}".format(vm._display), "-screen", "0", "1280x1024x16") mock_exec.assert_any_call("x11vnc", "-forever", "-nopw", "-shared", "-geometry", "1280x1024", "-display", "WAIT:{}".format(vm._display), "-rfbport", str(vm.console), "-rfbportv6", str(vm.console), "-noncache", "-listen", "127.0.0.1") @@ -909,13 +911,13 @@ def test_start_vnc(vm, loop): def test_start_vnc_xvfb_missing(vm, loop): with pytest.raises(DockerError): - loop.run_until_complete(asyncio.ensure_future(vm._start_vnc())) + loop.run_until_complete(asyncio.async(vm._start_vnc())) def test_start_aux(vm, loop): with asyncio_patch("asyncio.subprocess.create_subprocess_exec", return_value=MagicMock()) as mock_exec: - loop.run_until_complete(asyncio.ensure_future(vm._start_aux())) + loop.run_until_complete(asyncio.async(vm._start_aux())) mock_exec.assert_called_with('docker', 'exec', '-i', 'e90e34656842', '/gns3/bin/busybox', 'script', '-qfc', 'while true; do TERM=vt100 /gns3/bin/busybox sh; done', '/dev/null', stderr=asyncio.subprocess.STDOUT, stdin=asyncio.subprocess.PIPE, stdout=asyncio.subprocess.PIPE) @@ -977,5 +979,5 @@ def test_read_console_output_with_binary_mode(vm, loop): output_stream = MagicMock() with asyncio_patch('gns3server.compute.docker.docker_vm.DockerVM.stop'): - loop.run_until_complete(asyncio.ensure_future(vm._read_console_output(input_stream, output_stream))) + loop.run_until_complete(asyncio.async(vm._read_console_output(input_stream, output_stream))) output_stream.feed_data.assert_called_once_with(b"test") diff --git a/win-requirements.txt b/win-requirements.txt index 1446069f..017a1d07 100644 --- a/win-requirements.txt +++ b/win-requirements.txt @@ -1,3 +1,3 @@ -rrequirements.txt -pypiwin32<222 # pyup: ignore +pywin32>=223 # pyup: ignore