deltacloud-client 0.0.9.2 → 0.0.9.3
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/deltacloudc +6 -7
- data/lib/deltacloud.rb +25 -14
- data/lib/plain_formatter.rb +1 -1
- metadata +3 -3
data/bin/deltacloudc
CHANGED
@@ -20,8 +20,8 @@
|
|
20
20
|
require 'rubygems'
|
21
21
|
require 'optparse'
|
22
22
|
require 'uri'
|
23
|
-
require 'lib/deltacloud'
|
24
|
-
require 'lib/plain_formatter'
|
23
|
+
require 'lib/deltacloud.rb'
|
24
|
+
require 'lib/plain_formatter.rb'
|
25
25
|
|
26
26
|
include DeltaCloud::PlainFormatter
|
27
27
|
|
@@ -80,8 +80,7 @@ collections.delete(:instance_states)
|
|
80
80
|
# with API documentation
|
81
81
|
if options[:list] and options[:collection].nil?
|
82
82
|
collections.each do |c|
|
83
|
-
|
84
|
-
puts sprintf("%-22s: %s", c.to_s[0, 22], doc[:description])
|
83
|
+
puts sprintf("%-22s", c.to_s[0, 22])
|
85
84
|
end
|
86
85
|
exit(0)
|
87
86
|
end
|
@@ -89,9 +88,9 @@ end
|
|
89
88
|
# If collection parameter is present and user requested list
|
90
89
|
# print all operation defined for collection with API documentation
|
91
90
|
if options[:list] and options[:collection]
|
92
|
-
doc = client.
|
93
|
-
doc
|
94
|
-
puts sprintf("%-20s: %s", c
|
91
|
+
doc = client.documentation(options[:collection])
|
92
|
+
doc.operations.each do |c|
|
93
|
+
puts sprintf("%-20s: %s", c.operation, c.description)
|
95
94
|
end
|
96
95
|
exit(0)
|
97
96
|
end
|
data/lib/deltacloud.rb
CHANGED
@@ -241,15 +241,15 @@ module DeltaCloud
|
|
241
241
|
declare_entry_points_methods(@entry_points)
|
242
242
|
end
|
243
243
|
|
244
|
-
def
|
244
|
+
def create_instance_credential(opts={}, &block)
|
245
245
|
params = { :name => opts[:name] }
|
246
|
-
|
247
|
-
request(:post, entry_points[:
|
248
|
-
c = DeltaCloud.define_class("
|
249
|
-
|
250
|
-
yield
|
246
|
+
instance_credential = nil
|
247
|
+
request(:post, entry_points[:instance_credentials], {}, params) do |response|
|
248
|
+
c = DeltaCloud.define_class("InstanceCredential")
|
249
|
+
instance_credential = base_object(c, :instance_credential, response)
|
250
|
+
yield instance_credential if block_given?
|
251
251
|
end
|
252
|
-
return
|
252
|
+
return instance_credential
|
253
253
|
end
|
254
254
|
|
255
255
|
# Create a new instance, using image +image_id+. Possible optiosn are
|
@@ -328,7 +328,7 @@ module DeltaCloud
|
|
328
328
|
|
329
329
|
# Check if specified collection have wanted feature
|
330
330
|
def feature?(collection, name)
|
331
|
-
@
|
331
|
+
@features.has_key?(collection) && @features[collection].include?(name)
|
332
332
|
end
|
333
333
|
|
334
334
|
# List available instance states and transitions between them
|
@@ -364,7 +364,8 @@ module DeltaCloud
|
|
364
364
|
request(:get, "/docs/#{collection}") do |body|
|
365
365
|
document = Nokogiri::XML(body)
|
366
366
|
if operation
|
367
|
-
data[:
|
367
|
+
data[:operation] = operation
|
368
|
+
data[:description] = document.xpath('/docs/collection/operations/operation[@name = "'+operation+'"]/description').first.text.strip
|
368
369
|
return false unless data[:description]
|
369
370
|
data[:params] = []
|
370
371
|
(document/"/docs/collection/operations/operation[@name='#{operation}']/parameter").each do |param|
|
@@ -376,9 +377,11 @@ module DeltaCloud
|
|
376
377
|
end
|
377
378
|
else
|
378
379
|
data[:description] = (document/'/docs/collection/description').text
|
380
|
+
data[:collection] = collection
|
381
|
+
data[:operations] = (document/"/docs/collection/operations/operation").collect{ |o| o['name'] }
|
379
382
|
end
|
380
383
|
end
|
381
|
-
return Documentation.new(data)
|
384
|
+
return Documentation.new(self, data)
|
382
385
|
end
|
383
386
|
|
384
387
|
private
|
@@ -393,15 +396,23 @@ module DeltaCloud
|
|
393
396
|
end
|
394
397
|
|
395
398
|
class Documentation
|
396
|
-
attr_reader :description
|
397
|
-
attr_reader :params
|
398
399
|
|
399
|
-
|
400
|
-
|
400
|
+
attr_reader :api, :description, :params, :collection_operations
|
401
|
+
attr_reader :collection, :operation
|
402
|
+
|
403
|
+
def initialize(api, opts={})
|
404
|
+
@description, @api = opts[:description], api
|
401
405
|
@params = parse_parameters(opts[:params]) if opts[:params]
|
406
|
+
@collection_operations = opts[:operations] if opts[:operations]
|
407
|
+
@collection = opts[:collection]
|
408
|
+
@operation = opts[:operation]
|
402
409
|
self
|
403
410
|
end
|
404
411
|
|
412
|
+
def operations
|
413
|
+
@collection_operations.collect { |o| api.documentation(@collection, o) }
|
414
|
+
end
|
415
|
+
|
405
416
|
class OperationParameter
|
406
417
|
attr_reader :name
|
407
418
|
attr_reader :type
|
data/lib/plain_formatter.rb
CHANGED
@@ -77,7 +77,7 @@ module DeltaCloud
|
|
77
77
|
end
|
78
78
|
|
79
79
|
def format(obj)
|
80
|
-
object_name = obj.class.name.classify.gsub(/^DeltaCloud::/, '')
|
80
|
+
object_name = obj.class.name.classify.gsub(/^DeltaCloud::API::/, '')
|
81
81
|
format_class = DeltaCloud::PlainFormatter::FormatObject.const_get(object_name)
|
82
82
|
format_class.new(obj).format
|
83
83
|
end
|
metadata
CHANGED
@@ -6,8 +6,8 @@ version: !ruby/object:Gem::Version
|
|
6
6
|
- 0
|
7
7
|
- 0
|
8
8
|
- 9
|
9
|
-
-
|
10
|
-
version: 0.0.9.
|
9
|
+
- 3
|
10
|
+
version: 0.0.9.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Red Hat, Inc.
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-08-
|
18
|
+
date: 2010-08-11 00:00:00 +02:00
|
19
19
|
default_executable: deltacloudc
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|