def test_disconnect_floatingip(self): fake_client, fake_ctx = self.generate_client_and_context_floating_ip() fake_ctx._target.node.properties = { 'floatingip': { 'edge_gateway': 'gateway' } } fake_ctx._target.instance.runtime_properties = { network_plugin.PUBLIC_IP: '10.10.1.2' } fake_client._vdc_gateway.deallocate_public_ip = mock.MagicMock( return_value=self.generate_task( vcloud_plugin_common.TASK_STATUS_SUCCESS ) ) with mock.patch( 'vcloud_plugin_common.VcloudAirClient.get', mock.MagicMock(return_value=fake_client) ): floatingip.disconnect_floatingip( ctx=fake_ctx ) runtime_properties = fake_ctx._target.instance.runtime_properties self.assertFalse( network_plugin.PUBLIC_IP in runtime_properties )
def test_floating_ip_create_delete_with_explicit_ip(self): self.ctx.target.node.properties['floatingip'].update( self.test_config['floatingip']) public_ip = self.ctx.target.node.properties['floatingip']['public_ip'] CheckAssignedExternalIp(public_ip, self._get_gateway()) floatingip.connect_floatingip() floatingip.disconnect_floatingip() CheckAssignedExternalIp(public_ip, self._get_gateway())
def test_floating_ip_create_delete_with_autoget_ip(self): self.ctx.target.node.properties['floatingip'].update( self.test_config['floatingip']) del self.ctx.target.node.properties['floatingip']['public_ip'] floatingip.connect_floatingip() public_ip = self.ctx.target.instance.runtime_properties['public_ip'] self.assertRaises(cfy_exc.NonRecoverableError, CheckAssignedExternalIp, public_ip, self._get_gateway()) self.assertTrue(public_ip) floatingip.disconnect_floatingip() CheckAssignedExternalIp(public_ip, self._get_gateway())
def test_disconnect_floatingip(self): fake_client, fake_ctx = self.generate_client_and_context_floating_ip() fake_ctx._target.node.properties = { 'floatingip': { 'edge_gateway': 'gateway' } } fake_ctx._target.instance.runtime_properties = { network_plugin.PUBLIC_IP: '10.10.1.2' } fake_client._vdc_gateway.deallocate_public_ip = mock.MagicMock( return_value=self.generate_task( vcloud_plugin_common.TASK_STATUS_SUCCESS)) with mock.patch('vcloud_plugin_common.VcloudAirClient.get', mock.MagicMock(return_value=fake_client)): floatingip.disconnect_floatingip(ctx=fake_ctx) runtime_properties = fake_ctx._target.instance.runtime_properties self.assertFalse(network_plugin.PUBLIC_IP in runtime_properties)
def _disconnect_floating_ip(self): with contextlib.nested( mock.patch('network_plugin.floatingip.ctx', self.fip_ctx), mock.patch('vcloud_plugin_common.ctx', self.fip_ctx)): floatingip.disconnect_floatingip()