Add storage to VMWare Service

Hi,

Is there a method to permit a user to provision additional storage (i.e. a second disk) to a VM? For example, let’s say I have RHEL6 service offering that is comprised of a 10GB vmware template. Is there any way to allow the tenant to add an additional 50GB volume to the service (so that it shows up as /dev/sdb) at the time of request?

I know that cloudforms provides this via the vmwareAPI, but as I understand it, there are licensing issues with providing it with MIQ.

Is there another method?

thanks,
Steve

Sure you can try something like this (mind you it only works in vmware right now):

# add_disk - look in ws_values and prov.options for add_disk? parameters
if add_disk
  log(:info, "Processing add_disk...", true)
  ws_disks = []
  if prov.options.has_key?(:ws_values)
    ws_values = prov.options[:ws_values]
    # :ws_values=>{:add_disk1 => '20', :add_disk2=>'50'}
    ws_values.each {|k,v| ws_disks[$1.to_i] = v.to_i if k.to_s =~ /add_disk(\d*)/}
    ws_disks.compact!
  end
  if ws_disks.blank?
    # prov.options=>{:add_disk1 => '20', :add_disk2=>'50'}
    prov.options.each {|k,v| ws_disks[$1.to_i] = v.to_i if k.to_s =~ /add_disk(\d*)/}
    ws_disks.compact!
  end

  unless ws_disks.blank?
    new_disks = []
    scsi_start_idx = 2

    ws_disks.each_with_index do |size_in_gb, idx|
      next if size_in_gb.zero?
      new_disks << {:bus=>0, :pos=>scsi_start_idx + idx, :sizeInMB=> size_in_gb.gigabytes / 1.megabyte}
    end
    prov.set_option(:disk_scsi, new_disks) unless new_disks.blank?
    log(:info, "Provisioning object <:disk_scsi> updated with <#{prov.get_option(:disk_scsi)}>")
  end
  log(:info, "Processing add_disk...Complete", true)
end
2 Likes

Hello Guys, It is nice to see what I need. Where should we use this code is this a method?
One more question, “we have requirement that an additional disk is chosen to be added or not, it is completely users wish. A decision dialog appears in the service dialog yes/no to add the additional disk” Does this code work like this in the Yes/No scenario? If so, where should I use this code.