fog-oneandone 1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +36 -0
- data/CONTRIBUTING.md +276 -0
- data/CONTRIBUTORS.md +1 -0
- data/Gemfile +4 -0
- data/LICENSE.md +20 -0
- data/README.md +317 -0
- data/bin/fog +78 -0
- data/examples/example_app.rb +80 -0
- data/fog-oneandone.gemspec +22 -0
- data/gemfiles/Gemfile-edge +7 -0
- data/lib/fog-oneandone.rb +10 -0
- data/lib/oneandone/compute.rb +713 -0
- data/lib/oneandone/core.rb +11 -0
- data/lib/oneandone/models/compute/firewall.rb +128 -0
- data/lib/oneandone/models/compute/firewalls.rb +24 -0
- data/lib/oneandone/models/compute/image.rb +72 -0
- data/lib/oneandone/models/compute/images.rb +24 -0
- data/lib/oneandone/models/compute/load_balancer.rb +149 -0
- data/lib/oneandone/models/compute/load_balancers.rb +24 -0
- data/lib/oneandone/models/compute/monitoring_policies.rb +24 -0
- data/lib/oneandone/models/compute/monitoring_policy.rb +196 -0
- data/lib/oneandone/models/compute/private_network.rb +105 -0
- data/lib/oneandone/models/compute/private_networks.rb +24 -0
- data/lib/oneandone/models/compute/public_ip.rb +68 -0
- data/lib/oneandone/models/compute/public_ips.rb +24 -0
- data/lib/oneandone/models/compute/server.rb +434 -0
- data/lib/oneandone/models/compute/servers.rb +24 -0
- data/lib/oneandone/models/compute/shared_storage.rb +101 -0
- data/lib/oneandone/models/compute/shared_storages.rb +24 -0
- data/lib/oneandone/models/compute/vpn.rb +70 -0
- data/lib/oneandone/models/compute/vpns.rb +24 -0
- data/lib/oneandone/requests/compute/access.rb +35 -0
- data/lib/oneandone/requests/compute/add_firewall.rb +70 -0
- data/lib/oneandone/requests/compute/add_firewall_ips.rb +67 -0
- data/lib/oneandone/requests/compute/add_firewall_rules.rb +68 -0
- data/lib/oneandone/requests/compute/add_hdds.rb +65 -0
- data/lib/oneandone/requests/compute/add_load_balancer.rb +76 -0
- data/lib/oneandone/requests/compute/add_load_balancer_ips.rb +67 -0
- data/lib/oneandone/requests/compute/add_load_balancer_rules.rb +68 -0
- data/lib/oneandone/requests/compute/add_mp_servers.rb +64 -0
- data/lib/oneandone/requests/compute/add_ports.rb +65 -0
- data/lib/oneandone/requests/compute/add_private_network.rb +65 -0
- data/lib/oneandone/requests/compute/add_private_network_servers.rb +67 -0
- data/lib/oneandone/requests/compute/add_processes.rb +65 -0
- data/lib/oneandone/requests/compute/add_server_ip.rb +72 -0
- data/lib/oneandone/requests/compute/add_shared_storage_servers.rb +64 -0
- data/lib/oneandone/requests/compute/change_password.rb +45 -0
- data/lib/oneandone/requests/compute/change_status.rb +69 -0
- data/lib/oneandone/requests/compute/clone_server.rb +67 -0
- data/lib/oneandone/requests/compute/create_firewall.rb +78 -0
- data/lib/oneandone/requests/compute/create_image.rb +101 -0
- data/lib/oneandone/requests/compute/create_load_balancer.rb +104 -0
- data/lib/oneandone/requests/compute/create_monitoring_policy.rb +93 -0
- data/lib/oneandone/requests/compute/create_private_network.rb +82 -0
- data/lib/oneandone/requests/compute/create_public_ip.rb +77 -0
- data/lib/oneandone/requests/compute/create_server.rb +139 -0
- data/lib/oneandone/requests/compute/create_shared_storage.rb +83 -0
- data/lib/oneandone/requests/compute/create_snapshot.rb +51 -0
- data/lib/oneandone/requests/compute/create_vpn.rb +80 -0
- data/lib/oneandone/requests/compute/delete_firewall.rb +51 -0
- data/lib/oneandone/requests/compute/delete_firewall_rule.rb +60 -0
- data/lib/oneandone/requests/compute/delete_hdd.rb +61 -0
- data/lib/oneandone/requests/compute/delete_image.rb +51 -0
- data/lib/oneandone/requests/compute/delete_load_balancer.rb +51 -0
- data/lib/oneandone/requests/compute/delete_load_balancer_rule.rb +60 -0
- data/lib/oneandone/requests/compute/delete_monitoring_policy.rb +51 -0
- data/lib/oneandone/requests/compute/delete_port.rb +60 -0
- data/lib/oneandone/requests/compute/delete_private_network.rb +51 -0
- data/lib/oneandone/requests/compute/delete_process.rb +60 -0
- data/lib/oneandone/requests/compute/delete_public_ip.rb +51 -0
- data/lib/oneandone/requests/compute/delete_server.rb +51 -0
- data/lib/oneandone/requests/compute/delete_server_ip.rb +60 -0
- data/lib/oneandone/requests/compute/delete_shared_storage.rb +51 -0
- data/lib/oneandone/requests/compute/delete_snapshot.rb +51 -0
- data/lib/oneandone/requests/compute/delete_vpn.rb +51 -0
- data/lib/oneandone/requests/compute/eject_dvd.rb +51 -0
- data/lib/oneandone/requests/compute/get_datacenter.rb +50 -0
- data/lib/oneandone/requests/compute/get_dvd.rb +50 -0
- data/lib/oneandone/requests/compute/get_dvd_iso.rb +50 -0
- data/lib/oneandone/requests/compute/get_firewall.rb +50 -0
- data/lib/oneandone/requests/compute/get_firewall_ip.rb +59 -0
- data/lib/oneandone/requests/compute/get_firewall_rule.rb +59 -0
- data/lib/oneandone/requests/compute/get_fixed_server.rb +50 -0
- data/lib/oneandone/requests/compute/get_hardware.rb +50 -0
- data/lib/oneandone/requests/compute/get_hdd.rb +60 -0
- data/lib/oneandone/requests/compute/get_hdds.rb +50 -0
- data/lib/oneandone/requests/compute/get_image.rb +50 -0
- data/lib/oneandone/requests/compute/get_load_balancer.rb +50 -0
- data/lib/oneandone/requests/compute/get_load_balancer_ip.rb +59 -0
- data/lib/oneandone/requests/compute/get_load_balancer_rule.rb +59 -0
- data/lib/oneandone/requests/compute/get_log.rb +51 -0
- data/lib/oneandone/requests/compute/get_monitored_server.rb +49 -0
- data/lib/oneandone/requests/compute/get_monitoring_policy.rb +50 -0
- data/lib/oneandone/requests/compute/get_mp_server.rb +59 -0
- data/lib/oneandone/requests/compute/get_port.rb +59 -0
- data/lib/oneandone/requests/compute/get_private_network.rb +50 -0
- data/lib/oneandone/requests/compute/get_private_network_server.rb +59 -0
- data/lib/oneandone/requests/compute/get_process.rb +59 -0
- data/lib/oneandone/requests/compute/get_public_ip.rb +50 -0
- data/lib/oneandone/requests/compute/get_server.rb +50 -0
- data/lib/oneandone/requests/compute/get_server_appliance.rb +50 -0
- data/lib/oneandone/requests/compute/get_server_image.rb +50 -0
- data/lib/oneandone/requests/compute/get_server_ip.rb +59 -0
- data/lib/oneandone/requests/compute/get_server_private_network.rb +59 -0
- data/lib/oneandone/requests/compute/get_shared_storage.rb +50 -0
- data/lib/oneandone/requests/compute/get_shared_storage_server.rb +59 -0
- data/lib/oneandone/requests/compute/get_snapshot.rb +50 -0
- data/lib/oneandone/requests/compute/get_vpn.rb +50 -0
- data/lib/oneandone/requests/compute/install_server_image.rb +72 -0
- data/lib/oneandone/requests/compute/list_datacenters.rb +56 -0
- data/lib/oneandone/requests/compute/list_dvds.rb +56 -0
- data/lib/oneandone/requests/compute/list_firewall_ips.rb +50 -0
- data/lib/oneandone/requests/compute/list_firewall_rules.rb +50 -0
- data/lib/oneandone/requests/compute/list_firewalls.rb +56 -0
- data/lib/oneandone/requests/compute/list_fixed_servers.rb +40 -0
- data/lib/oneandone/requests/compute/list_images.rb +56 -0
- data/lib/oneandone/requests/compute/list_ip_firewalls.rb +59 -0
- data/lib/oneandone/requests/compute/list_ip_load_balancers.rb +59 -0
- data/lib/oneandone/requests/compute/list_load_balancer_ips.rb +50 -0
- data/lib/oneandone/requests/compute/list_load_balancer_rules.rb +50 -0
- data/lib/oneandone/requests/compute/list_load_balancers.rb +56 -0
- data/lib/oneandone/requests/compute/list_logs.rb +59 -0
- data/lib/oneandone/requests/compute/list_monitored_servers.rb +51 -0
- data/lib/oneandone/requests/compute/list_monitoring_policies.rb +56 -0
- data/lib/oneandone/requests/compute/list_mp_servers.rb +50 -0
- data/lib/oneandone/requests/compute/list_ports.rb +51 -0
- data/lib/oneandone/requests/compute/list_private_network_servers.rb +50 -0
- data/lib/oneandone/requests/compute/list_private_networks.rb +56 -0
- data/lib/oneandone/requests/compute/list_processes.rb +51 -0
- data/lib/oneandone/requests/compute/list_public_ips.rb +56 -0
- data/lib/oneandone/requests/compute/list_server_appliances.rb +56 -0
- data/lib/oneandone/requests/compute/list_server_ips.rb +50 -0
- data/lib/oneandone/requests/compute/list_server_private_networks.rb +50 -0
- data/lib/oneandone/requests/compute/list_servers.rb +56 -0
- data/lib/oneandone/requests/compute/list_shared_storage_servers.rb +50 -0
- data/lib/oneandone/requests/compute/list_shared_storages.rb +56 -0
- data/lib/oneandone/requests/compute/list_usages.rb +54 -0
- data/lib/oneandone/requests/compute/list_vpns.rb +56 -0
- data/lib/oneandone/requests/compute/load_dvd.rb +65 -0
- data/lib/oneandone/requests/compute/ping.rb +38 -0
- data/lib/oneandone/requests/compute/ping_auth.rb +38 -0
- data/lib/oneandone/requests/compute/remove_firewall.rb +60 -0
- data/lib/oneandone/requests/compute/remove_firewall_ip.rb +60 -0
- data/lib/oneandone/requests/compute/remove_load_balancer.rb +71 -0
- data/lib/oneandone/requests/compute/remove_load_balancer_ip.rb +60 -0
- data/lib/oneandone/requests/compute/remove_mp_server.rb +60 -0
- data/lib/oneandone/requests/compute/remove_private_network.rb +60 -0
- data/lib/oneandone/requests/compute/remove_private_network_server.rb +60 -0
- data/lib/oneandone/requests/compute/remove_shared_storage_server.rb +60 -0
- data/lib/oneandone/requests/compute/restore_snapshot.rb +35 -0
- data/lib/oneandone/requests/compute/status.rb +50 -0
- data/lib/oneandone/requests/compute/update_firewall.rb +76 -0
- data/lib/oneandone/requests/compute/update_hardware.rb +82 -0
- data/lib/oneandone/requests/compute/update_hdd.rb +71 -0
- data/lib/oneandone/requests/compute/update_image.rb +80 -0
- data/lib/oneandone/requests/compute/update_load_balancer.rb +96 -0
- data/lib/oneandone/requests/compute/update_monitoring_policy.rb +82 -0
- data/lib/oneandone/requests/compute/update_port.rb +74 -0
- data/lib/oneandone/requests/compute/update_private_network.rb +82 -0
- data/lib/oneandone/requests/compute/update_process.rb +76 -0
- data/lib/oneandone/requests/compute/update_public_ip.rb +71 -0
- data/lib/oneandone/requests/compute/update_server.rb +76 -0
- data/lib/oneandone/requests/compute/update_shared_storage.rb +80 -0
- data/lib/oneandone/requests/compute/update_vpn.rb +76 -0
- data/tests/oneandone/test_firewalls.rb +188 -0
- data/tests/oneandone/test_images.rb +79 -0
- data/tests/oneandone/test_load_balancers.rb +192 -0
- data/tests/oneandone/test_monitoring_policies.rb +342 -0
- data/tests/oneandone/test_private_networks.rb +123 -0
- data/tests/oneandone/test_public_ips.rb +75 -0
- data/tests/oneandone/test_servers.rb +465 -0
- data/tests/oneandone/test_shared_storages.rb +131 -0
- metadata +259 -0
@@ -0,0 +1,105 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class OneAndOne
|
4
|
+
class PrivateNetwork < Fog::Model
|
5
|
+
|
6
|
+
# Declare Model Attributes
|
7
|
+
identity :id
|
8
|
+
|
9
|
+
attribute :name
|
10
|
+
attribute :description
|
11
|
+
attribute :datacenter_id
|
12
|
+
attribute :network_address
|
13
|
+
attribute :subnet_mask
|
14
|
+
|
15
|
+
attribute :state
|
16
|
+
attribute :creation_date
|
17
|
+
attribute :datacenter
|
18
|
+
attribute :servers
|
19
|
+
|
20
|
+
|
21
|
+
def save
|
22
|
+
|
23
|
+
requires :name
|
24
|
+
|
25
|
+
# Perform Request
|
26
|
+
response = service.create_private_network(name: name,
|
27
|
+
description: description, network_address: network_address,
|
28
|
+
subnet_mask: subnet_mask, datacenter_id: datacenter_id)
|
29
|
+
|
30
|
+
# Merge Attributes
|
31
|
+
merge_attributes(response.body)
|
32
|
+
|
33
|
+
true
|
34
|
+
|
35
|
+
end
|
36
|
+
|
37
|
+
|
38
|
+
def update(options = {})
|
39
|
+
|
40
|
+
requires :id
|
41
|
+
|
42
|
+
response = service.update_private_network(private_network_id: id,
|
43
|
+
name: options[:name], description: options[:description],
|
44
|
+
network_address: options[:network_address],
|
45
|
+
subnet_mask: options[:subnet_mask])
|
46
|
+
|
47
|
+
# Merge Attributes
|
48
|
+
merge_attributes(response.body)
|
49
|
+
|
50
|
+
true
|
51
|
+
|
52
|
+
end
|
53
|
+
|
54
|
+
|
55
|
+
def add_servers(options = {})
|
56
|
+
|
57
|
+
requires :id
|
58
|
+
|
59
|
+
response = service.add_private_network_servers(private_network_id: id,
|
60
|
+
servers: options[:servers])
|
61
|
+
|
62
|
+
# Merge Attributes
|
63
|
+
merge_attributes(response.body)
|
64
|
+
|
65
|
+
true
|
66
|
+
|
67
|
+
end
|
68
|
+
|
69
|
+
|
70
|
+
def remove_server(options = {})
|
71
|
+
|
72
|
+
requires :id
|
73
|
+
|
74
|
+
response = service.remove_private_network_server(private_network_id: id,
|
75
|
+
server_id: options[:server_id])
|
76
|
+
|
77
|
+
# Merge Attributes
|
78
|
+
merge_attributes(response.body)
|
79
|
+
|
80
|
+
true
|
81
|
+
|
82
|
+
end
|
83
|
+
|
84
|
+
|
85
|
+
def destroy
|
86
|
+
|
87
|
+
requires :id
|
88
|
+
|
89
|
+
service.delete_private_network(id)
|
90
|
+
|
91
|
+
true
|
92
|
+
|
93
|
+
end
|
94
|
+
|
95
|
+
|
96
|
+
def ready?
|
97
|
+
|
98
|
+
state == 'ACTIVE'
|
99
|
+
|
100
|
+
end
|
101
|
+
|
102
|
+
end # PrivateNetwork
|
103
|
+
end # OneAndOne
|
104
|
+
end # Compute
|
105
|
+
end # Fog
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require_relative 'private_network'
|
2
|
+
|
3
|
+
module Fog
|
4
|
+
module Compute
|
5
|
+
class OneAndOne
|
6
|
+
class PrivateNetworks < Fog::Collection
|
7
|
+
model Fog::Compute::OneAndOne::PrivateNetwork
|
8
|
+
|
9
|
+
def all
|
10
|
+
response = service.list_private_networks
|
11
|
+
load(response.body)
|
12
|
+
end
|
13
|
+
|
14
|
+
def get(id)
|
15
|
+
response = service.get_private_network(id)
|
16
|
+
new(response.body)
|
17
|
+
rescue Excon::Errors::NotFound
|
18
|
+
nil
|
19
|
+
end
|
20
|
+
|
21
|
+
end # PrivateNetworks
|
22
|
+
end # OneAndOne
|
23
|
+
end # Compute
|
24
|
+
end # Fog
|
@@ -0,0 +1,68 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class OneAndOne
|
4
|
+
class PublicIp < Fog::Model
|
5
|
+
|
6
|
+
# Declare Model Attributes
|
7
|
+
identity :id
|
8
|
+
|
9
|
+
attribute :type
|
10
|
+
attribute :reverse_dns
|
11
|
+
attribute :datacenter_id
|
12
|
+
attribute :datacenter
|
13
|
+
attribute :ip
|
14
|
+
attribute :assigned_to
|
15
|
+
attribute :state
|
16
|
+
attribute :creation_date
|
17
|
+
|
18
|
+
|
19
|
+
def save
|
20
|
+
|
21
|
+
# Perform Request
|
22
|
+
response = service.create_public_ip(type: type,
|
23
|
+
reverse_dns: reverse_dns, datacenter_id: datacenter_id)
|
24
|
+
|
25
|
+
# Merge Attributes
|
26
|
+
merge_attributes(response.body)
|
27
|
+
|
28
|
+
true
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
|
33
|
+
def update(options = {})
|
34
|
+
|
35
|
+
requires :id
|
36
|
+
|
37
|
+
response = service.update_public_ip(ip_id: id,
|
38
|
+
reverse_dns: options[:reverse_dns])
|
39
|
+
|
40
|
+
# Merge Attributes
|
41
|
+
merge_attributes(response.body)
|
42
|
+
|
43
|
+
true
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
|
48
|
+
def destroy
|
49
|
+
|
50
|
+
requires :id
|
51
|
+
|
52
|
+
service.delete_public_ip(id)
|
53
|
+
|
54
|
+
true
|
55
|
+
|
56
|
+
end
|
57
|
+
|
58
|
+
|
59
|
+
def ready?
|
60
|
+
|
61
|
+
state == 'ACTIVE'
|
62
|
+
|
63
|
+
end
|
64
|
+
|
65
|
+
end # PublicIp
|
66
|
+
end # OneAndOne
|
67
|
+
end # Compute
|
68
|
+
end # Fog
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require_relative 'public_ip'
|
2
|
+
|
3
|
+
module Fog
|
4
|
+
module Compute
|
5
|
+
class OneAndOne
|
6
|
+
class PublicIps < Fog::Collection
|
7
|
+
model Fog::Compute::OneAndOne::PublicIp
|
8
|
+
|
9
|
+
def all
|
10
|
+
response = service.list_public_ips
|
11
|
+
load(response.body)
|
12
|
+
end
|
13
|
+
|
14
|
+
def get(id)
|
15
|
+
response = service.get_public_ip(id)
|
16
|
+
new(response.body)
|
17
|
+
rescue Excon::Errors::NotFound
|
18
|
+
nil
|
19
|
+
end
|
20
|
+
|
21
|
+
end # PublicIps
|
22
|
+
end # OneAndOne
|
23
|
+
end # Compute
|
24
|
+
end # Fog
|
@@ -0,0 +1,434 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class OneAndOne
|
4
|
+
class Server < Fog::Model
|
5
|
+
|
6
|
+
# Globals
|
7
|
+
GOOD_STATES = ['POWERED_ON', 'POWERED_OFF']
|
8
|
+
|
9
|
+
# Declare Model Attributes
|
10
|
+
identity :id
|
11
|
+
|
12
|
+
attribute :name
|
13
|
+
attribute :description
|
14
|
+
attribute :rsa_key
|
15
|
+
attribute :fixed_instance_id
|
16
|
+
attribute :ram
|
17
|
+
attribute :vcore
|
18
|
+
attribute :cores_per_processor
|
19
|
+
attribute :hdds
|
20
|
+
attribute :datacenter
|
21
|
+
attribute :datacenter_id
|
22
|
+
attribute :creation_date
|
23
|
+
attribute :first_password
|
24
|
+
attribute :status
|
25
|
+
attribute :hardware
|
26
|
+
attribute :image
|
27
|
+
attribute :appliance_id
|
28
|
+
attribute :password
|
29
|
+
attribute :power_on
|
30
|
+
attribute :firewall_id
|
31
|
+
attribute :ip_id
|
32
|
+
attribute :load_balancer_id
|
33
|
+
attribute :monitoring_policy_id
|
34
|
+
attribute :dvd
|
35
|
+
attribute :snapshot
|
36
|
+
attribute :ips
|
37
|
+
attribute :alerts
|
38
|
+
attribute :monitoring_policy
|
39
|
+
attribute :private_networks
|
40
|
+
|
41
|
+
|
42
|
+
def save
|
43
|
+
|
44
|
+
requires :name, :appliance_id
|
45
|
+
|
46
|
+
# Check for Additional Required Parameters
|
47
|
+
if (!fixed_instance_id)
|
48
|
+
requires :ram, :vcore, :cores_per_processor, :hdds
|
49
|
+
end
|
50
|
+
|
51
|
+
# Perform Request
|
52
|
+
response = service.create_server(name: name, description: description,
|
53
|
+
rsa_key: rsa_key, fixed_instance_id: fixed_instance_id,
|
54
|
+
vcore: vcore, cores_per_processor: cores_per_processor, ram: ram,
|
55
|
+
appliance_id: appliance_id, hdds: hdds, datacenter_id: datacenter_id,
|
56
|
+
password: password, power_on: power_on, firewall_id: firewall_id,
|
57
|
+
ip_id: ip_id, load_balancer_id: load_balancer_id,
|
58
|
+
monitoring_policy_id: monitoring_policy_id)
|
59
|
+
|
60
|
+
# Merge Attributes
|
61
|
+
merge_attributes(response.body)
|
62
|
+
|
63
|
+
true
|
64
|
+
|
65
|
+
end
|
66
|
+
|
67
|
+
|
68
|
+
def update(options = {})
|
69
|
+
|
70
|
+
requires :id
|
71
|
+
|
72
|
+
response = service.update_server(server_id: id, name: options[:name],
|
73
|
+
description: options[:description])
|
74
|
+
|
75
|
+
# Merge Attributes
|
76
|
+
merge_attributes(response.body)
|
77
|
+
|
78
|
+
true
|
79
|
+
|
80
|
+
end
|
81
|
+
|
82
|
+
|
83
|
+
def update_hardware(options = {})
|
84
|
+
|
85
|
+
requires :id
|
86
|
+
|
87
|
+
response = service.update_hardware(server_id: id,
|
88
|
+
fixed_instance_id: options[:fixed_instance_id],
|
89
|
+
vcore: options[:vcore], ram: options[:ram],
|
90
|
+
cores_per_processor: options[:cores_per_processor])
|
91
|
+
|
92
|
+
# Merge Attributes
|
93
|
+
merge_attributes(response.body)
|
94
|
+
|
95
|
+
true
|
96
|
+
|
97
|
+
end
|
98
|
+
|
99
|
+
|
100
|
+
def add_hdds(options = {})
|
101
|
+
|
102
|
+
requires :id
|
103
|
+
|
104
|
+
response = service.add_hdds(server_id: id,
|
105
|
+
hdds: options[:hdds])
|
106
|
+
|
107
|
+
# Merge Attributes
|
108
|
+
merge_attributes(response.body)
|
109
|
+
|
110
|
+
true
|
111
|
+
|
112
|
+
end
|
113
|
+
|
114
|
+
|
115
|
+
def delete_hdd(options = {})
|
116
|
+
|
117
|
+
requires :id
|
118
|
+
|
119
|
+
response = service.delete_hdd(server_id: id,
|
120
|
+
hdd_id: options[:hdd_id])
|
121
|
+
|
122
|
+
# Merge Attributes
|
123
|
+
merge_attributes(response.body)
|
124
|
+
|
125
|
+
true
|
126
|
+
|
127
|
+
end
|
128
|
+
|
129
|
+
|
130
|
+
def resize_hdd(options = {})
|
131
|
+
|
132
|
+
requires :id
|
133
|
+
|
134
|
+
response = service.update_hdd(server_id: id,
|
135
|
+
hdd_id: options[:hdd_id], size: options[:size])
|
136
|
+
|
137
|
+
# Merge Attributes
|
138
|
+
merge_attributes(response.body)
|
139
|
+
|
140
|
+
true
|
141
|
+
|
142
|
+
end
|
143
|
+
|
144
|
+
|
145
|
+
def install_image(options = {})
|
146
|
+
|
147
|
+
requires :id
|
148
|
+
|
149
|
+
response = service.install_server_image(server_id: id,
|
150
|
+
image_id: options[:image_id], password: options[:password],
|
151
|
+
firewall_id: options[:firewall_id])
|
152
|
+
|
153
|
+
# Merge Attributes
|
154
|
+
merge_attributes(response.body)
|
155
|
+
|
156
|
+
true
|
157
|
+
|
158
|
+
end
|
159
|
+
|
160
|
+
|
161
|
+
def add_ip
|
162
|
+
|
163
|
+
requires :id
|
164
|
+
|
165
|
+
response = service.add_server_ip(server_id: id)
|
166
|
+
|
167
|
+
# Merge Attributes
|
168
|
+
merge_attributes(response.body)
|
169
|
+
|
170
|
+
true
|
171
|
+
|
172
|
+
end
|
173
|
+
|
174
|
+
|
175
|
+
def delete_ip(options = {})
|
176
|
+
|
177
|
+
requires :id
|
178
|
+
|
179
|
+
response = service.delete_server_ip(server_id: id,
|
180
|
+
ip_id: options[:ip_id])
|
181
|
+
|
182
|
+
# Merge Attributes
|
183
|
+
merge_attributes(response.body)
|
184
|
+
|
185
|
+
true
|
186
|
+
|
187
|
+
end
|
188
|
+
|
189
|
+
|
190
|
+
def add_firewall(options = {})
|
191
|
+
|
192
|
+
requires :id
|
193
|
+
|
194
|
+
response = service.add_firewall(server_id: id,
|
195
|
+
ip_id: options[:ip_id], firewall_id: options[:firewall_id])
|
196
|
+
|
197
|
+
# Merge Attributes
|
198
|
+
merge_attributes(response.body)
|
199
|
+
|
200
|
+
true
|
201
|
+
|
202
|
+
end
|
203
|
+
|
204
|
+
|
205
|
+
def remove_firewall(options = {})
|
206
|
+
|
207
|
+
requires :id
|
208
|
+
|
209
|
+
response = service.remove_firewall(server_id: id,
|
210
|
+
ip_id: options[:ip_id])
|
211
|
+
|
212
|
+
# Merge Attributes
|
213
|
+
merge_attributes(response.body)
|
214
|
+
|
215
|
+
true
|
216
|
+
|
217
|
+
end
|
218
|
+
|
219
|
+
|
220
|
+
def add_load_balancer(options = {})
|
221
|
+
|
222
|
+
requires :id
|
223
|
+
|
224
|
+
response = service.add_load_balancer(server_id: id,
|
225
|
+
ip_id: options[:ip_id],
|
226
|
+
load_balancer_id: options[:load_balancer_id])
|
227
|
+
|
228
|
+
# Merge Attributes
|
229
|
+
merge_attributes(response.body)
|
230
|
+
|
231
|
+
true
|
232
|
+
|
233
|
+
end
|
234
|
+
|
235
|
+
|
236
|
+
def remove_load_balancer(options = {})
|
237
|
+
|
238
|
+
requires :id
|
239
|
+
|
240
|
+
response = service.remove_load_balancer(server_id: id,
|
241
|
+
ip_id: options[:ip_id],
|
242
|
+
load_balancer_id: options[:load_balancer_id])
|
243
|
+
|
244
|
+
# Merge Attributes
|
245
|
+
merge_attributes(response.body)
|
246
|
+
|
247
|
+
true
|
248
|
+
|
249
|
+
end
|
250
|
+
|
251
|
+
|
252
|
+
def on
|
253
|
+
|
254
|
+
requires :id
|
255
|
+
|
256
|
+
response = service.change_status(server_id: id,
|
257
|
+
action: 'POWER_ON', method: 'SOFTWARE')
|
258
|
+
|
259
|
+
# Merge Attributes
|
260
|
+
merge_attributes(response.body)
|
261
|
+
|
262
|
+
true
|
263
|
+
|
264
|
+
end
|
265
|
+
|
266
|
+
|
267
|
+
def off
|
268
|
+
|
269
|
+
requires :id
|
270
|
+
|
271
|
+
response = service.change_status(server_id: id,
|
272
|
+
action: 'POWER_OFF', method: 'SOFTWARE')
|
273
|
+
|
274
|
+
# Merge Attributes
|
275
|
+
merge_attributes(response.body)
|
276
|
+
|
277
|
+
true
|
278
|
+
|
279
|
+
end
|
280
|
+
|
281
|
+
|
282
|
+
def reboot
|
283
|
+
|
284
|
+
requires :id
|
285
|
+
|
286
|
+
response = service.change_status(server_id: id,
|
287
|
+
action: 'REBOOT', method: 'SOFTWARE')
|
288
|
+
|
289
|
+
# Merge Attributes
|
290
|
+
merge_attributes(response.body)
|
291
|
+
|
292
|
+
true
|
293
|
+
|
294
|
+
end
|
295
|
+
|
296
|
+
|
297
|
+
def load_dvd(options = {})
|
298
|
+
|
299
|
+
requires :id
|
300
|
+
|
301
|
+
response = service.load_dvd(server_id: id, dvd_id: options[:dvd_id])
|
302
|
+
|
303
|
+
# Merge Attributes
|
304
|
+
merge_attributes(response.body)
|
305
|
+
|
306
|
+
true
|
307
|
+
|
308
|
+
end
|
309
|
+
|
310
|
+
|
311
|
+
def eject_dvd
|
312
|
+
|
313
|
+
requires :id
|
314
|
+
|
315
|
+
response = service.eject_dvd(server_id: id)
|
316
|
+
|
317
|
+
# Merge Attributes
|
318
|
+
merge_attributes(response.body)
|
319
|
+
|
320
|
+
true
|
321
|
+
|
322
|
+
end
|
323
|
+
|
324
|
+
|
325
|
+
def add_private_network(options = {})
|
326
|
+
|
327
|
+
requires :id
|
328
|
+
|
329
|
+
response = service.add_private_network(server_id: id,
|
330
|
+
private_network_id: options[:private_network_id])
|
331
|
+
|
332
|
+
# Merge Attributes
|
333
|
+
merge_attributes(response.body)
|
334
|
+
|
335
|
+
true
|
336
|
+
|
337
|
+
end
|
338
|
+
|
339
|
+
|
340
|
+
def remove_private_network(options = {})
|
341
|
+
|
342
|
+
requires :id
|
343
|
+
|
344
|
+
response = service.remove_private_network(server_id: id,
|
345
|
+
private_network_id: options[:private_network_id])
|
346
|
+
|
347
|
+
# Merge Attributes
|
348
|
+
merge_attributes(response.body)
|
349
|
+
|
350
|
+
true
|
351
|
+
|
352
|
+
end
|
353
|
+
|
354
|
+
|
355
|
+
def create_snapshot
|
356
|
+
|
357
|
+
requires :id
|
358
|
+
|
359
|
+
response = service.create_snapshot(server_id: id)
|
360
|
+
|
361
|
+
# Merge Attributes
|
362
|
+
merge_attributes(response.body)
|
363
|
+
|
364
|
+
true
|
365
|
+
|
366
|
+
end
|
367
|
+
|
368
|
+
|
369
|
+
def restore_snapshot(options = {})
|
370
|
+
|
371
|
+
requires :id
|
372
|
+
|
373
|
+
response = service.restore_snapshot(server_id: id,
|
374
|
+
snapshot_id: options[:snapshot_id])
|
375
|
+
|
376
|
+
# Merge Attributes
|
377
|
+
merge_attributes(response.body)
|
378
|
+
|
379
|
+
true
|
380
|
+
|
381
|
+
end
|
382
|
+
|
383
|
+
|
384
|
+
def delete_snapshot(options = {})
|
385
|
+
|
386
|
+
requires :id
|
387
|
+
|
388
|
+
response = service.delete_snapshot(server_id: id,
|
389
|
+
snapshot_id: options[:snapshot_id])
|
390
|
+
|
391
|
+
# Merge Attributes
|
392
|
+
merge_attributes(response.body)
|
393
|
+
|
394
|
+
true
|
395
|
+
|
396
|
+
end
|
397
|
+
|
398
|
+
|
399
|
+
def clone(options = {})
|
400
|
+
|
401
|
+
requires :id
|
402
|
+
|
403
|
+
response = service.clone_server(server_id: id, name: options[:name],
|
404
|
+
datacenter_id: options[:datacenter_id])
|
405
|
+
|
406
|
+
# Merge Attributes
|
407
|
+
merge_attributes(response.body)
|
408
|
+
|
409
|
+
true
|
410
|
+
|
411
|
+
end
|
412
|
+
|
413
|
+
|
414
|
+
def destroy
|
415
|
+
|
416
|
+
requires :id
|
417
|
+
|
418
|
+
service.delete_server(id)
|
419
|
+
|
420
|
+
true
|
421
|
+
|
422
|
+
end
|
423
|
+
|
424
|
+
|
425
|
+
def ready?
|
426
|
+
|
427
|
+
(GOOD_STATES.include? status['state']) && (status['percent'] == nil)
|
428
|
+
|
429
|
+
end
|
430
|
+
|
431
|
+
end # Server
|
432
|
+
end # OneAndOne
|
433
|
+
end # Compute
|
434
|
+
end # Fog
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require_relative 'server'
|
2
|
+
|
3
|
+
module Fog
|
4
|
+
module Compute
|
5
|
+
class OneAndOne
|
6
|
+
class Servers < Fog::Collection
|
7
|
+
model Fog::Compute::OneAndOne::Server
|
8
|
+
|
9
|
+
def all
|
10
|
+
response = service.list_servers
|
11
|
+
load(response.body)
|
12
|
+
end
|
13
|
+
|
14
|
+
def get(id)
|
15
|
+
response = service.get_server(id)
|
16
|
+
new(response.body)
|
17
|
+
rescue Excon::Errors::NotFound
|
18
|
+
nil
|
19
|
+
end
|
20
|
+
|
21
|
+
end # Servers
|
22
|
+
end # OneAndOne
|
23
|
+
end # Compute
|
24
|
+
end # Fog
|