vcloud-core 0.0.6 → 0.0.7

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.
@@ -1,3 +1,9 @@
1
+ ## 0.0.7 (2014-03-03)
2
+
3
+ Bugfixes:
4
+
5
+ - vAppTemplate not retrieved if ISO exists with similar name [#66758184]
6
+
1
7
  ## 0.0.6 (2014-02-13)
2
8
 
3
9
  Features:
data/Rakefile CHANGED
@@ -6,11 +6,16 @@ RSpec::Core::RakeTask.new(:spec) do |task|
6
6
  # tests to accidentially run (and succeed against!) an actual
7
7
  # environment, if Fog connection is not stubbed correctly.
8
8
  ENV['FOG_CREDENTIAL'] = 'random_nonsense_owiejfoweijf'
9
+ ENV['COVERAGE'] = 'true'
9
10
  task.pattern = FileList['spec/vcloud/**/*_spec.rb']
10
11
  end
11
12
 
12
13
  task :default => [:spec]
13
14
 
15
+ RSpec::Core::RakeTask.new('integration') do |t|
16
+ t.pattern = FileList['spec/integration/**/*_spec.rb']
17
+ end
18
+
14
19
  require "gem_publisher"
15
20
  task :publish_gem do |t|
16
21
  gem = GemPublisher.publish_if_updated("vcloud-core.gemspec", :rubygems)
@@ -23,11 +23,27 @@ module Vcloud
23
23
  vcloud_attributes[:name]
24
24
  end
25
25
 
26
+ def self.get_ids_by_name_and_catalog name, catalog_name
27
+ raise "provide Catalog and vAppTemplate name" unless name && catalog_name
28
+ q = Query.new(
29
+ 'vAppTemplate',
30
+ :filter => "name==#{name};catalogName==#{catalog_name}"
31
+ )
32
+ unless query_results = q.get_all_results
33
+ raise "Error retreiving #{q.type} query '#{q.filter}'"
34
+ end
35
+ query_results.collect do |record|
36
+ record[:href].split('/').last if record.key?(:href)
37
+ end
38
+ end
39
+
26
40
  def self.get catalog_name, catalog_item_name
27
- raise "provide catalog and catalog item name to load vappTemplate" unless catalog_name && catalog_item_name
28
- body = Vcloud::Fog::ServiceInterface.new.template(catalog_name, catalog_item_name)
29
- raise 'Could not find template vApp' unless body && body.key?(:href)
30
- self.new(body[:href].split('/').last)
41
+ ids = self.get_ids_by_name_and_catalog(catalog_item_name, catalog_name)
42
+ raise 'Could not find template vApp' if ids.size == 0
43
+ if ids.size > 1
44
+ raise "Template #{catalog_item_name} is not unique in catalog #{catalog_name}"
45
+ end
46
+ return self.new(ids.first)
31
47
  end
32
48
 
33
49
  def self.id_prefix
@@ -1,5 +1,5 @@
1
1
  module Vcloud
2
2
  module Core
3
- VERSION = '0.0.6'
3
+ VERSION = '0.0.7'
4
4
  end
5
5
  end
@@ -192,14 +192,6 @@ module Vcloud
192
192
  response_body[:VAppRecord].detect { |record| record[:vdcName] == vdc_name }
193
193
  end
194
194
 
195
- def catalog(name)
196
- link = org[:Link].select { |l| l[:rel] == RELATION::CHILD }.detect do |l|
197
- l[:type] == ContentTypes::CATALOG && l[:name] == name
198
- end
199
- raise "catalog #{name} cannot be found" unless link
200
- @fog.get_catalog(extract_id(link))
201
- end
202
-
203
195
  def vdc(name)
204
196
  link = org[:Link].select { |l| l[:rel] == RELATION::CHILD }.detect do |l|
205
197
  l[:type] == ContentTypes::VDC && l[:name] == name
@@ -209,19 +201,6 @@ module Vcloud
209
201
 
210
202
  end
211
203
 
212
- def template(catalog_name, template_name)
213
- link = catalog(catalog_name)[:CatalogItems][:CatalogItem].detect do |l|
214
- l[:type] == ContentTypes::CATALOG_ITEM && l[:name].match(template_name)
215
- end
216
- if link.nil?
217
- Vcloud::Core.logger.warn("Template #{template_name} not found in catalog #{catalog_name}")
218
- return nil
219
- end
220
- catalog_item = @fog.get_catalog_item(extract_id(link))
221
- catalog_item[:Entity]
222
- end
223
-
224
-
225
204
  def put_network_connection_system_section_vapp(vm_id, section)
226
205
  begin
227
206
  Vcloud::Core.logger.info("adding NIC into VM #{vm_id}")
@@ -1,26 +1,29 @@
1
- require 'simplecov'
1
+ if ENV['COVERAGE']
2
+ require 'simplecov'
2
3
 
3
- SimpleCov.profiles.define 'gem' do
4
- add_filter '/spec/'
5
- add_filter '/features/'
6
- add_filter '/vendor/'
4
+ SimpleCov.profiles.define 'gem' do
5
+ add_filter '/spec/'
6
+ add_filter '/features/'
7
+ add_filter '/vendor/'
7
8
 
8
- add_group 'Libraries', '/lib/'
9
- end
9
+ add_group 'Libraries', '/lib/'
10
+ end
10
11
 
11
- SimpleCov.start 'gem'
12
+ SimpleCov.start 'gem'
13
+ end
12
14
 
13
15
  require 'bundler/setup'
14
16
  require 'vcloud/core'
15
17
  require 'support/stub_fog_interface.rb'
16
18
 
17
-
18
- SimpleCov.at_exit do
19
- SimpleCov.result.format!
20
- # do not change the coverage percentage, instead add more unit tests to fix coverage failures.
21
- if SimpleCov.result.covered_percent < 71
22
- print "ERROR::BAD_COVERAGE\n"
23
- print "Coverage is less than acceptable limit(71%). Please add more tests to improve the coverage"
24
- exit(1)
19
+ if ENV['COVERAGE']
20
+ SimpleCov.at_exit do
21
+ SimpleCov.result.format!
22
+ # do not change the coverage percentage, instead add more unit tests to fix coverage failures.
23
+ if SimpleCov.result.covered_percent < 71
24
+ print "ERROR::BAD_COVERAGE\n"
25
+ print "Coverage is less than acceptable limit(71%). Please add more tests to improve the coverage"
26
+ exit(1)
27
+ end
25
28
  end
26
29
  end
@@ -49,23 +49,39 @@ module Vcloud
49
49
  context '#get' do
50
50
 
51
51
  it 'should raise a RuntimeError if there is no template' do
52
- @mock_fog_interface.should_receive(:template).
53
- with('test_catalog', 'test_template').and_return(nil)
52
+ q_results = [ ]
53
+ mock_query = double(:query, :get_all_results => q_results)
54
+ Vcloud::Query.should_receive(:new).
55
+ with('vAppTemplate', :filter => "name==test_template;catalogName==test_catalog").
56
+ and_return(mock_query)
54
57
  expect { VappTemplate.get('test_catalog', 'test_template') }.
55
58
  to raise_error('Could not find template vApp')
56
59
  end
57
60
 
61
+ it 'should raise an error if more than one template is returned' do
62
+ q_results = [
63
+ { :name => 'test_template',
64
+ :href => "/vappTemplate-12345678-90ab-cdef-0123-4567890ab001" },
65
+ { :name => 'test_template',
66
+ :href => "/vappTemplate-12345678-90ab-cdef-0123-4567890ab002" },
67
+ ]
68
+ mock_query = double(:query, :get_all_results => q_results)
69
+ Vcloud::Query.should_receive(:new).
70
+ with('vAppTemplate', :filter => "name==test_template;catalogName==test_catalog").
71
+ and_return(mock_query)
72
+ expect { VappTemplate.get('test_catalog', 'test_template') }.
73
+ to raise_error('Template test_template is not unique in catalog test_catalog')
74
+ end
58
75
 
59
76
  it 'should return a valid template object if it exists' do
60
- test_catalog_item_entity = {
61
- :href => "/vappTemplate-12345678-90ab-cdef-0123-4567890abcde"
62
- }
63
- @mock_fog_interface.should_receive(:template).
64
- with('test_catalog', 'test_template').
65
- and_return(test_catalog_item_entity)
66
- Vcloud::Fog::ServiceInterface.should_receive(:new).
67
- and_return(@mock_fog_interface)
68
-
77
+ q_results = [
78
+ { :name => 'test_template',
79
+ :href => "/vappTemplate-12345678-90ab-cdef-0123-4567890abcde" }
80
+ ]
81
+ mock_query = double(:query, :get_all_results => q_results)
82
+ Vcloud::Query.should_receive(:new).
83
+ with('vAppTemplate', :filter => "name==test_template;catalogName==test_catalog").
84
+ and_return(mock_query)
69
85
  test_template = VappTemplate.get('test_catalog', 'test_template')
70
86
  test_template.id.should == 'vappTemplate-12345678-90ab-cdef-0123-4567890abcde'
71
87
  end
@@ -18,17 +18,6 @@ module Vcloud
18
18
  expect { service_interface.vdc('DoesNotExist') }.to raise_exception(RuntimeError, 'vdc DoesNotExist cannot be found')
19
19
  end
20
20
 
21
- it 'should raise a exception if named catalog cannot be found in the data returned' do
22
-
23
- fog_facade = double(:FogFacade)
24
- expect(fog_facade).to receive(:session).and_return { FOG_SESSION_RESPONSE }
25
- expect(fog_facade).to receive(:get_organization).and_return { FOG_ORGANIZATION_RESPONSE }
26
-
27
- service_interface = ServiceInterface.new(fog_facade)
28
-
29
- expect { service_interface.catalog('DoesNotExist') }.to raise_exception(RuntimeError, 'catalog DoesNotExist cannot be found')
30
- end
31
-
32
21
  context 'configure edge gateway' do
33
22
  before(:each) do
34
23
  @config = { :Blah => 'TestData' }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vcloud-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-02-13 00:00:00.000000000 Z
12
+ date: 2014-03-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: fog
@@ -181,7 +181,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
181
181
  version: '0'
182
182
  segments:
183
183
  - 0
184
- hash: 4034652362745429730
184
+ hash: -512267274305654333
185
185
  requirements: []
186
186
  rubyforge_project:
187
187
  rubygems_version: 1.8.23