abiquo-etk 0.5.8 → 0.5.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (27) hide show
  1. data/VERSION +1 -1
  2. data/lib/abicli/commands/remote-services-settings.rb +0 -2
  3. data/lib/abicli/commands/server-settings.rb +0 -2
  4. data/lib/abicli/commands/set.rb +0 -2
  5. data/lib/abicli/commands/set18.ext +0 -1
  6. data/lib/abicli/commands/upload-template.rb +2 -2
  7. metadata +100 -82
  8. data/vendor/api_ruby_client/Gemfile +0 -10
  9. data/vendor/api_ruby_client/LICENSE +0 -20
  10. data/vendor/api_ruby_client/README +0 -39
  11. data/vendor/api_ruby_client/Rakefile +0 -89
  12. data/vendor/api_ruby_client/abiquo.gemspec +0 -43
  13. data/vendor/api_ruby_client/examples/create_dc_and_hv.rb +0 -38
  14. data/vendor/api_ruby_client/examples/hypervisor_resource.rb +0 -16
  15. data/vendor/api_ruby_client/examples/rack_resource.rb +0 -38
  16. data/vendor/api_ruby_client/lib/abiquo.rb +0 -201
  17. data/vendor/api_ruby_client/lib/core_ext.rb +0 -28
  18. data/vendor/api_ruby_client/lib/to_xml.rb +0 -22
  19. data/vendor/api_ruby_client/spec/acceptance/create_resource_spec.rb +0 -43
  20. data/vendor/api_ruby_client/spec/acceptance/delete_resource_spec.rb +0 -27
  21. data/vendor/api_ruby_client/spec/acceptance/fetch_resource_collections_spec.rb +0 -55
  22. data/vendor/api_ruby_client/spec/acceptance/fetch_single_resources_spec.rb +0 -47
  23. data/vendor/api_ruby_client/spec/acceptance/from_xml_spec.rb +0 -15
  24. data/vendor/api_ruby_client/spec/acceptance/navigate_linked_resources_spec.rb +0 -61
  25. data/vendor/api_ruby_client/spec/acceptance/update_resource_spec.rb +0 -26
  26. data/vendor/api_ruby_client/spec/spec_helper.rb +0 -32
  27. data/vendor/api_ruby_client/spec/unit/to_xml_spec.rb +0 -56
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.8
1
+ 0.5.9
@@ -11,8 +11,6 @@ if ARGV[0] == 'remote-services-settings'
11
11
  load File.dirname(__FILE__) + "/remote-services-settings16.ext"
12
12
  elsif rel_info =~ /Version: 1\.8/
13
13
  load File.dirname(__FILE__) + "/remote-services-settings18.ext"
14
- elsif rel_info =~ /Version: 2\.0/
15
- load File.dirname(__FILE__) + "/remote-services-settings18.ext"
16
14
  else
17
15
  $stderr.puts "Abiquo release version not found. Unsupported installation."
18
16
  exit
@@ -11,8 +11,6 @@ if ARGV[0] == 'server-settings'
11
11
  load File.dirname(__FILE__) + "/server-settings168.ext"
12
12
  elsif rel_info =~ /Version: 1\.8/
13
13
  load File.dirname(__FILE__) + "/server-settings18.ext"
14
- elsif rel_info =~ /Version: 2\.0/
15
- load File.dirname(__FILE__) + "/server-settings18.ext"
16
14
  else
17
15
  $stderr.puts "Abiquo release version not found. Unsupported installation."
18
16
  exit
@@ -12,8 +12,6 @@ if ARGV[0] == 'set'
12
12
  load File.dirname(__FILE__) + "/set168.ext"
13
13
  elsif rel_info =~ /Version: 1\.8/
14
14
  load File.dirname(__FILE__) + "/set18.ext"
15
- elsif rel_info =~ /Version: 2\.0/
16
- load File.dirname(__FILE__) + "/set18.ext"
17
15
  else
18
16
  $stderr.puts "Abiquo release version not found. Unsupported installation."
19
17
  exit
@@ -73,7 +73,6 @@ def set_nfs_repository(val)
73
73
  config.save('/opt/abiquo/config/abiquo.properties.bak')
74
74
  config['remote-services']['abiquo.appliancemanager.repositoryLocation'] = val
75
75
  config['remote-services']['abiquo.virtualfactory.xenserver.repositoryLocation'] = val
76
- config['remote-services']['abiquo.virtualfactory.vmware.repositoryLocation'] = val
77
76
  config.save('/opt/abiquo/config/abiquo.properties')
78
77
  end
79
78
 
