vcloud-core 0.7.0 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. data/.gitignore +1 -1
  2. data/CHANGELOG.md +12 -0
  3. data/lib/vcloud/core.rb +2 -1
  4. data/lib/vcloud/core/api_interface.rb +35 -0
  5. data/lib/vcloud/core/compute_metadata.rb +1 -1
  6. data/lib/vcloud/core/edge_gateway.rb +2 -2
  7. data/lib/vcloud/core/fog.rb +40 -0
  8. data/lib/vcloud/core/fog/fog_constants.rb +35 -0
  9. data/lib/vcloud/core/fog/login.rb +40 -0
  10. data/lib/vcloud/core/fog/model_interface.rb +41 -0
  11. data/lib/vcloud/core/fog/service_interface.rb +253 -0
  12. data/lib/vcloud/core/login_cli.rb +1 -1
  13. data/lib/vcloud/core/metadata_helper.rb +1 -1
  14. data/lib/vcloud/core/org_vdc_network.rb +3 -3
  15. data/lib/vcloud/core/query_runner.rb +1 -1
  16. data/lib/vcloud/core/vapp.rb +6 -6
  17. data/lib/vcloud/core/vapp_template.rb +1 -1
  18. data/lib/vcloud/core/vdc.rb +1 -1
  19. data/lib/vcloud/core/version.rb +1 -1
  20. data/lib/vcloud/core/vm.rb +9 -9
  21. data/lib/vcloud/fog.rb +2 -39
  22. data/lib/vcloud/temporary_fog_classes.rb +11 -0
  23. data/spec/integration/{fog → core/fog}/login_manual.rb +1 -1
  24. data/spec/integration/{fog → core/fog}/login_spec.rb +13 -9
  25. data/spec/integration/core/vm_spec.rb +1 -1
  26. data/spec/support/integration_helper.rb +1 -1
  27. data/spec/vcloud/core/edge_gateway_spec.rb +1 -1
  28. data/spec/vcloud/{fog → core/fog}/fog_model_interface_spec.rb +2 -2
  29. data/spec/vcloud/{fog → core/fog}/login_spec.rb +4 -4
  30. data/spec/vcloud/core/fog/service_interface_spec.rb +53 -0
  31. data/spec/vcloud/{fog_spec.rb → core/fog_spec.rb} +2 -2
  32. data/spec/vcloud/core/login_cli_spec.rb +6 -6
  33. data/spec/vcloud/core/org_vdc_network_spec.rb +1 -1
  34. data/spec/vcloud/core/query_runner_spec.rb +1 -1
  35. data/spec/vcloud/core/vapp_spec.rb +1 -1
  36. data/spec/vcloud/core/vapp_template_spec.rb +1 -1
  37. data/spec/vcloud/core/vdc_spec.rb +1 -1
  38. data/spec/vcloud/core/vm_spec.rb +1 -1
  39. metadata +22 -21
  40. data/jenkins_integration_tests.sh +0 -5
  41. data/lib/vcloud/fog/content_types.rb +0 -18
  42. data/lib/vcloud/fog/login.rb +0 -38
  43. data/lib/vcloud/fog/model_interface.rb +0 -33
  44. data/lib/vcloud/fog/relation.rb +0 -8
  45. data/lib/vcloud/fog/service_interface.rb +0 -245
  46. data/spec/vcloud/fog/service_interface_spec.rb +0 -51
@@ -13,7 +13,7 @@ module Vcloud
13
13
  def run
14
14
  begin
15
15
  pass = read_pass
16
- puts Vcloud::Fog::Login.token_export(pass)
16
+ puts Vcloud::Core::Fog::Login.token_export(pass)
17
17
  rescue => e
18
18
  $stderr.puts(e)
19
19
  exit 1
@@ -5,7 +5,7 @@ module Vcloud
5
5
  def extract_metadata vcloud_metadata_entries
6
6
  metadata = {}
