solusvm 1.0.0.beta3 → 1.1.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +3 -0
- data/.travis.yml +10 -4
- data/LICENSE +1 -1
- data/README.markdown +1 -1
- data/lib/solusvm.rb +2 -2
- data/lib/solusvm/base.rb +10 -32
- data/lib/solusvm/cli/base_cli.rb +30 -5
- data/lib/solusvm/cli/client_cli.rb +9 -9
- data/lib/solusvm/cli/general_cli.rb +5 -5
- data/lib/solusvm/cli/node_cli.rb +8 -8
- data/lib/solusvm/cli/reseller_cli.rb +7 -7
- data/lib/solusvm/cli/server_cli.rb +31 -31
- data/lib/solusvm/solusvm_errors.rb +22 -0
- data/lib/solusvm/version.rb +1 -1
- data/solusvm.gemspec +2 -0
- data/test/cli/test_base_cli.rb +32 -0
- data/test/cli/test_client_cli.rb +38 -21
- data/test/cli/test_general_cli.rb +13 -4
- data/test/cli/test_node_cli.rb +28 -14
- data/test/cli/test_reseller_cli.rb +69 -58
- data/test/cli/test_server_cli.rb +128 -39
- data/test/solusvm/test_base.rb +103 -0
- data/test/{test_cli.rb → solusvm/test_cli.rb} +1 -1
- data/test/solusvm/test_client.rb +109 -0
- data/test/solusvm/test_general.rb +69 -0
- data/test/{test_hash.rb → solusvm/test_hash.rb} +1 -1
- data/test/solusvm/test_node.rb +120 -0
- data/test/solusvm/test_reseller.rb +93 -0
- data/test/solusvm/test_server.rb +253 -0
- data/test/{helper.rb → test_helper.rb} +19 -4
- data/test/test_solusvm.rb +1 -1
- data/test/vcr_cassettes/base/invalid_key.yml +19 -0
- data/test/vcr_cassettes/base/invalid_status.yml +19 -0
- data/test/vcr_cassettes/base/nonexistent_node.yml +19 -0
- data/test/vcr_cassettes/base/parse_response.yml +28 -0
- data/test/vcr_cassettes/base/statusmsg.yml +28 -0
- data/test/vcr_cassettes/base/successful.yml +45 -0
- data/test/vcr_cassettes/base/unauthorized_ip.yml +19 -0
- data/test/vcr_cassettes/client/authenticate.yml +37 -0
- data/test/vcr_cassettes/client/change_password.yml +39 -0
- data/test/vcr_cassettes/client/create.yml +42 -0
- data/test/vcr_cassettes/client/delete.yml +37 -0
- data/test/vcr_cassettes/client/exists.yml +20 -0
- data/test/vcr_cassettes/client/list.yml +66 -0
- data/test/vcr_cassettes/general/isos.yml +38 -0
- data/test/vcr_cassettes/general/plans.yml +38 -0
- data/test/vcr_cassettes/general/templates.yml +38 -0
- data/test/vcr_cassettes/node/available_ips.yml +41 -0
- data/test/vcr_cassettes/node/ids.yml +21 -0
- data/test/vcr_cassettes/node/list.yml +38 -0
- data/test/vcr_cassettes/node/statistics.yml +32 -0
- data/test/vcr_cassettes/node/virtualservers.yml +67 -0
- data/test/vcr_cassettes/node/xenresources.yml +22 -0
- data/test/vcr_cassettes/reseller/change_resources.yml +27 -0
- data/test/vcr_cassettes/reseller/create.yml +27 -0
- data/test/vcr_cassettes/reseller/delete.yml +15 -0
- data/test/vcr_cassettes/reseller/info.yml +27 -0
- data/test/vcr_cassettes/reseller/list.yml +27 -0
- data/test/vcr_cassettes/server/.yml +1017 -0
- data/test/vcr_cassettes/server/boot.yml +15 -0
- data/test/vcr_cassettes/server/change_bootorder.yml +15 -0
- data/test/vcr_cassettes/server/change_consolepass.yml +16 -0
- data/test/vcr_cassettes/server/change_hostname.yml +15 -0
- data/test/vcr_cassettes/server/change_owner.yml +15 -0
- data/test/vcr_cassettes/server/change_plan.yml +15 -0
- data/test/vcr_cassettes/server/change_rootpassword.yml +15 -0
- data/test/vcr_cassettes/server/change_vncpass.yml +15 -0
- data/test/vcr_cassettes/server/console.yml +15 -0
- data/test/vcr_cassettes/server/create.yml +27 -0
- data/test/vcr_cassettes/server/exists.yml +15 -0
- data/test/vcr_cassettes/server/info.yml +27 -0
- data/test/vcr_cassettes/server/info_all.yml +15 -0
- data/test/vcr_cassettes/server/mountiso.yml +15 -0
- data/test/vcr_cassettes/server/network_disable.yml +15 -0
- data/test/vcr_cassettes/server/network_enable.yml +15 -0
- data/test/vcr_cassettes/server/pae_disable.yml +15 -0
- data/test/vcr_cassettes/server/pae_enable.yml +15 -0
- data/test/vcr_cassettes/server/reboot.yml +15 -0
- data/test/vcr_cassettes/server/rebuild.yml +15 -0
- data/test/vcr_cassettes/server/resume.yml +15 -0
- data/test/vcr_cassettes/server/shutdown.yml +15 -0
- data/test/vcr_cassettes/server/status.yml +15 -0
- data/test/vcr_cassettes/server/suspend.yml +15 -0
- data/test/vcr_cassettes/server/terminate.yml +27 -0
- data/test/vcr_cassettes/server/tun_disable.yml +15 -0
- data/test/vcr_cassettes/server/tun_enable.yml +15 -0
- data/test/vcr_cassettes/server/unmountiso.yml +15 -0
- data/test/vcr_cassettes/server/vnc.yml +15 -0
- metadata +220 -156
- data/.rbenv-version +0 -1
- data/.rvmrc +0 -47
- data/test/fixtures/base_bad_key.txt +0 -1
- data/test/fixtures/base_node_does_not_exist.txt +0 -1
- data/test/fixtures/base_unauthorized_ip.txt +0 -1
- data/test/fixtures/client_authenticate_error.txt +0 -2
- data/test/fixtures/client_authenticate_success.txt +0 -2
- data/test/fixtures/client_change_password_error.txt +0 -2
- data/test/fixtures/client_change_password_success.txt +0 -4
- data/test/fixtures/client_create_error.txt +0 -2
- data/test/fixtures/client_create_success.txt +0 -7
- data/test/fixtures/client_delete_success.txt +0 -2
- data/test/fixtures/client_exists_success.txt +0 -2
- data/test/fixtures/client_list_success.txt +0 -14
- data/test/fixtures/client_list_success_empty.txt +0 -2
- data/test/fixtures/error.txt +0 -2
- data/test/fixtures/general_isos_success.txt +0 -3
- data/test/fixtures/general_plans_success.txt +0 -3
- data/test/fixtures/general_templates_success.txt +0 -3
- data/test/fixtures/node_list_all_ips_available.txt +0 -4
- data/test/fixtures/node_list_all_ips_not_available.txt +0 -4
- data/test/fixtures/node_statistics_success.txt +0 -14
- data/test/fixtures/node_virtualservers_success.txt +0 -15
- data/test/fixtures/node_virtualservers_success_empty.txt +0 -2
- data/test/fixtures/node_xenresources_success.txt +0 -4
- data/test/fixtures/nodes_ids_success.txt +0 -3
- data/test/fixtures/nodes_list_success.txt +0 -3
- data/test/fixtures/reseller_change_resources_success.txt +0 -16
- data/test/fixtures/reseller_create_success.txt +0 -23
- data/test/fixtures/reseller_delete_success.txt +0 -2
- data/test/fixtures/reseller_info_success.txt +0 -23
- data/test/fixtures/reseller_list_success.txt +0 -3
- data/test/fixtures/server_boot_success.txt +0 -2
- data/test/fixtures/server_bootorder_success.txt +0 -2
- data/test/fixtures/server_change_consolepass_success.txt +0 -3
- data/test/fixtures/server_change_owner_success.txt +0 -2
- data/test/fixtures/server_change_success.txt +0 -2
- data/test/fixtures/server_change_vncpass_success.txt +0 -3
- data/test/fixtures/server_console_success.txt +0 -7
- data/test/fixtures/server_create_success.txt +0 -10
- data/test/fixtures/server_exists_success.txt +0 -2
- data/test/fixtures/server_hostname_success.txt +0 -3
- data/test/fixtures/server_info_success.txt +0 -10
- data/test/fixtures/server_infoall_success.txt +0 -13
- data/test/fixtures/server_mountiso_success.txt +0 -2
- data/test/fixtures/server_network_disable_success.txt +0 -2
- data/test/fixtures/server_network_enable_success.txt +0 -2
- data/test/fixtures/server_pae_success.txt +0 -2
- data/test/fixtures/server_reboot_success.txt +0 -2
- data/test/fixtures/server_rebuild_success.txt +0 -2
- data/test/fixtures/server_resume_success.txt +0 -2
- data/test/fixtures/server_rootpassword_success.txt +0 -3
- data/test/fixtures/server_shutdown_success.txt +0 -2
- data/test/fixtures/server_status_success.txt +0 -2
- data/test/fixtures/server_suspend_success.txt +0 -2
- data/test/fixtures/server_terminate_success.txt +0 -2
- data/test/fixtures/server_tun_disable_success.txt +0 -2
- data/test/fixtures/server_tun_enable_success.txt +0 -2
- data/test/fixtures/server_unmountiso_success.txt +0 -2
- data/test/fixtures/server_vnc_success.txt +0 -6
- data/test/test_base.rb +0 -115
- data/test/test_client.rb +0 -98
- data/test/test_general.rb +0 -70
- data/test/test_node.rb +0 -112
- data/test/test_reseller.rb +0 -80
- data/test/test_server.rb +0 -227
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
@@ -1,11 +1,17 @@
|
|
1
|
-
|
1
|
+
language: ruby
|
2
|
+
script: "bundle exec rake spec"
|
2
3
|
notifications:
|
3
|
-
|
4
|
+
email:
|
5
|
+
recipients:
|
6
|
+
- engineering@internal.site5.com
|
7
|
+
on_success: never
|
8
|
+
on_failure: always
|
4
9
|
rvm:
|
5
10
|
- 1.8.7
|
6
11
|
- 1.9.2
|
7
12
|
- 1.9.3
|
8
13
|
- ree
|
9
|
-
- rbx
|
10
14
|
- rbx-head
|
11
|
-
-
|
15
|
+
- rbx-18mode
|
16
|
+
- jruby-18mode
|
17
|
+
- jruby-19mode
|
data/LICENSE
CHANGED
data/README.markdown
CHANGED
data/lib/solusvm.rb
CHANGED
@@ -1,8 +1,7 @@
|
|
1
|
-
require 'net/http'
|
2
|
-
require 'net/https'
|
3
1
|
require 'cgi'
|
4
2
|
require 'rubygems'
|
5
3
|
require 'xmlsimple'
|
4
|
+
require 'faraday'
|
6
5
|
|
7
6
|
module Solusvm
|
8
7
|
class << self
|
@@ -28,6 +27,7 @@ end
|
|
28
27
|
|
29
28
|
require 'solusvm/exceptions'
|
30
29
|
require 'solusvm/hash'
|
30
|
+
require 'solusvm/solusvm_errors'
|
31
31
|
require 'solusvm/base'
|
32
32
|
require 'solusvm/general'
|
33
33
|
require 'solusvm/client'
|
data/lib/solusvm/base.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
Faraday.register_middleware :response, :solusvm_errors => Solusvm::SolusvmErrors
|
2
|
+
|
1
3
|
module Solusvm
|
2
4
|
# Solusvm::Base is the main class for mapping API resources as subclasses.
|
3
5
|
class Base
|
@@ -18,20 +20,13 @@ module Solusvm
|
|
18
20
|
#
|
19
21
|
# <tt>force_array</tt> - see parse_response
|
20
22
|
def perform_request(options = {}, force_array = false)
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
request = Net::HTTP::Get.new("#{api_endpoint.path}?#{options.to_query}")
|
29
|
-
response = http.request(request)
|
30
|
-
|
31
|
-
handle_errors(response)
|
32
|
-
@returned_parameters = parse_response(response.body, force_array)
|
33
|
-
log_messages(options)
|
34
|
-
end
|
23
|
+
response = Faraday.new(:url => api_endpoint, :ssl => {:verify => true}) do |c|
|
24
|
+
c.params = options.merge(api_login)
|
25
|
+
c.response :solusvm_errors
|
26
|
+
c.adapter :net_http
|
27
|
+
end.get
|
28
|
+
@returned_parameters = parse_response(response.body, force_array)
|
29
|
+
log_messages(options)
|
35
30
|
successful?
|
36
31
|
end
|
37
32
|
|
@@ -52,23 +47,6 @@ module Solusvm
|
|
52
47
|
end
|
53
48
|
end
|
54
49
|
|
55
|
-
# Look for known error messages
|
56
|
-
def handle_errors(response)
|
57
|
-
if (200..299).include? response.code.to_i
|
58
|
-
# Checks for application errors
|
59
|
-
case response.body.downcase
|
60
|
-
when /invalid ipaddress/i
|
61
|
-
raise "This IP is not authorized to use the API"
|
62
|
-
when /Invalid id or key/i
|
63
|
-
raise "Invalid ID or key"
|
64
|
-
when /Node not found/i
|
65
|
-
raise "Node does not exist"
|
66
|
-
end
|
67
|
-
else
|
68
|
-
raise SolusvmError, "Bad HTTP Status: #{response.code}"
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
50
|
# Returns true when a request has been successful
|
73
51
|
#
|
74
52
|
# my_class = MyClass.new
|
@@ -80,7 +58,7 @@ module Solusvm
|
|
80
58
|
|
81
59
|
# URI parsed API URL
|
82
60
|
def api_endpoint
|
83
|
-
Solusvm.api_endpoint
|
61
|
+
Solusvm.api_endpoint.dup
|
84
62
|
end
|
85
63
|
|
86
64
|
def api_login
|
data/lib/solusvm/cli/base_cli.rb
CHANGED
@@ -6,7 +6,7 @@ require 'solusvm/version'
|
|
6
6
|
module Solusvm
|
7
7
|
class BaseCli < Thor
|
8
8
|
include Thor::Actions
|
9
|
-
|
9
|
+
|
10
10
|
class << self
|
11
11
|
# Overrides the default banner implementation to output the whole command
|
12
12
|
def banner(task, namespace = true, subcommand = false)
|
@@ -40,14 +40,39 @@ module Solusvm
|
|
40
40
|
end
|
41
41
|
|
42
42
|
# Default required options
|
43
|
-
class_option :api_login, :type => :string, :desc => "API ID; Required.", :aliases => ["-I", "--api-login"]
|
44
|
-
class_option :api_key, :type => :string, :desc => "API KEY; Required.", :aliases => ["-K", "--api-key"]
|
45
|
-
class_option :api_url, :type => :string, :desc => "API URL; Required.", :aliases => ["-U", "--api-url"]
|
43
|
+
class_option :api_login, :type => :string, :desc => "API ID; Required.", :aliases => ["-I", "--api-login"]
|
44
|
+
class_option :api_key, :type => :string, :desc => "API KEY; Required.", :aliases => ["-K", "--api-key"]
|
45
|
+
class_option :api_url, :type => :string, :desc => "API URL; Required.", :aliases => ["-U", "--api-url"]
|
46
|
+
|
47
|
+
no_tasks do
|
48
|
+
def api
|
49
|
+
raise NotImplementedError
|
50
|
+
end
|
51
|
+
|
52
|
+
# prints one result element per line, in case it is a list
|
53
|
+
def output(result="", color=nil, force_new_line=(result.to_s !~ /( |\t)$/))
|
54
|
+
if api.successful?
|
55
|
+
Array(result).each do |entry|
|
56
|
+
say(entry, color, force_new_line)
|
57
|
+
end
|
58
|
+
else
|
59
|
+
say("Request failed: #{api.statusmsg}", color, force_new_line)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
46
63
|
|
47
64
|
protected
|
48
65
|
|
49
66
|
def configure
|
50
|
-
Solusvm.config(
|
67
|
+
Solusvm.config(
|
68
|
+
present_or_exit(:api_login, :id, "api_login required"),
|
69
|
+
present_or_exit(:api_key, :key, "api_key required"),
|
70
|
+
:url => present_or_exit(:api_url, :url, "api_url required")
|
71
|
+
)
|
72
|
+
end
|
73
|
+
|
74
|
+
def present_or_exit(options_key, default_option_key, message)
|
75
|
+
options[options_key] || BaseCli.default_option(default_option_key) || (say(message) && raise(SystemExit))
|
51
76
|
end
|
52
77
|
end
|
53
78
|
end
|
@@ -1,7 +1,7 @@
|
|
1
|
-
module Solusvm
|
1
|
+
module Solusvm
|
2
2
|
class ClientCli < BaseCli
|
3
3
|
|
4
|
-
desc "create", "Creates a new
|
4
|
+
desc "create", "Creates a new h"
|
5
5
|
method_option :username, :type => :string, :desc => "Username", :aliases => ["-u", "--username"]
|
6
6
|
method_option :password, :type => :string, :desc => "Password", :aliases => ["-p", "--password"]
|
7
7
|
method_option :email, :type => :string, :desc => "Email", :aliases => ["-e", "--email"]
|
@@ -9,37 +9,37 @@ module Solusvm
|
|
9
9
|
method_option :lastname, :type => :string, :desc => "Lastname", :aliases => ["-l", "--lastname"]
|
10
10
|
method_option :company, :type => :string, :desc => "Company", :aliases => ["-c", "--company"]
|
11
11
|
def create
|
12
|
-
|
12
|
+
output api.create(options)
|
13
13
|
end
|
14
14
|
|
15
15
|
desc "change-password USERNAME NEWPASSWORD", "Changes the password of an existing client"
|
16
16
|
def change_password(username, password)
|
17
|
-
|
17
|
+
output api.change_password(username, password)
|
18
18
|
end
|
19
19
|
|
20
20
|
desc "authenticate USERNAME NEWPASSWORD", "Verify a clients login. Returns true when the specified login is correct"
|
21
21
|
def authenticate(username, password)
|
22
|
-
|
22
|
+
output api.authenticate(username, password)
|
23
23
|
end
|
24
24
|
|
25
25
|
desc "check-exists USERNAME", "Checks if a client exists"
|
26
26
|
def check_exists(username)
|
27
|
-
|
27
|
+
output api.exists?(username)
|
28
28
|
end
|
29
29
|
|
30
30
|
desc "delete USERNAME", "Deletes an existing client"
|
31
31
|
def delete(username)
|
32
|
-
|
32
|
+
output api.delete(username)
|
33
33
|
end
|
34
34
|
|
35
35
|
desc "list", "Lists existing clients"
|
36
36
|
def list
|
37
|
-
|
37
|
+
output api.list
|
38
38
|
end
|
39
39
|
|
40
40
|
private
|
41
41
|
|
42
|
-
def
|
42
|
+
def api
|
43
43
|
@client ||= begin
|
44
44
|
configure
|
45
45
|
Solusvm::Client.new
|
@@ -1,24 +1,24 @@
|
|
1
|
-
module Solusvm
|
1
|
+
module Solusvm
|
2
2
|
class GeneralCli < BaseCli
|
3
3
|
|
4
4
|
desc "templates TYPE", "Lists existing templates for a given type [openvz|xen|xen hvm|kvm]"
|
5
5
|
def templates(type)
|
6
|
-
|
6
|
+
output api.templates(type)
|
7
7
|
end
|
8
8
|
|
9
9
|
desc "plans TYPE", "Lists existing plans for a given type [openvz|xen|xen hvm|kvm]"
|
10
10
|
def plans(type)
|
11
|
-
|
11
|
+
output api.plans(type)
|
12
12
|
end
|
13
13
|
|
14
14
|
desc "isos TYPE", "Lists existing isos for a given type [openvz|xen|xen hvm|kvm]"
|
15
15
|
def isos(type)
|
16
|
-
|
16
|
+
output api.isos(type)
|
17
17
|
end
|
18
18
|
|
19
19
|
private
|
20
20
|
|
21
|
-
def
|
21
|
+
def api
|
22
22
|
@general ||= begin
|
23
23
|
configure
|
24
24
|
Solusvm::General.new
|
data/lib/solusvm/cli/node_cli.rb
CHANGED
@@ -1,39 +1,39 @@
|
|
1
|
-
module Solusvm
|
1
|
+
module Solusvm
|
2
2
|
class NodeCli < BaseCli
|
3
3
|
|
4
4
|
desc "list TYPE", "Lists existing nodes for a given type [openvz|xen|xen hvm|kvm]"
|
5
5
|
def list(type)
|
6
|
-
|
6
|
+
output api.list(type)
|
7
7
|
end
|
8
8
|
|
9
9
|
desc "list-ids TYPE", "Lists existing nodes ids for a given type [openvz|xen|xen hvm|kvm]"
|
10
10
|
def list_ids(type)
|
11
|
-
|
11
|
+
output api.ids(type)
|
12
12
|
end
|
13
13
|
|
14
14
|
desc "available-ips VSERVERID", "Lists the available ips for a given node"
|
15
15
|
def available_ips(vserverid)
|
16
|
-
|
16
|
+
output api.available_ips(vserverid)
|
17
17
|
end
|
18
18
|
|
19
19
|
desc "stats VSERVERID", "Lists statistics for a given node"
|
20
20
|
def stats(vserverid)
|
21
|
-
|
21
|
+
output api.statistics(vserverid)
|
22
22
|
end
|
23
23
|
|
24
24
|
desc "xenresources VSERVERID", "Lists xen resources for a given node"
|
25
25
|
def xenresources(vserverid)
|
26
|
-
|
26
|
+
output api.xenresources(vserverid)
|
27
27
|
end
|
28
28
|
|
29
29
|
desc "virtualservers VSERVERID", "Lists the virtual servers for a given node"
|
30
30
|
def virtualservers(vserverid)
|
31
|
-
|
31
|
+
output api.virtualservers(vserverid)
|
32
32
|
end
|
33
33
|
|
34
34
|
private
|
35
35
|
|
36
|
-
def
|
36
|
+
def api
|
37
37
|
@node ||= begin
|
38
38
|
configure
|
39
39
|
Solusvm::Node.new
|
@@ -1,4 +1,4 @@
|
|
1
|
-
module Solusvm
|
1
|
+
module Solusvm
|
2
2
|
class ResellerCli < BaseCli
|
3
3
|
|
4
4
|
desc "create", "Creates a new reseller"
|
@@ -24,7 +24,7 @@ module Solusvm
|
|
24
24
|
method_option :xenhvm, :type => :string, :desc => "y|n Allow building of xen hvm virtual servers (optional)", :aliases => ["-xhvm", "--xenhvm"]
|
25
25
|
method_option :kvm, :type => :string, :desc => "y|n Allow building of kvmvirtual servers (optional)", :aliases => ["-kvm"]
|
26
26
|
def create
|
27
|
-
|
27
|
+
output api.create(options)
|
28
28
|
end
|
29
29
|
|
30
30
|
desc "change", "Changes the available resources of a reseller"
|
@@ -43,27 +43,27 @@ module Solusvm
|
|
43
43
|
method_option :xenhvm, :type => :string, :desc => "y|n Allow building of xen hvm virtual servers (optional)", :aliases => ["-xhvm", "--xenhvm"]
|
44
44
|
method_option :kvm, :type => :string, :desc => "y|n Allow building of kvmvirtual servers (optional)", :aliases => ["-kvm"]
|
45
45
|
def change_resources
|
46
|
-
|
46
|
+
output api.change_resources(options)
|
47
47
|
end
|
48
48
|
|
49
49
|
desc "info USERNAME", "Retrieves information from an existing reseller"
|
50
50
|
def info(username)
|
51
|
-
|
51
|
+
output api.info(username)
|
52
52
|
end
|
53
53
|
|
54
54
|
desc "delete USERNAME", "Deletes an existing reseller"
|
55
55
|
def delete(username)
|
56
|
-
|
56
|
+
output api.delete(username)
|
57
57
|
end
|
58
58
|
|
59
59
|
desc "list", "Lists existing resellers"
|
60
60
|
def list
|
61
|
-
|
61
|
+
output api.list
|
62
62
|
end
|
63
63
|
|
64
64
|
private
|
65
65
|
|
66
|
-
def
|
66
|
+
def api
|
67
67
|
@reseller ||= begin
|
68
68
|
configure
|
69
69
|
Solusvm::Reseller.new
|
@@ -3,133 +3,133 @@ module Solusvm
|
|
3
3
|
|
4
4
|
desc "status VSERVERID", "Checks the status of a server"
|
5
5
|
def status(vserverid)
|
6
|
-
|
6
|
+
output api.status(vserverid)
|
7
7
|
end
|
8
8
|
|
9
9
|
desc "info VSERVERID", "Retrieves information from a server"
|
10
10
|
def info(vserverid)
|
11
|
-
|
11
|
+
output api.info(vserverid)
|
12
12
|
end
|
13
13
|
|
14
14
|
desc "vnc VSERVERID", "Retrieves vnc information from a server"
|
15
15
|
def vnc(vserverid)
|
16
|
-
|
16
|
+
output api.vnc(vserverid)
|
17
17
|
end
|
18
18
|
|
19
19
|
desc "console VSERVERID", "Retrieves console information from a server"
|
20
20
|
def console(vserverid)
|
21
|
-
|
21
|
+
output api.console(vserverid)
|
22
22
|
end
|
23
23
|
|
24
24
|
desc "info-all VSERVERID", "Retrieves all availavle information from a server"
|
25
25
|
def info_all(vserverid)
|
26
|
-
|
26
|
+
output api.info_all(vserverid)
|
27
27
|
end
|
28
28
|
|
29
29
|
desc "change-plan VSERVERID NEWPLAN", "Changes the plan of a server"
|
30
30
|
def change_plan(vserverid, newplan)
|
31
|
-
|
31
|
+
output api.change_plan(vserverid, newplan)
|
32
32
|
end
|
33
33
|
|
34
34
|
desc "change-owner VSERVERID CLIENTID", "Changes the owner of a server"
|
35
35
|
def change_owner(vserverid, clientid)
|
36
|
-
|
36
|
+
output api.change_owner(vserverid, clientid)
|
37
37
|
end
|
38
38
|
|
39
39
|
desc "change-consolepass VSERVERID NEWPASSWORD", "Changes the console password of a server"
|
40
40
|
def change_consolepass(vserverid, newpassword)
|
41
|
-
|
41
|
+
output api.change_consolepass(vserverid, newpassword)
|
42
42
|
end
|
43
43
|
|
44
44
|
desc "change-vncpass VSERVERID NEWPASSWORD", "Changes the vnc password of a server"
|
45
45
|
def change_vncpass(vserverid, newpassword)
|
46
|
-
|
46
|
+
output api.change_vncpass(vserverid, newpassword)
|
47
47
|
end
|
48
48
|
|
49
49
|
desc "change-rootpass VSERVERID NEWPASSWORD", "Changes the root password of a server"
|
50
50
|
def change_rootpass(vserverid, newpassword)
|
51
|
-
|
51
|
+
output api.change_rootpassword(vserverid, newpassword)
|
52
52
|
end
|
53
53
|
|
54
54
|
desc "change-bootorder VSERVERID BOOTORDER", "Changes the boot order of a server [cd(Hard Disk CDROM)|dc(CDROM Hard Disk)|c(Hard Disk)|d(CDROM)]"
|
55
55
|
def change_bootorder(vserverid, newbootorder)
|
56
|
-
|
56
|
+
output api.change_bootorder(vserverid, newbootorder)
|
57
57
|
end
|
58
58
|
|
59
59
|
desc "change-hostname VSERVERID HOSTNAME", "Changes the hostname of a server"
|
60
60
|
def change_hostname(vserverid, newhostname)
|
61
|
-
|
61
|
+
output api.change_hostname(vserverid, newhostname)
|
62
62
|
end
|
63
63
|
|
64
64
|
desc "addip VSERVERID", "Adds an ip to the server"
|
65
65
|
def addip(vserverid)
|
66
|
-
|
66
|
+
output api.add_ip(vserverid)
|
67
67
|
end
|
68
68
|
|
69
69
|
desc "boot VSERVERID", "Boots up a server"
|
70
70
|
def boot(vserverid)
|
71
|
-
|
71
|
+
output api.boot(vserverid)
|
72
72
|
end
|
73
73
|
|
74
74
|
desc "reboot VSERVERID", "Reboots a server"
|
75
75
|
def reboot(vserverid)
|
76
|
-
|
76
|
+
output api.reboot(vserverid)
|
77
77
|
end
|
78
78
|
|
79
79
|
desc "shutdown VSERVERID", "Shuts down a server"
|
80
80
|
def shutdown(vserverid)
|
81
|
-
|
81
|
+
output api.shutdown(vserverid)
|
82
82
|
end
|
83
83
|
|
84
84
|
desc "suspend VSERVERID", "Suspends a server"
|
85
85
|
def suspend(vserverid)
|
86
|
-
|
86
|
+
output api.suspend(vserverid)
|
87
87
|
end
|
88
88
|
|
89
89
|
desc "resume VSERVERID", "Resumes a server"
|
90
90
|
def resume(vserverid)
|
91
|
-
|
91
|
+
output api.resume(vserverid)
|
92
92
|
end
|
93
93
|
|
94
94
|
desc "check-exists VSERVERID", "Checks if a server exists"
|
95
95
|
def check_exists(vserverid)
|
96
|
-
|
96
|
+
output api.exists?(vserverid)
|
97
97
|
end
|
98
98
|
|
99
99
|
desc "terminate VSERVERID", "Terminates a server"
|
100
100
|
def terminate(vserverid)
|
101
|
-
|
101
|
+
output api.terminate(vserverid)
|
102
102
|
end
|
103
103
|
|
104
104
|
desc "rebuild VSERVERID", "Rebuilds a server"
|
105
105
|
method_option :template, :type => :string, :desc => "VPS template to boot from", :aliases => ["-t", "--template"]
|
106
106
|
def rebuild(vserverid)
|
107
|
-
|
107
|
+
output api.rebuild(vserverid, {:template => options[:template]})
|
108
108
|
end
|
109
109
|
|
110
110
|
desc "tun-switcher VSERVERID SWITCH(on|off)", "Enable/Disable TUN/TAP"
|
111
111
|
def tun_switcher(vserverid, switch)
|
112
|
-
|
112
|
+
output switch(vserverid, switch, :tun_enable, :tun_disable)
|
113
113
|
end
|
114
114
|
|
115
115
|
desc "network-switcher VSERVERID SWITCH(on|off)", "Enable/Disable Network mode"
|
116
116
|
def network_switcher(vserverid, switch)
|
117
|
-
|
117
|
+
output switch(vserverid, switch, :network_enable, :network_disable)
|
118
118
|
end
|
119
119
|
|
120
120
|
desc "pae-switcher VSERVERID SWITCH(on|off)", "Enable/Disable PAE"
|
121
121
|
def pae_switcher(vserverid, switch)
|
122
|
-
|
122
|
+
output switch(vserverid, switch, :pae_enable, :pae_disable)
|
123
123
|
end
|
124
124
|
|
125
125
|
desc "mountiso VSERVERID ISO", "Mounts an iso"
|
126
126
|
def mountiso(vserverid, iso)
|
127
|
-
|
127
|
+
output api.mountiso(vserverid, iso)
|
128
128
|
end
|
129
129
|
|
130
130
|
desc "unmountiso VSERVERID", "Unmounts an iso"
|
131
131
|
def unmountiso(vserverid)
|
132
|
-
|
132
|
+
output api.unmountiso(vserverid)
|
133
133
|
end
|
134
134
|
|
135
135
|
desc "create HOSTNAME PASSWORD", "Creates a new server"
|
@@ -140,15 +140,15 @@ module Solusvm
|
|
140
140
|
method_option :template, :type => :string, :desc => "VPS template to boot from", :aliases => ["-t", "--template"]
|
141
141
|
method_option :node, :type => :string, :desc => "Node to provision on", :aliases => ["-n", "--node"]
|
142
142
|
def create(hostname, password)
|
143
|
-
|
144
|
-
:plan => options[:plan], :ips => options[:ips], :type => options[:kind],
|
143
|
+
output api.create(hostname, password, {
|
144
|
+
:plan => options[:plan], :ips => options[:ips], :type => options[:kind],
|
145
145
|
:username => options[:username], :template => options[:template], :node => options[:node]
|
146
146
|
})
|
147
147
|
end
|
148
148
|
|
149
149
|
private
|
150
150
|
|
151
|
-
def
|
151
|
+
def api
|
152
152
|
@server ||= begin
|
153
153
|
configure
|
154
154
|
Solusvm::Server.new
|
@@ -157,9 +157,9 @@ module Solusvm
|
|
157
157
|
|
158
158
|
def switch(vserverid, switch_value, on_method, off_method)
|
159
159
|
if switch_value == "on"
|
160
|
-
|
160
|
+
api.send(on_method, vserverid)
|
161
161
|
elsif switch_value == "off"
|
162
|
-
|
162
|
+
api.send(off_method, vserverid)
|
163
163
|
else
|
164
164
|
"Invalid switch value. Valid values are on|off"
|
165
165
|
end
|