Exemplo n.º 1
0
 def execute(self, disk_path):
     metadata = image.generate_snapshot_metadata(self.context,
                                                 self.image_api,
                                                 self.image_id,
                                                 self.instance)
     LOG.info(
         "Starting stream of boot device (local blockdev %(devpath)s) "
         "to glance image %(img_id)s.", {
             'devpath': disk_path,
             'img_id': self.image_id
         },
         instance=self.instance)
     image.stream_blockdev_to_glance(self.context, self.image_api,
                                     self.image_id, metadata, disk_path)
Exemplo n.º 2
0
 def test_generate_snapshot_metadata(self, mock_api):
     mock_api.get.return_value = {'name': 'image_name'}
     mock_instance = mock.Mock()
     mock_instance.project_id = 'project_id'
     ret = image.generate_snapshot_metadata('context', mock_api, 'image_id',
                                            mock_instance)
     mock_api.get.assert_called_with('context', 'image_id')
     self.assertEqual({
         'name': 'image_name',
         'status': 'active',
         'disk_format': 'raw',
         'container_format': 'bare',
         'properties': {
             'image_location': 'snapshot',
             'image_state': 'available',
             'owner_id': 'project_id',
         }
     }, ret)
Exemplo n.º 3
0
 def test_generate_snapshot_metadata(self, mock_api):
     mock_api.get.return_value = {'name': 'image_name'}
     mock_instance = mock.Mock()
     mock_instance.project_id = 'project_id'
     ret = image.generate_snapshot_metadata('context', mock_api, 'image_id',
                                            mock_instance)
     mock_api.get.assert_called_with('context', 'image_id')
     self.assertEqual({
         'name': 'image_name',
         'status': 'active',
         'disk_format': 'raw',
         'container_format': 'bare',
         'properties': {
             'image_location': 'snapshot',
             'image_state': 'available',
             'owner_id': 'project_id',
         }
     }, ret)