7
7
  vcloud_metadata_entries.each do |entry|
8
- next unless entry[:type] == Vcloud::Fog::ContentTypes::METADATA
8
+ next unless entry[:type] == Vcloud::Core::Fog::ContentTypes::METADATA
9
9
  key = entry[:Key].to_sym
10
10
  val = entry[:TypedValue][:Value]
11
11
  case entry[:TypedValue][:xsi_type]
@@ -35,7 +35,7 @@ module Vcloud
35
35
 
36
36
  begin
37
37
  Vcloud::Core.logger.info("Provisioning new OrgVdcNetwork #{name} in vDC '#{vdc_name}'")
38
- attrs = Vcloud::Fog::ServiceInterface.new.post_create_org_vdc_network(vdc.id, name, options)
38
+ attrs = Vcloud::Core::Fog::ServiceInterface.new.post_create_org_vdc_network(vdc.id, name, options)
39
39
  rescue RuntimeError => e
40
40
  Vcloud::Core.logger.error("Could not provision orgVdcNetwork: #{e.message}")
41
41
  end
@@ -46,7 +46,7 @@ module Vcloud
46
46
  end
47
47
 
48
48
  def vcloud_attributes
49
- Vcloud::Fog::ServiceInterface.new.get_network_complete(id)
49
+ Vcloud::Core::Fog::ServiceInterface.new.get_network_complete(id)
50
50
  end
51
51
 
52
52
  def name
@@ -58,7 +58,7 @@ module Vcloud
58
58
  end
59
59
 
60
60
  def delete
61
- Vcloud::Fog::ServiceInterface.new.delete_network(id)
61
+ Vcloud::Core::Fog::ServiceInterface.new.delete_network(id)
62
62
  end
63
63
 
64
64
  def self.construct_network_options(config)
@@ -3,7 +3,7 @@ module Vcloud
3
3
  class QueryRunner
4
4
 
5
5
  def initialize
6
- @fsi = Vcloud::Fog::ServiceInterface.new
6
+ @fsi = Vcloud::Core::Fog::ServiceInterface.new
7
7
  end
8
8
 
9
9
  def run(type=nil, options={})
@@ -27,7 +27,7 @@ module Vcloud
27
27
  end
28
28
 
29
29
  def vcloud_attributes
30
- Vcloud::Fog::ServiceInterface.new.get_vapp(id)
30
+ Vcloud::Core::Fog::ServiceInterface.new.get_vapp(id)
31
31
  end
32
32
 
33
33
  module STATUS
@@ -57,14 +57,14 @@ module Vcloud
57
57
  end
58
58
 
59
59
  def self.get_by_name_and_vdc_name(name, vdc_name)
60
- fog_interface = Vcloud::Fog::ServiceInterface.new
60
+ fog_interface = Vcloud::Core::Fog::ServiceInterface.new
61
61
  attrs = fog_interface.get_vapp_by_name_and_vdc_name(name, vdc_name)
62
62
  self.new(attrs[:href].split('/').last) if attrs && attrs.key?(:href)
63
63
  end
64
64
 
65
65
  def self.instantiate(name, network_names, template_id, vdc_name)
66
66
  Vcloud::Core.logger.info("Instantiating new vApp #{name} in vDC '#{vdc_name}'")
67
- fog_interface = Vcloud::Fog::ServiceInterface.new
67
+ fog_interface = Vcloud::Core::Fog::ServiceInterface.new
68
68
  networks = get_networks(network_names, vdc_name)
69
69
 