@@ -281,14 +281,14 @@ json = """{'ovfPackageInstanceDto':{
281
281
  json.gsub!("'",'"')
282
282
  $stdout.sync = true
283
283
  line_reset = "\r\e[0K"
284
- rsurl = "#{cli.config[:rs_url]}/am/erepos/#{cli.config[:enterprise_id]}/ovfs"
284
+ rsurl = "#{cli.config[:rs_url]}/am/erepos/#{cli.config[:enterprise_id]}/templates"
285
285
  if cli.config[:debug]
286
286
  puts "Upload URL: #{rsurl}"
287
287
  puts "JSON sent:\n#{json}"
288
288
  end
289
289
  StreamingUploader.post(
290
290
  rsurl,
291
- { :ovfpackageinstance => json, :diskFile => fo }
291
+ { :aovfpackageinstance => json, :diskFile => fo }
292
292
  ) do |size|
293
293
  count += size
294
294
  per = (100*count)/fsize
metadata CHANGED
@@ -1,84 +1,112 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: abiquo-etk
3
- version: !ruby/object:Gem::Version
4
- version: 0.5.8
3
+ version: !ruby/object:Gem::Version
4
+ hash: 25
5
5
  prerelease:
6
+ segments:
7
+ - 0
8
+ - 5
9
+ - 9
10
+ version: 0.5.9
6
11
  platform: ruby
7
- authors:
12
+ authors:
8
13
  - Sergio Rubio
9
14
  autorequire:
10
15
  bindir: bin
11
16
  cert_chain: []
12
- date: 2012-02-09 00:00:00.000000000 Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
17
+
18
+ date: 2012-04-10 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
15
21
  name: nokogiri
16
- requirement: &17225360 !ruby/object:Gem::Requirement
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
17
24
  none: false
18
- requirements:
19
- - - ! '>='
20
- - !ruby/object:Gem::Version
21
- version: '1.3'
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ hash: 9
29
+ segments:
30
+ - 1
31
+ - 3
32
+ version: "1.3"
22
33
  type: :runtime
23
- prerelease: false
24
- version_requirements: *17225360
25
- - !ruby/object:Gem::Dependency
34
+ version_requirements: *id001
35
+ - !ruby/object:Gem::Dependency
26
36
  name: rpm-utils
27
- requirement: &17223840 !ruby/object:Gem::Requirement
37
+ prerelease: false
38
+ requirement: &id002 !ruby/object:Gem::Requirement
28
39
  none: false
29
- requirements:
30
- - - ! '>='
31
- - !ruby/object:Gem::Version
32
- version: '0.1'
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ hash: 9
44
+ segments:
45
+ - 0
46
+ - 1
47
+ version: "0.1"
33
48
  type: :runtime
34
- prerelease: false
35
- version_requirements: *17223840
36
- - !ruby/object:Gem::Dependency
49
+ version_requirements: *id002
50
+ - !ruby/object:Gem::Dependency
37
51
  name: term-ansicolor
38
- requirement: &17236700 !ruby/object:Gem::Requirement
52
+ prerelease: false
53
+ requirement: &id003 !ruby/object:Gem::Requirement
39
54
  none: false
40
- requirements:
41
- - - ! '>='
42
- - !ruby/object:Gem::Version
43
- version: '1.0'
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ hash: 15
59
+ segments:
60
+ - 1
61
+ - 0
62
+ version: "1.0"
44
63
  type: :runtime
45
- prerelease: false
46
- version_requirements: *17236700
47
- - !ruby/object:Gem::Dependency
64
+ version_requirements: *id003
65
+ - !ruby/object:Gem::Dependency
48
66
  name: mixlib-cli
49
- requirement: &17234440 !ruby/object:Gem::Requirement
67
+ prerelease: false
68
+ requirement: &id004 !ruby/object:Gem::Requirement
50
69
  none: false
51
- requirements:
52
- - - ! '>='
53
- - !ruby/object:Gem::Version
54
- version: '1.2'
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ hash: 11
74
+ segments:
75
+ - 1
76
+ - 2
77
+ version: "1.2"
55
78
  type: :runtime
56
- prerelease: false
57
- version_requirements: *17234440
58
- - !ruby/object:Gem::Dependency
79
+ version_requirements: *id004
80
+ - !ruby/object:Gem::Dependency
59
81
  name: iniparse
60
- requirement: &17247160 !ruby/object:Gem::Requirement
82
+ prerelease: false
83
+ requirement: &id005 !ruby/object:Gem::Requirement
61
84
  none: false
62
- requirements:
63
- - - ! '>='
64
- - !ruby/object:Gem::Version
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ hash: 27
89
+ segments:
90
+ - 1
91
+ - 1
92
+ - 4
65
93
  version: 1.1.4
66
94
  type: :runtime
67
- prerelease: false
68
- version_requirements: *17247160
95
+ version_requirements: *id005
69
96
  description: Tools to troubleshoot and manage your Abiquo installation
70
97
  email: srubio@abiquo.com
71
- executables:
72
- - abicli
73
- - abiquo-check-16-install
98
+ executables:
74
99
  - abiquo-check-install
100
+ - abicli
75
101
  - ciab-setup
102
+ - abiquo-check-16-install
76
103
  extensions: []
77
- extra_rdoc_files:
104
+
105
+ extra_rdoc_files:
78
106
  - LICENSE
79
107
  - README.rdoc
80
108
  - TODO
81
- files:
109
+ files:
82
110
  - .document
83
111
  - LICENSE
84
112
  - README.rdoc
@@ -538,26 +566,6 @@ files:
538
566
  - vendor/addressable-2.2.1/tasks/spec.rake
539
567
  - vendor/addressable-2.2.1/tasks/yard.rake
540
568
  - vendor/addressable-2.2.1/website/index.html
541
- - vendor/api_ruby_client/Gemfile
542
- - vendor/api_ruby_client/LICENSE
543
- - vendor/api_ruby_client/README
544
- - vendor/api_ruby_client/Rakefile
545
- - vendor/api_ruby_client/abiquo.gemspec
546
- - vendor/api_ruby_client/examples/create_dc_and_hv.rb
547
- - vendor/api_ruby_client/examples/hypervisor_resource.rb
548
- - vendor/api_ruby_client/examples/rack_resource.rb
549
- - vendor/api_ruby_client/lib/abiquo.rb
550
- - vendor/api_ruby_client/lib/core_ext.rb
551
- - vendor/api_ruby_client/lib/to_xml.rb
552
- - vendor/api_ruby_client/spec/acceptance/create_resource_spec.rb
553
- - vendor/api_ruby_client/spec/acceptance/delete_resource_spec.rb
554
- - vendor/api_ruby_client/spec/acceptance/fetch_resource_collections_spec.rb
555
- - vendor/api_ruby_client/spec/acceptance/fetch_single_resources_spec.rb
556
- - vendor/api_ruby_client/spec/acceptance/from_xml_spec.rb
557
- - vendor/api_ruby_client/spec/acceptance/navigate_linked_resources_spec.rb
558
- - vendor/api_ruby_client/spec/acceptance/update_resource_spec.rb
559
- - vendor/api_ruby_client/spec/spec_helper.rb
560
- - vendor/api_ruby_client/spec/unit/to_xml_spec.rb
561
569
  - vendor/fattr-2.1.0/README
562
570
  - vendor/fattr-2.1.0/README.erb
563
571
  - vendor/fattr-2.1.0/Rakefile
@@ -639,26 +647,36 @@ files:
639
647
  - vendor/resourceful-1.0.1/spec/spec_helper.rb
640
648
  homepage: http://github.com/abiquo/abiquo-etk
641
649
  licenses: []
650
+
642
651
  post_install_message:
643
652
  rdoc_options: []
644
- require_paths:
653
+
654
+ require_paths:
645
655
  - lib
646
- required_ruby_version: !ruby/object:Gem::Requirement
656
+ required_ruby_version: !ruby/object:Gem::Requirement
647
657
  none: false
648
- requirements:
649
- - - ! '>='
650
- - !ruby/object:Gem::Version
651
- version: '0'
652
- required_rubygems_version: !ruby/object:Gem::Requirement
658
+ requirements:
659
+ - - ">="
660
+ - !ruby/object:Gem::Version
661
+ hash: 3
662
+ segments:
663
+ - 0
664
+ version: "0"
665
+ required_rubygems_version: !ruby/object:Gem::Requirement
653
666
  none: false
654
- requirements:
655
- - - ! '>='
656
- - !ruby/object:Gem::Version
657
- version: '0'
667
+ requirements:
668
+ - - ">="
669
+ - !ruby/object:Gem::Version
670
+ hash: 3
671
+ segments:
672
+ - 0
673
+ version: "0"
658
674
  requirements: []
675
+
659
676
  rubyforge_project:
660
- rubygems_version: 1.8.10
677
+ rubygems_version: 1.8.17
661
678
  signing_key:
662
679
  specification_version: 3
663
680
  summary: Abiquo Elite Toolkit
664
681
  test_files: []
682
+
@@ -1,10 +0,0 @@
1
- source "http://rubygems.org"
2
-
3
- gem 'resourceful'
4
- gem 'nokogiri'
5
- gem 'activesupport'
6
-
7
- group :test do
8
- gem 'steak'
9
- gem 'webmock'
10
- end
@@ -1,20 +0,0 @@
1
- Copyright (c) 2010 Abiquo Holdings
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining
4
- a copy of this software and associated documentation files (the
5
- "Software"), to deal in the Software without restriction, including
6
- without limitation the rights to use, copy, modify, merge, publish,
7
- distribute, sublicense, and/or sell copies of the Software, and to
8
- permit persons to whom the Software is furnished to do so, subject to
9
- the following conditions:
10
-
11
- The above copyright notice and this permission notice shall be
12
- included in all copies or substantial portions of the Software.
13
-
14
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -1,39 +0,0 @@
1
- =Abiquo API Ruby client
2
-
3
- Rest client to work with the Abiquo's API.
4
-
5
- ==Installation
6
-
7
- gem install abiquo
8
-
9
- ==Usage
10
-
11
- The first version of the api just uses basic authentication, so we need to create an instance with our credentials:
12
-
13
- auth = Abiquo::BasicAuth.new('Abiquo', 'username', 'password')
14
-
15
- The entry point for the Abiquo's API is an atom document service:
16
-
17
- api = Abiquo::Resource('http://abiquo.example.com/api', auth)
18
-
19
- from this point we can access to every resource exposed by the api calling nested methods:
20
-
21
- datacenters = api.datacenters
22
- racks = api.datacenters.first.racks
23
-
24
- or get the values of their elements:
25
-
26
- datacenter = api.datacenters.first
27
- datacenter.name # => The name of the datacenter
28
-
29
- You can find further example into the specs:
30
-
31
- http://github.com/abiquo/api_ruby_client/tree/master/spec/acceptance
32
-
33
- Further documentation of the API can be found in our wiki:
34
-
35
- http://abicloud.org/display/ABI16/Abiquo's+API
36
-
37
- ==Copyright
38
-
39
- Copyright (c) 2010 Abiquo Holdings. See LICENSE for details.
@@ -1,89 +0,0 @@
1
- require "rubygems"
2
- require "rake/gempackagetask"
3
- require "rake/rdoctask"
4
-
5
- require "spec"
6
- require "spec/rake/spectask"
7
-
8
- desc "Run acceptance specs"
9
- Spec::Rake::SpecTask.new("spec:acceptance") do |t|
10
- t.spec_opts = "--format specdoc --colour".split
11
- t.spec_files = ["spec/acceptance"]
12
- end
13
-
14
- desc "Run unit specs"
15
- Spec::Rake::SpecTask.new("spec:unit") do |t|
16
- t.spec_files = ["spec/unit"]
17
- end
18
-
19
- desc "Run all specs"
20
- task :spec => ["spec:unit", "spec:acceptance"]
21
-
22
- task :default => ["spec"]
23
-
24
- # This builds the actual gem. For details of what all these options
25
- # mean, and other ones you can add, check the documentation here:
26
- #
27
- # http://rubygems.org/read/chapter/20
28
- #
29
- spec = Gem::Specification.new do |s|
30
-
31
- # Change these as appropriate
32
- s.name = "abiquo"
33
- s.version = "0.1.0"
34
- s.summary = "Abiquo API client"
35
- s.author = "Abiquo"
36
- s.email = "support@abiquo.com"
37
- s.homepage = "http://github.com/abiquo/api_ruby_client"
38
-
39
- s.has_rdoc = true
40
- # You should probably have a README of some kind. Change the filename
41
- # as appropriate
42
- s.extra_rdoc_files = %w(README)
43
- s.rdoc_options = %w(--main README)
44
-
45
- # Add any extra files to include in the gem (like your README)
46
- s.files = %w() + Dir.glob("{lib/**/*}")
47
- s.require_paths = ["lib"]
48
-
49
- # If you want to depend on other gems, add them here, along with any
50
- # relevant versions
51
- s.add_dependency("resourceful")
52
- s.add_dependency("nokogiri")
53
- s.add_dependency("activesupport") # for to_xml, singularize, delegate, & try, should we implement them?
54
-
55
- # If your tests use any gems, include them here
56
- s.add_development_dependency("steak")
57
- s.add_development_dependency("webmock")
58
- end
59
-
60
- # This task actually builds the gem. We also regenerate a static
61
- # .gemspec file, which is useful if something (i.e. GitHub) will
62
- # be automatically building a gem for this project. If you're not
63
- # using GitHub, edit as appropriate.
64
- #
65
- # To publish your gem online, install the 'gemcutter' gem; Read more
66
- # about that here: http://gemcutter.org/pages/gem_docs
67
- Rake::GemPackageTask.new(spec) do |pkg|
68
- pkg.gem_spec = spec
69
- end
70
-
71
- desc "Build the gemspec file #{spec.name}.gemspec"
72
- task :gemspec do
73
- file = File.dirname(__FILE__) + "/#{spec.name}.gemspec"
74
- File.open(file, "w") {|f| f << spec.to_ruby }
75
- end
76
-
77
- task :package => :gemspec
78
-
79
- # Generate documentation
80
- Rake::RDocTask.new do |rd|
81
-
82
- rd.rdoc_files.include("lib/**/*.rb", "README.rdoc")
83
- rd.rdoc_dir = "rdoc"
84
- end
85
-
86
- desc 'Clear out RDoc and generated packages'
87
- task :clean => [:clobber_rdoc, :clobber_package] do
88
- rm "#{spec.name}.gemspec"
89
- end
@@ -1,43 +0,0 @@
1
- # -*- encoding: utf-8 -*-
2
-
3
- Gem::Specification.new do |s|
4
- s.name = %q{abiquo}
5
- s.version = "0.1.0"
6
-
7
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
- s.authors = ["Abiquo"]
9
- s.date = %q{2010-07-28}
10
- s.email = %q{support@abiquo.com}
11
- s.extra_rdoc_files = ["README.rdoc"]
12
- s.files = ["lib/to_xml.rb", "lib/core_ext.rb", "lib/abiquo.rb", "README.rdoc"]
13
- s.homepage = %q{http://wiki.github.com/abiquo/abiquo/}
14
- s.rdoc_options = ["--main", "README.rdoc"]
15
- s.require_paths = ["lib"]
16
- s.rubygems_version = %q{1.3.6}
17
- s.summary = %q{Abiquo API client}
18
-
19
- if s.respond_to? :specification_version then
20
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
21
- s.specification_version = 3
22
-
23
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
24
- s.add_runtime_dependency(%q<resourceful>, [">= 0"])
25
- s.add_runtime_dependency(%q<nokogiri>, [">= 0"])
26
- s.add_runtime_dependency(%q<activesupport>, [">= 0"])
27
- s.add_development_dependency(%q<steak>, [">= 0"])
28
- s.add_development_dependency(%q<webmock>, [">= 0"])
29
- else
30
- s.add_dependency(%q<resourceful>, [">= 0"])
31
- s.add_dependency(%q<nokogiri>, [">= 0"])
32
- s.add_dependency(%q<activesupport>, [">= 0"])
33
- s.add_dependency(%q<steak>, [">= 0"])
34
- s.add_dependency(%q<webmock>, [">= 0"])
35
- end
36
- else
37
- s.add_dependency(%q<resourceful>, [">= 0"])
38
- s.add_dependency(%q<nokogiri>, [">= 0"])
39
- s.add_dependency(%q<activesupport>, [">= 0"])
40
- s.add_dependency(%q<steak>, [">= 0"])
41
- s.add_dependency(%q<webmock>, [">= 0"])
42
- end
43
- end
@@ -1,38 +0,0 @@
1
- require 'rubygems'
2
- require 'abiquo'
3
- require 'pp'
4
-
5
- auth = Abiquo::BasicAuth.new('Abiquo', 'admin', 'xabiquo')
6
- api = Abiquo::Resource('http://abiquo-server-ip:8080/api', auth)
7
-
8
-
9
- #
10
- # Create a DataCenter
11
- #
12
- #puts "Creating DC1 in BCN..."
13
- api.datacenters.create :name => 'DC1', :location => 'BCN'
14
-
15
- #
16
- # Create Remote Services
17
- #
18
- api.datacenters.first.remoteServices.create :type => 'VIRTUAL_FACTORY', :uri => 'http://localhost:8080/virtualfactory'
19
- api.datacenters.first.remoteServices.create :type => 'STORAGE_SYSTEM_MONITOR', :uri => 'http://localhost:8080/ssm'
20
- api.datacenters.first.remoteServices.create :type => 'VIRTUAL_SYSTEM_MONITOR', :uri => 'http://localhost:8080/vsm'
21
- api.datacenters.first.remoteServices.create :type => 'NODE_COLLECTOR', :uri => 'http://localhost:8080/nodecollector'
22
- api.datacenters.first.remoteServices.create :type => 'APPLIANCE_MANAGER', :uri => 'http://localhost:8080/am'
23
- api.datacenters.first.remoteServices.create :type => 'DHCP_SERVICE', :uri => 'http://localhost:7911'
24
- api.datacenters.first.remoteServices.create :type => 'BPM_SERVICE', :uri => 'http://localhost:7911'
25
-
26
- #
27
- # Create a new Rack
28
- #
29
- puts "Creating rack 'myrack01'..."
30
- api.datacenters.first.racks.create :name => 'myrack01'
31
-
32
- #
33
- # Iterate over all the racks and print the rack name
34
- #
35
- puts "Listing racks.."
36
- api.datacenters.first.racks.each do |rack|
37
- pp rack.name
38
- end
@@ -1,16 +0,0 @@
1
- require 'rubygems'
2
- require 'abiquo'
3
- require 'pp'
4
-
5
- auth = Abiquo::BasicAuth.new('Abiquo', 'admin', 'admin')
6
- api = Abiquo::Resource('http://as-testing.bcn.abiquo.com:8080/api', auth)
7
-
8
- #
9
- # Iterate over all the racks and print the rack name and the hypervisors underneath
10
- #
11
- api.datacenters.first.racks.each do |rack|
12
- puts "- RACK [#{rack.name}]"
13
- rack.machines.each do |m|
14
- puts "---" + m.name
15
- end
16
- end
@@ -1,38 +0,0 @@
1
- require 'rubygems'
2
- require 'abiquo'
3
- require 'pp'
4
-
5
- auth = Abiquo::BasicAuth.new('Abiquo', 'admin', 'admin')
6
- api = Abiquo::Resource('http://as-testing.bcn.abiquo.com:8080/api', auth)
7
-
8
- #
9
- # Create a new Rack
10
- #
11
- puts "Creating rack 'myrack01'..."
12
- api.datacenters.first.racks.create :name => 'myrack01'
13
-
14
- #
15
- # Iterate over all the racks and print the rack name
16
- #
17
- puts "Listing racks.."
18
- api.datacenters.first.racks.each do |rack|
19
- pp rack.name
20
- end
21
-
22
- #
23
- # Iterate over all the racks and print the rack name
24
- #
25
- puts "Listing racks..."
26
- api.datacenters.first.racks.each do |rack|
27
- pp rack.name
28
- end
29
-
30
- #
31
- # Delete the rack myrack01
32
- #
33
- # NOT SUPPORTED IN ABIQUO1.6
34
- #
35
- #puts "Deleting rack 'myrack01'..."
36
- #api.datacenters.first.racks.each do |r|
37
- # r.delete if r.name == 'myrack01'
38
- #end
@@ -1,201 +0,0 @@
1
- require 'resourceful'
2
- require 'nokogiri'
3
- #gem 'activesupport', '2.3.8'
4
- require 'active_support'
5
- require File.expand_path('../core_ext', __FILE__)
6
- require File.expand_path('../to_xml', __FILE__)
7
- require 'uri'
8
-
9
- module Abiquo
10
-
11
- class NotAllowed < RuntimeError
12
- def initialize(method, url)
13
- @method = method
14
- @url = url
15
- end
16
-
17
- def message
18
- "Method #{@method} not allowed for #{@url}"
19
- end
20
- end
21
-
22
- class BasicAuth < Resourceful::BasicAuthenticator
23
- def can_handle?(request); true; end
24
- end
25
-
26
- module HttpAccessor
27
-
28
- def xml
29
- @xml ||= begin
30
- response = http.resource(url_with_params).get
31
- Nokogiri.parse(response.body).root
32
- end
33
- end
34
-
35
- private
36
-
37
- def url_with_params
38
- @options[:expand] = @options[:expand].join(",") if @options[:expand].is_a?(Array)
39
- params = @options.map { |k, v| "#{k}=#{v}" }.join("&")
40
- params = "?#{params}" unless params.empty?
41
- @url + params
42
- end
43
-
44
- def http
45
- Resourceful::HttpAccessor.new(:authenticator => @auth)
46
- end
47
-
48
- def rest_options
49
- @rest_options ||= begin
50
- response = http.resource(@url).options
51
- response.header['Allow'].map {|m| m.to_sym }
52
- end
53
- end
54
-
55
- end
56
-
57
- class SingleResource
58
-
59
- include HttpAccessor
60
-
61
- undef id
62
-
63
- def initialize(url, auth, xml = nil, options = {})
64
- @url = url
65
- @auth = auth
66
- @xml = xml
67
- @options = options
68
- end
69
-
70
- def update(attrs = {})
71
- raise Abiquo::NotAllowed.new(:PUT, url) unless rest_options.include?(:PUT)
72
- response = http.resource(url).put(attrs.to_xml(:root => object_type), :content_type => "application/xml")
73
- @xml = Nokogiri.parse(response.body).root
74
- end
75
-
76
- def delete
77
- raise Abiquo::NotAllowed.new(:DELETE, url) unless rest_options.include?(:DELETE)
78
- http.resource(url).delete
79
- end
80
-
81
- def url
82
- @url ||= xml.at_xpath("./link[@rel='edit']").try(:[], "href")
83
- end
84
-
85
- delegate :to_xml, :to => :xml
86
- alias_method :inspect, :to_xml
87
-
88
- private
89
-
90
- def object_type
91
- @object_type ||= URI.parse(url).path.split("/")[-2].singularize
92
- end
93
-
94
- def method_missing(meth, *args, &blk)
95
- attribute = xml.at_xpath("./*[name()='#{meth}' or name()='#{attribute_name(meth)}']")
96
- return node_text(attribute) if attribute
97
-
98
- link = xml.at_xpath("./link[@rel='#{meth}' or @rel='#{attribute_name(meth)}']")
99
- return Resource.new(link["href"], @auth, link.at_xpath("./*"), *args) if link
100
-
101
- if xml.namespaces.has_key?('xmlns:ns2')
102
- @xml = Nokogiri.parse(xml.to_s.downcase).root
103
- link = xml.at_xpath("//ns2:collection/xmlns:title[. = '#{meth}']").try(:parent)
104
- return Resource.new(link['href'], @auth, nil, *args) if link
105
- end
106
-
107
- super
108
- end
109
-
110
- def node_text(node)
111
- node.text
112
- end
113
-
114
- def attribute_name(attribute)
115
- attribute.to_s.gsub('_', '-')
116
- end
117
-
118
- end
119
-
120
- class ResourceCollection
121
-
122
- include HttpAccessor
123
-
124
- delegate :inspect, :to => :resources
125
-
126
- def initialize(url, auth, xml = nil, options = {})
127
- @url = url
128
- @auth = auth
129
- @xml = xml if options.empty?
130
- @options = options
131
- end
132
-
133
- def create(attrs = {})
134
- raise Abiquo::NotAllowed.new(:POST, url) unless rest_options.include?(:POST)
135
- response = http.resource(url_with_params).post(attrs.to_xml(:root => object_type, :convert_links => true), :content_type => "application/xml")
136
- Resource.new(nil, @auth, Nokogiri.parse(response.body).root)
137
- end
138
-
139
- private
140
-
141
- def object_type
142
- @object_type ||= URI.parse(@url).path.split("/").last.singularize
143
- end
144
-
145
- def resources
146
- @resources ||= xml.xpath("./*").map { |subnode| Resource.new(subnode.at_xpath("./link[@rel='edit']").try(:[], "href"), @auth, subnode, @options) }
147
- end
148
-
149
- def method_missing(meth, *args, &blk)
150
- resources.send(meth, *args, &blk)
151
- end
152
- end
153
-
154
- class Resource
155
-
156
- include HttpAccessor
157
-
158
- undef id
159
- undef type
160
-
161
- delegate :inspect, :to => :get!
162
-
163
- def self.from_xml(xml, auth = nil)
164
- new(nil, auth, Nokogiri.parse(xml).root)
165
- end
166
-
167
- def initialize(url, auth, xml = nil, options = {})
168
- @url = url
169
- @auth = auth
170
- @xml = xml
171
- @options = options
172
- end
173
-
174
- def method_missing(meth, *args, &blk)
175
- @resource_object ||= resource_class(meth).new(@url, @auth, @xml, @options)
176
- @resource_object.send(meth, *args, &blk)
177
- end
178
-
179
- def resource_class(meth)
180
- @resource_class ||= if (Array.instance_methods + ["create"] - ["delete", "id"]).include?(meth.to_s)
181
- ResourceCollection
182
- else
183
- SingleResource
184
- end
185
- end
186
-
187
- def get!
188
- klass = SingleResource
189
- if (!xml.children.empty? && xml.name.singularize == xml.children.first.name)
190
- klass = ResourceCollection
191
- end
192
- @resource_object = klass.new(@url, @auth, @xml, @options)
193
- end
194
-
195
- end
196
-
197
- def self.Resource(url, auth, params = {})
198
- Resource.new(url, auth, nil, params)
199
- end
200
-
201
- end
@@ -1,28 +0,0 @@
1
- require 'net/http'
2
-
3
- module Resourceful
4
- class Resource
5
- def options(header = {})
6
- request(:options, nil, header)
7
- end
8
-
9
- def host_with_port
10
- add = Addressable::URI.parse(uri)
11
- !add.port.blank? && add.port != 80 ? [add.host, add.port].join(':') : add.host
12
- end
13
-
14
- alias_method_chain :host, :port
15
- end
16
-
17
- class NetHttpAdapter
18
- def net_http_request_class_with_options(method)
19
- if method == :options
20
- Net::HTTP::Options
21
- else
22
- net_http_request_class_without_options(method)
23
- end
24
- end
25
-
26
- alias_method_chain :net_http_request_class, :options
27
- end
28
- end
@@ -1,22 +0,0 @@
1
- module Abiquo
2
-
3
- module ToXml
4
-
5
- def to_xml_with_links(options = {})
6
- if options[:convert_links] && options[:builder]
7
- options[:builder].tag!(:link, :rel => options[:root]) do
8
- to_xml_without_links(options)
9
- end
10
- else
11
- to_xml_without_links(options)
12
- end
13
- end
14
-
15
- end
16
-
17
- end
18
-
19
- class Array
20
- include Abiquo::ToXml
21
- alias_method_chain :to_xml, :links
22
- end
@@ -1,43 +0,0 @@
1
- require 'spec_helper'
2
-
3
- feature "Creating new resources" do
4
-
5
- scenario "Creating a resource in a collection" do
6
-
7
- datacenters = Abiquo::Resource("http://abiquo.example.com/api/admin/datacenters", auth)
8
-
9
- stub_auth_request(:options, "http://admin:admin@abiquo.example.com/api/admin/datacenters").
10
- to_return(:headers => {'Allow' => 'GET, POST, OPTIONS'})
11
-
12
- stub_auth_request(:post, "http://admin:admin@abiquo.example.com/api/admin/datacenters").with do |req|
13
- # we parse because comparing strings is too fragile because of order changing, different indentations, etc.
14
- # we're expecting something very close to this:
15
- # <datacenter>
16
- # <name>Wadus</name>
17
- # </datacenter>
18
- Nokogiri.parse(req.body).at_xpath("/datacenter/name").text == "Wadus"
19
- end.to_return(:body => %q{
20
- <datacenter>
21
- <name>Wadus</name>
22
- <link rel="edit" href="http://abiquo.example.com/api/admin/datacenters/1"/>
23
- </datacenter>
24
- })
25
-
26
- datacenter = datacenters.create(:name => "Wadus")
27
-
28
- datacenter.should be_a(Abiquo::Resource)
29
- datacenter.name.should == "Wadus"
30
-
31
- stub_auth_request(:options, "http://admin:admin@abiquo.example.com/api/admin/datacenters/1").
32
- to_return(:headers => {'Allow' => 'GET, PUT, OPTIONS'})
33
-
34
- stub_auth_request(:get, "http://admin:admin@abiquo.example.com/api/admin/datacenters/1").to_return(:body => %q{
35
- <datacenter>
36
- <name>Wadus</name>
37
- <link rel="edit" href="http://abiquo.example.com/api/admin/datacenters/1"/>
38
- </datacenter>
39
- })
40
-
41
- datacenter.name == Abiquo::Resource(datacenter.url, auth).name
42
- end
43
- end
@@ -1,27 +0,0 @@
1
- require 'spec_helper'
2
-
3
- feature "Deleting resources" do
4
-
5
- scenario "return status 200 when delete is allowed" do
6
- datacenter = Abiquo::Resource("http://abiquo.example.com/api/admin/datacenters/1", auth)
7
-
8
- stub_auth_request(:options, "http://admin:admin@abiquo.example.com/api/admin/datacenters/1").
9
- to_return(:status => 200, :headers => {'Allow' => 'GET, PUT, OPTIONS, HEAD, DELETE'})
10
-
11
- stub_auth_request(:delete, "http://admin:admin@abiquo.example.com/api/admin/datacenters/1").to_return(:status => 200)
12
-
13
- datacenter.delete
14
-
15
- auth_request(:delete, "http://admin:admin@abiquo.example.com/api/admin/datacenters/1").should have_been_made.once
16
- end
17
-
18
- scenario "raise Abiquo::NotAllowed when delete is not allowed" do
19
- datacenter = Abiquo::Resource("http://abiquo.example.com/api/admin/datacenters/1", auth)
20
-
21
- stub_auth_request(:options, "http://admin:admin@abiquo.example.com/api/admin/datacenters/1").
22
- to_return(:status => 200, :headers => {'Allow' => 'GET, PUT, OPTIONS, HEAD'})
23
-
24
- lambda { datacenter.delete }.should raise_error(Abiquo::NotAllowed)
25
- end
26
-
27
- end
@@ -1,55 +0,0 @@
1
- require 'spec_helper'
2
-
3
- feature "Fetching resource collections" do
4
-
5
- scenario "Fetch collection" do
6
- stub_auth_request(:get, "http://admin:admin@abiquo.example.com/api/admin/datacenters").to_return(:body => <<-XML)
7
- <datacenters>
8
- <datacenter>
9
- <link rel='edit' href='http://abiquo.example.com/api/admin/datacenters/1'/>
10
- <name>Resource 1</name>
11
- </datacenter>
12
- <datacenter>
13
- <link rel='edit' href='http://abiquo.example.com/api/admin/datacenters/2'/>
14
- <name>Resource 2</name>
15
- </datacenter>
16
- </datacenters>
17
- XML
18
-
19
- resources = Abiquo::Resource("http://abiquo.example.com/api/admin/datacenters", auth)
20
-
21
- resources.map(&:name).should == ["Resource 1", "Resource 2"]
22
- resources.size.should == 2
23
- resources.first.name.should == "Resource 1"
24
- resources.last.name.should == "Resource 2"
25
- end
26
-
27
- scenario "Inspecting a collection" do
28
- stub_auth_request(:get, "http://admin:admin@abiquo.example.com/api/admin/datacenters").to_return(:body => %q{
29
- <datacenters><datacenter><name>Resource 1</name></datacenter></datacenters>
30
- })
31
-
32
- resources = Abiquo::Resource("http://abiquo.example.com/api/admin/datacenters", auth)
33
-
34
- resources.inspect.should == "[#{resources.first.inspect}]"
35
- end
36
-
37
- scenario 'Fetch service document' do
38
- stub_auth_request(:get, 'http://admin:admin@abiquo.example.com/api').to_return(:body => <<-XML)
39
- <ns2:service xmlns="http://www.w3.org/2005/Atom" xmlns:ns2="http://www.w3.org/2007/app" xmlns:ns3="http://a9.com/-/spec/opensearch/1.1/" xmlns:ns4="http://www.w3.org/1999/xhtml">
40
- <ns2:workspace>
41
- <title>Abiquo administration workspace</title>
42
- <ns2:collection href="http://localhost:8080/api/admin/datacenters">
43
- <title>Datacenters</title>
44
- <ns2:accept/>
45
- </ns2:collection>
46
- </ns2:workspace>
47
- </ns2:service>
48
- XML
49
-
50
- resources = Abiquo::Resource('http://abiquo.example.com/api', auth)
51
-
52
- lambda { resources.datacenters }.should_not raise_error
53
- end
54
-
55
- end
@@ -1,47 +0,0 @@
1
- require "spec_helper"
2
-
3
- feature "Fetching individual resources" do
4
-
5
- scenario "Fetching untyped attributes" do
6
- stub_auth_request(:get, "http://admin:admin@abiquo.example.com/api/admin/datacenters/1").to_return(:body => <<-XML)
7
- <datacenter>
8
- <name>Resource Name</name>
9
- <id>12345</id>
10
- </datacenter>
11
- XML
12
-
13
- datacenter = Abiquo::Resource("http://abiquo.example.com/api/admin/datacenters/1", auth)
14
- datacenter.name.should == "Resource Name"
15
- datacenter.id.should == "12345"
16
-
17
- expect { datacenter.wadus }.to raise_error(NoMethodError)
18
- end
19
-
20
- scenario "Fetching typed attributes" do
21
- stub_auth_request(:get, "http://admin:admin@abiquo.example.com/api/admin/datacenters/1").to_return(:body => <<-XML)
22
- <datacenter>
23
- <id>12345</id>
24
- <name>Resource Name</name>
25
- </datacenter>
26
- XML
27
-
28
- datacenter = Abiquo::Resource("http://abiquo.example.com/api/admin/datacenters/1", auth)
29
-
30
- datacenter.id.should == "12345"
31
- end
32
-
33
- scenario "Inspecting a resource" do
34
- xml = %q{
35
- <datacenter>
36
- <id>12345</id>
37
- <name>Resource Name</name>
38
- </datacenter>
39
- }
40
- stub_auth_request(:get, "http://admin:admin@abiquo.example.com/api/admin/datacenters/1").to_return(:body => xml)
41
-
42
- datacenter = Abiquo::Resource("http://abiquo.example.com/api/admin/datacenters/1", auth)
43
-
44
- Nokogiri.parse(datacenter.inspect).to_xml.should == Nokogiri.parse(xml).to_xml
45
- end
46
-
47
- end
@@ -1,15 +0,0 @@
1
- require "spec_helper"
2
-
3
- feature "Instantiate resources from xml" do
4
-
5
- it "should instantiate the resource without HTTP calls" do
6
- xml = %q{
7
- <datacenter>
8
- <name>Resource 1</name>
9
- </datacenter>
10
- }
11
- datacenter = Abiquo::Resource.from_xml(xml)
12
-
13
- datacenter.name.should == "Resource 1"
14
- end
15
- end
@@ -1,61 +0,0 @@
1
- require 'spec_helper'
2
-
3
- feature "Navigating linked resources" do
4
- scenario "Link to a collection of resources" do
5
- stub_auth_request(:get, "http://admin:admin@abiquo.example.com/api/admin/datacenters/1").to_return(:body => <<-XML)
6
- <datacenter>
7
- <link rel="racks" href="http://abiquo.example.com/api/admin/datacenters/1/racks"/>
8
- </datacenter>
9
- XML
10
-
11
- datacenter = Abiquo::Resource("http://abiquo.example.com/api/admin/datacenters/1", auth)
12
-
13
- stub_auth_request(:get, "http://admin:admin@abiquo.example.com/api/admin/datacenters/1/racks").to_return(:body => <<-XML)
14
- <racks>
15
- <rack>
16
- <name>Rack 1</name>
17
- </rack>
18
- <rack>
19
- <name>Rack 2</name>
20
- </rack>
21
- </racks>
22
- XML
23
-
24
- datacenter.racks.size.should == 2
25
- datacenter.racks.first.name.should == 'Rack 1'
26
- datacenter.racks.last.name.should == 'Rack 2'
27
- end
28
-
29
- scenario "Link to a collection of resources with params" do
30
- stub_auth_request(:get, "http://admin:admin@abiquo.example.com/api/admin/datacenters/1").to_return(:body => <<-XML)
31
- <datacenter>
32
- <link rel="racks" href="http://abiquo.example.com/api/admin/datacenters/1/racks"/>
33
- </datacenter>
34
- XML
35
-
36
- datacenter = Abiquo::Resource("http://abiquo.example.com/api/admin/datacenters/1", auth)
37
-
38
- stub_auth_request(:get, "http://admin:admin@abiquo.example.com/api/admin/datacenters/1/racks").to_return(:body => <<-XML)
39
- <racks>
40
- <rack>
41
- <name>Rack 1</name>
42
- </rack>
43
- </racks>
44
- XML
45
-
46
- datacenter.racks.size.should == 1
47
- datacenter.racks.first.name.should == 'Rack 1'
48
- end
49
-
50
- scenario "Link to self" do
51
- stub_auth_request(:get, "http://admin:admin@abiquo.example.com/api/admin/datacenters/1").to_return(:body => <<-XML)
52
- <datacenter>
53
- <link rel="edit" href="http://abiquo.example.com/datacenters/1"/>
54
- </datacenter>
55
- XML
56
-
57
- datacenter = Abiquo::Resource("http://abiquo.example.com/api/admin/datacenters/1", auth)
58
-
59
- datacenter.url.should == "http://abiquo.example.com/api/admin/datacenters/1"
60
- end
61
- end
@@ -1,26 +0,0 @@
1
- require 'spec_helper'
2
-
3
- feature "Updating resources" do
4
-
5
- scenario "Updating a resource" do
6
- datacenter = Abiquo::Resource("http://abiquo.example.com/api/admin/datacenters/1", auth)
7
-
8
- stub_auth_request(:options, "http://admin:admin@abiquo.example.com/api/admin/datacenters/1").
9
- to_return(:headers => {'Allow' => 'GET, PUT, OPTIONS'})
10
-
11
- stub_auth_request(:put, "http://admin:admin@abiquo.example.com/api/admin/datacenters/1").with do |req|
12
- req.body == {:name => "Wadus Wadus"}.to_xml(:root => "datacenter")
13
- end.to_return(:body => <<-XML)
14
- <datacenter>
15
- <name>Wadus Wadus</name>
16
- <link rel="edit" href="http://abiquo.example.com/api/admin/datacenters/1"/>
17
- </datacenter>
18
- XML
19
-
20
-
21
- datacenter.update(:name => "Wadus Wadus")
22
-
23
- datacenter.name.should == "Wadus Wadus"
24
- end
25
-
26
- end
@@ -1,32 +0,0 @@
1
- require 'rubygems'
2
- require 'steak'
3
- require 'webmock/rspec'
4
- require "abiquo"
5
-
6
- module Helpers
7
-
8
- def stub_auth_request(*args)
9
- stub_request(*args)
10
- end
11
-
12
- def auth_request(*args)
13
- request(*args)
14
- end
15
-
16
- def auth
17
- Abiquo::BasicAuth.new("Abiquo", "admin", "admin")
18
- end
19
- end
20
-
21
- Spec::Runner.configure do |config|
22
- config.include Helpers
23
- config.include WebMock
24
- config.before(:each) do
25
- stub_request(:any, //).with { |request| !request.headers.has_key?("Authorization") }.
26
- to_return(
27
- :status => 401, :headers => {
28
- "WWW-Authenticate" => 'Basic realm="Abiquo"'
29
- })
30
- end
31
- config.after(:each) { reset_webmock }
32
- end
@@ -1,56 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Hash do
4
-
5
- describe "to_xml" do
6
-
7
- it "should convert the nested resources into 'link' tags if the :convert_links option is present" do
8
- xml = Nokogiri.parse({"name" => "Almodovar", "tasks" => [{"name" => "Wadus"}]}.to_xml(:root => "project", :convert_links => true))
9
-
10
- # <project>
11
- # <name>Almodovar</name>
12
- # <link rel="tasks">
13
- # <tasks type="array">
14
- # <task>
15
- # <name>Wadus</name>
16
- # </task>
17
- # </tasks>
18
- # </link>
19
- # </project>
20
- xml.at_xpath("/project/name").text.should == "Almodovar"
21
- xml.at_xpath("/project/tasks").should be_nil
22
- xml.at_xpath("/project/link[@rel='tasks']/tasks[@type='array']/task/name").text.should == "Wadus"
23
- end
24
-
25
- it "should not convert the nested resources into 'link' tags if the :convert_links option is not present" do
26
- xml = Nokogiri.parse({"name" => "Almodovar", "tasks" => [{"name" => "Wadus"}]}.to_xml(:root => "project", :convert_links => false))
27
-
28
- # <project>
29
- # <name>Almodovar</name>
30
- # <tasks type="array">
31
- # <task>
32
- # <name>Wadus</name>
33
- # </task>
34
- # </tasks>
35
- # </project>
36
- xml.at_xpath("/project/name").text.should == "Almodovar"
37
- xml.at_xpath("//link").should be_nil
38
- xml.at_xpath("/project/tasks[@type='array']/task/name").text.should == "Wadus"
39
- end
40
-
41
-
42
- end
43
-
44
- end
45
-
46
- describe Array do
47
-
48
- describe "to_xml" do
49
-
50
- it "should convert an array into xml" do
51
- [].to_xml.should == "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<nil-classes type=\"array\"/>\n"
52
- end
53
-
54
- end
55
-
56
- end