solusvm 0.10.1 → 1.0.0.beta

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. data/README.markdown +75 -25
  2. data/bin/solusvm +3 -153
  3. data/lib/solusvm/base.rb +17 -10
  4. data/lib/solusvm/cli/base_cli.rb +47 -0
  5. data/lib/solusvm/cli/client_cli.rb +49 -0
  6. data/lib/solusvm/cli/general_cli.rb +28 -0
  7. data/lib/solusvm/cli/node_cli.rb +43 -0
  8. data/lib/solusvm/cli/reseller_cli.rb +73 -0
  9. data/lib/solusvm/cli/server_cli.rb +168 -0
  10. data/lib/solusvm/cli.rb +22 -0
  11. data/lib/solusvm/client.rb +26 -12
  12. data/lib/solusvm/general.rb +25 -17
  13. data/lib/solusvm/node.rb +60 -0
  14. data/lib/solusvm/reseller.rb +72 -0
  15. data/lib/solusvm/server.rb +116 -2
  16. data/lib/solusvm/version.rb +1 -1
  17. data/lib/solusvm.rb +8 -8
  18. data/solusvm.gemspec +3 -0
  19. data/test/cli/test_client_cli.rb +80 -0
  20. data/test/cli/test_general_cli.rb +35 -0
  21. data/test/cli/test_node_cli.rb +64 -0
  22. data/test/cli/test_reseller_cli.rb +139 -0
  23. data/test/cli/test_server_cli.rb +267 -0
  24. data/test/fixtures/client_delete_success.txt +2 -0
  25. data/test/fixtures/client_list_success.txt +14 -0
  26. data/test/fixtures/client_list_success_empty.txt +2 -0
  27. data/test/fixtures/general_isos_success.txt +3 -0
  28. data/test/fixtures/general_node_virtualservers_success.txt +15 -0
  29. data/test/fixtures/general_node_virtualservers_success_empty.txt +2 -0
  30. data/test/fixtures/general_node_xenresources_success.txt +4 -0
  31. data/test/fixtures/general_nodes_ids_success.txt +3 -0
  32. data/test/fixtures/general_plans_success.txt +3 -0
  33. data/test/fixtures/reseller_change_resources_success.txt +16 -0
  34. data/test/fixtures/reseller_create_success.txt +23 -0
  35. data/test/fixtures/reseller_delete_success.txt +2 -0
  36. data/test/fixtures/reseller_info_success.txt +23 -0
  37. data/test/fixtures/reseller_list_success.txt +3 -0
  38. data/test/fixtures/server_bootorder_success.txt +2 -0
  39. data/test/fixtures/server_change_consolepass_success.txt +3 -0
  40. data/test/fixtures/server_change_owner_success.txt +2 -0
  41. data/test/fixtures/server_change_vncpass_success.txt +3 -0
  42. data/test/fixtures/server_console_success.txt +7 -0
  43. data/test/fixtures/server_hostname_success.txt +3 -0
  44. data/test/fixtures/server_mountiso_success.txt +2 -0
  45. data/test/fixtures/server_network_disable_success.txt +2 -0
  46. data/test/fixtures/server_network_enable_success.txt +2 -0
  47. data/test/fixtures/server_pae_success.txt +2 -0
  48. data/test/fixtures/server_rootpassword_success.txt +3 -0
  49. data/test/fixtures/server_status_success.txt +2 -0
  50. data/test/fixtures/server_tun_disable_success.txt +2 -0
  51. data/test/fixtures/server_tun_enable_success.txt +2 -0
  52. data/test/fixtures/server_unmountiso_success.txt +2 -0
  53. data/test/fixtures/server_vnc_success.txt +6 -0
  54. data/test/helper.rb +6 -0
  55. data/test/test_cli.rb +17 -0
  56. data/test/test_client.rb +50 -6
  57. data/test/test_general.rb +24 -48
  58. data/test/test_node.rb +107 -0
  59. data/test/test_reseller.rb +75 -0
  60. data/test/test_server.rb +95 -1
  61. metadata +132 -17
