Class: Chef::Knife::ProfitbricksVolumeCreate

Inherits:
Chef::Knife
  • Object
show all
Includes:
ProfitbricksBase
Defined in:
lib/chef/knife/profitbricks_volume_create.rb

Instance Method Summary collapse

Methods included from ProfitbricksBase

#connection, included, #msg_pair

Instance Method Details

#runObject



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# File 'lib/chef/knife/profitbricks_volume_create.rb', line 66

def run
  $stdout.sync = true

  print "#{ui.color('Creating volume...', :magenta)}"

  params = {
    name: config[:name],
    size: config[:size],
    bus: config[:bus] || 'VIRTIO',
    image: config[:image],
    type: config[:type],
    licenceType: config[:licencetype],
  }

  if config[:sshkeys]
    params[:sshKeys] = config[:sshkeys]
  end

  if config[:imagepassword]
    params[:imagePassword] = config[:imagepassword]
  end

  if config[:volume_availability_zone]
    params[:availabilityZone] = config[:volume_availability_zone]
  end

  connection
  volume = ProfitBricks::Volume.create(
    config[:datacenter_id],
    params.compact
  )

  dot = ui.color('.', :magenta)
  volume.wait_for(300) { print dot; ready? }
  volume.reload

  puts "\n"
  puts "#{ui.color('ID', :cyan)}: #{volume.id}"
  puts "#{ui.color('Name', :cyan)}: #{volume.properties['name']}"
  puts "#{ui.color('Size', :cyan)}: #{volume.properties['size']}"
  puts "#{ui.color('Bus', :cyan)}: #{volume.properties['bus']}"
  puts "#{ui.color('Image', :cyan)}: #{volume.properties['image']}"
  puts "#{ui.color('Type', :cyan)}: #{volume.properties['type']}"
  puts "#{ui.color('Licence Type', :cyan)}: #{volume.properties['licenceType']}"
  puts "#{ui.color('Zone', :cyan)}: #{volume.properties['availabilityZone']}"
  puts 'done'
end