Method: CIMI::Service::VolumeCreate#create

Defined in:
lib/cimi/service/volume_create.rb

#createObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/cimi/service/volume_create.rb', line 18

def create
  template = resolve(volume_template)
  volume_image = resolve(template.volume_image)
  volume_config = resolve(template.volume_config)

  params = {
    :name => name,
    :capacity => volume_config.capacity,
    :snapshot_id => ref_id(volume_image.id),
  }

  unless context.driver.respond_to? :create_storage_volume
     raise Deltacloud::Exceptions.exception_from_status(
       501,
       "Creating Volume is not supported by the current driver"
     )
  end

  volume = context.driver.create_storage_volume(context.credentials, params)

  result = CIMI::Service::Volume.from_storage_volume(volume, context)
  result.name = name if name
  result.description = description if description
  result.property = property if property
  result.save
  result
end