@@ -0,0 +1,80 @@
1
+ require 'helper'
2
+ require 'solusvm/cli'
3
+
4
+ class TestClientCli < Test::Unit::TestCase
5
+
6
+ def setup
7
+ # Prevents mocha from stubbing non existent methods so that we now if the CLI is failing because
8
+ # something was moved around.
9
+ Mocha::Configuration.prevent(:stubbing_non_existent_method)
10
+ end
11
+
12
+ def test_should_delegate_client_create_to_client
13
+ Solusvm.expects(:config).with("thelogin", "thekey", { :url => "theurl" })
14
+ Solusvm::Client.stubs(:new => mock{ expects(:create).with() do |options|
15
+ expected = {
16
+ :username => "theusername",
17
+ :password => "thepassword",
18
+ :email => "theemail",
19
+ :firstname => "thefirstname",
20
+ :lastname => "thelastname",
21
+ :company => "thecompany"
22
+ }
23
+
24
+ expected.all? { |k,v| options[k] == v }
25
+
26
+ end.returns("theresult")
27
+ })
28
+
29
+ $stdout.expects(:puts).with("theresult")
30
+ Solusvm::Cli.start(cli_expand_base_arguments([
31
+ "client", "create",
32
+ "--username", "theusername",
33
+ "--password", "thepassword",
34
+ "--email", "theemail",
35
+ "--firstname", "thefirstname",
36
+ "--lastname", "thelastname",
37
+ "--company", "thecompany"
38
+ ]))
39
+ end
40
+
41
+ def test_should_delegate_client_change_password_to_client
42
+ Solusvm.expects(:config).with("thelogin", "thekey", { :url => "theurl" })
43
+ Solusvm::Client.stubs(:new => mock{ expects(:change_password).with("theusername", "thepassword").returns("theresult") })
44
+
45
+ $stdout.expects(:puts).with("theresult")
46
+ Solusvm::Cli.start(cli_expand_base_arguments(["client", "change-password", "theusername", "thepassword"]))
47
+ end
48
+
49
+ def test_should_delegate_client_authenticate_to_client
50
+ Solusvm.expects(:config).with("thelogin", "thekey", { :url => "theurl" })
51
+ Solusvm::Client.stubs(:new => mock{ expects(:authenticate).with("theusername", "thepassword").returns("theresult") })
52
+
53
+ $stdout.expects(:puts).with("theresult")
54
+ Solusvm::Cli.start(cli_expand_base_arguments(["client", "authenticate", "theusername", "thepassword"]))
55
+ end
56
+
57
+ def test_should_delegate_client_check_exists_to_client
58
+ Solusvm.expects(:config).with("thelogin", "thekey", { :url => "theurl" })
59
+ Solusvm::Client.stubs(:new => mock{ expects(:exists?).with("theusername").returns("theresult") })
60
+
61
+ $stdout.expects(:puts).with("theresult")
62
+ Solusvm::Cli.start(cli_expand_base_arguments(["client", "check-exists", "theusername"]))
63
+ end
64
+
65
+ def test_should_delegate_client_delete_to_client
66
+ Solusvm.expects(:config).with("thelogin", "thekey", { :url => "theurl" })
67
+ Solusvm::Client.stubs(:new => mock{ expects(:delete).with("theusername").returns("theresult") })
68
+
69
+ $stdout.expects(:puts).with("theresult")
70
+ Solusvm::Cli.start(cli_expand_base_arguments(["client", "delete", "theusername"]))
71
+ end
72
+
73
+ def test_should_delegate_client_list_to_client
74
+ Solusvm.expects(:config).with("thelogin", "thekey", { :url => "theurl" })
75
+ Solusvm::Client.stubs(:new => mock{ expects(:list).returns("theresult") })
76
+
77
+ $stdout.expects(:puts).with("theresult")
78
+ Solusvm::Cli.start(cli_expand_base_arguments(["client", "list"]))
79
+ end
80
+ end
@@ -0,0 +1,35 @@
1
+ require 'helper'
2
+ require 'solusvm/cli'
3
+
4
+ class TestGeneralCli < Test::Unit::TestCase
5
+
6
+ def setup
7
+ # Prevents mocha from stubbing non existent methods so that we now if the CLI is failing because
8
+ # something was moved around.
9
+ Mocha::Configuration.prevent(:stubbing_non_existent_method)
10
+ end
11
+
12
+ def test_should_delegate_templates_to_general
13
+ Solusvm.expects(:config).with("thelogin", "thekey", { :url => "theurl" })
14
+ Solusvm::General.stubs(:new => mock{ expects(:templates).with("type").returns("thetemplates")})
15
+
16
+ $stdout.expects(:puts).with("thetemplates")
17
+ Solusvm::Cli.start(cli_expand_base_arguments(["general", "templates", "type"]))
18
+ end
19
+
20
+ def test_should_delegate_plans_to_general
21
+ Solusvm.expects(:config).with("thelogin", "thekey", { :url => "theurl" })
22
+ Solusvm::General.stubs(:new => mock{ expects(:plans).with("type").returns("theplans")})
23
+
24
+ $stdout.expects(:puts).with("theplans")
25
+ Solusvm::Cli.start(cli_expand_base_arguments(["general", "plans", "type"]))
26
+ end
27
+
28
+ def test_should_delegate_isos_to_general
29
+ Solusvm.expects(:config).with("thelogin", "thekey", { :url => "theurl" })
30
+ Solusvm::General.stubs(:new => mock{ expects(:isos).with("type").returns("theisos")})
31
+
32
+ $stdout.expects(:puts).with("theisos")
33
+ Solusvm::Cli.start(cli_expand_base_arguments(["general", "isos", "type"]))
34
+ end
35
+ end
@@ -0,0 +1,64 @@
1
+ require 'helper'
2
+ require 'solusvm/cli'
3
+
4
+ class TestNodeCli < Test::Unit::TestCase
5
+
6
+ def setup
7
+ # Prevents mocha from stubbing non existent methods so that we now if the CLI is failing because
8
+ # something was moved around.
9
+ Mocha::Configuration.prevent(:stubbing_non_existent_method)
10
+ end
11
+
12
+ def test_should_delegate_node_available_ips_to_node
13
+ Solusvm.expects(:config).with("thelogin", "thekey", { :url => "theurl" })
14
+ Solusvm::Node.stubs(:new => mock{ expects(:available_ips).with("thevserverid").returns(["ip1", "ip2"]) })
15
+
16
+ $stdout.expects(:puts).with("ip1\nip2")
17
+ Solusvm::Cli.start(cli_expand_base_arguments(["node", "available-ips", "thevserverid"]))
18
+ end
19
+
20
+ def test_should_delegate_node_stats_to_node
21
+ Solusvm.expects(:config).with("thelogin", "thekey", { :url => "theurl" })
22
+ Solusvm::Node.stubs(:new => mock{ expects(:statistics).with("thevserverid").returns({
23
+ :stat1 => "val1", :stat2 => "val2"
24
+ })})
25
+
26
+ $stdout.expects(:puts).with("stat1 => val1\nstat2 => val2")
27
+ Solusvm::Cli.start(cli_expand_base_arguments(["node", "stats", "thevserverid"]))
28
+ end
29
+
30
+ def test_should_delegate_node_xenresources_to_node
31
+ Solusvm.expects(:config).with("thelogin", "thekey", { :url => "theurl" })
32
+ Solusvm::Node.stubs(:new => mock{ expects(:xenresources).with("thevserverid").returns({
33
+ :stat1 => "val1", :stat2 => "val2"
34
+ })})
35
+
36
+ $stdout.expects(:puts).with("stat1 => val1\nstat2 => val2")
37
+ Solusvm::Cli.start(cli_expand_base_arguments(["node", "xenresources", "thevserverid"]))
38
+ end
39
+
40
+ def test_should_delegate_node_virtualservers_to_node
41
+ Solusvm.expects(:config).with("thelogin", "thekey", { :url => "theurl" })
42
+ Solusvm::Node.stubs(:new => mock{ expects(:virtualservers).with("thevserverid").returns("thedata")})
43
+
44
+ $stdout.expects(:puts).with("thedata")
45
+ Solusvm::Cli.start(cli_expand_base_arguments(["node", "virtualservers", "thevserverid"]))
46
+ end
47
+
48
+ def test_should_delegate_nodes_list_to_node
49
+ Solusvm.expects(:config).with("thelogin", "thekey", { :url => "theurl" })
50
+ Solusvm::Node.stubs(:new => mock{ expects(:list).with("type").returns("thenodes")})
51
+
52
+ $stdout.expects(:puts).with("thenodes")
53
+ Solusvm::Cli.start(cli_expand_base_arguments(["node", "list", "type"]))
54
+ end
55
+
56
+ def test_should_delegate_nodes_ids_to_node
57
+ Solusvm.expects(:config).with("thelogin", "thekey", { :url => "theurl" })
58
+ Solusvm::Node.stubs(:new => mock{ expects(:ids).with("type").returns("thenodes")})
59
+
60
+ $stdout.expects(:puts).with("thenodes")
61
+ Solusvm::Cli.start(cli_expand_base_arguments(["node", "list-ids", "type"]))
62
+ end
63
+
64
+ end
@@ -0,0 +1,139 @@
1
+ require 'helper'
2
+ require 'solusvm/cli'
3
+
4
+ class TestResellerCli < Test::Unit::TestCase
5
+
6
+ def setup
7
+ # Prevents mocha from stubbing non existent methods so that we now if the CLI is failing because
8
+ # something was moved around.
9
+ Mocha::Configuration.prevent(:stubbing_non_existent_method)
10
+ end
11
+
12
+ def test_should_delegate_reseller_create_to_reseller
13
+ Solusvm.expects(:config).with("thelogin", "thekey", { :url => "theurl" })
14
+ Solusvm::Reseller.stubs(:new => mock{ expects(:create).with() do |options|
15
+ expected = {
16
+ :username => "theusername",
17
+ :password => "thepassword",
18
+ :email => "theemail",
19
+ :firstname => "thefirstname",
20
+ :lastname => "thelastname",
21
+ :company => "thecompany",
22
+ :usernameprefix => "theusernameprefix",
23
+ :maxvps => "themaxvps",
24
+ :maxusers => "themaxusers",
25
+ :maxmem => "themaxmem",
26
+ :maxburst => "themaxburst",
27
+ :maxdisk => "themaxdisk",
28
+ :maxbw => "themaxbw",
29
+ :maxipv4 => "themaxipv4",
30
+ :maxipv6 => "themaxipv6",
31
+ :nodegroups => "thenodegroups",
32
+ :mediagroups => "themediagroups",
33
+ :openvz => "theopenvz",
34
+ :xenpv => "thexenpv",
35
+ :xenhvm => "thexenhvm",
36
+ :kvm => "thekvm"
37
+ }
38
+
39
+ expected.all? { |k,v| options[k] == v }
40
+
41
+ end.returns("theresult")
42
+ })
43
+
44
+ $stdout.expects(:puts).with("theresult")
45
+ Solusvm::Cli.start(cli_expand_base_arguments([
46
+ "reseller", "create",
47
+ "--username", "theusername",
48
+ "--password", "thepassword",
49
+ "--email", "theemail",
50
+ "--firstname", "thefirstname",
51
+ "--lastname", "thelastname",
52
+ "--company", "thecompany",
53
+ "--usernameprefix", "theusernameprefix",
54
+ "--maxvps", "themaxvps",
55
+ "--maxusers", "themaxusers",
56
+ "--maxmem", "themaxmem",
57
+ "--maxburst", "themaxburst",
58
+ "--maxdisk", "themaxdisk",
59
+ "--maxbw", "themaxbw",
60
+ "--maxipv4", "themaxipv4",
61
+ "--maxipv6", "themaxipv6",
62
+ "--nodegroups", "thenodegroups",
63
+ "--mediagroups", "themediagroups",
64
+ "--openvz", "theopenvz",
65
+ "--xenpv", "thexenpv",
66
+ "--xenhvm", "thexenhvm",
67
+ "--kvm", "thekvm"
68
+ ]))
69
+ end
70
+
71
+ def test_should_delegate_reseller_change_resources_to_reseller
72
+ Solusvm.expects(:config).with("thelogin", "thekey", { :url => "theurl" })
73
+ Solusvm::Reseller.stubs(:new => mock{ expects(:change_resources).with() do |options|
74
+ expected = {
75
+ :maxvps => "themaxvps",
76
+ :maxusers => "themaxusers",
77
+ :maxmem => "themaxmem",
78
+ :maxburst => "themaxburst",
79
+ :maxdisk => "themaxdisk",
80
+ :maxbw => "themaxbw",
81
+ :maxipv4 => "themaxipv4",
82
+ :maxipv6 => "themaxipv6",
83
+ :nodegroups => "thenodegroups",
84
+ :mediagroups => "themediagroups",
85
+ :openvz => "theopenvz",
86
+ :xenpv => "thexenpv",
87
+ :xenhvm => "thexenhvm",
88
+ :kvm => "thekvm"
89
+ }
90
+
91
+ expected.all? { |k,v| options[k] == v }
92
+
93
+ end.returns("theresult")
94
+ })
95
+
96
+ $stdout.expects(:puts).with("theresult")
97
+ Solusvm::Cli.start(cli_expand_base_arguments([
98
+ "reseller", "change-resources",
99
+ "--maxvps", "themaxvps",
100
+ "--maxusers", "themaxusers",
101
+ "--maxmem", "themaxmem",
102
+ "--maxburst", "themaxburst",
103
+ "--maxdisk", "themaxdisk",
104
+ "--maxbw", "themaxbw",
105
+ "--maxipv4", "themaxipv4",
106
+ "--maxipv6", "themaxipv6",
107
+ "--nodegroups", "thenodegroups",
108
+ "--mediagroups", "themediagroups",
109
+ "--openvz", "theopenvz",
110
+ "--xenpv", "thexenpv",
111
+ "--xenhvm", "thexenhvm",
112
+ "--kvm", "thekvm"
113
+ ]))
114
+ end
115
+
116
+ def test_should_delegate_reseller_info_to_reseller
117
+ Solusvm.expects(:config).with("thelogin", "thekey", { :url => "theurl" })
118
+ Solusvm::Reseller.stubs(:new => mock{ expects(:info).with("theusername").returns("theresult") })
119
+
120
+ $stdout.expects(:puts).with("theresult")
121
+ Solusvm::Cli.start(cli_expand_base_arguments(["reseller", "info", "theusername"]))
122
+ end
123
+
124
+ def test_should_delegate_reseller_delete_to_reseller
125
+ Solusvm.expects(:config).with("thelogin", "thekey", { :url => "theurl" })
126
+ Solusvm::Reseller.stubs(:new => mock{ expects(:delete).with("theusername").returns("theresult") })
127
+
128
+ $stdout.expects(:puts).with("theresult")
129
+ Solusvm::Cli.start(cli_expand_base_arguments(["reseller", "delete", "theusername"]))
130
+ end
131
+
132
+ def test_should_delegate_reseller_list_to_reseller
133
+ Solusvm.expects(:config).with("thelogin", "thekey", { :url => "theurl" })
134
+ Solusvm::Reseller.stubs(:new => mock{ expects(:list).returns("theresult") })
135
+
136
+ $stdout.expects(:puts).with("theresult")
137
+ Solusvm::Cli.start(cli_expand_base_arguments(["reseller", "list"]))
138
+ end
139
+ end
@@ -0,0 +1,267 @@
1
+ require 'helper'
2
+ require 'solusvm/cli'
3
+
4
+ class TestServerCli < Test::Unit::TestCase
5
+
6
+ def setup
7
+ # Prevents mocha from stubbing non existent methods so that we now if the CLI is failing because
8
+ # something was moved around.
9
+ Mocha::Configuration.prevent(:stubbing_non_existent_method)
10
+ end
11
+
12
+ def test_should_delegate_server_status_to_server
13
+ Solusvm.expects(:config).with("thelogin", "thekey", { :url => "theurl" })
14
+ Solusvm::Server.stubs(:new => mock{ expects(:status).with("thevserverid").returns("theresult") })
15
+
16
+ $stdout.expects(:puts).with("theresult")
17
+ Solusvm::Cli.start(cli_expand_base_arguments(["server", "status", "thevserverid"]))
18
+ end
19
+
20
+ def test_should_delegate_server_change_plan_to_server
21
+ Solusvm.expects(:config).with("thelogin", "thekey", { :url => "theurl" })
22
+ Solusvm::Server.stubs(:new => mock{ expects(:change_plan).with("thevserverid", "thenewplan").returns("theresult") })
23
+
24
+ $stdout.expects(:puts).with("theresult")
25
+ Solusvm::Cli.start(cli_expand_base_arguments(["server", "change-plan", "thevserverid", "thenewplan"]))
26
+ end
27
+
28
+ def test_should_delegate_server_change_owner_to_server
29
+ Solusvm.expects(:config).with("thelogin", "thekey", { :url => "theurl" })
30
+ Solusvm::Server.stubs(:new => mock{ expects(:change_owner).with("thevserverid", "thenewowner").returns("theresult") })
31
+
32
+ $stdout.expects(:puts).with("theresult")
33
+ Solusvm::Cli.start(cli_expand_base_arguments(["server", "change-owner", "thevserverid", "thenewowner"]))
34
+ end
35
+
36
+ def test_should_delegate_server_change_consolepass_to_server
37
+ Solusvm.expects(:config).with("thelogin", "thekey", { :url => "theurl" })
38
+ Solusvm::Server.stubs(:new => mock{ expects(:change_consolepass).with("thevserverid", "thenewpass").returns("theresult") })
39
+
40
+ $stdout.expects(:puts).with("theresult")
41
+ Solusvm::Cli.start(cli_expand_base_arguments(["server", "change-consolepass", "thevserverid", "thenewpass"]))
42
+ end
43
+
44
+ def test_should_delegate_server_change_vncpass_to_server
45
+ Solusvm.expects(:config).with("thelogin", "thekey", { :url => "theurl" })
46
+ Solusvm::Server.stubs(:new => mock{ expects(:change_vncpass).with("thevserverid", "thenewpass").returns("theresult") })
47
+
48
+ $stdout.expects(:puts).with("theresult")
49
+ Solusvm::Cli.start(cli_expand_base_arguments(["server", "change-vncpass", "thevserverid", "thenewpass"]))
50
+ end
51
+
52
+ def test_should_delegate_server_change_rootpass_to_server
53
+ Solusvm.expects(:config).with("thelogin", "thekey", { :url => "theurl" })
54
+ Solusvm::Server.stubs(:new => mock{ expects(:change_rootpassword).with("thevserverid", "thenewpass").returns("theresult") })
55
+
56
+ $stdout.expects(:puts).with("theresult")
57
+ Solusvm::Cli.start(cli_expand_base_arguments(["server", "change-rootpass", "thevserverid", "thenewpass"]))
58
+ end
59
+
60
+ def test_should_delegate_server_change_bootorder_to_server
61
+ Solusvm.expects(:config).with("thelogin", "thekey", { :url => "theurl" })
62
+ Solusvm::Server.stubs(:new => mock{ expects(:change_bootorder).with("thevserverid", "theneworder").returns("theresult") })
63
+
64
+ $stdout.expects(:puts).with("theresult")
65
+ Solusvm::Cli.start(cli_expand_base_arguments(["server", "change-bootorder", "thevserverid", "theneworder"]))
66
+ end
67
+
68
+ def test_should_delegate_server_change_hostname_to_server
69
+ Solusvm.expects(:config).with("thelogin", "thekey", { :url => "theurl" })
70
+ Solusvm::Server.stubs(:new => mock{ expects(:change_hostname).with("thevserverid", "thenewhostname").returns("theresult") })
71
+
72
+ $stdout.expects(:puts).with("theresult")
73
+ Solusvm::Cli.start(cli_expand_base_arguments(["server", "change-hostname", "thevserverid", "thenewhostname"]))
74
+ end
75
+
76
+ def test_should_delegate_server_add_ip_to_server
77
+ Solusvm.expects(:config).with("thelogin", "thekey", { :url => "theurl" })
78
+ Solusvm::Server.stubs(:new => mock{ expects(:add_ip).with("thevserverid").returns("theresult") })
79
+
80
+ $stdout.expects(:puts).with("theresult")
81
+ Solusvm::Cli.start(cli_expand_base_arguments(["server", "addip", "thevserverid"]))
82
+ end
83
+
84
+ def test_should_delegate_server_boot_to_server
85
+ Solusvm.expects(:config).with("thelogin", "thekey", { :url => "theurl" })
86
+ Solusvm::Server.stubs(:new => mock{ expects(:boot).with("thevserverid").returns("theresult") })
87
+
88
+ $stdout.expects(:puts).with("theresult")
89
+ Solusvm::Cli.start(cli_expand_base_arguments(["server", "boot", "thevserverid"]))
90
+ end
91
+
92
+ def test_should_delegate_server_reboot_to_server
93
+ Solusvm.expects(:config).with("thelogin", "thekey", { :url => "theurl" })
94
+ Solusvm::Server.stubs(:new => mock{ expects(:reboot).with("thevserverid").returns("theresult") })
95
+
96
+ $stdout.expects(:puts).with("theresult")
97
+ Solusvm::Cli.start(cli_expand_base_arguments(["server", "reboot", "thevserverid"]))
98
+ end
99
+
100
+ def test_should_delegate_server_shutdown_to_server
101
+ Solusvm.expects(:config).with("thelogin", "thekey", { :url => "theurl" })
102
+ Solusvm::Server.stubs(:new => mock{ expects(:shutdown).with("thevserverid").returns("theresult") })
103
+
104
+ $stdout.expects(:puts).with("theresult")
105
+ Solusvm::Cli.start(cli_expand_base_arguments(["server", "shutdown", "thevserverid"]))
106
+ end
107
+
108
+ def test_should_delegate_server_suspend_to_server
109
+ Solusvm.expects(:config).with("thelogin", "thekey", { :url => "theurl" })
110
+ Solusvm::Server.stubs(:new => mock{ expects(:suspend).with("thevserverid").returns("theresult") })
111
+
112
+ $stdout.expects(:puts).with("theresult")
113
+ Solusvm::Cli.start(cli_expand_base_arguments(["server", "suspend", "thevserverid"]))
114
+ end
115
+
116
+ def test_should_delegate_server_resume_to_server
117
+ Solusvm.expects(:config).with("thelogin", "thekey", { :url => "theurl" })
118
+ Solusvm::Server.stubs(:new => mock{ expects(:resume).with("thevserverid").returns("theresult") })
119
+
120
+ $stdout.expects(:puts).with("theresult")
121
+ Solusvm::Cli.start(cli_expand_base_arguments(["server", "resume", "thevserverid"]))
122
+ end
123
+
124
+ def test_should_delegate_server_check_exists_to_server
125
+ Solusvm.expects(:config).with("thelogin", "thekey", { :url => "theurl" })
126
+ Solusvm::Server.stubs(:new => mock{ expects(:check_exists).with("thevserverid").returns("theresult") })
127
+
128
+ $stdout.expects(:puts).with("theresult")
129
+ Solusvm::Cli.start(cli_expand_base_arguments(["server", "check-exists", "thevserverid"]))
130
+ end
131
+
132
+ def test_should_delegate_server_terminate_to_server
133
+ Solusvm.expects(:config).with("thelogin", "thekey", { :url => "theurl" })
134
+ Solusvm::Server.stubs(:new => mock{ expects(:terminate).with("thevserverid").returns("theresult") })
135
+
136
+ $stdout.expects(:puts).with("theresult")
137
+ Solusvm::Cli.start(cli_expand_base_arguments(["server", "terminate", "thevserverid"]))
138
+ end
139
+
140
+ def test_should_delegate_server_rebuild_to_server
141
+ Solusvm.expects(:config).with("thelogin", "thekey", { :url => "theurl" })
142
+ Solusvm::Server.stubs(:new => mock{ expects(:rebuild).with(
143
+ "thevserverid", :template => "thetemplate").returns("theresult") })
144
+
145
+ $stdout.expects(:puts).with("theresult")
146
+ Solusvm::Cli.start(cli_expand_base_arguments(["server", "rebuild", "thevserverid", "--template", "thetemplate"]))
147
+ end
148
+
149
+ def test_should_delegate_server_tun_switcher_on_to_server
150
+ Solusvm.expects(:config).with("thelogin", "thekey", { :url => "theurl" })
151
+ Solusvm::Server.stubs(:new => mock{ expects(:tun_enable).with("thevserverid").returns("theresult") })
152
+
153
+ $stdout.expects(:puts).with("theresult")
154
+ Solusvm::Cli.start(cli_expand_base_arguments(["server", "tun-switcher", "thevserverid", "on"]))
155
+ end
156
+
157
+ def test_should_delegate_server_tun_switcher_off_to_server
158
+ Solusvm.expects(:config).with("thelogin", "thekey", { :url => "theurl" })
159
+ Solusvm::Server.stubs(:new => mock{ expects(:tun_disable).with("thevserverid").returns("theresult") })
160
+
161
+ $stdout.expects(:puts).with("theresult")
162
+ Solusvm::Cli.start(cli_expand_base_arguments(["server", "tun-switcher", "thevserverid", "off"]))
163
+ end
164
+
165
+ def test_should_delegate_server_network_switcher_on_to_server
166
+ Solusvm.expects(:config).with("thelogin", "thekey", { :url => "theurl" })
167
+ Solusvm::Server.stubs(:new => mock{ expects(:network_enable).with("thevserverid").returns("theresult") })
168
+
169
+ $stdout.expects(:puts).with("theresult")
170
+ Solusvm::Cli.start(cli_expand_base_arguments(["server", "network-switcher", "thevserverid", "on"]))
171
+ end
172
+
173
+ def test_should_delegate_server_network_switcher_off_to_server
174
+ Solusvm.expects(:config).with("thelogin", "thekey", { :url => "theurl" })
175
+ Solusvm::Server.stubs(:new => mock{ expects(:network_disable).with("thevserverid").returns("theresult") })
176
+
177
+ $stdout.expects(:puts).with("theresult")
178
+ Solusvm::Cli.start(cli_expand_base_arguments(["server", "network-switcher", "thevserverid", "off"]))
179
+ end
180
+
181
+ def test_should_delegate_server_pae_switcher_on_to_server
182
+ Solusvm.expects(:config).with("thelogin", "thekey", { :url => "theurl" })
183
+ Solusvm::Server.stubs(:new => mock{ expects(:pae_enable).with("thevserverid").returns("theresult") })
184
+
185
+ $stdout.expects(:puts).with("theresult")
186
+ Solusvm::Cli.start(cli_expand_base_arguments(["server", "pae-switcher", "thevserverid", "on"]))
187
+ end
188
+
189
+ def test_should_delegate_server_pae_switcher_off_to_server
190
+ Solusvm.expects(:config).with("thelogin", "thekey", { :url => "theurl" })
191
+ Solusvm::Server.stubs(:new => mock{ expects(:pae_disable).with("thevserverid").returns("theresult") })
192
+
193
+ $stdout.expects(:puts).with("theresult")
194
+ Solusvm::Cli.start(cli_expand_base_arguments(["server", "pae-switcher", "thevserverid", "off"]))
195
+ end
196
+
197
+ def test_should_delegate_server_info_to_server
198
+ Solusvm.expects(:config).with("thelogin", "thekey", { :url => "theurl" })
199
+ Solusvm::Server.stubs(:new => mock{ expects(:info).with("thevserverid").returns("theresult") })
200
+
201
+ $stdout.expects(:puts).with("theresult")
202
+ Solusvm::Cli.start(cli_expand_base_arguments(["server", "info", "thevserverid"]))
203
+ end
204
+
205
+ def test_should_delegate_server_vnc_to_server
206
+ Solusvm.expects(:config).with("thelogin", "thekey", { :url => "theurl" })
207
+ Solusvm::Server.stubs(:new => mock{ expects(:vnc).with("thevserverid").returns("theresult") })
208
+
209
+ $stdout.expects(:puts).with("theresult")
210
+ Solusvm::Cli.start(cli_expand_base_arguments(["server", "vnc", "thevserverid"]))
211
+ end
212
+
213
+ def test_should_delegate_server_console_to_server
214
+ Solusvm.expects(:config).with("thelogin", "thekey", { :url => "theurl" })
215
+ Solusvm::Server.stubs(:new => mock{ expects(:console).with("thevserverid").returns("theresult") })
216
+
217
+ $stdout.expects(:puts).with("theresult")
218
+ Solusvm::Cli.start(cli_expand_base_arguments(["server", "console", "thevserverid"]))
219
+ end
220
+
221
+ def test_should_delegate_server_info_all_to_server
222
+ Solusvm.expects(:config).with("thelogin", "thekey", { :url => "theurl" })
223
+ Solusvm::Server.stubs(:new => mock{ expects(:info_all).with("thevserverid").returns("theresult") })
224
+
225
+ $stdout.expects(:puts).with("theresult")
226
+ Solusvm::Cli.start(cli_expand_base_arguments(["server", "info-all", "thevserverid"]))
227
+ end
228
+
229
+ def test_should_delegate_server_mountiso_to_server
230
+ Solusvm.expects(:config).with("thelogin", "thekey", { :url => "theurl" })
231
+ Solusvm::Server.stubs(:new => mock{ expects(:mountiso).with("thevserverid", "theiso").returns("theresult") })
232
+
233
+ $stdout.expects(:puts).with("theresult")
234
+ Solusvm::Cli.start(cli_expand_base_arguments(["server", "mountiso", "thevserverid", "theiso"]))
235
+ end
236
+
237
+ def test_should_delegate_server_unmountiso_to_server
238
+ Solusvm.expects(:config).with("thelogin", "thekey", { :url => "theurl" })
239
+ Solusvm::Server.stubs(:new => mock{ expects(:unmountiso).with("thevserverid").returns("theresult") })
240
+
241
+ $stdout.expects(:puts).with("theresult")
242
+ Solusvm::Cli.start(cli_expand_base_arguments(["server", "unmountiso", "thevserverid"]))
243
+ end
244
+
245
+ def test_should_delegate_server_create_to_server
246
+ Solusvm.expects(:config).with("thelogin", "thekey", { :url => "theurl" })
247
+ Solusvm::Server.stubs(:new => mock{ expects(:create).with(
248
+ "thehostname", "thepassword",
249
+ :plan => "theplan", :ips => "theips", :type => "thekind",
250
+ :username => "theusername", :template => "thetemplate", :node => "thenode"
251
+ ).returns("theresult") })
252
+
253
+ $stdout.expects(:puts).with("theresult")
254
+ Solusvm::Cli.start(cli_expand_base_arguments([
255
+ "server", "create",
256
+ "thehostname",
257
+ "thepassword",
258
+ "--plan", "theplan",
259
+ "--ips", "theips",
260
+ "--kind", "thekind",
261
+ "--username", "theusername",
262
+ "--template", "thetemplate",
263
+ "--node", "thenode"
264
+ ]))
265
+ end
266
+
267
+ end
@@ -0,0 +1,2 @@
1
+ <status>success</status>
2
+ <statusmsg>Client deleted</statusmsg>
@@ -0,0 +1,14 @@
1
+ <clients>
2
+ <client>
3
+ <id>1</id>
4
+ <username>vps123</username>
5
+ <email>vps123@email.com</email>
6
+ <firstname>phill</firstname>
7
+ <lastname>smith</lastname>
8
+ <company>VPS Co</company>
9
+ <level>Client</level>
10
+ <status>Active</status>
11
+ <created>2009-01-01</created>
12
+ <lastlogin>2010-04-23</lastlogin>
13
+ </client>
14
+ </clients>
@@ -0,0 +1,2 @@
1
+ <clients>
2
+ </clients>
@@ -0,0 +1,3 @@
1
+ <status>success</status>
2
+ <statusmsg></statusmsg>
3
+ <iso>iso1,iso2,iso3</iso>
@@ -0,0 +1,15 @@
1
+ <virtualservers>
2
+ <virtualserver>
3
+ <vserverid>theid</vserverid>
4
+ <ctid-xid>thexid</ctid-xid>
5
+ <clientid>theclientid</clientid>
6
+ <ipaddress>theip</ipaddress>
7
+ <hostname>thehostname</hostname>
8
+ <template>thetemplate</template>
9
+ <hdd>thediskspace</hdd>
10
+ <memory>thememory</memory>
11
+ <swap-burst>theswap</swap-burst>
12
+ <type>thetype</type>
13
+ <mac>themac</mac>
14
+ </virtualserver>
15
+ </virtualservers>
@@ -0,0 +1,2 @@
1
+ <virtualservers>
2
+ </virtualservers>
@@ -0,0 +1,4 @@
1
+ <status>success</status>
2
+ <statusmsg></statusmsg>
3
+ <freememory>thefreememory</freememory>
4
+ <freehdd>thefreehdd</freehdd>
@@ -0,0 +1,3 @@
1
+ <status>success</status>
2
+ <statusmsg></statusmsg>
3
+ <nodes>nodeid1,nodeid2,nodeid3,nodeid4</nodes>
@@ -0,0 +1,3 @@
1
+ <status>success</status>
2
+ <statusmsg></statusmsg>
3
+ <plans>plan1,plan2,plan3,plan4</plans>