def test_volume(self):
     disks_count = lambda: len(
         self.vca_client.get_disks(self.vcloud_config['vdc']))
     volume.creation_validation()
     disks_before = disks_count()
     volume.create_volume()
     if self.relationctx.source.node.properties['use_external_resource']:
         self.assertEqual(disks_before, disks_count())
     else:
         self.assertEqual(disks_before + 1, disks_count())
     self._attach_detach()
     volume.delete_volume()
     self.assertEqual(disks_before, disks_count())
Ejemplo n.º 2
0
 def test_volume(self):
     disks_count = lambda: len(
         self.vca_client.get_disks(self.vcloud_config['vdc']))
     volume.creation_validation()
     disks_before = disks_count()
     volume.create_volume()
     if self.relationctx.source.node.properties['use_external_resource']:
         self.assertEqual(disks_before, disks_count())
     else:
         self.assertEqual(disks_before + 1, disks_count())
     self._attach_detach()
     volume.delete_volume()
     self.assertEqual(disks_before, disks_count())
Ejemplo n.º 3
0
 def test_create_volume(self):
     fake_client = self.generate_client()
     # external resource
     fake_ctx = cfy_mocks.MockCloudifyContext(
         node_id='test',
         node_name='test',
         properties={
             'use_external_resource': True,
             'vcloud_config': {
                 'vdc': 'vdc_name'
             }
         }
     )
     with mock.patch(
         'vcloud_plugin_common.VcloudAirClient.get',
         mock.MagicMock(return_value=fake_client)
     ):
         volume.create_volume(ctx=fake_ctx)
     # fail on create volume
     fake_ctx = cfy_mocks.MockCloudifyContext(
         node_id='test',
         node_name='test',
         properties={
             'use_external_resource': False,
             'volume': {
                 'name': 'some-other',
                 'size': 11
             },
             'vcloud_config': {
                 'vdc': 'vdc_name'
             }
         }
     )
     with mock.patch(
         'vcloud_plugin_common.VcloudAirClient.get',
         mock.MagicMock(return_value=fake_client)
     ):
         with self.assertRaises(cfy_exc.NonRecoverableError):
             volume.create_volume(ctx=fake_ctx)
     fake_client.add_disk.assert_called_with(
         'vdc_name', 'some-other', 11534336
     )
     # positive case
     disk = mock.Mock()
     disk.get_Tasks = mock.MagicMock(
         return_value=[self.generate_task(
             vcloud_plugin_common.TASK_STATUS_SUCCESS
         )]
     )
     fake_client.add_disk = mock.MagicMock(
         return_value=(True, disk)
     )
     with mock.patch(
         'vcloud_plugin_common.VcloudAirClient.get',
         mock.MagicMock(return_value=fake_client)
     ):
         volume.create_volume(ctx=fake_ctx)