Class: Chef::Knife::AcropolisSnapshotCreate
Instance Method Summary
collapse
#delete, #get, included, #post
Instance Method Details
#run ⇒ Object
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
# File 'lib/chef/knife/acropolis_snapshot_create.rb', line 36
def run
validate
task_list = [
ui.color('Task ID', :bold)
]
uuid = SecureRandom.uuid
specs = '{
"snapshotSpecs": [
{
"vmUuid": "'"#{Chef::Config[:knife][:uuid].to_s}"'",
"snapshotName": "'"#{Chef::Config[:knife][:snap].to_s}"'",
"uuid": "'"#{uuid}"'"
}
]
}'
task = post("/snapshots", specs)
uuid = JSON.parse(task)
task_list << uuid["taskUuid"].to_s
print ui.list(task_list, :uneven_columns_across, 1)
end
|
#validate ⇒ Object
28
29
30
31
32
33
|
# File 'lib/chef/knife/acropolis_snapshot_create.rb', line 28
def validate
unless Chef::Config[:knife][:uuid] && Chef::Config[:knife][:snap]
ui.error('Missing ID or Name. Use -I (--vm-uuid) to set the VM and -S (--snap-name) for the snapshot name.')
exit 1
end
end
|