def test_connect_floatingip(self):
     """
         check connect_floatingip with explicitly defined ip
     """
     fake_client, fake_ctx = self.generate_client_and_context_floating_ip(
         vcloud_plugin_common.SUBSCRIPTION_SERVICE_TYPE
     )
     fake_ctx._target.node.properties = {
         'floatingip': {
             'edge_gateway': 'gateway',
             network_plugin.PUBLIC_IP: '10.10.2.3'
         }
     }
     fake_ctx._target.instance.runtime_properties = {}
     fake_client._vdc_gateway.get_public_ips = mock.MagicMock(return_value=[
         '10.18.1.1', '10.10.2.3'
     ])
     fake_client._vdc_gateway.get_nat_rules = mock.MagicMock(
         return_value=[]
     )
     with mock.patch(
         'vcloud_plugin_common.VcloudAirClient.get',
         mock.MagicMock(return_value=fake_client)
     ):
         floatingip.connect_floatingip(
             ctx=fake_ctx
         )
     runtime_properties = fake_ctx._target.instance.runtime_properties
     self.assertTrue(
         network_plugin.PUBLIC_IP in runtime_properties
     )
     self.assertEqual(
         runtime_properties.get(network_plugin.PUBLIC_IP),
         '10.10.2.3'
     )
 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_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_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())
Ejemplo n.º 6
0
 def test_connect_floatingip(self):
     """
         check connect_floatingip with explicitly defined ip
     """
     fake_client, fake_ctx = self.generate_client_and_context_floating_ip(
         vcloud_plugin_common.SUBSCRIPTION_SERVICE_TYPE)
     fake_ctx._target.node.properties = {
         'floatingip': {
             'edge_gateway': 'gateway',
             network_plugin.PUBLIC_IP: '10.10.2.3'
         }
     }
     fake_ctx._target.instance.runtime_properties = {}
     fake_client._vdc_gateway.get_public_ips = mock.MagicMock(
         return_value=['10.18.1.1', '10.10.2.3'])
     fake_client._vdc_gateway.get_nat_rules = mock.MagicMock(
         return_value=[])
     with mock.patch('vcloud_plugin_common.VcloudAirClient.get',
                     mock.MagicMock(return_value=fake_client)):
         floatingip.connect_floatingip(ctx=fake_ctx)
     runtime_properties = fake_ctx._target.instance.runtime_properties
     self.assertTrue(network_plugin.PUBLIC_IP in runtime_properties)
     self.assertEqual(runtime_properties.get(network_plugin.PUBLIC_IP),
                      '10.10.2.3')
Ejemplo n.º 7
0
 def _connect_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.connect_floatingip()
Ejemplo n.º 8
0
 def _connect_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.connect_floatingip()