Module: ConohaApi::Client::Compute
- Included in:
- ConohaApi::Client
- Defined in:
- lib/conoha_api/client/compute.rb
Constant Summary collapse
- SERVICE =
'compute'
Instance Method Summary collapse
- #add_keypair(name, public_key = nil) ⇒ Object
- #add_server(image_ref, flavor_ref, options = {}) ⇒ Object
- #change_console_keymap(id, vnc_keymap) ⇒ Object
- #change_network_adapter(id, hardware_virtualinterface_model) ⇒ Object
- #change_strage_controller(id, hardware_disk_bus) ⇒ Object
- #change_video_device(id, hardware_video_model) ⇒ Object
- #confirm_resize(id) ⇒ Object
- #create_image(id, name) ⇒ Object
- #delete_keypair(name) ⇒ Object
- #delete_server(id) ⇒ Object
- #flavor(id) ⇒ Object
- #flavors ⇒ Object
- #flavors_detail ⇒ Object
- #force_stop_server(id, force = true) ⇒ Object
- #get_web_console(id, type = 'nova') ⇒ Object
- #image(id) ⇒ Object
- #images ⇒ Object
- #images_detail(options = {}) ⇒ Object
- #keypair(name) ⇒ Object
- #keypairs ⇒ Object
- #mount_iso_image(id, file_path) ⇒ Object
- #reboot_server(id, type = 'SOFT') ⇒ Object
- #rebuild_server(id, image_ref, options = {}) ⇒ Object
- #resize(id, flavor_ref) ⇒ Object
- #revert_resize(id) ⇒ Object
- #server(id) ⇒ Object
- #servers ⇒ Object
- #servers_detail ⇒ Object
- #start_server(id) ⇒ Object
- #stop_server(id) ⇒ Object
- #unmount_iso_image(id) ⇒ Object
- #vnc(id) ⇒ Object
Instance Method Details
#add_keypair(name, public_key = nil) ⇒ Object
144 145 146 147 148 149 150 151 152 |
# File 'lib/conoha_api/client/compute.rb', line 144 def add_keypair(name, public_key = nil) request_json = { keypair: { name: name } } request_json[:keypair][:public_key] = public_key if public_key post "os-keypairs", request_json end |
#add_server(image_ref, flavor_ref, options = {}) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/conoha_api/client/compute.rb', line 31 def add_server(image_ref, flavor_ref, = {}) request_json = { server: { imageRef: image_ref, flavorRef: flavor_ref } } request_json[:server][:adminPass] = [:admin_pass] if [:admin_pass] request_json[:server][:keyName] = [:key_name] if [:key_name] post "servers", request_json, end |
#change_console_keymap(id, vnc_keymap) ⇒ Object
111 112 113 114 |
# File 'lib/conoha_api/client/compute.rb', line 111 def change_console_keymap(id, vnc_keymap) raise ArgumentError.new("#{vnc_keymap} is not valid") unless ['us-en', 'jp'].include?(vnc_keymap) action(id, vncKeymap: vnc_keymap) end |
#change_network_adapter(id, hardware_virtualinterface_model) ⇒ Object
101 102 103 104 |
# File 'lib/conoha_api/client/compute.rb', line 101 def change_network_adapter(id, hardware_virtualinterface_model) raise ArgumentError.new("#{hardware_virtualinterface_model} is not valid") unless ['e1000', 'virtio', 'rtl8139'].include?(hardware_virtualinterface_model) action(id, hwVifModel: hardware_virtualinterface_model) end |
#change_strage_controller(id, hardware_disk_bus) ⇒ Object
96 97 98 99 |
# File 'lib/conoha_api/client/compute.rb', line 96 def change_strage_controller(id, hardware_disk_bus) raise ArgumentError.new("#{hardware_disk_bus} is not valid") unless ['virtio', 'scsi', 'ide'].include?(hardware_disk_bus) action(id, hwDiskBus: hardware_disk_bus) end |
#change_video_device(id, hardware_video_model) ⇒ Object
106 107 108 109 |
# File 'lib/conoha_api/client/compute.rb', line 106 def change_video_device(id, hardware_video_model) raise ArgumentError.new("#{hardware_video_model} is not valid") unless ['qxl', 'vga', 'cirrus'].include?(hardware_video_model) action(id, hwVideoModel: hardware_video_model) end |
#confirm_resize(id) ⇒ Object
80 81 82 |
# File 'lib/conoha_api/client/compute.rb', line 80 def confirm_resize(id) action(id, confirmResize: nil) end |
#create_image(id, name) ⇒ Object
92 93 94 |
# File 'lib/conoha_api/client/compute.rb', line 92 def create_image(id, name) action(id, createImage: { name: name }) end |
#delete_keypair(name) ⇒ Object
154 155 156 |
# File 'lib/conoha_api/client/compute.rb', line 154 def delete_keypair(name) delete "os-keypairs/#{name}" end |
#delete_server(id) ⇒ Object
44 45 46 |
# File 'lib/conoha_api/client/compute.rb', line 44 def delete_server(id) delete "servers/#{id}" end |
#flavor(id) ⇒ Object
15 16 17 |
# File 'lib/conoha_api/client/compute.rb', line 15 def flavor(id) get "flavors/#{id}" end |
#flavors ⇒ Object
7 8 9 |
# File 'lib/conoha_api/client/compute.rb', line 7 def flavors get "flavors" end |
#flavors_detail ⇒ Object
11 12 13 |
# File 'lib/conoha_api/client/compute.rb', line 11 def flavors_detail get "flavors/detail" end |
#force_stop_server(id, force = true) ⇒ Object
57 58 59 |
# File 'lib/conoha_api/client/compute.rb', line 57 def force_stop_server(id, force = true) action(id, :"os-stop" => { force_shutdown: force }) end |
#get_web_console(id, type = 'nova') ⇒ Object
116 117 118 119 120 121 |
# File 'lib/conoha_api/client/compute.rb', line 116 def get_web_console(id, type = 'nova') raise ArgumentError.new("#{type} is not valid") unless ['nova', 'http'].include?(type) request_json = {} type == 'nova' ? request_json[:"os-getSerialConsole"] = {type: :serial} : request_json[:"os-getWebConsole"] = {type: :serial} action(id, request_json) end |
#image(id) ⇒ Object
166 167 168 |
# File 'lib/conoha_api/client/compute.rb', line 166 def image(id) get "images/#{id}" end |
#images ⇒ Object
158 159 160 |
# File 'lib/conoha_api/client/compute.rb', line 158 def images get "images" end |
#images_detail(options = {}) ⇒ Object
162 163 164 |
# File 'lib/conoha_api/client/compute.rb', line 162 def images_detail( = {}) get "images/detail", end |
#keypair(name) ⇒ Object
140 141 142 |
# File 'lib/conoha_api/client/compute.rb', line 140 def keypair(name) get "os-keypairs/#{name}" end |
#keypairs ⇒ Object
136 137 138 |
# File 'lib/conoha_api/client/compute.rb', line 136 def keypairs get "os-keypairs" end |
#mount_iso_image(id, file_path) ⇒ Object
123 124 125 |
# File 'lib/conoha_api/client/compute.rb', line 123 def mount_iso_image(id, file_path) action(id, mountImage: file_path) end |
#reboot_server(id, type = 'SOFT') ⇒ Object
52 53 54 55 |
# File 'lib/conoha_api/client/compute.rb', line 52 def reboot_server(id, type = 'SOFT') raise ArgumentError.new("#{type} is not valid") unless ['SOFT', 'HARD'].include?(type.upcase) action(id, reboot: { type: type.upcase }) end |
#rebuild_server(id, image_ref, options = {}) ⇒ Object
65 66 67 68 69 70 71 72 73 74 |
# File 'lib/conoha_api/client/compute.rb', line 65 def rebuild_server(id, image_ref, = {}) request_json = { rebuild: { imageRef: image_ref } } request_json[:rebuild][:adminPass] = [:admin_pass] if [:admin_pass] request_json[:rebuild][:keyName] = [:key_name] if [:key_name] action(id, request_json) end |
#resize(id, flavor_ref) ⇒ Object
76 77 78 |
# File 'lib/conoha_api/client/compute.rb', line 76 def resize(id, flavor_ref) action(id, resize: { flavorRef: flavor_ref }) end |
#revert_resize(id) ⇒ Object
84 85 86 |
# File 'lib/conoha_api/client/compute.rb', line 84 def revert_resize(id) action(id, revertResize: nil) end |
#server(id) ⇒ Object
27 28 29 |
# File 'lib/conoha_api/client/compute.rb', line 27 def server(id) get "servers/#{id}" end |
#servers ⇒ Object
19 20 21 |
# File 'lib/conoha_api/client/compute.rb', line 19 def servers get "servers" end |
#servers_detail ⇒ Object
23 24 25 |
# File 'lib/conoha_api/client/compute.rb', line 23 def servers_detail get "servers/detail" end |
#start_server(id) ⇒ Object
48 49 50 |
# File 'lib/conoha_api/client/compute.rb', line 48 def start_server(id) action(id, :"os-start" => nil) end |
#stop_server(id) ⇒ Object
61 62 63 |
# File 'lib/conoha_api/client/compute.rb', line 61 def stop_server(id) action(id, :"os-stop" => nil) end |
#unmount_iso_image(id) ⇒ Object
127 128 129 |
# File 'lib/conoha_api/client/compute.rb', line 127 def unmount_iso_image(id) action(id, unmountImage: nil) end |
#vnc(id) ⇒ Object
88 89 90 |
# File 'lib/conoha_api/client/compute.rb', line 88 def vnc(id) action(id, :"os-getVNCConsole" => { type: :novnc }) end |