70
70
  attrs = fog_interface.post_instantiate_vapp_template(
@@ -79,14 +79,14 @@ module Vcloud
79
79
  def power_on
80
80
  raise "Cannot power on a missing vApp." unless id
81
81
  return true if running?
82
- Vcloud::Fog::ServiceInterface.new.power_on_vapp(id)
82
+ Vcloud::Core::Fog::ServiceInterface.new.power_on_vapp(id)
83
83
  running?
84
84
  end
85
85
 
86
86
  private
87
87
  def running?
88
88
  raise "Cannot call running? on a missing vApp." unless id
89
- vapp = Vcloud::Fog::ServiceInterface.new.get_vapp(id)
89
+ vapp = Vcloud::Core::Fog::ServiceInterface.new.get_vapp(id)
90
90
  vapp[:status].to_i == STATUS::RUNNING ? true : false
91
91
  end
92
92
 
@@ -110,7 +110,7 @@ module Vcloud
110
110
  end
111
111
 
112
112
  def self.get_networks(network_names, vdc_name)
113
- fsi = Vcloud::Fog::ServiceInterface.new
113
+ fsi = Vcloud::Core::Fog::ServiceInterface.new
114
114
  fsi.find_networks(network_names, vdc_name) if network_names
115
115
  end
116
116
  end
@@ -12,7 +12,7 @@ module Vcloud
12
12
  end
13
13
 
14
14
  def vcloud_attributes
15
- Vcloud::Fog::ServiceInterface.new.get_vapp_template(id)
15
+ Vcloud::Core::Fog::ServiceInterface.new.get_vapp_template(id)
16
16
  end
17
17
 
18
18
  def href
@@ -20,7 +20,7 @@ module Vcloud
20
20
  end
21
21
 
22
22
  def vcloud_attributes
23
- Vcloud::Fog::ServiceInterface.new.get_vdc(id)
23
+ Vcloud::Core::Fog::ServiceInterface.new.get_vdc(id)
24
24
  end
25
25
 
26
26
  def name
@@ -1,5 +1,5 @@
1
1
  module Vcloud
2
2
  module Core
3
- VERSION = '0.7.0'
3
+ VERSION = '0.8.0'
4
4
  end
5
5
  end
@@ -14,14 +14,14 @@ module Vcloud
14
14
  end
15
15
 
16
16
  def vcloud_attributes
17
- Vcloud::Fog::ServiceInterface.new.get_vapp(id)
17
+ Vcloud::Core::Fog::ServiceInterface.new.get_vapp(id)
18
18
  end
19
19
 
20
20
  def update_memory_size_in_mb(new_memory)
21
21
  return if new_memory.nil?
22
22
  return if new_memory.to_i < 64
23
23
  unless memory.to_i == new_memory.to_i
24
- Vcloud::Fog::ServiceInterface.new.put_memory(id, new_memory)
24
+ Vcloud::Core::Fog::ServiceInterface.new.put_memory(id, new_memory)
25
25
  end
26
26
  end
27
27
 
@@ -44,7 +44,7 @@ module Vcloud
44
44
  end
45
45
 
46
46
  def update_name(new_name)
47
- fsi = Vcloud::Fog::ServiceInterface.new
47
+ fsi = Vcloud::Core::Fog::ServiceInterface.new
48
48
  fsi.put_vm(id, new_name) unless name == new_name
49
49
  end
50
50
 
@@ -56,13 +56,13 @@ module Vcloud
56
56
  return if new_cpu_count.nil?
57
57
  return if new_cpu_count.to_i == 0
58
58
  unless cpu.to_i == new_cpu_count.to_i
59
- Vcloud::Fog::ServiceInterface.new.put_cpu(id, new_cpu_count)
59
+ Vcloud::Core::Fog::ServiceInterface.new.put_cpu(id, new_cpu_count)
60
60
  end
61
61
  end
62
62
 
63
63
  def update_metadata(metadata)
64
64
  return if metadata.nil?
65
- fsi = Vcloud::Fog::ServiceInterface.new
65
+ fsi = Vcloud::Core::Fog::ServiceInterface.new
66
66
  metadata.each do |k, v|
67
67
  fsi.put_vapp_metadata_value(@vapp.id, k, v)
68
68
  fsi.put_vapp_metadata_value(id, k, v)
@@ -70,7 +70,7 @@ module Vcloud
70
70
  end
71
71
 
72
72
  def add_extra_disks(extra_disks)
73
- vm = Vcloud::Fog::ModelInterface.new.get_vm_by_href(href)
73
+ vm = Vcloud::Core::Fog::ModelInterface.new.get_vm_by_href(href)
74
74
  if extra_disks
75
75
  extra_disks.each do |extra_disk|
76
76
  Vcloud::Core.logger.debug("adding a disk of size #{extra_disk[:size]}MB into VM #{id}")
@@ -99,16 +99,16 @@ module Vcloud
99
99
  connection[:IpAddress] = ip_address if ip_address
100
100
  connection
101
101
  end
102
- Vcloud::Fog::ServiceInterface.new.put_network_connection_system_section_vapp(id, section)
102
+ Vcloud::Core::Fog::ServiceInterface.new.put_network_connection_system_section_vapp(id, section)
103
103
  end
104
104
 
105
105
  def configure_guest_customization_section(preamble)
106
- Vcloud::Fog::ServiceInterface.new.put_guest_customization_section(id, vapp_name, preamble)
106
+ Vcloud::Core::Fog::ServiceInterface.new.put_guest_customization_section(id, vapp_name, preamble)
107
107
  end
108
108
 
109
109
  def update_storage_profile storage_profile
110
110
  storage_profile_href = get_storage_profile_href_by_name(storage_profile, @vapp.name)
111
- Vcloud::Fog::ServiceInterface.new.put_vm(id, name, {
111
+ Vcloud::Core::Fog::ServiceInterface.new.put_vm(id, name, {
112
112
  :StorageProfile => {
113
113
  name: storage_profile,
114
114
  href: storage_profile_href
data/lib/vcloud/fog.rb CHANGED
@@ -1,39 +1,2 @@
1
- require 'fog'
2
- require 'vcloud/fog/content_types'
3
- require 'vcloud/fog/login'
4
- require 'vcloud/fog/relation'
5
- require 'vcloud/fog/service_interface'
6
- require 'vcloud/fog/model_interface'
7
-
8
- module Vcloud
9
- module Fog
10
- TOKEN_ENV_VAR_NAME = 'FOG_VCLOUD_TOKEN'
11
- FOG_CREDS_PASS_NAME = :vcloud_director_password
12
-
13
- def self.check_credentials
14
- pass = fog_credentials_pass
15
- unless pass.nil? or pass.empty?
16
- warn <<EOF
17
- [WARNING] Storing :vcloud_director_password in your plaintext FOG_RC file is
18
- insecure. Future releases of vcloud-core (and tools that depend on
19
- it) will prevent you from doing this. Please use vcloud-login to
20
- get a session token instead.
21
- EOF
22
- end
23
- end
24
-
25
- def self.fog_credentials_pass
26
- begin
27
- pass = ::Fog.credentials[FOG_CREDS_PASS_NAME]
28
- rescue ::Fog::Errors::LoadError
29
- # Assume no password if Fog has been unable to load creds.
30
- # Suppresses a noisy error about missing credentials.
31
- pass = nil
32
- end
33
-
34
- pass
35
- end
36
- end
37
- end
38
-
39
- Vcloud::Fog.check_credentials
1
+ require 'vcloud/core/fog'
2
+ require 'vcloud/temporary_fog_classes'
@@ -0,0 +1,11 @@
1
+ module Vcloud
2
+ module Fog
3
+
4
+ # FIXME: This is required because vCloud Core has a dependency
5
+ # on vCloud Tools Tester. Once vCloud Tools Tester has been
6
+ # updated to use the correct class, this can be removed.
7
+ class ModelInterface < Vcloud::Core::Fog::ModelInterface
8
+ end
9
+
10
+ end
11
+ end
@@ -6,7 +6,7 @@ require 'spec_helper'
6
6
  # of our tests should fail if the behaviour of Fog changes. However these
7
7
  # may came in useful when debugging such a scenario.
8
8
 
9
- describe Vcloud::Fog::Login do
9
+ describe Vcloud::Core::Fog::Login do
10
10
  let!(:mock_env) { ENV.clone }
11
11
 
12
12
  before(:each) do
@@ -1,26 +1,30 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Vcloud::Fog::Login do
4
- let!(:mock_env) { ENV.clone }
5
-
3
+ describe Vcloud::Core::Fog::Login do
6
4
  before(:each) do
7
- stub_const('ENV', mock_env)
5
+ stub_const('ENV', {})
6
+
7
+ @orig_credential = ::Fog.credential
8
+ ::Fog.credential = 'null'
9
+ @orig_credentials_path = ::Fog.credentials_path
10
+ ::Fog.credentials_path = '/dev/null'
11
+ end
12
+
13
+ after(:each) do
14
+ ::Fog.credential = @orig_credential
15
+ ::Fog.credentials_path = @orig_credentials_path
8
16
  end
9
17
 
10
18
  describe "#token" do
11
19
  context "unable to load credentials" do
12
20
  it "should raise an exception succinctly listing the missing credentials" do
13
- mock_env.clear
14
- ::Fog.credential = 'null'
15
- ::Fog.credentials_path = '/dev/null'
16
-
17
21
  # This test is known to fail with a TypeError due to a bug in Ruby 1.9.3 that
18
22
  # has since been fixed. See https://github.com/gds-operations/vcloud-core/pull/100
19
23
  expect { ::Fog.credentials['doesnotexist'] }.to raise_error(
20
24
  Fog::Errors::LoadError,
21
25
  /^Missing Credentials\n/
22
26
  )
23
- expect { subject.token(@real_password) }.to raise_error(
27
+ expect { subject.token('supersekret') }.to raise_error(
24
28
  ArgumentError,
25
29
  /^Missing required arguments: vcloud_director_.*$/
26
30
  )
@@ -147,7 +147,7 @@ describe Vcloud::Core::Vm do
147
147
  context "#add_extra_disks" do
148
148
 
149
149
  before(:all) do
150
- @fog_model_vm = Vcloud::Fog::ModelInterface.new.get_vm_by_href(@vm.href)
150
+ @fog_model_vm = Vcloud::Core::Fog::ModelInterface.new.get_vm_by_href(@vm.href)
151
151
  @initial_vm_disks = get_vm_hard_disks(@fog_model_vm)
152
152
  end
153
153
 
@@ -23,7 +23,7 @@ module IntegrationHelper
23
23
  end
24
24
 
25
25
  def self.delete_vapps(vapp_list)
26
- fsi = Vcloud::Fog::ServiceInterface.new()
26
+ fsi = Vcloud::Core::Fog::ServiceInterface.new()
27
27
  vapp_list.each do |vapp|
28
28
  if Integer(vapp.vcloud_attributes[:status]) == Vcloud::Core::Vapp::STATUS::RUNNING
29
29
  fsi.post_undeploy_vapp(vapp.id)
@@ -7,7 +7,7 @@ module Vcloud
7
7
  before(:each) do
8
8
  @edgegw_id = '12345678-1234-1234-1234-000000111454'
9
9
  @mock_fog_interface = StubFogInterface.new
10
- allow(Vcloud::Fog::ServiceInterface).to receive(:new).and_return(@mock_fog_interface)
10
+ allow(Vcloud::Core::Fog::ServiceInterface).to receive(:new).and_return(@mock_fog_interface)
11
11
  end
12
12
 
13
13
  context "Class public interface" do
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Vcloud::Fog::ModelInterface do
3
+ describe Vcloud::Core::Fog::ModelInterface do
4
4
 
5
5
  it "should retrive logged in organization" do
6
6
  vm_href, vdc_href = 'https://vmware.net/vapp/vm-1', 'vdc/vdc-1'
@@ -20,6 +20,6 @@ describe Vcloud::Fog::ModelInterface do
20
20
  )
21
21
  expect(Fog::Compute::VcloudDirector).to receive(:new).and_return(vcloud)
22
22
 
23
- expect(Vcloud::Fog::ModelInterface.new.get_vm_by_href(vm_href)).to eq(vm)
23
+ expect(Vcloud::Core::Fog::ModelInterface.new.get_vm_by_href(vm_href)).to eq(vm)
24
24
  end
25
25
  end
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
  require 'stringio'
3
3
 
4
- describe Vcloud::Fog::Login do
4
+ describe Vcloud::Core::Fog::Login do
5
5
  describe "#token" do
6
6
  it "should return the output from get_token" do
7
7
  expect(subject).to receive(:check_plaintext_pass)
@@ -20,7 +20,7 @@ describe Vcloud::Fog::Login do
20
20
  describe "#check_plaintext_pass" do
21
21
  context "vcloud_director_password not set" do
22
22
  it "should not raise an exception" do
23
- expect(Vcloud::Fog).to receive(:fog_credentials_pass).and_return(nil)
23
+ expect(Vcloud::Core::Fog).to receive(:fog_credentials_pass).and_return(nil)
24
24
  expect(subject).to receive(:get_token)
25
25
  expect { subject.token('supersekret') }.not_to raise_error
26
26
  end
@@ -28,7 +28,7 @@ describe Vcloud::Fog::Login do
28
28
 
29
29
  context "vcloud_director_password empty string" do
30
30
  it "should not raise an exception" do
31
- expect(Vcloud::Fog).to receive(:fog_credentials_pass).and_return('')
31
+ expect(Vcloud::Core::Fog).to receive(:fog_credentials_pass).and_return('')
32
32
  expect(subject).to receive(:get_token)
33
33
  expect { subject.token('supersekret') }.not_to raise_error
34
34
  end
@@ -36,7 +36,7 @@ describe Vcloud::Fog::Login do
36
36
 
37
37
  context "vcloud_director_password non-empty string" do
38
38
  it "should raise an exception" do
39
- expect(Vcloud::Fog).to receive(:fog_credentials_pass).and_return('supersekret')
39
+ expect(Vcloud::Core::Fog).to receive(:fog_credentials_pass).and_return('supersekret')
40
40
  expect(subject).to_not receive(:get_token)
41
41
  expect { subject.token('supersekret') }.to raise_error(
42
42
  RuntimeError,
@@ -0,0 +1,53 @@
1
+ require 'spec_helper'
2
+
3
+ module Vcloud
4
+ module Core
5
+ module Fog
6
+ describe ServiceInterface do
7
+
8
+ FOG_SESSION_RESPONSE = {:xmlns => 'http://www.vmware.com/vcloud/v5.1', :xmlns_xsi => 'http://www.w3.org/2001/XMLSchema-instance', :user => 'me@dexample.com', :org => 'my_org', :type => 'application/vnd.vmware.vcloud.session+xml', :href => 'https://example.org/api/session/', :xsi_schemaLocation => 'http://www.vmware.com/vcloud/v5.1 http://example.org/api/v5.1/schema/master.xsd', :Link => [{:rel => 'down', :type => 'application/vnd.vmware.vcloud.orgList+xml', :href => 'https://example.com/api/org/'}, {:rel => 'down', :type => 'application/vnd.vmware.admin.vcloud+xml', :href => 'https://example.com/api/admin/'}, {:rel => 'down', :type => 'application/vnd.vmware.vcloud.org+xml', :name => 'vdc_name', :href => 'https://example.com/api/org/0a0a0a0-0a0a0-0a0a-0a0a-0a0a0a0a0a0'}, {:rel => 'down', :type => 'application/vnd.vmware.vcloud.query.queryList+xml', :href => 'https://example.com/api/query'}, {:rel => 'entityResolver', :type => 'application/vnd.vmware.vcloud.entity+xml', :href => 'https://example.com/api/entity/'}, {:rel => 'down:extensibility', :type => 'application/vnd.vmware.vcloud.apiextensibility+xml', :href => 'https://example.com/api/extensibility'}]}
9
+ FOG_ORGANIZATION_RESPONSE = {:xmlns => 'http://www.vmware.com/vcloud/v5.1', :xmlns_xsi => 'http://www.w3.org/2001/XMLSchema-instance', :name => 'org_name', :id => 'urn:vcloud:org:0a0a0a0-0a0a0-0a0a-0a0a-0a0a0a0a0a0', :type => 'application/vnd.vmware.vcloud.org+xml', :href => 'https://example.com/api/org/0a0a0a0-0a0a0-0a0a-0a0a-0a0a0a0a0a0', :xsi_schemaLocation => 'http://www.vmware.com/vcloud/v1.5 http://example.com/api/v1.5/schema/master.xsd', :Link => [{:rel => 'down', :type => 'application/vnd.vmware.vcloud.vdc+xml', :name => 'vdc_name', :href => 'https://example.com/api/vdc/0a0a0a0-0a0a0-0a0a-0a0a-0a0a0a0a0a0'}, {:rel => 'down', :type => 'application/vnd.vmware.vcloud.tasksList+xml', :href => 'https://example.com/api/tasksList/0a0a0a0-0a0a0-0a0a-0a0a-0a0a0a0a0a0'}, {:rel => 'down', :type => 'application/vnd.vmware.vcloud.catalog+xml', :name => 'Appliances', :href => 'https://example.com/api/catalog/0a0a0a0-0a0a0-0a0a-0a0a-0a0a0a0a0a0'}, {:rel => 'down', :type => 'application/vnd.vmware.vcloud.controlAccess+xml', :href => 'https://example.com/api/org/0a0a0a0-0a0a0-0a0a-0a0a-0a0a0a0a0a0X/catalog/0a0a0a0-0a0a0-0a0a-0a0a-0a0a0a0a0a0/controlAccess/'}, {:rel => 'down', :type => 'application/vnd.vmware.vcloud.catalog+xml', :name => 'Public Catalog', :href => 'https://example.com/api/catalog/0a0a0a0-0a0a0-0a0a-0a0a-0a0a0a0a0a0'}, {:rel => 'down', :type => 'application/vnd.vmware.vcloud.controlAccess+xml', :href => 'https://example.com/api/org/0a0a0a0-0a0a0-0a0a-0a0a-0a0a0a0a0a0/catalog/0a0a0a0-0a0a0-0a0a-0a0a-0a0a0a0a0a0/controlAccess/'}, {:rel => 'down', :type => 'application/vnd.vmware.vcloud.catalog+xml', :name => 'walker-ci', :href => 'https://example.com/api/catalog/0a0a0a0-0a0a0-0a0a-0a0a-0a0a0a0a0a0'}, {:rel => 'down', :type => 'application/vnd.vmware.vcloud.controlAccess+xml', :href => 'https://example.com/api/org/0a0a0a0-0a0a0-0a0a-0a0a-0a0a0a0a0a0/catalog/0a0a0a0-0a0a0-0a0a-0a0a-0a0a0a0a0a0/controlAccess/'}, {:rel => 'controlAccess', :type => 'application/vnd.vmware.vcloud.controlAccess+xml', :href => 'https://example.com/api/org/0a0a0a0-0a0a0-0a0a-0a0a-0a0a0a0a0a0/catalog/0a0a0a0-0a0a0-0a0a-0a0a-0a0a0a0a0a0/action/controlAccess'}, {:rel => 'down', :type => 'application/vnd.vmware.vcloud.catalog+xml', :name => 'Images', :href => 'https://example.com/api/catalog/0a0a0a0-0a0a0-0a0a-0a0a-0a0a0a0a0a0'}, {:rel => 'down', :type => 'application/vnd.vmware.vcloud.controlAccess+xml', :href => 'https://example.com/api/org/0a0a0a0-0a0a0-0a0a-0a0a-0a0a0a0a0a0/catalog/0a0a0a0-0a0a0-0a0a-0a0a-0a0a0a0a0a0/controlAccess/'}, {:rel => 'add', :type => 'application/vnd.vmware.admin.catalog+xml', :href => 'https://example.com/api/admin/org/0a0a0a0-0a0a0-0a0a-0a0a-0a0a0a0a0a0/catalogs'}, {:rel => 'down', :type => 'application/vnd.vmware.vcloud.orgNetwork+xml', :name => 'walker-ci-network', :href => 'https://example.com/api/network/0a0a0a0-0a0a0-0a0a-0a0a-0a0a0a0a0a0'}, {:rel => 'down', :type => 'application/vnd.vmware.vcloud.orgNetwork+xml', :name => 'backend', :href => 'https://example.com/api/network/0a0a0a0-0a0a0-0a0a-0a0a-0a0a0a0a0a0'}, {:rel => 'down', :type => 'application/vnd.vmware.vcloud.supportedSystemsInfo+xml', :href => 'https://example.com/api/supportedSystemsInfo/'}, {:rel => 'down', :type => 'application/vnd.vmware.vcloud.metadata+xml', :href => 'https://example.com/api/org/0a0a0a0-0a0a0-0a0a-0a0a-0a0a0a0a0a0/metadata'}], :Description => 'Added description', :FullName => 'GDS CI Tools', :Tasks => {:Task => []}}
10
+
11
+ it 'should raise a exception if named vdc not found in the data returned' do
12
+
13
+ fog_facade = double(:FogFacade)
14
+ expect(fog_facade).to receive(:session) { FOG_SESSION_RESPONSE }
15
+ expect(fog_facade).to receive(:get_organization) { FOG_ORGANIZATION_RESPONSE }
16
+
17
+ service_interface = ServiceInterface.new(fog_facade)
18
+
19
+ expect { service_interface.vdc('DoesNotExist') }.to raise_exception(RuntimeError, 'vdc DoesNotExist cannot be found')
20
+ end
21
+
22
+ context 'configure edge gateway' do
23
+ before(:each) do
24
+ @config = { :Blah => 'TestData' }
25
+ @vcloud = double(:vcloud)
26
+ expect(::Fog::Compute::VcloudDirector).to receive(:new).and_return(@vcloud)
27
+ end
28
+
29
+ it "should configure firewall for given edge gateway id" do
30
+ task = double(:task)
31
+ expect(Vcloud::Core::logger).to receive(:info).with("Updating EdgeGateway 1234")
32
+ expect(@vcloud).to receive(:post_configure_edge_gateway_services).with("1234", @config).
33
+ and_return(double(:response, :body => task ))
34
+ expect(@vcloud).to receive(:process_task).with(task)
35
+
36
+ ServiceInterface.new.post_configure_edge_gateway_services "1234", @config
37
+ end
38
+
39
+
40
+ it "should log and return exceptions without swallowing" do
41
+ expect(Vcloud::Core::logger).to receive(:info).with("Updating EdgeGateway 1234")
42
+ runtime_error = RuntimeError.new('Test Error')
43
+ expect(Vcloud::Core::logger).to receive(:error).with("Could not update EdgeGateway 1234 : #{runtime_error}")
44
+ expect(@vcloud).to receive(:post_configure_edge_gateway_services).with("1234", @config).
45
+ and_raise(runtime_error)
46
+ expect{ ServiceInterface.new.post_configure_edge_gateway_services("1234", @config) }.to raise_error("Test Error")
47
+ end
48
+ end
49
+
50
+ end
51
+ end
52
+ end
53
+ end