solusvm 0.3.3 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +35 -3
- data/Rakefile +5 -0
- data/VERSION.yml +3 -3
- data/bin/solusvm +119 -0
- data/solusvm.gemspec +6 -2
- metadata +10 -9
data/README.rdoc
CHANGED
@@ -1,6 +1,38 @@
|
|
1
|
-
=
|
1
|
+
= Solusvm
|
2
2
|
|
3
|
-
|
3
|
+
Solusvm allows for easy interaction with the SolusVM Admin::API.
|
4
|
+
|
5
|
+
This library was first created for internal use at {Site5 LLC}[http://www.site5.com].
|
6
|
+
|
7
|
+
== Basic Examples
|
8
|
+
|
9
|
+
Solusvm.config('api_id', 'api_password', :url => 'http://www.example.com/api')
|
10
|
+
server = Solusvm::Server.new
|
11
|
+
|
12
|
+
# 200 is the id of the virtual server
|
13
|
+
server.shutdown(200) # => true
|
14
|
+
server.boot(200) # => true
|
15
|
+
server.reboot(200) # => true
|
16
|
+
server.suspend(200) # => true
|
17
|
+
server.resume(200) # => true
|
18
|
+
|
19
|
+
== Server creation
|
20
|
+
options = {:type => 'xen', :username => 'bob', :node => 'node1', :plan => 'plan1', :template => 'mytpl', :ips => 1}
|
21
|
+
result = sever.create('server.hostname.com', 'password', options}
|
22
|
+
p server.successful?
|
23
|
+
=> true
|
24
|
+
|
25
|
+
p result
|
26
|
+
=> {"mainipaddress"=>"127.0.0.1", "consoleuser"=>"console-user", "vserverid"=>"10",
|
27
|
+
"statusmsg"=>"Virtual server created", "virtid"=>"vm10", "consolepassword"=>"myPassisL33t",
|
28
|
+
"extraipaddress"=>{}, "hostname"=>"server.hostname", "rootpassword"=>"password", "status"=>"success"}
|
29
|
+
|
30
|
+
|
31
|
+
== REQUIREMENTS:
|
32
|
+
* xml-simple
|
33
|
+
|
34
|
+
== INSTALL:
|
35
|
+
* gem install solusvm
|
4
36
|
|
5
37
|
== Note on Patches/Pull Requests
|
6
38
|
|
@@ -14,4 +46,4 @@ Description goes here.
|
|
14
46
|
|
15
47
|
== Copyright
|
16
48
|
|
17
|
-
Copyright (c) 2010
|
49
|
+
Copyright (c) 2010 Site5. See LICENSE for details.
|
data/Rakefile
CHANGED
@@ -11,8 +11,13 @@ begin
|
|
11
11
|
gem.homepage = "http://github.com/site5/solusvm"
|
12
12
|
gem.authors = ["Justin Mazzi"]
|
13
13
|
gem.add_dependency 'xml-simple'
|
14
|
+
gem.rubyforge_project = 'solusvm'
|
14
15
|
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
15
16
|
end
|
17
|
+
|
18
|
+
Jeweler::RubyforgeTasks.new do |rubyforge|
|
19
|
+
rubyforge.doc_task = "rdoc"
|
20
|
+
end
|
16
21
|
Jeweler::GemcutterTasks.new
|
17
22
|
rescue LoadError
|
18
23
|
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
data/VERSION.yml
CHANGED
data/bin/solusvm
ADDED
@@ -0,0 +1,119 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "optparse"
|
4
|
+
require "pp"
|
5
|
+
require "yaml"
|
6
|
+
|
7
|
+
$:.unshift(File.join(File.dirname(__FILE__), "/../lib"))
|
8
|
+
require "solusvm"
|
9
|
+
|
10
|
+
opts = {}
|
11
|
+
shell_methods = {}
|
12
|
+
shell_methods['server-create'] = "<hostname> <password> -t myimag -k xen -p myplan -i 1"
|
13
|
+
shell_methods['server-boot'] = "<vserverid>"
|
14
|
+
shell_methods['server-reboot'] = "<vserverid>"
|
15
|
+
shell_methods['server-shutdown'] = "<vserverid>"
|
16
|
+
shell_methods['server-suspend'] = "<vserverid>"
|
17
|
+
shell_methods['server-resume'] = "<vserverid>"
|
18
|
+
shell_methods['server-status'] = "<vserverid>"
|
19
|
+
shell_methods['server-addip'] = "<vserverid>"
|
20
|
+
shell_methods['server-changeplan'] = "<vserverid> <newplan>"
|
21
|
+
shell_methods['server-check-exists'] = "<vserverid>"
|
22
|
+
|
23
|
+
OptionParser.new do |o|
|
24
|
+
o.banner = "USAGE: #{$0} <command> [options]"
|
25
|
+
o.on("-I", "--api-login [id]", "API ID: ") do |opt|
|
26
|
+
opts[:api_id] = opt
|
27
|
+
end
|
28
|
+
|
29
|
+
o.on("-K", "--api-key [key]", "API KEY: ") do |opt|
|
30
|
+
opts[:api_key] = opt
|
31
|
+
end
|
32
|
+
|
33
|
+
o.on("-N", "--node [node]", "Node to provision on: ") do |opt|
|
34
|
+
opts[:node] = opt
|
35
|
+
end
|
36
|
+
|
37
|
+
o.on("-U", "--api-url [URL]", "URL to the API: ") do |opt|
|
38
|
+
opts[:api_url] = opt
|
39
|
+
end
|
40
|
+
|
41
|
+
o.on("-u", "--username [username]", "The client to put the VPS under: ") do |opt|
|
42
|
+
opts[:username] = opt
|
43
|
+
end
|
44
|
+
|
45
|
+
o.on("-k", "--kind [kind]", "Type of VPS (#{Solusvm::Server::VALID_SERVER_TYPES.join(',')}): ") do |opt|
|
46
|
+
opts[:kind] = opt
|
47
|
+
end
|
48
|
+
|
49
|
+
o.on("-t", "--template [template]", "VPS template to boot from: ") do |opt|
|
50
|
+
opts[:template] = opt
|
51
|
+
end
|
52
|
+
|
53
|
+
o.on("-p", "--plan [plan]", "Plan to use: ") do |opt|
|
54
|
+
opts[:plan] = opt
|
55
|
+
end
|
56
|
+
|
57
|
+
o.on("-i", "--ips [number]", "Number of ips to add to the VPS: ") do |opt|
|
58
|
+
opts[:ips] = opt.to_i
|
59
|
+
end
|
60
|
+
|
61
|
+
o.on("-h", "--help", "Show help documentation") do |h|
|
62
|
+
puts o
|
63
|
+
puts "Commands:"
|
64
|
+
puts shell_methods.collect { |k,v| " #{k} #{v}"}.join("\n")
|
65
|
+
|
66
|
+
exit
|
67
|
+
end
|
68
|
+
end.parse!
|
69
|
+
|
70
|
+
config_file = File.join(File.expand_path(ENV['HOME']), '.soulsvm.yml')
|
71
|
+
server = Solusvm::Server.new
|
72
|
+
if ARGV.empty?
|
73
|
+
STDERR.puts "USAGE: #{$0} [function] [options]"
|
74
|
+
else
|
75
|
+
if File.exists?(config_file)
|
76
|
+
config = YAML::load(File.open(config_file))
|
77
|
+
Solusvm.config(config['id'], config['key'], :url => config['url'])
|
78
|
+
opts[:username] = config['username'] unless opts[:username]
|
79
|
+
elsif opts[:api_url] && opts[:api_id] && opts[:api_key]
|
80
|
+
Solusvm.config(opts[:api_id], opts[:api_key], :url => opts[:api_url])
|
81
|
+
else
|
82
|
+
puts "Must supply the api id/key and URL"
|
83
|
+
exit
|
84
|
+
end
|
85
|
+
meth = ARGV[0].chomp
|
86
|
+
if shell_methods.include?(meth)
|
87
|
+
ARGV.shift
|
88
|
+
if ARGV.empty?
|
89
|
+
p shell_methods[meth]
|
90
|
+
exit
|
91
|
+
else
|
92
|
+
case meth
|
93
|
+
when 'server-create'
|
94
|
+
unless ARGV.size == 2
|
95
|
+
p shell_methods[meth]
|
96
|
+
exit
|
97
|
+
end
|
98
|
+
p server.create(ARGV[0], ARGV[1], :plan => opts[:plan], :ips => opts[:ips], :type => opts[:kind],
|
99
|
+
:username => opts[:username], :template => opts[:template], :node => opts[:node])
|
100
|
+
when 'server-status'
|
101
|
+
p server.status(ARGV[0])
|
102
|
+
when 'server-boot'
|
103
|
+
p server.boot(ARGV[0])
|
104
|
+
when 'server-reboot'
|
105
|
+
p server.reboot(ARGV[0])
|
106
|
+
when 'server-suspend'
|
107
|
+
p server.suspend(ARGV[0])
|
108
|
+
when 'server-resume'
|
109
|
+
p server.resume(ARGV[0])
|
110
|
+
when 'server-check-exists'
|
111
|
+
p server.exists?(ARGV[0])
|
112
|
+
when 'server-terminate'
|
113
|
+
p server.terminate(ARGV[0])
|
114
|
+
end
|
115
|
+
end
|
116
|
+
else
|
117
|
+
puts "#{meth} is not a valid function"
|
118
|
+
end
|
119
|
+
end
|
data/solusvm.gemspec
CHANGED
@@ -5,13 +5,15 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{solusvm}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.4.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Justin Mazzi"]
|
12
|
-
s.date = %q{2010-06-
|
12
|
+
s.date = %q{2010-06-22}
|
13
|
+
s.default_executable = %q{solusvm}
|
13
14
|
s.description = %q{Solusvm allows for easy interaction with the SolusVM Admin::API.}
|
14
15
|
s.email = %q{jmazzi@gmail.com}
|
16
|
+
s.executables = ["solusvm"]
|
15
17
|
s.extra_rdoc_files = [
|
16
18
|
"LICENSE",
|
17
19
|
"README.rdoc"
|
@@ -23,6 +25,7 @@ Gem::Specification.new do |s|
|
|
23
25
|
"README.rdoc",
|
24
26
|
"Rakefile",
|
25
27
|
"VERSION.yml",
|
28
|
+
"bin/solusvm",
|
26
29
|
"lib/solusvm.rb",
|
27
30
|
"lib/solusvm/base.rb",
|
28
31
|
"lib/solusvm/client.rb",
|
@@ -58,6 +61,7 @@ Gem::Specification.new do |s|
|
|
58
61
|
s.homepage = %q{http://github.com/site5/solusvm}
|
59
62
|
s.rdoc_options = ["--charset=UTF-8"]
|
60
63
|
s.require_paths = ["lib"]
|
64
|
+
s.rubyforge_project = %q{solusvm}
|
61
65
|
s.rubygems_version = %q{1.3.7}
|
62
66
|
s.summary = %q{Wrapper for the SolusVM Admin::API}
|
63
67
|
s.test_files = [
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: solusvm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 15
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 0.
|
8
|
+
- 4
|
9
|
+
- 0
|
10
|
+
version: 0.4.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Justin Mazzi
|
@@ -15,8 +15,8 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-06-
|
19
|
-
default_executable:
|
18
|
+
date: 2010-06-22 00:00:00 -04:00
|
19
|
+
default_executable: solusvm
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
22
22
|
name: xml-simple
|
@@ -34,8 +34,8 @@ dependencies:
|
|
34
34
|
version_requirements: *id001
|
35
35
|
description: Solusvm allows for easy interaction with the SolusVM Admin::API.
|
36
36
|
email: jmazzi@gmail.com
|
37
|
-
executables:
|
38
|
-
|
37
|
+
executables:
|
38
|
+
- solusvm
|
39
39
|
extensions: []
|
40
40
|
|
41
41
|
extra_rdoc_files:
|
@@ -48,6 +48,7 @@ files:
|
|
48
48
|
- README.rdoc
|
49
49
|
- Rakefile
|
50
50
|
- VERSION.yml
|
51
|
+
- bin/solusvm
|
51
52
|
- lib/solusvm.rb
|
52
53
|
- lib/solusvm/base.rb
|
53
54
|
- lib/solusvm/client.rb
|
@@ -108,7 +109,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
108
109
|
version: "0"
|
109
110
|
requirements: []
|
110
111
|
|
111
|
-
rubyforge_project:
|
112
|
+
rubyforge_project: solusvm
|
112
113
|
rubygems_version: 1.3.7
|
113
114
|
signing_key:
|
114
115
|
specification_version: 3
|