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
145 146 147 148 149 150 151 152 153 |
# File 'lib/conoha_api/client/compute.rb', line 145 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
32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/conoha_api/client/compute.rb', line 32 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
112 113 114 115 |
# File 'lib/conoha_api/client/compute.rb', line 112 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
102 103 104 105 |
# File 'lib/conoha_api/client/compute.rb', line 102 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
97 98 99 100 |
# File 'lib/conoha_api/client/compute.rb', line 97 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
107 108 109 110 |
# File 'lib/conoha_api/client/compute.rb', line 107 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
81 82 83 |
# File 'lib/conoha_api/client/compute.rb', line 81 def confirm_resize(id) action(id, confirmResize: nil) end |
#create_image(id, name) ⇒ Object
93 94 95 |
# File 'lib/conoha_api/client/compute.rb', line 93 def create_image(id, name) action(id, createImage: { name: name }) end |
#delete_keypair(name) ⇒ Object
155 156 157 |
# File 'lib/conoha_api/client/compute.rb', line 155 def delete_keypair(name) delete "os-keypairs/#{name}" end |
#delete_server(id) ⇒ Object
45 46 47 |
# File 'lib/conoha_api/client/compute.rb', line 45 def delete_server(id) delete "servers/#{id}" end |
#flavor(id) ⇒ Object
16 17 18 |
# File 'lib/conoha_api/client/compute.rb', line 16 def flavor(id) get "flavors/#{id}" end |
#flavors ⇒ Object
8 9 10 |
# File 'lib/conoha_api/client/compute.rb', line 8 def flavors get "flavors" end |
#flavors_detail ⇒ Object
12 13 14 |
# File 'lib/conoha_api/client/compute.rb', line 12 def flavors_detail get "flavors/detail" end |
#force_stop_server(id, force = true) ⇒ Object
58 59 60 |
# File 'lib/conoha_api/client/compute.rb', line 58 def force_stop_server(id, force = true) action(id, :"os-stop" => { force_shutdown: force }) end |
#get_web_console(id, type = 'nova') ⇒ Object
117 118 119 120 121 122 |
# File 'lib/conoha_api/client/compute.rb', line 117 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
167 168 169 |
# File 'lib/conoha_api/client/compute.rb', line 167 def image(id) get "images/#{id}" end |
#images ⇒ Object
159 160 161 |
# File 'lib/conoha_api/client/compute.rb', line 159 def images get "images" end |
#images_detail(options = {}) ⇒ Object
163 164 165 |
# File 'lib/conoha_api/client/compute.rb', line 163 def images_detail( = {}) get "images/detail", end |
#keypair(name) ⇒ Object
141 142 143 |
# File 'lib/conoha_api/client/compute.rb', line 141 def keypair(name) get "os-keypairs/#{name}" end |
#keypairs ⇒ Object
137 138 139 |
# File 'lib/conoha_api/client/compute.rb', line 137 def keypairs get "os-keypairs" end |
#mount_iso_image(id, file_path) ⇒ Object
124 125 126 |
# File 'lib/conoha_api/client/compute.rb', line 124 def mount_iso_image(id, file_path) action(id, mountImage: file_path) end |
#reboot_server(id, type = 'SOFT') ⇒ Object
53 54 55 56 |
# File 'lib/conoha_api/client/compute.rb', line 53 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
66 67 68 69 70 71 72 73 74 75 |
# File 'lib/conoha_api/client/compute.rb', line 66 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
77 78 79 |
# File 'lib/conoha_api/client/compute.rb', line 77 def resize(id, flavor_ref) action(id, resize: { flavorRef: flavor_ref }) end |
#revert_resize(id) ⇒ Object
85 86 87 |
# File 'lib/conoha_api/client/compute.rb', line 85 def revert_resize(id) action(id, revertResize: nil) end |
#server(id) ⇒ Object
28 29 30 |
# File 'lib/conoha_api/client/compute.rb', line 28 def server(id) get "servers/#{id}" end |
#servers ⇒ Object
20 21 22 |
# File 'lib/conoha_api/client/compute.rb', line 20 def servers get "servers" end |
#servers_detail ⇒ Object
24 25 26 |
# File 'lib/conoha_api/client/compute.rb', line 24 def servers_detail get "servers/detail" end |
#start_server(id) ⇒ Object
49 50 51 |
# File 'lib/conoha_api/client/compute.rb', line 49 def start_server(id) action(id, :"os-start" => nil) end |
#stop_server(id) ⇒ Object
62 63 64 |
# File 'lib/conoha_api/client/compute.rb', line 62 def stop_server(id) action(id, :"os-stop" => nil) end |
#unmount_iso_image(id) ⇒ Object
128 129 130 |
# File 'lib/conoha_api/client/compute.rb', line 128 def unmount_iso_image(id) action(id, unmountImage: nil) end |
#vnc(id) ⇒ Object
89 90 91 |
# File 'lib/conoha_api/client/compute.rb', line 89 def vnc(id) action(id, :"os-getVNCConsole" => { type: :novnc }) end |