Guest User

Untitled

a guest
May 27th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.60 KB | None | 0 0
  1. def validate
  2. unless Chef::Config[:knife][:mem] && Chef::Config[:knife][:cpu] && Chef::Config[:knife][:disk_size] && Chef::Config[:knife][:networkUuid] && Chef::Config[:knife][:node_name]
  3. ui.error('Missing mem, cpu, name or gateway. Use -M (--mem), -C (--cpu), -N (--node-name), -D (--disk-size) and -U (--network-uuid) to set the mandatory values.')
  4. exit 1
  5. end
  6. end
  7.  
  8. def run
  9. validate
  10.  
  11. task_list = [
  12. ui.color('Task ID', :bold)
  13. ]
  14.  
  15. specs = '{
  16. "name": "'"#{Chef::Config[:knife][:node_name]}"'",
  17. "memoryMb": "'"#{Chef::Config[:knife][:mem]}"'",
  18. "numVcpus": "'"#{Chef::Config[:knife][:cpu]}"'",
  19. "hypervisorType": "Acropolis",
  20. "description": "Created with knife-acropolis",
  21. "vmDisks": [
  22. {
  23. "isCdrom": false,
  24. "isEmpty": false,
  25. "isScsiPassThrough": false,
  26. "vmDiskCreate": {
  27. "containerName": "default",
  28. "sizeMb": "'"#{Chef::Config[:knife][:disk_size]}"'"
  29. }
  30. }
  31. ],
  32. "vmNics": [
  33. {
  34. "networkUuid": "'"#{Chef::Config[:knife][:networkUuid]}"'",
  35. "requestIp": true
  36. }
  37. ]
  38. }'
  39. task = post('/vms', specs)
  40. uuid = JSON.parse(task)
  41. task_list << uuid['taskUuid'].to_s
  42. print ui.list(task_list, :uneven_columns_across, 1)
  43. end
  44.  
  45. task = post('/vms', specs)
  46. uuid = JSON.parse(task)
  47. task_list << uuid['taskUuid'].to_s
  48. print ui.list(task_list, :uneven_columns_across, 1)
Add Comment
Please, Sign In to add comment