econe 1.4.2
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.
- data/bin/econe-describe-images +134 -0
- data/bin/econe-describe-instances +131 -0
- data/bin/econe-register +131 -0
- data/bin/econe-run-instances +147 -0
- data/bin/econe-terminate-instances +128 -0
- data/bin/econe-upload +129 -0
- data/lib/CloudClient.rb +121 -0
- data/lib/econe/EC2QueryClient.rb +219 -0
- metadata +106 -0
@@ -0,0 +1,134 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# == Synopsis
|
4
|
+
# econe-describe-images
|
5
|
+
#
|
6
|
+
# List and describe previously uploaded images of a user for use
|
7
|
+
# with an OpenNebula Cloud.
|
8
|
+
#
|
9
|
+
# == Usage
|
10
|
+
#
|
11
|
+
# econe-describe-images [OPTIONS]
|
12
|
+
#
|
13
|
+
# -h, --help:
|
14
|
+
# show help
|
15
|
+
#
|
16
|
+
# --access-key <id>, -K <id>:
|
17
|
+
# The username of the user
|
18
|
+
#
|
19
|
+
# --secret-key <key>, -K <key>:
|
20
|
+
# The password of the user
|
21
|
+
#
|
22
|
+
# --url <url>, -U <url>:
|
23
|
+
# Set url as the web service url to use
|
24
|
+
#
|
25
|
+
# --headers, -H:
|
26
|
+
# Display column headers
|
27
|
+
|
28
|
+
# -------------------------------------------------------------------------- #
|
29
|
+
# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
|
30
|
+
# #
|
31
|
+
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
32
|
+
# not use this file except in compliance with the License. You may obtain #
|
33
|
+
# a copy of the License at #
|
34
|
+
# #
|
35
|
+
# http://www.apache.org/licenses/LICENSE-2.0 #
|
36
|
+
# #
|
37
|
+
# Unless required by applicable law or agreed to in writing, software #
|
38
|
+
# distributed under the License is distributed on an "AS IS" BASIS, #
|
39
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
|
40
|
+
# See the License for the specific language governing permissions and #
|
41
|
+
# limitations under the License. #
|
42
|
+
#--------------------------------------------------------------------------- #
|
43
|
+
|
44
|
+
ONE_LOCATION=ENV["ONE_LOCATION"]
|
45
|
+
|
46
|
+
if !ONE_LOCATION
|
47
|
+
_libdir = File.join(File.dirname(__FILE__), "..", "lib")
|
48
|
+
if (Dir.chdir(_libdir) { true } rescue false)
|
49
|
+
RUBY_LIB_LOCATION = _libdir
|
50
|
+
else
|
51
|
+
RUBY_LIB_LOCATION="/usr/lib/one/ruby"
|
52
|
+
end
|
53
|
+
else
|
54
|
+
RUBY_LIB_LOCATION=ONE_LOCATION+"/lib/ruby"
|
55
|
+
end
|
56
|
+
|
57
|
+
|
58
|
+
$: << RUBY_LIB_LOCATION
|
59
|
+
$: << RUBY_LIB_LOCATION+"/cloud"
|
60
|
+
|
61
|
+
require 'econe/EC2QueryClient'
|
62
|
+
require 'CloudClient'
|
63
|
+
require 'getoptlong'
|
64
|
+
require 'rdoc/usage'
|
65
|
+
require 'pp'
|
66
|
+
|
67
|
+
include CloudCLI
|
68
|
+
|
69
|
+
opts = GetoptLong.new(
|
70
|
+
['--help', '-h',GetoptLong::NO_ARGUMENT],
|
71
|
+
['--access-key', '-K',GetoptLong::REQUIRED_ARGUMENT],
|
72
|
+
['--secret-key', '-S',GetoptLong::REQUIRED_ARGUMENT],
|
73
|
+
['--url', '-U',GetoptLong::REQUIRED_ARGUMENT],
|
74
|
+
['--headers', '-H',GetoptLong::NO_ARGUMENT]
|
75
|
+
)
|
76
|
+
|
77
|
+
headers = false
|
78
|
+
url = nil
|
79
|
+
access = nil
|
80
|
+
secret = nil
|
81
|
+
auth = nil
|
82
|
+
|
83
|
+
begin
|
84
|
+
opts.each do |opt, arg|
|
85
|
+
case opt
|
86
|
+
when '--help'
|
87
|
+
RDoc::usage
|
88
|
+
when '--access-key'
|
89
|
+
access = arg
|
90
|
+
when '--secret-key'
|
91
|
+
secret = arg
|
92
|
+
when '--url'
|
93
|
+
url = arg
|
94
|
+
when '--headers'
|
95
|
+
headers = true
|
96
|
+
end
|
97
|
+
end
|
98
|
+
rescue Exception => e
|
99
|
+
exit -1
|
100
|
+
end
|
101
|
+
|
102
|
+
auth = "#{access}:#{secret}" if secret && access
|
103
|
+
|
104
|
+
begin
|
105
|
+
ec2_client = EC2QueryClient::Client.new(auth,url)
|
106
|
+
rescue Exception => e
|
107
|
+
puts "#{cmd_name}: #{e.message}"
|
108
|
+
exit -1
|
109
|
+
end
|
110
|
+
|
111
|
+
rc = ec2_client.describe_images()
|
112
|
+
|
113
|
+
if CloudClient::is_error?(rc)
|
114
|
+
puts "#{cmd_name}: #{rc.message}"
|
115
|
+
exit -1
|
116
|
+
end
|
117
|
+
|
118
|
+
images = rc['imagesSet']['item']
|
119
|
+
|
120
|
+
fmt = "%-4s %-36s %s"
|
121
|
+
|
122
|
+
if headers
|
123
|
+
puts fmt % ["Owner", "ImageId", "Location"]
|
124
|
+
puts "------------------------------------------------------------------------------"
|
125
|
+
end
|
126
|
+
|
127
|
+
if images
|
128
|
+
images.each { |img|
|
129
|
+
puts fmt % [img['imageOwnerId'],img['imageId'],img['imageLocation']]
|
130
|
+
}
|
131
|
+
end
|
132
|
+
|
133
|
+
exit 0
|
134
|
+
|
@@ -0,0 +1,131 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# == Synopsis
|
4
|
+
# econe-describe-instances
|
5
|
+
#
|
6
|
+
# List and describe running instances
|
7
|
+
#
|
8
|
+
# == Usage
|
9
|
+
#
|
10
|
+
# econe-describe-instances [OPTIONS]
|
11
|
+
#
|
12
|
+
# -h, --help:
|
13
|
+
# show help
|
14
|
+
#
|
15
|
+
# --access-key <id>, -K <id>:
|
16
|
+
# The username of the user
|
17
|
+
#
|
18
|
+
# --secret-key <key>, -S <key>:
|
19
|
+
# The password of the user
|
20
|
+
#
|
21
|
+
# --url <url>, -U <url>:
|
22
|
+
# Set url as the web service url to use
|
23
|
+
#
|
24
|
+
# --headers, -H:
|
25
|
+
# Display column headers
|
26
|
+
|
27
|
+
# -------------------------------------------------------------------------- #
|
28
|
+
# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
|
29
|
+
# #
|
30
|
+
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
31
|
+
# not use this file except in compliance with the License. You may obtain #
|
32
|
+
# a copy of the License at #
|
33
|
+
# #
|
34
|
+
# http://www.apache.org/licenses/LICENSE-2.0 #
|
35
|
+
# #
|
36
|
+
# Unless required by applicable law or agreed to in writing, software #
|
37
|
+
# distributed under the License is distributed on an "AS IS" BASIS, #
|
38
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
|
39
|
+
# See the License for the specific language governing permissions and #
|
40
|
+
# limitations under the License. #
|
41
|
+
#--------------------------------------------------------------------------- #
|
42
|
+
|
43
|
+
ONE_LOCATION=ENV["ONE_LOCATION"]
|
44
|
+
|
45
|
+
if !ONE_LOCATION
|
46
|
+
_libdir = File.join(File.dirname(__FILE__), "..", "lib")
|
47
|
+
if (Dir.chdir(_libdir) { true } rescue false)
|
48
|
+
RUBY_LIB_LOCATION = _libdir
|
49
|
+
else
|
50
|
+
RUBY_LIB_LOCATION="/usr/lib/one/ruby"
|
51
|
+
end
|
52
|
+
else
|
53
|
+
RUBY_LIB_LOCATION=ONE_LOCATION+"/lib/ruby"
|
54
|
+
end
|
55
|
+
|
56
|
+
$: << RUBY_LIB_LOCATION
|
57
|
+
$: << RUBY_LIB_LOCATION+"/cloud"
|
58
|
+
|
59
|
+
require 'econe/EC2QueryClient'
|
60
|
+
require 'CloudClient'
|
61
|
+
require 'getoptlong'
|
62
|
+
require 'rdoc/usage'
|
63
|
+
require 'pp'
|
64
|
+
|
65
|
+
include CloudCLI
|
66
|
+
|
67
|
+
opts = GetoptLong.new(
|
68
|
+
['--help', '-h',GetoptLong::NO_ARGUMENT],
|
69
|
+
['--access-key', '-K',GetoptLong::REQUIRED_ARGUMENT],
|
70
|
+
['--secret-key', '-S',GetoptLong::REQUIRED_ARGUMENT],
|
71
|
+
['--url', '-U',GetoptLong::REQUIRED_ARGUMENT],
|
72
|
+
['--headers', '-H',GetoptLong::NO_ARGUMENT]
|
73
|
+
)
|
74
|
+
|
75
|
+
headers = false
|
76
|
+
url = nil
|
77
|
+
access = nil
|
78
|
+
secret = nil
|
79
|
+
auth = nil
|
80
|
+
|
81
|
+
begin
|
82
|
+
opts.each do |opt, arg|
|
83
|
+
case opt
|
84
|
+
when '--help'
|
85
|
+
RDoc::usage
|
86
|
+
when '--access-key'
|
87
|
+
access = arg
|
88
|
+
when '--secret-key'
|
89
|
+
secret = arg
|
90
|
+
when '--url'
|
91
|
+
url = arg
|
92
|
+
when '--headers'
|
93
|
+
headers = true
|
94
|
+
end
|
95
|
+
end
|
96
|
+
rescue Exception => e
|
97
|
+
exit -1
|
98
|
+
end
|
99
|
+
|
100
|
+
auth = "#{access}:#{secret}" if secret && access
|
101
|
+
|
102
|
+
begin
|
103
|
+
ec2_client = EC2QueryClient::Client.new(auth,url)
|
104
|
+
rescue Exception => e
|
105
|
+
puts "#{cmd_name}: #{e.message}"
|
106
|
+
exit -1
|
107
|
+
end
|
108
|
+
|
109
|
+
rc = ec2_client.describe_instances()
|
110
|
+
|
111
|
+
if CloudClient::is_error?(rc)
|
112
|
+
puts "#{cmd_name}: #{rc.message}"
|
113
|
+
exit -1
|
114
|
+
end
|
115
|
+
|
116
|
+
instances = rc['reservationSet']['item'][0]['instancesSet']['item']
|
117
|
+
owner = rc['reservationSet']['item'][0]['ownerId']
|
118
|
+
|
119
|
+
fmt = "%-12s\t%-12s\t%-16s\t%-15s\t%-10s"
|
120
|
+
|
121
|
+
if headers
|
122
|
+
puts fmt % ["InstanceId", "ImageId", "State", "IP", "Type"]
|
123
|
+
puts "------------------------------------------------------------------------------------------------------------"
|
124
|
+
end
|
125
|
+
|
126
|
+
if instances
|
127
|
+
instances.each { |img|
|
128
|
+
puts fmt % [owner, img['instanceId'],img['imageId'],img['instanceState']['name'],img['dnsName'],img['instanceType']]
|
129
|
+
}
|
130
|
+
end
|
131
|
+
exit 0
|
data/bin/econe-register
ADDED
@@ -0,0 +1,131 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
USAGE = <<_END_USAGE_
|
4
|
+
Synopsis:
|
5
|
+
econe-register
|
6
|
+
|
7
|
+
Register a previously uploaded image for use with an
|
8
|
+
OpenNebula Cloud.
|
9
|
+
|
10
|
+
Usage:
|
11
|
+
|
12
|
+
econe-register [OPTIONS] ImageId
|
13
|
+
|
14
|
+
-h, --help:
|
15
|
+
show help
|
16
|
+
|
17
|
+
--access-key <id>, -K <id>:
|
18
|
+
The username of the user
|
19
|
+
|
20
|
+
--secret-key <key>, -S <key>:
|
21
|
+
The password of the user
|
22
|
+
|
23
|
+
--url <url>, -U <url>:
|
24
|
+
Set url as the web service url to use
|
25
|
+
|
26
|
+
--headers, -H:
|
27
|
+
Display column headers
|
28
|
+
|
29
|
+
IMAGE-ID: The image identification as returned by
|
30
|
+
the econe-upload command
|
31
|
+
_END_USAGE_
|
32
|
+
|
33
|
+
|
34
|
+
# -------------------------------------------------------------------------- #
|
35
|
+
# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
|
36
|
+
# #
|
37
|
+
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
38
|
+
# not use this file except in compliance with the License. You may obtain #
|
39
|
+
# a copy of the License at #
|
40
|
+
# #
|
41
|
+
# http://www.apache.org/licenses/LICENSE-2.0 #
|
42
|
+
# #
|
43
|
+
# Unless required by applicable law or agreed to in writing, software #
|
44
|
+
# distributed under the License is distributed on an "AS IS" BASIS, #
|
45
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
|
46
|
+
# See the License for the specific language governing permissions and #
|
47
|
+
# limitations under the License. #
|
48
|
+
#--------------------------------------------------------------------------- #
|
49
|
+
|
50
|
+
ONE_LOCATION=ENV["ONE_LOCATION"]
|
51
|
+
|
52
|
+
if !ONE_LOCATION
|
53
|
+
_libdir = File.join(File.dirname(__FILE__), "..", "lib")
|
54
|
+
if (Dir.chdir(_libdir) { true } rescue false)
|
55
|
+
RUBY_LIB_LOCATION = _libdir
|
56
|
+
else
|
57
|
+
RUBY_LIB_LOCATION="/usr/lib/one/ruby"
|
58
|
+
end
|
59
|
+
else
|
60
|
+
RUBY_LIB_LOCATION=ONE_LOCATION+"/lib/ruby"
|
61
|
+
end
|
62
|
+
|
63
|
+
$: << RUBY_LIB_LOCATION
|
64
|
+
$: << RUBY_LIB_LOCATION+"/cloud"
|
65
|
+
|
66
|
+
require 'econe/EC2QueryClient'
|
67
|
+
require 'CloudClient'
|
68
|
+
require 'getoptlong'
|
69
|
+
require 'pp'
|
70
|
+
|
71
|
+
include CloudCLI
|
72
|
+
|
73
|
+
opts = GetoptLong.new(
|
74
|
+
['--help', '-h',GetoptLong::NO_ARGUMENT],
|
75
|
+
['--access-key', '-K',GetoptLong::REQUIRED_ARGUMENT],
|
76
|
+
['--secret-key', '-S',GetoptLong::REQUIRED_ARGUMENT],
|
77
|
+
['--url', '-U',GetoptLong::REQUIRED_ARGUMENT],
|
78
|
+
['--headers', '-H',GetoptLong::NO_ARGUMENT]
|
79
|
+
)
|
80
|
+
|
81
|
+
headers = false
|
82
|
+
url = nil
|
83
|
+
access = nil
|
84
|
+
secret = nil
|
85
|
+
auth = nil
|
86
|
+
|
87
|
+
begin
|
88
|
+
opts.each do |opt, arg|
|
89
|
+
case opt
|
90
|
+
when '--help'
|
91
|
+
puts USAGE
|
92
|
+
when '--access-key'
|
93
|
+
access = arg
|
94
|
+
when '--secret-key'
|
95
|
+
secret = arg
|
96
|
+
when '--url'
|
97
|
+
url = arg
|
98
|
+
when '--headers'
|
99
|
+
headers = true
|
100
|
+
end
|
101
|
+
end
|
102
|
+
rescue Exception => e
|
103
|
+
exit -1
|
104
|
+
end
|
105
|
+
|
106
|
+
image_id = ARGV.shift
|
107
|
+
|
108
|
+
if !image_id
|
109
|
+
puts "#{cmd_name}: missing ImageId parameter"
|
110
|
+
exit -1
|
111
|
+
end
|
112
|
+
|
113
|
+
auth = "#{access}:#{secret}" if secret && access
|
114
|
+
|
115
|
+
begin
|
116
|
+
ec2_client = EC2QueryClient::Client.new(auth,url)
|
117
|
+
rescue Exception => e
|
118
|
+
puts "#{cmd_name}: #{e.message}"
|
119
|
+
exit -1
|
120
|
+
end
|
121
|
+
|
122
|
+
rc = ec2_client.register_image(image_id)
|
123
|
+
|
124
|
+
if CloudClient::is_error?(rc)
|
125
|
+
puts "#{cmd_name}: #{rc.message}"
|
126
|
+
exit -1
|
127
|
+
end
|
128
|
+
|
129
|
+
puts "Success: ImageId #{rc['imageId']}"
|
130
|
+
|
131
|
+
exit 0
|
@@ -0,0 +1,147 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# == Synopsis
|
4
|
+
# econe-run-instances
|
5
|
+
#
|
6
|
+
# Runs an instance of a particular image
|
7
|
+
#
|
8
|
+
# == Usage
|
9
|
+
#
|
10
|
+
# econe-run-instances [OPTIONS]
|
11
|
+
#
|
12
|
+
# -h, --help:
|
13
|
+
# show help
|
14
|
+
#
|
15
|
+
# --access-key <id>, -K <id>:
|
16
|
+
# The username of the user
|
17
|
+
#
|
18
|
+
# --secret-key <key>, -S <key>:
|
19
|
+
# The password of the user
|
20
|
+
#
|
21
|
+
# --url <url>, -U <url>:
|
22
|
+
# Set url as the web service url to use
|
23
|
+
#
|
24
|
+
# --type <type>, -t <type>
|
25
|
+
#
|
26
|
+
# --headers, -H:
|
27
|
+
# Display column headers
|
28
|
+
|
29
|
+
# -------------------------------------------------------------------------- #
|
30
|
+
# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
|
31
|
+
# #
|
32
|
+
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
33
|
+
# not use this file except in compliance with the License. You may obtain #
|
34
|
+
# a copy of the License at #
|
35
|
+
# #
|
36
|
+
# http://www.apache.org/licenses/LICENSE-2.0 #
|
37
|
+
# #
|
38
|
+
# Unless required by applicable law or agreed to in writing, software #
|
39
|
+
# distributed under the License is distributed on an "AS IS" BASIS, #
|
40
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
|
41
|
+
# See the License for the specific language governing permissions and #
|
42
|
+
# limitations under the License. #
|
43
|
+
#--------------------------------------------------------------------------- #
|
44
|
+
|
45
|
+
ONE_LOCATION=ENV["ONE_LOCATION"]
|
46
|
+
|
47
|
+
if !ONE_LOCATION
|
48
|
+
_libdir = File.join(File.dirname(__FILE__), "..", "lib")
|
49
|
+
if (Dir.chdir(_libdir) { true } rescue false)
|
50
|
+
RUBY_LIB_LOCATION = _libdir
|
51
|
+
else
|
52
|
+
RUBY_LIB_LOCATION="/usr/lib/one/ruby"
|
53
|
+
end
|
54
|
+
else
|
55
|
+
RUBY_LIB_LOCATION=ONE_LOCATION+"/lib/ruby"
|
56
|
+
end
|
57
|
+
|
58
|
+
|
59
|
+
$: << RUBY_LIB_LOCATION
|
60
|
+
$: << RUBY_LIB_LOCATION+"/cloud"
|
61
|
+
|
62
|
+
require 'econe/EC2QueryClient'
|
63
|
+
require 'CloudClient'
|
64
|
+
require 'getoptlong'
|
65
|
+
require 'rdoc/usage'
|
66
|
+
require 'pp'
|
67
|
+
|
68
|
+
include CloudCLI
|
69
|
+
|
70
|
+
opts = GetoptLong.new(
|
71
|
+
['--help', '-h',GetoptLong::NO_ARGUMENT],
|
72
|
+
['--access-key', '-K',GetoptLong::REQUIRED_ARGUMENT],
|
73
|
+
['--secret-key', '-S',GetoptLong::REQUIRED_ARGUMENT],
|
74
|
+
['--url', '-U',GetoptLong::REQUIRED_ARGUMENT],
|
75
|
+
['--type', '-t',GetoptLong::REQUIRED_ARGUMENT],
|
76
|
+
['--headers', '-H',GetoptLong::NO_ARGUMENT]
|
77
|
+
)
|
78
|
+
|
79
|
+
headers = false
|
80
|
+
url = nil
|
81
|
+
access = nil
|
82
|
+
secret = nil
|
83
|
+
auth = nil
|
84
|
+
type = nil
|
85
|
+
|
86
|
+
begin
|
87
|
+
opts.each do |opt, arg|
|
88
|
+
case opt
|
89
|
+
when '--help'
|
90
|
+
RDoc::usage
|
91
|
+
when '--access-key'
|
92
|
+
access = arg
|
93
|
+
when '--secret-key'
|
94
|
+
secret = arg
|
95
|
+
when '--url'
|
96
|
+
url = arg
|
97
|
+
when '--type'
|
98
|
+
type = arg
|
99
|
+
when '--headers'
|
100
|
+
headers = true
|
101
|
+
end
|
102
|
+
end
|
103
|
+
rescue Exception => e
|
104
|
+
exit -1
|
105
|
+
end
|
106
|
+
|
107
|
+
image_id = ARGV.shift
|
108
|
+
|
109
|
+
if !image_id
|
110
|
+
puts "#{cmd_name}: missing IMAGE-ID parameter"
|
111
|
+
exit -1
|
112
|
+
end
|
113
|
+
|
114
|
+
if !type
|
115
|
+
type = "m1.small"
|
116
|
+
end
|
117
|
+
|
118
|
+
auth = "#{access}:#{secret}" if secret && access
|
119
|
+
|
120
|
+
begin
|
121
|
+
ec2_client = EC2QueryClient::Client.new(auth,url)
|
122
|
+
rescue Exception => e
|
123
|
+
puts "#{cmd_name}: #{e.message}"
|
124
|
+
exit -1
|
125
|
+
end
|
126
|
+
|
127
|
+
rc = ec2_client.run_instances(image_id,type)
|
128
|
+
|
129
|
+
if CloudClient::is_error?(rc)
|
130
|
+
puts "#{cmd_name}: #{rc.message}"
|
131
|
+
exit -1
|
132
|
+
end
|
133
|
+
|
134
|
+
images = rc['instancesSet']['item']
|
135
|
+
|
136
|
+
fmt = "%-10s %-36s %-10s %s"
|
137
|
+
|
138
|
+
if headers
|
139
|
+
puts fmt % ["Owner", "ImageId", "InstanceId", "InstanceType"]
|
140
|
+
puts "------------------------------------------------------------------------------"
|
141
|
+
end
|
142
|
+
|
143
|
+
images.each { |img|
|
144
|
+
puts fmt % [rc['ownerId'],img['imageId'],img['instanceId'],img['instanceType']]
|
145
|
+
}
|
146
|
+
|
147
|
+
exit 0
|
@@ -0,0 +1,128 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# == Synopsis
|
4
|
+
# econe-terminate-instances
|
5
|
+
#
|
6
|
+
# Terminate the selected running instance
|
7
|
+
#
|
8
|
+
# == Usage
|
9
|
+
#
|
10
|
+
# econe-register [OPTIONS] INSTANCE-ID
|
11
|
+
#
|
12
|
+
# -h, --help:
|
13
|
+
# show help
|
14
|
+
#
|
15
|
+
# --access-key <id>, -K <id>:
|
16
|
+
# The username of the user
|
17
|
+
#
|
18
|
+
# --secret-key <key>, -K <key>:
|
19
|
+
# The password of the user
|
20
|
+
#
|
21
|
+
# --url <url>, -U <url>:
|
22
|
+
# Set url as the web service url to use
|
23
|
+
#
|
24
|
+
# INSTANCE-ID: The instance identification as returned by
|
25
|
+
# the econe-run-instances command
|
26
|
+
|
27
|
+
|
28
|
+
|
29
|
+
# -------------------------------------------------------------------------- #
|
30
|
+
# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
|
31
|
+
# #
|
32
|
+
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
33
|
+
# not use this file except in compliance with the License. You may obtain #
|
34
|
+
# a copy of the License at #
|
35
|
+
# #
|
36
|
+
# http://www.apache.org/licenses/LICENSE-2.0 #
|
37
|
+
# #
|
38
|
+
# Unless required by applicable law or agreed to in writing, software #
|
39
|
+
# distributed under the License is distributed on an "AS IS" BASIS, #
|
40
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
|
41
|
+
# See the License for the specific language governing permissions and #
|
42
|
+
# limitations under the License. #
|
43
|
+
#--------------------------------------------------------------------------- #
|
44
|
+
|
45
|
+
ONE_LOCATION=ENV["ONE_LOCATION"]
|
46
|
+
|
47
|
+
if !ONE_LOCATION
|
48
|
+
_libdir = File.join(File.dirname(__FILE__), "..", "lib")
|
49
|
+
if (Dir.chdir(_libdir) { true } rescue false)
|
50
|
+
RUBY_LIB_LOCATION = _libdir
|
51
|
+
else
|
52
|
+
RUBY_LIB_LOCATION="/usr/lib/one/ruby"
|
53
|
+
end
|
54
|
+
else
|
55
|
+
RUBY_LIB_LOCATION=ONE_LOCATION+"/lib/ruby"
|
56
|
+
end
|
57
|
+
|
58
|
+
|
59
|
+
$: << RUBY_LIB_LOCATION
|
60
|
+
$: << RUBY_LIB_LOCATION+"/cloud"
|
61
|
+
|
62
|
+
require 'econe/EC2QueryClient'
|
63
|
+
require 'CloudClient'
|
64
|
+
require 'getoptlong'
|
65
|
+
require 'rdoc/usage'
|
66
|
+
require 'pp'
|
67
|
+
|
68
|
+
include CloudCLI
|
69
|
+
|
70
|
+
opts = GetoptLong.new(
|
71
|
+
['--help', '-h',GetoptLong::NO_ARGUMENT],
|
72
|
+
['--access-key', '-K',GetoptLong::REQUIRED_ARGUMENT],
|
73
|
+
['--secret-key', '-S',GetoptLong::REQUIRED_ARGUMENT],
|
74
|
+
['--url', '-U',GetoptLong::REQUIRED_ARGUMENT]
|
75
|
+
)
|
76
|
+
|
77
|
+
url = nil
|
78
|
+
access = nil
|
79
|
+
secret = nil
|
80
|
+
auth = nil
|
81
|
+
|
82
|
+
begin
|
83
|
+
opts.each do |opt, arg|
|
84
|
+
case opt
|
85
|
+
when '--help'
|
86
|
+
RDoc::usage
|
87
|
+
when '--access-key'
|
88
|
+
access = arg
|
89
|
+
when '--secret-key'
|
90
|
+
secret = arg
|
91
|
+
when '--url'
|
92
|
+
url = arg
|
93
|
+
when '--headers'
|
94
|
+
headers = true
|
95
|
+
end
|
96
|
+
end
|
97
|
+
rescue Exception => e
|
98
|
+
exit -1
|
99
|
+
end
|
100
|
+
|
101
|
+
instance = ARGV.shift
|
102
|
+
|
103
|
+
if !instance
|
104
|
+
puts "#{cmd_name}: missing INSTANCE-ID parameter"
|
105
|
+
exit -1
|
106
|
+
end
|
107
|
+
|
108
|
+
auth = "#{access}:#{secret}" if secret && access
|
109
|
+
|
110
|
+
begin
|
111
|
+
ec2_client = EC2QueryClient::Client.new(auth,url)
|
112
|
+
rescue Exception => e
|
113
|
+
puts "#{cmd_name}: #{e.message}"
|
114
|
+
exit -1
|
115
|
+
end
|
116
|
+
|
117
|
+
rc = ec2_client.terminate_instances(instance)
|
118
|
+
|
119
|
+
if CloudClient::is_error?(rc)
|
120
|
+
puts "#{cmd_name}: #{rc.message}"
|
121
|
+
exit -1
|
122
|
+
end
|
123
|
+
|
124
|
+
result = rc['instancesSet']['item'][0]
|
125
|
+
|
126
|
+
puts "Success: Terminating #{result['instanceId']} in #{result['previousState']['name']} state"
|
127
|
+
|
128
|
+
exit 0
|
data/bin/econe-upload
ADDED
@@ -0,0 +1,129 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# == Synopsis
|
4
|
+
# econe-upload
|
5
|
+
#
|
6
|
+
# Uploads an image for use with an OpenNebula Cloud. This image should
|
7
|
+
# be later register with econe-register using the returned ImageId
|
8
|
+
#
|
9
|
+
# == Usage
|
10
|
+
#
|
11
|
+
# econe-upload [OPTIONS] IMAGE-PATH
|
12
|
+
#
|
13
|
+
# -h, --help:
|
14
|
+
# show help
|
15
|
+
#
|
16
|
+
# --access-key <id>, -K <id>:
|
17
|
+
# The username of the user
|
18
|
+
#
|
19
|
+
# --secret-key <key>, -K <key>:
|
20
|
+
# The password of the user
|
21
|
+
#
|
22
|
+
# --url <url>, -U <url>:
|
23
|
+
# Set url as the web service url to use
|
24
|
+
#
|
25
|
+
# --multipart, -M:
|
26
|
+
# Use 'multipart-post' library instead of Curb/Curl
|
27
|
+
#
|
28
|
+
# IMAGE-PATH: Path to the image to upload
|
29
|
+
|
30
|
+
# -------------------------------------------------------------------------- #
|
31
|
+
# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
|
32
|
+
# #
|
33
|
+
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
34
|
+
# not use this file except in compliance with the License. You may obtain #
|
35
|
+
# a copy of the License at #
|
36
|
+
# #
|
37
|
+
# http://www.apache.org/licenses/LICENSE-2.0 #
|
38
|
+
# #
|
39
|
+
# Unless required by applicable law or agreed to in writing, software #
|
40
|
+
# distributed under the License is distributed on an "AS IS" BASIS, #
|
41
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
|
42
|
+
# See the License for the specific language governing permissions and #
|
43
|
+
# limitations under the License. #
|
44
|
+
#--------------------------------------------------------------------------- #
|
45
|
+
|
46
|
+
ONE_LOCATION=ENV["ONE_LOCATION"]
|
47
|
+
|
48
|
+
if !ONE_LOCATION
|
49
|
+
_libdir = File.join(File.dirname(__FILE__), "..", "lib")
|
50
|
+
if (Dir.chdir(_libdir) { true } rescue false)
|
51
|
+
RUBY_LIB_LOCATION = _libdir
|
52
|
+
else
|
53
|
+
RUBY_LIB_LOCATION="/usr/lib/one/ruby"
|
54
|
+
end
|
55
|
+
else
|
56
|
+
RUBY_LIB_LOCATION=ONE_LOCATION+"/lib/ruby"
|
57
|
+
end
|
58
|
+
|
59
|
+
$: << RUBY_LIB_LOCATION
|
60
|
+
$: << RUBY_LIB_LOCATION+"/cloud"
|
61
|
+
|
62
|
+
require 'econe/EC2QueryClient'
|
63
|
+
require 'CloudClient'
|
64
|
+
require 'getoptlong'
|
65
|
+
require 'rdoc/usage'
|
66
|
+
require 'pp'
|
67
|
+
|
68
|
+
include CloudCLI
|
69
|
+
|
70
|
+
opts = GetoptLong.new(
|
71
|
+
['--help', '-h',GetoptLong::NO_ARGUMENT],
|
72
|
+
['--access-key', '-K',GetoptLong::REQUIRED_ARGUMENT],
|
73
|
+
['--secret-key', '-S',GetoptLong::REQUIRED_ARGUMENT],
|
74
|
+
['--url', '-U',GetoptLong::REQUIRED_ARGUMENT],
|
75
|
+
['--multipart', '-M',GetoptLong::NO_ARGUMENT]
|
76
|
+
)
|
77
|
+
|
78
|
+
url = nil
|
79
|
+
access = nil
|
80
|
+
secret = nil
|
81
|
+
auth = nil
|
82
|
+
curb = true
|
83
|
+
|
84
|
+
begin
|
85
|
+
opts.each do |opt, arg|
|
86
|
+
case opt
|
87
|
+
when '--help'
|
88
|
+
RDoc::usage
|
89
|
+
when '--access-key'
|
90
|
+
access = arg
|
91
|
+
when '--secret-key'
|
92
|
+
secret = arg
|
93
|
+
when '--url'
|
94
|
+
url = arg
|
95
|
+
when '--multipart'
|
96
|
+
curb = false
|
97
|
+
end
|
98
|
+
end
|
99
|
+
rescue Exception => e
|
100
|
+
exit -1
|
101
|
+
end
|
102
|
+
|
103
|
+
image = ARGV.shift
|
104
|
+
|
105
|
+
if !image || !File.exists?(image)
|
106
|
+
puts "#{cmd_name}: missing IMAGE-PATH parameter or file not found"
|
107
|
+
exit -1
|
108
|
+
end
|
109
|
+
|
110
|
+
auth = "#{access}:#{secret}" if secret && access
|
111
|
+
|
112
|
+
begin
|
113
|
+
ec2_client = EC2QueryClient::Client.new(auth,url)
|
114
|
+
rescue Exception => e
|
115
|
+
puts "#{cmd_name}: #{e.message}"
|
116
|
+
exit -1
|
117
|
+
end
|
118
|
+
|
119
|
+
rc = ec2_client.upload_image(image, curb)
|
120
|
+
|
121
|
+
if CloudClient::is_error?(rc)
|
122
|
+
puts "#{cmd_name}: #{rc.message}"
|
123
|
+
exit -1
|
124
|
+
end
|
125
|
+
|
126
|
+
puts "Success: ImageId #{rc['imageId']}"
|
127
|
+
|
128
|
+
exit 0
|
129
|
+
|
data/lib/CloudClient.rb
ADDED
@@ -0,0 +1,121 @@
|
|
1
|
+
# -------------------------------------------------------------------------- #
|
2
|
+
# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
|
3
|
+
# #
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
5
|
+
# not use this file except in compliance with the License. You may obtain #
|
6
|
+
# a copy of the License at #
|
7
|
+
# #
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0 #
|
9
|
+
# #
|
10
|
+
# Unless required by applicable law or agreed to in writing, software #
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS, #
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
|
13
|
+
# See the License for the specific language governing permissions and #
|
14
|
+
# limitations under the License. #
|
15
|
+
#--------------------------------------------------------------------------- #
|
16
|
+
|
17
|
+
require 'rubygems'
|
18
|
+
require 'uri'
|
19
|
+
|
20
|
+
require 'digest'
|
21
|
+
require 'net/https'
|
22
|
+
|
23
|
+
begin
|
24
|
+
require 'curb'
|
25
|
+
CURL_LOADED=true
|
26
|
+
rescue LoadError
|
27
|
+
CURL_LOADED=false
|
28
|
+
end
|
29
|
+
|
30
|
+
begin
|
31
|
+
require 'net/http/post/multipart'
|
32
|
+
rescue LoadError
|
33
|
+
end
|
34
|
+
|
35
|
+
###############################################################################
|
36
|
+
# The CloudClient module contains general functionality to implement a
|
37
|
+
# Cloud Client
|
38
|
+
###############################################################################
|
39
|
+
module CloudClient
|
40
|
+
# #########################################################################
|
41
|
+
# Default location for the authentication file
|
42
|
+
# #########################################################################
|
43
|
+
DEFAULT_AUTH_FILE = ENV["HOME"]+"/.one/one_auth"
|
44
|
+
|
45
|
+
# #########################################################################
|
46
|
+
# Gets authorization credentials from ONE_AUTH or default
|
47
|
+
# auth file.
|
48
|
+
#
|
49
|
+
# Raises an error if authorization is not found
|
50
|
+
# #########################################################################
|
51
|
+
def self.get_one_auth
|
52
|
+
if ENV["ONE_AUTH"] and !ENV["ONE_AUTH"].empty? and
|
53
|
+
File.file?(ENV["ONE_AUTH"])
|
54
|
+
one_auth=File.read(ENV["ONE_AUTH"]).strip.split(':')
|
55
|
+
elsif File.file?(DEFAULT_AUTH_FILE)
|
56
|
+
one_auth=File.read(DEFAULT_AUTH_FILE).strip.split(':')
|
57
|
+
else
|
58
|
+
raise "No authorization data present"
|
59
|
+
end
|
60
|
+
|
61
|
+
raise "Authorization data malformed" if one_auth.length < 2
|
62
|
+
|
63
|
+
one_auth
|
64
|
+
end
|
65
|
+
|
66
|
+
# #########################################################################
|
67
|
+
# Starts an http connection and calls the block provided. SSL flag
|
68
|
+
# is set if needed.
|
69
|
+
# #########################################################################
|
70
|
+
def self.http_start(url, &block)
|
71
|
+
http = Net::HTTP.new(url.host, url.port)
|
72
|
+
if url.scheme=='https'
|
73
|
+
http.use_ssl = true
|
74
|
+
http.verify_mode=OpenSSL::SSL::VERIFY_NONE
|
75
|
+
end
|
76
|
+
|
77
|
+
begin
|
78
|
+
http.start do |connection|
|
79
|
+
block.call(connection)
|
80
|
+
end
|
81
|
+
rescue Errno::ECONNREFUSED => e
|
82
|
+
str = "Error connecting to server (#{e.to_s})."
|
83
|
+
str << "Server: #{url.host}:#{url.port}"
|
84
|
+
|
85
|
+
return CloudClient::Error.new(str)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
# #########################################################################
|
90
|
+
# The Error Class represents a generic error in the Cloud Client
|
91
|
+
# library. It contains a readable representation of the error.
|
92
|
+
# #########################################################################
|
93
|
+
class Error
|
94
|
+
attr_reader :message
|
95
|
+
|
96
|
+
# +message+ a description of the error
|
97
|
+
def initialize(message=nil)
|
98
|
+
@message=message
|
99
|
+
end
|
100
|
+
|
101
|
+
def to_s()
|
102
|
+
@message
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
# #########################################################################
|
107
|
+
# Returns true if the object returned by a method of the OpenNebula
|
108
|
+
# library is an Error
|
109
|
+
# #########################################################################
|
110
|
+
def self.is_error?(value)
|
111
|
+
value.class==CloudClient::Error
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
# Command line help functions
|
116
|
+
module CloudCLI
|
117
|
+
# Returns the command name
|
118
|
+
def cmd_name
|
119
|
+
File.basename($0)
|
120
|
+
end
|
121
|
+
end
|
@@ -0,0 +1,219 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
# -------------------------------------------------------------------------- #
|
3
|
+
# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
|
4
|
+
# #
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
6
|
+
# not use this file except in compliance with the License. You may obtain #
|
7
|
+
# a copy of the License at #
|
8
|
+
# #
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0 #
|
10
|
+
# #
|
11
|
+
# Unless required by applicable law or agreed to in writing, software #
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS, #
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
|
14
|
+
# See the License for the specific language governing permissions and #
|
15
|
+
# limitations under the License. #
|
16
|
+
#--------------------------------------------------------------------------- #
|
17
|
+
|
18
|
+
$ec2url = ENV["ECONE_URL"] || File.open(File.dirname(__FILE__).join("econe.conf")).readlines.first rescue nil
|
19
|
+
puts "ec2url: >>#{$ec2url}<<"
|
20
|
+
|
21
|
+
require 'CloudClient'
|
22
|
+
require 'AWS'
|
23
|
+
|
24
|
+
module EC2QueryClient
|
25
|
+
##########################################################################
|
26
|
+
#
|
27
|
+
#
|
28
|
+
##########################################################################
|
29
|
+
class Client
|
30
|
+
|
31
|
+
API_VERSION = '2008-12-01'
|
32
|
+
|
33
|
+
######################################################################
|
34
|
+
#
|
35
|
+
#
|
36
|
+
######################################################################
|
37
|
+
def initialize(secret=nil, endpoint=nil)
|
38
|
+
# Autentication
|
39
|
+
ec2auth=nil
|
40
|
+
|
41
|
+
if secret
|
42
|
+
ec2auth = secret.split(':')
|
43
|
+
elsif ENV["ECONE_ACCESS_KEY"] and ENV["ECONE_SECRET_KEY"]
|
44
|
+
ec2auth = [ENV["ECONE_ACCESS_KEY"], ENV["ECONE_SECRET_KEY"]]
|
45
|
+
else
|
46
|
+
ec2auth=CloudClient::get_one_auth
|
47
|
+
end
|
48
|
+
|
49
|
+
if !ec2auth
|
50
|
+
raise "No authorization data present"
|
51
|
+
end
|
52
|
+
|
53
|
+
@access_key_id = ec2auth[0]
|
54
|
+
@access_key_secret = Digest::SHA1.hexdigest(ec2auth[1])
|
55
|
+
|
56
|
+
# Server location
|
57
|
+
|
58
|
+
if !endpoint
|
59
|
+
if $ec2url
|
60
|
+
endpoint = $ec2url
|
61
|
+
else
|
62
|
+
endpoint = "http://localhost:4567"
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
@uri = URI.parse(endpoint)
|
67
|
+
|
68
|
+
@ec2_connection = AWS::EC2::Base.new(
|
69
|
+
:access_key_id => @access_key_id,
|
70
|
+
:secret_access_key => @access_key_secret,
|
71
|
+
:server => @uri.host,
|
72
|
+
:port => @uri.port,
|
73
|
+
:use_ssl => @uri.scheme == 'https')
|
74
|
+
end
|
75
|
+
|
76
|
+
|
77
|
+
######################################################################
|
78
|
+
#
|
79
|
+
#
|
80
|
+
######################################################################
|
81
|
+
def describe_instances()
|
82
|
+
begin
|
83
|
+
response = @ec2_connection.describe_instances
|
84
|
+
rescue Exception => e
|
85
|
+
error = CloudClient::Error.new(e.message)
|
86
|
+
return error
|
87
|
+
end
|
88
|
+
|
89
|
+
return response
|
90
|
+
end
|
91
|
+
|
92
|
+
######################################################################
|
93
|
+
# :image_id
|
94
|
+
# :instance_type
|
95
|
+
######################################################################
|
96
|
+
def run_instances(ami_id, type)
|
97
|
+
begin
|
98
|
+
response = @ec2_connection.run_instances(
|
99
|
+
:image_id => ami_id,
|
100
|
+
:min_count => 1,
|
101
|
+
:max_count => 1,
|
102
|
+
:instance_type => type
|
103
|
+
)
|
104
|
+
rescue Exception => e
|
105
|
+
error = CloudClient::Error.new(e.message)
|
106
|
+
return error
|
107
|
+
end
|
108
|
+
|
109
|
+
return response
|
110
|
+
end
|
111
|
+
|
112
|
+
######################################################################
|
113
|
+
#
|
114
|
+
#
|
115
|
+
######################################################################
|
116
|
+
def terminate_instances(instance_id)
|
117
|
+
begin
|
118
|
+
response = @ec2_connection.terminate_instances(
|
119
|
+
:instance_id => instance_id
|
120
|
+
)
|
121
|
+
rescue Exception => e
|
122
|
+
error = CloudClient::Error.new(e.message)
|
123
|
+
return error
|
124
|
+
end
|
125
|
+
|
126
|
+
return response
|
127
|
+
end
|
128
|
+
|
129
|
+
######################################################################
|
130
|
+
#
|
131
|
+
# Returns true if HTTP code is 200,
|
132
|
+
######################################################################
|
133
|
+
def upload_image(file_name, curb=true)
|
134
|
+
params = { "Action" => "UploadImage",
|
135
|
+
"SignatureVersion" => "2",
|
136
|
+
"SignatureMethod" => 'HmacSHA1',
|
137
|
+
"AWSAccessKeyId" => @access_key_id,
|
138
|
+
"Version" => API_VERSION,
|
139
|
+
"Timestamp" => Time.now.getutc.iso8601 }
|
140
|
+
|
141
|
+
str = AWS.canonical_string(params, @uri.host)
|
142
|
+
sig = AWS.encode(@access_key_secret, str, false)
|
143
|
+
|
144
|
+
post_fields = Array.new;
|
145
|
+
|
146
|
+
if curb and CURL_LOADED
|
147
|
+
params.each { |k,v|
|
148
|
+
post_fields << Curl::PostField.content(k,v)
|
149
|
+
}
|
150
|
+
|
151
|
+
post_fields << Curl::PostField.content("Signature",sig)
|
152
|
+
post_fields << Curl::PostField.file("file",file_name)
|
153
|
+
|
154
|
+
connection = Curl::Easy.new(@uri.to_s)
|
155
|
+
connection.multipart_form_post = true
|
156
|
+
|
157
|
+
connection.http_post(*post_fields)
|
158
|
+
|
159
|
+
if connection.response_code == 200
|
160
|
+
return AWS::Response.parse(:xml => connection.body_str)
|
161
|
+
else
|
162
|
+
return CloudClient::Error.new(connection.body_str)
|
163
|
+
end
|
164
|
+
else
|
165
|
+
params["Signature"]=sig
|
166
|
+
|
167
|
+
file=File.open(file_name)
|
168
|
+
params["file"]=UploadIO.new(file,
|
169
|
+
'application/octet-stream', file_name)
|
170
|
+
|
171
|
+
req = Net::HTTP::Post::Multipart.new('/', params)
|
172
|
+
res = CloudClient.http_start(@uri) do |http|
|
173
|
+
http.request(req)
|
174
|
+
end
|
175
|
+
|
176
|
+
file.close
|
177
|
+
|
178
|
+
if res.code == '200'
|
179
|
+
return AWS::Response.parse(:xml => res.body)
|
180
|
+
else
|
181
|
+
return CloudClient::Error.new(res.body)
|
182
|
+
end
|
183
|
+
end
|
184
|
+
end
|
185
|
+
|
186
|
+
######################################################################
|
187
|
+
#
|
188
|
+
#
|
189
|
+
######################################################################
|
190
|
+
def register_image(image_id)
|
191
|
+
begin
|
192
|
+
response = @ec2_connection.register_image(
|
193
|
+
:image_location => image_id
|
194
|
+
)
|
195
|
+
rescue Exception => e
|
196
|
+
error = CloudClient::Error.new(e.message)
|
197
|
+
return error
|
198
|
+
end
|
199
|
+
|
200
|
+
return response
|
201
|
+
end
|
202
|
+
|
203
|
+
######################################################################
|
204
|
+
# :image_id --> ALL
|
205
|
+
# :owner_id --> mine (ALWAYS)
|
206
|
+
# :executable_by --> Always Public (NO ACLS)
|
207
|
+
######################################################################
|
208
|
+
def describe_images()
|
209
|
+
begin
|
210
|
+
response = @ec2_connection.describe_images
|
211
|
+
rescue Exception => e
|
212
|
+
error = CloudClient::Error.new(e.message)
|
213
|
+
return error
|
214
|
+
end
|
215
|
+
|
216
|
+
return response
|
217
|
+
end
|
218
|
+
end
|
219
|
+
end
|
metadata
ADDED
@@ -0,0 +1,106 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: econe
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 3
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 1
|
8
|
+
- 4
|
9
|
+
- 2
|
10
|
+
version: 1.4.2
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- cnoshpitz@attinteractive.com
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2010-05-20 00:00:00 -07:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: amazon-ec2
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 3
|
30
|
+
segments:
|
31
|
+
- 0
|
32
|
+
version: "0"
|
33
|
+
type: :runtime
|
34
|
+
version_requirements: *id001
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: multipart-post
|
37
|
+
prerelease: false
|
38
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
hash: 3
|
44
|
+
segments:
|
45
|
+
- 0
|
46
|
+
version: "0"
|
47
|
+
type: :runtime
|
48
|
+
version_requirements: *id002
|
49
|
+
description:
|
50
|
+
email:
|
51
|
+
executables:
|
52
|
+
- econe-describe-images
|
53
|
+
- econe-describe-instances
|
54
|
+
- econe-register
|
55
|
+
- econe-run-instances
|
56
|
+
- econe-terminate-instances
|
57
|
+
- econe-upload
|
58
|
+
extensions: []
|
59
|
+
|
60
|
+
extra_rdoc_files: []
|
61
|
+
|
62
|
+
files:
|
63
|
+
- lib/CloudClient.rb
|
64
|
+
- lib/econe/EC2QueryClient.rb
|
65
|
+
- bin/econe-describe-images
|
66
|
+
- bin/econe-describe-instances
|
67
|
+
- bin/econe-register
|
68
|
+
- bin/econe-run-instances
|
69
|
+
- bin/econe-terminate-instances
|
70
|
+
- bin/econe-upload
|
71
|
+
has_rdoc: true
|
72
|
+
homepage:
|
73
|
+
licenses: []
|
74
|
+
|
75
|
+
post_install_message:
|
76
|
+
rdoc_options: []
|
77
|
+
|
78
|
+
require_paths:
|
79
|
+
- lib
|
80
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ">="
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
hash: 3
|
86
|
+
segments:
|
87
|
+
- 0
|
88
|
+
version: "0"
|
89
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
90
|
+
none: false
|
91
|
+
requirements:
|
92
|
+
- - ">="
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
hash: 3
|
95
|
+
segments:
|
96
|
+
- 0
|
97
|
+
version: "0"
|
98
|
+
requirements: []
|
99
|
+
|
100
|
+
rubyforge_project:
|
101
|
+
rubygems_version: 1.3.7
|
102
|
+
signing_key:
|
103
|
+
specification_version: 3
|
104
|
+
summary: EC2-style CLI
|
105
|
+
test_files: []
|
106
|
+
|