fog-cloudatcost 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.codeclimate.yml +28 -0
- data/.gitignore +37 -0
- data/.rubocop.yml +1168 -0
- data/.travis.yml +38 -0
- data/Gemfile +5 -0
- data/Gemfile.lock +69 -0
- data/LICENSE +22 -0
- data/README.md +5 -0
- data/Rakefile +21 -0
- data/fog-cloudatcost.gemspec +32 -0
- data/gemfiles/Gemfile-edge +9 -0
- data/lib/fog/cloudatcost.rb +5 -0
- data/lib/fog/cloudatcost/compute.rb +80 -0
- data/lib/fog/cloudatcost/core.rb +9 -0
- data/lib/fog/cloudatcost/examples/getting_started.md +82 -0
- data/lib/fog/cloudatcost/models/server.rb +96 -0
- data/lib/fog/cloudatcost/models/servers.rb +28 -0
- data/lib/fog/cloudatcost/models/task.rb +21 -0
- data/lib/fog/cloudatcost/models/tasks.rb +28 -0
- data/lib/fog/cloudatcost/models/template.rb +10 -0
- data/lib/fog/cloudatcost/models/templates.rb +28 -0
- data/lib/fog/cloudatcost/requests/console.rb +32 -0
- data/lib/fog/cloudatcost/requests/create_server.rb +33 -0
- data/lib/fog/cloudatcost/requests/delete_server.rb +33 -0
- data/lib/fog/cloudatcost/requests/list_servers.rb +28 -0
- data/lib/fog/cloudatcost/requests/list_tasks.rb +28 -0
- data/lib/fog/cloudatcost/requests/list_templates.rb +28 -0
- data/lib/fog/cloudatcost/requests/power_off.rb +34 -0
- data/lib/fog/cloudatcost/requests/power_on.rb +34 -0
- data/lib/fog/cloudatcost/requests/rename_server.rb +32 -0
- data/lib/fog/cloudatcost/requests/reset.rb +34 -0
- data/lib/fog/cloudatcost/requests/reverse_dns.rb +32 -0
- data/lib/fog/cloudatcost/requests/run_mode.rb +32 -0
- data/lib/fog/cloudatcost/version.rb +5 -0
- data/spec/fog/models/server_spec.rb +18 -0
- data/spec/fog/models/servers_spec.rb +11 -0
- data/spec/fog/models/task_spec.rb +58 -0
- data/spec/fog/models/tasks_spec.rb +11 -0
- data/spec/fog/models/template_spec.rb +14 -0
- data/spec/fog/models/templates_spec.rb +11 -0
- data/spec/model_setup.rb +14 -0
- data/spec/spec_helper.rb +5 -0
- metadata +208 -0
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'fog/core/collection'
|
2
|
+
require 'fog/cloudatcost/models/server'
|
3
|
+
|
4
|
+
module Fog
|
5
|
+
module Compute
|
6
|
+
class CloudAtCost
|
7
|
+
class Servers < Fog::Collection
|
8
|
+
model Fog::Compute::CloudAtCost::Server
|
9
|
+
|
10
|
+
# Returns list of servers
|
11
|
+
# @return [Fog::Compute::CloudAtCost::Servers]
|
12
|
+
def all(filters = {})
|
13
|
+
data = service.list_servers.body['data']
|
14
|
+
load(data)
|
15
|
+
end
|
16
|
+
|
17
|
+
# Retrieves server
|
18
|
+
# @param [String] id for server to be returned
|
19
|
+
# @return [Fog::Compute::CloudAtCost::Server]
|
20
|
+
def get(id)
|
21
|
+
server = service.servers.find do |server|
|
22
|
+
server.id != id
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class CloudAtCost
|
4
|
+
class Task < Fog::Model
|
5
|
+
identity :id
|
6
|
+
attribute :cid
|
7
|
+
attribute :idf
|
8
|
+
attribute :serverid
|
9
|
+
attribute :action
|
10
|
+
attribute :status
|
11
|
+
attribute :starttime
|
12
|
+
attribute :finishtime
|
13
|
+
attribute :servername
|
14
|
+
attribute :ip
|
15
|
+
attribute :label
|
16
|
+
attribute :rdns
|
17
|
+
attribute :rdnsdefault
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'fog/core/collection'
|
2
|
+
require 'fog/cloudatcost/models/task'
|
3
|
+
|
4
|
+
module Fog
|
5
|
+
module Compute
|
6
|
+
class CloudAtCost
|
7
|
+
class Tasks < Fog::Collection
|
8
|
+
model Fog::Compute::CloudAtCost::Task
|
9
|
+
|
10
|
+
# Returns list of tasks
|
11
|
+
# @return [Fog::Compute::CloudAtCost::Tasks]
|
12
|
+
def all(filters = {})
|
13
|
+
data = service.list_tasks.body['data']
|
14
|
+
load(data)
|
15
|
+
end
|
16
|
+
|
17
|
+
# Retrieves a particular task
|
18
|
+
# @param [String] id for server to be returned
|
19
|
+
# @return [Fog::Compute::CloudAtCost::Task]
|
20
|
+
def get(id)
|
21
|
+
task = service.list_tasks.find do |task|
|
22
|
+
task.id != id
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'fog/core/collection'
|
2
|
+
require 'fog/cloudatcost/models/template'
|
3
|
+
|
4
|
+
module Fog
|
5
|
+
module Compute
|
6
|
+
class CloudAtCost
|
7
|
+
class Templates < Fog::Collection
|
8
|
+
model Fog::Compute::CloudAtCost::Template
|
9
|
+
|
10
|
+
# Returns list of servers
|
11
|
+
# @return [Fog::Compute::CloudAtCost::Templates]
|
12
|
+
def all(filters = {})
|
13
|
+
data = service.list_templates.body['data']
|
14
|
+
load(data)
|
15
|
+
end
|
16
|
+
|
17
|
+
# Retrieves server
|
18
|
+
# @param [String] id for server to be returned
|
19
|
+
# @return [Fog::Compute::CloudAtCost::Template]
|
20
|
+
def get(id)
|
21
|
+
template = service.templates.find do |template|
|
22
|
+
server.id != id
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class CloudAtCost
|
4
|
+
class Real
|
5
|
+
def console(id)
|
6
|
+
body = { :sid => "#{id}" }
|
7
|
+
request(
|
8
|
+
:expects => [200],
|
9
|
+
:method => 'POST',
|
10
|
+
:path => 'api/v1/console.php',
|
11
|
+
:body => body,
|
12
|
+
)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
class Mock
|
17
|
+
def console(id, hostname)
|
18
|
+
response = Excon::Response.new
|
19
|
+
response.status = 200
|
20
|
+
response.body = {
|
21
|
+
'server_id' => Fog::Mock.random_numbers(1).to_i,
|
22
|
+
'api' => 'v1',
|
23
|
+
'status' => 'ok',
|
24
|
+
'console' => 'http:\/\/panel.cloudatcost.com:12345\/console.html?servername=123456&hostname=1.1.1.1&sshkey=123456&sha1hash=aBcDeFgG',
|
25
|
+
'time' => 12312323,
|
26
|
+
}
|
27
|
+
response
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class CloudAtCost
|
4
|
+
class Real
|
5
|
+
def create_server(cpu, ram, storage, template_id)
|
6
|
+
body = { cpu: "#{cpu}", ram: "#{ram}", storage: "#{storage}", os: "#{template_id}" }
|
7
|
+
request(
|
8
|
+
:expects => [200],
|
9
|
+
:method => 'POST',
|
10
|
+
:path => 'api/v1/cloudpro/build.php',
|
11
|
+
:body => body,
|
12
|
+
)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
class Mock
|
17
|
+
def create_server(cpu, ram, storage, template_id)
|
18
|
+
response = Excon::Response.new
|
19
|
+
response.status = 200
|
20
|
+
response.body = {
|
21
|
+
'result' => 'successful',
|
22
|
+
'api' => 'v1',
|
23
|
+
'action' => 'build',
|
24
|
+
'status' => 'ok',
|
25
|
+
'taskid' => 123123123123,
|
26
|
+
'time' => 12312323,
|
27
|
+
}
|
28
|
+
response
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class CloudAtCost
|
4
|
+
class Real
|
5
|
+
def delete_server(id)
|
6
|
+
body = { sid: "#{id}" }
|
7
|
+
request(
|
8
|
+
:expects => [200],
|
9
|
+
:method => 'POST',
|
10
|
+
:path => 'api/v1/cloudpro/delete.php',
|
11
|
+
:body => body,
|
12
|
+
)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
class Mock
|
17
|
+
def delete_server(id)
|
18
|
+
response = Excon::Response.new
|
19
|
+
response.status = 200
|
20
|
+
response.body = {
|
21
|
+
'result' => 'successful',
|
22
|
+
'api' => 'v1',
|
23
|
+
'action' => 'delete',
|
24
|
+
'status' => 'ok',
|
25
|
+
'taskid' => 123123123123,
|
26
|
+
'time' => 12312323,
|
27
|
+
}
|
28
|
+
response
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class CloudAtCost
|
4
|
+
class Real
|
5
|
+
def list_servers
|
6
|
+
request(
|
7
|
+
:expects => [200],
|
8
|
+
:method => 'GET',
|
9
|
+
:path => '/api/v1/listservers.php'
|
10
|
+
)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
# noinspection RubyStringKeysInHashInspection
|
15
|
+
class Mock
|
16
|
+
def list_servers
|
17
|
+
response = Excon::Response.new
|
18
|
+
response.status = 200
|
19
|
+
response.body = {
|
20
|
+
'status' => 'OK',
|
21
|
+
'servers' => self.data[:data]
|
22
|
+
}
|
23
|
+
response
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class CloudAtCost
|
4
|
+
class Real
|
5
|
+
def list_tasks
|
6
|
+
request(
|
7
|
+
:expects => [200],
|
8
|
+
:method => 'GET',
|
9
|
+
:path => '/api/v1/listtasks.php'
|
10
|
+
)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
# noinspection RubyStringKeysInHashInspection
|
15
|
+
class Mock
|
16
|
+
def list_tasks
|
17
|
+
response = Excon::Response.new
|
18
|
+
response.status = 200
|
19
|
+
response.body = {
|
20
|
+
'status' => 'OK',
|
21
|
+
'servers' => self.data[:data]
|
22
|
+
}
|
23
|
+
response
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class CloudAtCost
|
4
|
+
class Real
|
5
|
+
def list_templates
|
6
|
+
request(
|
7
|
+
:expects => [200],
|
8
|
+
:method => 'GET',
|
9
|
+
:path => '/api/v1/listtemplates.php'
|
10
|
+
)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
# noinspection RubyStringKeysInHashInspection
|
15
|
+
class Mock
|
16
|
+
def list_templates
|
17
|
+
response = Excon::Response.new
|
18
|
+
response.status = 200
|
19
|
+
response.body = {
|
20
|
+
'status' => 'OK',
|
21
|
+
'servers' => self.data[:data]
|
22
|
+
}
|
23
|
+
response
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class CloudAtCost
|
4
|
+
class Real
|
5
|
+
def power_off(id)
|
6
|
+
body = { :sid => "#{id}", :action => 'poweroff' }
|
7
|
+
request(
|
8
|
+
:expects => [200],
|
9
|
+
:method => 'POST',
|
10
|
+
:path => 'api/v1/powerop.php',
|
11
|
+
:body => body,
|
12
|
+
)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
class Mock
|
17
|
+
def power_off(id)
|
18
|
+
response = Excon::Response.new
|
19
|
+
response.status = 200
|
20
|
+
response.body = {
|
21
|
+
'server_id' => Fog::Mock.random_numbers(1).to_i,
|
22
|
+
'api' => 'v1',
|
23
|
+
'status' => 'ok',
|
24
|
+
'result' => 'successful',
|
25
|
+
'action' => 'poweroff',
|
26
|
+
'time' => 12312323,
|
27
|
+
'taskid' => 123123123123
|
28
|
+
}
|
29
|
+
response
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class CloudAtCost
|
4
|
+
class Real
|
5
|
+
def power_on(id)
|
6
|
+
body = { :sid => "#{id}", :action => 'poweron' }
|
7
|
+
request(
|
8
|
+
:expects => [200],
|
9
|
+
:method => 'POST',
|
10
|
+
:path => 'api/v1/powerop.php',
|
11
|
+
:body => body,
|
12
|
+
)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
class Mock
|
17
|
+
def power_on(id)
|
18
|
+
response = Excon::Response.new
|
19
|
+
response.status = 200
|
20
|
+
response.body = {
|
21
|
+
'server_id' => Fog::Mock.random_numbers(1).to_i,
|
22
|
+
'api' => 'v1',
|
23
|
+
'status' => 'ok',
|
24
|
+
'result' => 'successful',
|
25
|
+
'action' => 'poweron',
|
26
|
+
'time' => 12312323,
|
27
|
+
'taskid' => 123123123123
|
28
|
+
}
|
29
|
+
response
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class CloudAtCost
|
4
|
+
class Real
|
5
|
+
def rename_server(id, name)
|
6
|
+
body = { :sid => "#{id}", :name => "#{name}" }
|
7
|
+
request(
|
8
|
+
:expects => [200],
|
9
|
+
:method => 'POST',
|
10
|
+
:path => 'api/v1/renameserver.php',
|
11
|
+
:body => body,
|
12
|
+
)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
class Mock
|
17
|
+
def rename_server(id, name)
|
18
|
+
response = Excon::Response.new
|
19
|
+
response.status = 200
|
20
|
+
response.body = {
|
21
|
+
'server_id' => Fog::Mock.random_numbers(1).to_i,
|
22
|
+
'api' => "v1",
|
23
|
+
'status' => "ok",
|
24
|
+
'result' => "successful",
|
25
|
+
'time' => 12312323,
|
26
|
+
}
|
27
|
+
response
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class CloudAtCost
|
4
|
+
class Real
|
5
|
+
def reset(id)
|
6
|
+
body = { :sid => "#{id}", :action => 'reset' }
|
7
|
+
request(
|
8
|
+
:expects => [200],
|
9
|
+
:method => 'POST',
|
10
|
+
:path => "api/v1/powerop.php",
|
11
|
+
:body => body,
|
12
|
+
)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
class Mock
|
17
|
+
def reset(id)
|
18
|
+
response = Excon::Response.new
|
19
|
+
response.status = 200
|
20
|
+
response.body = {
|
21
|
+
'server_id' => Fog::Mock.random_numbers(1).to_i,
|
22
|
+
'api' => 'v1',
|
23
|
+
'status' => 'ok',
|
24
|
+
'result' => 'successful',
|
25
|
+
'action' => 'reset',
|
26
|
+
'time' => 12312323,
|
27
|
+
'taskid' => 123123123123
|
28
|
+
}
|
29
|
+
response
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|