Class: Fog::Hetznercloud::Compute::Mock
- Inherits:
-
Object
- Object
- Fog::Hetznercloud::Compute::Mock
- Defined in:
- lib/fog/hetznercloud/compute.rb,
lib/fog/hetznercloud/requests/compute/get_image.rb,
lib/fog/hetznercloud/requests/compute/get_action.rb,
lib/fog/hetznercloud/requests/compute/get_server.rb,
lib/fog/hetznercloud/requests/compute/get_ssh_key.rb,
lib/fog/hetznercloud/requests/compute/list_images.rb,
lib/fog/hetznercloud/requests/compute/delete_image.rb,
lib/fog/hetznercloud/requests/compute/get_location.rb,
lib/fog/hetznercloud/requests/compute/list_actions.rb,
lib/fog/hetznercloud/requests/compute/list_servers.rb,
lib/fog/hetznercloud/requests/compute/update_image.rb,
lib/fog/hetznercloud/requests/compute/create_server.rb,
lib/fog/hetznercloud/requests/compute/delete_server.rb,
lib/fog/hetznercloud/requests/compute/list_ssh_keys.rb,
lib/fog/hetznercloud/requests/compute/update_server.rb,
lib/fog/hetznercloud/requests/compute/create_ssh_key.rb,
lib/fog/hetznercloud/requests/compute/delete_ssh_key.rb,
lib/fog/hetznercloud/requests/compute/get_datacenter.rb,
lib/fog/hetznercloud/requests/compute/list_locations.rb,
lib/fog/hetznercloud/requests/compute/update_ssh_key.rb,
lib/fog/hetznercloud/requests/compute/get_floating_ip.rb,
lib/fog/hetznercloud/requests/compute/get_server_type.rb,
lib/fog/hetznercloud/requests/compute/list_datacenters.rb,
lib/fog/hetznercloud/requests/compute/list_floating_ips.rb,
lib/fog/hetznercloud/requests/compute/list_server_types.rb,
lib/fog/hetznercloud/requests/compute/create_floating_ip.rb,
lib/fog/hetznercloud/requests/compute/delete_floating_ip.rb,
lib/fog/hetznercloud/requests/compute/update_floating_ip.rb,
lib/fog/hetznercloud/requests/compute/floating_ip_unassign.rb,
lib/fog/hetznercloud/requests/compute/execute_server_action.rb,
lib/fog/hetznercloud/requests/compute/floating_ip_update_dns_ptr.rb,
lib/fog/hetznercloud/requests/compute/floating_ip_assign_to_server.rb
Instance Method Summary collapse
- #create_floating_ip(_type, _options = {}) ⇒ Object
- #create_server(_name, _image, _volumes, _options = {}) ⇒ Object
- #create_ssh_key(_type, _home_location, _server, _options = {}) ⇒ Object
- #delete_floating_ip(_id) ⇒ Object
- #delete_image(_id) ⇒ Object
- #delete_server(_server_id) ⇒ Object
- #delete_ssh_key(_id) ⇒ Object
- #execute_server_action(_id, _action) ⇒ Object
- #floating_ip_assign_to_server(_type, _body) ⇒ Object
- #floating_ip_unassign(_type, _body) ⇒ Object
- #floating_ip_update_dns_ptr(_type, _body) ⇒ Object
- #get_action(_id) ⇒ Object
- #get_datacenter(_id) ⇒ Object
- #get_floating_ip(_id) ⇒ Object
- #get_image(_image_id) ⇒ Object
- #get_location(_id) ⇒ Object
- #get_server(_server_id) ⇒ Object
- #get_server_type(_server_type_id) ⇒ Object
- #get_ssh_key(_id) ⇒ Object
- #list_datacenters ⇒ Object
- #list_floating_ips ⇒ Object
- #list_images ⇒ Object
- #list_locations ⇒ Object
- #list_server_types ⇒ Object
- #list_servers ⇒ Object
- #list_ssh_keys ⇒ Object
- #request(*_args) ⇒ Object
- #update_floating_ip(_id, _body) ⇒ Object
- #update_image(_server_id, _body) ⇒ Object
- #update_server(server_id, body) ⇒ Object
- #update_ssh_key(_server_id, _body) ⇒ Object
Instance Method Details
#create_floating_ip(_type, _options = {}) ⇒ Object
23 24 25 |
# File 'lib/fog/hetznercloud/requests/compute/create_floating_ip.rb', line 23 def create_floating_ip(_type, = {}) Fog::Mock.not_implemented end |
#create_server(_name, _image, _volumes, _options = {}) ⇒ Object
25 26 27 |
# File 'lib/fog/hetznercloud/requests/compute/create_server.rb', line 25 def create_server(_name, _image, _volumes, = {}) Fog::Mock.not_implemented end |
#create_ssh_key(_type, _home_location, _server, _options = {}) ⇒ Object
18 19 20 |
# File 'lib/fog/hetznercloud/requests/compute/create_ssh_key.rb', line 18 def create_ssh_key(_type, _home_location, _server, = {}) Fog::Mock.not_implemented end |
#delete_floating_ip(_id) ⇒ Object
11 12 13 |
# File 'lib/fog/hetznercloud/requests/compute/delete_floating_ip.rb', line 11 def delete_floating_ip(_id) Fog::Mock.not_implemented end |
#delete_image(_id) ⇒ Object
11 12 13 |
# File 'lib/fog/hetznercloud/requests/compute/delete_image.rb', line 11 def delete_image(_id) Fog::Mock.not_implemented end |
#delete_server(_server_id) ⇒ Object
11 12 13 |
# File 'lib/fog/hetznercloud/requests/compute/delete_server.rb', line 11 def delete_server(_server_id) Fog::Mock.not_implemented end |
#delete_ssh_key(_id) ⇒ Object
11 12 13 |
# File 'lib/fog/hetznercloud/requests/compute/delete_ssh_key.rb', line 11 def delete_ssh_key(_id) Fog::Mock.not_implemented end |
#execute_server_action(_id, _action) ⇒ Object
11 12 13 |
# File 'lib/fog/hetznercloud/requests/compute/execute_server_action.rb', line 11 def execute_server_action(_id, _action) Fog::Mock.not_implemented end |
#floating_ip_assign_to_server(_type, _body) ⇒ Object
11 12 13 |
# File 'lib/fog/hetznercloud/requests/compute/floating_ip_assign_to_server.rb', line 11 def floating_ip_assign_to_server(_type, _body) Fog::Mock.not_implemented end |
#floating_ip_unassign(_type, _body) ⇒ Object
11 12 13 |
# File 'lib/fog/hetznercloud/requests/compute/floating_ip_unassign.rb', line 11 def floating_ip_unassign(_type, _body) Fog::Mock.not_implemented end |
#floating_ip_update_dns_ptr(_type, _body) ⇒ Object
11 12 13 |
# File 'lib/fog/hetznercloud/requests/compute/floating_ip_update_dns_ptr.rb', line 11 def floating_ip_update_dns_ptr(_type, _body) Fog::Mock.not_implemented end |
#get_action(_id) ⇒ Object
11 12 13 |
# File 'lib/fog/hetznercloud/requests/compute/get_action.rb', line 11 def get_action(_id) Fog::Mock.not_implemented end |
#get_datacenter(_id) ⇒ Object
11 12 13 |
# File 'lib/fog/hetznercloud/requests/compute/get_datacenter.rb', line 11 def get_datacenter(_id) Fog::Mock.not_implemented end |
#get_floating_ip(_id) ⇒ Object
11 12 13 |
# File 'lib/fog/hetznercloud/requests/compute/get_floating_ip.rb', line 11 def get_floating_ip(_id) Fog::Mock.not_implemented end |
#get_image(_image_id) ⇒ Object
11 12 13 |
# File 'lib/fog/hetznercloud/requests/compute/get_image.rb', line 11 def get_image(_image_id) Fog::Mock.not_implemented end |
#get_location(_id) ⇒ Object
11 12 13 |
# File 'lib/fog/hetznercloud/requests/compute/get_location.rb', line 11 def get_location(_id) Fog::Mock.not_implemented end |
#get_server(_server_id) ⇒ Object
11 12 13 |
# File 'lib/fog/hetznercloud/requests/compute/get_server.rb', line 11 def get_server(_server_id) Fog::Mock.not_implemented end |
#get_server_type(_server_type_id) ⇒ Object
11 12 13 |
# File 'lib/fog/hetznercloud/requests/compute/get_server_type.rb', line 11 def get_server_type(_server_type_id) Fog::Mock.not_implemented end |
#get_ssh_key(_id) ⇒ Object
11 12 13 |
# File 'lib/fog/hetznercloud/requests/compute/get_ssh_key.rb', line 11 def get_ssh_key(_id) Fog::Mock.not_implemented end |
#list_datacenters ⇒ Object
11 12 13 |
# File 'lib/fog/hetznercloud/requests/compute/list_datacenters.rb', line 11 def list_datacenters Fog::Mock.not_implemented end |
#list_floating_ips ⇒ Object
11 12 13 |
# File 'lib/fog/hetznercloud/requests/compute/list_floating_ips.rb', line 11 def list_floating_ips Fog::Mock.not_implemented end |
#list_images ⇒ Object
11 12 13 |
# File 'lib/fog/hetznercloud/requests/compute/list_images.rb', line 11 def list_images Fog::Mock.not_implemented end |
#list_locations ⇒ Object
11 12 13 |
# File 'lib/fog/hetznercloud/requests/compute/list_ssh_keys.rb', line 11 def list_locations Fog::Mock.not_implemented end |
#list_server_types ⇒ Object
11 12 13 |
# File 'lib/fog/hetznercloud/requests/compute/list_server_types.rb', line 11 def list_server_types Fog::Mock.not_implemented end |
#list_servers ⇒ Object
11 12 13 |
# File 'lib/fog/hetznercloud/requests/compute/list_servers.rb', line 11 def list_servers Fog::Mock.not_implemented end |
#list_ssh_keys ⇒ Object
11 12 13 |
# File 'lib/fog/hetznercloud/requests/compute/list_actions.rb', line 11 def list_ssh_keys Fog::Mock.not_implemented end |
#request(*_args) ⇒ Object
140 141 142 |
# File 'lib/fog/hetznercloud/compute.rb', line 140 def request(*_args) Fog::Mock.not_implemented end |
#update_floating_ip(_id, _body) ⇒ Object
11 12 13 |
# File 'lib/fog/hetznercloud/requests/compute/update_floating_ip.rb', line 11 def update_floating_ip(_id, _body) Fog::Mock.not_implemented end |
#update_image(_server_id, _body) ⇒ Object
11 12 13 |
# File 'lib/fog/hetznercloud/requests/compute/update_image.rb', line 11 def update_image(_server_id, _body) Fog::Mock.not_implemented end |
#update_server(server_id, body) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/fog/hetznercloud/requests/compute/update_server.rb', line 11 def update_server(server_id, body) body = jsonify(body) server = lookup(:servers, server_id) bootscript = if body['bootscript'].is_a?(Hash) lookup(:bootscripts, body['bootscript']['id']) elsif body['bootscript'].is_a?(String) lookup(:bootscripts, body['bootscript']) end _, product_server = lookup_product_server(server['commercial_type']) if body['enable_ipv6'] && !product_server['network']['ipv6_support'] raise_invalid_request_error("Cannot enable ipv6 on #{commercial_type}") end volumes = {} body['volumes'].each do |index, volume| volume = lookup(:volumes, volume['id']) if volume['server'] && volume['server']['id'] != server['id'] = "volume #{volume['id']} is already attached to a server" raise_invalid_request_error() end volumes[index] = volume end server['bootscript'] = bootscript if bootscript server['dynamic_ip_required'] = body['dynamic_ip_required'] server['enable_ipv6'] = body['enable_ipv6'] server['hostname'] = body['name'] server['modification_date'] = now server['name'] = body['name'] server['tags'] = body['tags'] server['volumes'] = volumes if server['dynamic_ip_required'] && server['state'] == 'running' server['public_ip'] ||= create_dynamic_ip elsif !server['dynamic_ip_required'] && server['public_ip'] && server['public_ip']['dynamic'] server['public_ip'] = nil end if server['enable_ipv6'] && server['state'] == 'running' server['ipv6'] ||= create_ipv6 elsif !server['enable_ipv6'] server['ipv6'] = nil end data[:volumes].each do |id, volume| if server['volumes'].any? { |_i, v| v['id'] == id } volume['server'] = { 'id' => server['id'], 'name' => server['name'] } elsif volume['server'] && volume['server']['id'] == server['id'] volume['server'] = nil end end response(status: 200, body: { 'server' => server }) end |
#update_ssh_key(_server_id, _body) ⇒ Object
11 12 13 |
# File 'lib/fog/hetznercloud/requests/compute/update_ssh_key.rb', line 11 def update_ssh_key(_server_id, _body) Fog::Mock.not_implemented end |