Class: Deltacloud::Drivers::Rimuhosting::RimuhostingDriver
- Inherits:
-
BaseDriver
- Object
- BaseDriver
- Deltacloud::Drivers::Rimuhosting::RimuhostingDriver
show all
- Defined in:
- lib/deltacloud/drivers/rimuhosting/rimuhosting_driver.rb
Constant Summary
Constants inherited
from BaseDriver
BaseDriver::MEMBER_SHOW_METHODS, BaseDriver::STATE_MACHINE_OPTS
Constants included
from Deltacloud
API_VERSION, CIMI_API_VERSION
Instance Method Summary
collapse
-
#convert_srv_to_instance(inst) ⇒ Object
-
#create_instance(credentials, image_id, opts) ⇒ Object
-
#destroy_instance(credentials, id) ⇒ Object
-
#hardware_profiles(credentials, opts = nil) ⇒ Object
-
#images(credentails, opts = nil) ⇒ Object
-
#instances(credentials, opts = nil) ⇒ Object
-
#realms(credentials, opts = nil) ⇒ Object
-
#reboot_instance(credentials, id) ⇒ Object
-
#start_instance(credentials, id) ⇒ Object
-
#stop_instance(credentials, id) ⇒ Object
Methods inherited from BaseDriver
#address, #api_provider, #blob, #bucket, #catched_exceptions_list, #configured_providers, constraints, define_hardware_profile, define_instance_states, driver_name, feature, features, #filter_hardware_profiles, #filter_on, #find_hardware_profile, #firewall, #hardware_profile, hardware_profiles, #has_capability?, #has_feature?, has_feature?, #image, #instance, #instance_actions_for, instance_state_machine, #instance_state_machine, #key, #name, #realm, #storage_snapshot, #storage_volume, #supported_collections, #valid_credentials?
Methods included from Deltacloud
[], config, configure, connect, database, default_frontend, drivers, enabled_frontends, frontend_required?, frontends, generate_routes, initialize_database, need_database?, new, require_frontend!
#collection_exists?, #collection_names, #collections
Methods included from Exceptions
exception_from_status, exceptions, included, logger, #safely
Instance Method Details
#convert_srv_to_instance(inst) ⇒ Object
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
|
# File 'lib/deltacloud/drivers/rimuhosting/rimuhosting_driver.rb', line 122
def convert_srv_to_instance( inst )
Instance.new({
:id => inst["order_oid"].to_s,
:name => inst["domain_name"],
:image_id => "lenny",
:state => "RUNNING",
:name => inst["domain_name"],
:realm_id => "RH",
:owner_id => "root",
:instance_profile => InstanceProfile.new("none"),
:actions => instance_actions_for("RUNNING"),
:public_addresses => [ InstanceAddress.new(inst["allocated_ips"]["primary_ip"] )],
:launch_time => inst["billing_info"]["order_date"]["iso_format"]}
)
end
|
#create_instance(credentials, image_id, opts) ⇒ Object
109
110
111
112
113
114
115
116
117
118
119
120
|
# File 'lib/deltacloud/drivers/rimuhosting/rimuhosting_driver.rb', line 109
def create_instance(credentials, image_id, opts)
rh = RimuHostingClient.new(credentials)
hwp_id = opts[:hwp_id] || 1
name = opts[:name]
if not name
name = Time.now.to_i.to_s + '.com'
end
convert_srv_to_instance(rh.create_server(image_id, hwp_id, name))
end
|
#destroy_instance(credentials, id) ⇒ Object
102
103
104
105
106
107
|
# File 'lib/deltacloud/drivers/rimuhosting/rimuhosting_driver.rb', line 102
def destroy_instance(credentials, id)
safely do
rh = RimuHostingClient.new(credentials)
return rh.delete_server(id)
end
end
|
#hardware_profiles(credentials, opts = nil) ⇒ Object
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
# File 'lib/deltacloud/drivers/rimuhosting/rimuhosting_driver.rb', line 47
def hardware_profiles(credentials, opts = nil)
safely do
rh = RimuHostingClient.new(credentials)
results = rh.list_plans.map do |plan|
HardwareProfile.new(plan["pricing_plan_code"]) do
memory plan["minimum_memory_mb"].to_f
storage plan["minimum_disk_gb"].to_i
architecture "x86"
end
end
end
filter_hardware_profiles(results, opts)
end
|
#images(credentails, opts = nil) ⇒ Object
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/deltacloud/drivers/rimuhosting/rimuhosting_driver.rb', line 29
def images(credentails, opts=nil)
safely do
rh = RimuHostingClient.new(credentails)
images = rh.list_images.map do | image |
Image.new({
:id => image["distro_code"].gsub(/\./,"-"),
:name => image["distro_code"],
:description => image["distro_description"],
:owner_id => "root",
:architecture => "x86"
})
end
end
images.sort_by{|e| [e.description]}
images = filter_on( images, :id, opts)
images
end
|
#instances(credentials, opts = nil) ⇒ Object
72
73
74
75
76
77
78
79
80
81
82
|
# File 'lib/deltacloud/drivers/rimuhosting/rimuhosting_driver.rb', line 72
def instances(credentials, opts=nil)
safely do
rh = RimuHostingClient.new(credentials)
instances = rh.list_nodes.map do | inst |
convert_srv_to_instance(inst)
end
end
instances = filter_on( instances, :id, opts)
instances = filter_on( instances, :state, opts )
instances
end
|
#realms(credentials, opts = nil) ⇒ Object
64
65
66
67
68
69
70
|
# File 'lib/deltacloud/drivers/rimuhosting/rimuhosting_driver.rb', line 64
def realms(credentials, opts=nil)
[Realm.new( {
:id=>"rimu",
:name=>"RimuHosting",
:state=> "AVAILABLE"
} )]
end
|
#reboot_instance(credentials, id) ⇒ Object
84
85
86
87
88
89
|
# File 'lib/deltacloud/drivers/rimuhosting/rimuhosting_driver.rb', line 84
def reboot_instance(credentials, id)
safely do
rh = RimuHostingClient.new(credentials)
rh.set_server_state(id, :RESTARTING)
end
end
|
#start_instance(credentials, id) ⇒ Object
91
92
93
94
95
96
|
# File 'lib/deltacloud/drivers/rimuhosting/rimuhosting_driver.rb', line 91
def start_instance(credentials, id)
safely do
rh = RimuHostingClient.new(credentials)
rh.set_server_state(id, :STARTED)
end
end
|
#stop_instance(credentials, id) ⇒ Object
98
99
100
|
# File 'lib/deltacloud/drivers/rimuhosting/rimuhosting_driver.rb', line 98
def stop_instance(credentials, id)
destroy_instance(credentials, id)
end
|