fog 1.16.0 → 1.17.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +6 -0
- data/README.md +25 -0
- data/changelog.txt +108 -0
- data/fog.gemspec +7 -5
- data/lib/fog/aws.rb +8 -2
- data/lib/fog/aws/cloud_formation.rb +0 -1
- data/lib/fog/aws/compute.rb +1 -1
- data/lib/fog/aws/elb.rb +0 -1
- data/lib/fog/aws/iam.rb +4 -1
- data/lib/fog/aws/models/iam/access_key.rb +5 -1
- data/lib/fog/aws/models/iam/access_keys.rb +0 -1
- data/lib/fog/aws/parsers/compute/describe_reserved_instances.rb +2 -1
- data/lib/fog/aws/parsers/storage/get_bucket_tagging.rb +37 -0
- data/lib/fog/aws/requests/compute/copy_image.rb +1 -1
- data/lib/fog/aws/requests/compute/describe_reserved_instances.rb +1 -0
- data/lib/fog/aws/requests/compute/purchase_reserved_instances_offering.rb +1 -0
- data/lib/fog/aws/requests/iam/create_access_key.rb +22 -15
- data/lib/fog/aws/requests/iam/list_access_keys.rb +15 -11
- data/lib/fog/aws/requests/iam/update_access_key.rb +22 -0
- data/lib/fog/aws/requests/storage/delete_bucket_tagging.rb +46 -0
- data/lib/fog/aws/requests/storage/get_bucket_tagging.rb +53 -0
- data/lib/fog/aws/requests/storage/put_bucket_tagging.rb +60 -0
- data/lib/fog/aws/storage.rb +32 -19
- data/lib/fog/brightbox/models/compute/load_balancer.rb +47 -2
- data/lib/fog/core/logger.rb +4 -5
- data/lib/fog/core/service.rb +1 -1
- data/lib/fog/google/README.md +2 -2
- data/lib/fog/google/compute.rb +2 -1
- data/lib/fog/google/examples/bootstrap.rb +1 -1
- data/lib/fog/google/examples/get_list_images.rb +1 -2
- data/lib/fog/google/examples/network.rb +2 -0
- data/lib/fog/google/models/compute/disk.rb +23 -0
- data/lib/fog/google/models/compute/snapshot.rb +1 -0
- data/lib/fog/google/requests/compute/insert_server.rb +1 -1
- data/lib/fog/google/requests/compute/insert_snapshot.rb +49 -0
- data/lib/fog/google/storage.rb +54 -29
- data/lib/fog/hp.rb +0 -4
- data/lib/fog/hp/block_storage.rb +2 -2
- data/lib/fog/hp/cdn.rb +2 -2
- data/lib/fog/hp/compute.rb +2 -2
- data/lib/fog/hp/storage.rb +3 -3
- data/lib/fog/linode/compute.rb +1 -1
- data/lib/fog/linode/dns.rb +1 -1
- data/lib/fog/rackspace/block_storage.rb +0 -2
- data/lib/fog/vcloud_director/compute.rb +76 -2
- data/lib/fog/vcloud_director/generators/compute/{edge_gateway.rb → edge_gateway_service_configuration.rb} +2 -1
- data/lib/fog/vcloud_director/requests/compute/delete_disk.rb +33 -0
- data/lib/fog/vcloud_director/requests/compute/delete_media.rb +82 -2
- data/lib/fog/vcloud_director/requests/compute/get_disk.rb +99 -1
- data/lib/fog/vcloud_director/requests/compute/get_disk_owner.rb +45 -0
- data/lib/fog/vcloud_director/requests/compute/get_edge_gateway.rb +33 -19
- data/lib/fog/vcloud_director/requests/compute/get_media.rb +75 -4
- data/lib/fog/vcloud_director/requests/compute/get_media_owner.rb +34 -4
- data/lib/fog/vcloud_director/requests/compute/get_task.rb +122 -3
- data/lib/fog/vcloud_director/requests/compute/get_task_list.rb +80 -37
- data/lib/fog/vcloud_director/requests/compute/{get_vms_disks_attached_to.rb → get_vms_disk_attached_to.rb} +16 -2
- data/lib/fog/vcloud_director/requests/compute/post_cancel_task.rb +18 -0
- data/lib/fog/vcloud_director/requests/compute/post_clone_media.rb +52 -1
- data/lib/fog/vcloud_director/requests/compute/post_configure_edge_gateway_services.rb +14 -2
- data/lib/fog/vcloud_director/requests/compute/post_instantiate_vapp_template.rb +2 -2
- data/lib/fog/vcloud_director/requests/compute/post_upload_disk.rb +133 -0
- data/lib/fog/vcloud_director/requests/compute/post_upload_media.rb +48 -4
- data/lib/fog/vcloud_director/requests/compute/put_guest_customization_section_vapp.rb +103 -26
- data/lib/fog/vcloud_director/requests/compute/put_network_connection_system_section_vapp.rb +90 -32
- data/lib/fog/version.rb +1 -1
- data/lib/fog/vsphere/compute.rb +29 -14
- data/lib/fog/vsphere/models/compute/server.rb +18 -6
- data/lib/fog/vsphere/requests/compute/create_vm.rb +1 -0
- data/lib/fog/vsphere/requests/compute/vm_clone.rb +2 -9
- data/lib/fog/vsphere/requests/compute/vm_reconfig_cpus.rb +2 -2
- data/lib/fog/xenserver/requests/compute/create_server.rb +1 -1
- data/tests/aws/requests/compute/instance_tests.rb +1 -0
- data/tests/aws/requests/storage/bucket_tests.rb +19 -3
- data/tests/brightbox/compute/schema.rb +1 -0
- data/tests/core/credential_tests.rb +7 -1
- data/tests/core/parser_tests.rb +1 -1
- data/tests/rackspace/block_storage_tests.rb +1 -1
- data/tests/rackspace/cdn_tests.rb +1 -1
- data/tests/rackspace/compute_tests.rb +1 -1
- data/tests/rackspace/compute_v2_tests.rb +1 -1
- data/tests/rackspace/databases_tests.rb +1 -1
- data/tests/rackspace/dns_tests.rb +1 -1
- data/tests/rackspace/load_balancer_tests.rb +1 -1
- data/tests/rackspace/storage_tests.rb +1 -1
- data/tests/vcloud_director/ensure_list_tests.rb +30 -2
- data/tests/vcloud_director/requests/compute/disk_tests.rb +160 -5
- data/tests/vcloud_director/requests/compute/edge_gateway_tests.rb +59 -1
- data/tests/vcloud_director/requests/compute/helper.rb +5 -1
- data/tests/vcloud_director/requests/compute/media_tests.rb +109 -99
- data/tests/vcloud_director/requests/compute/schema_helper.rb +15 -2
- data/tests/vcloud_director/requests/compute/task_tests.rb +21 -6
- metadata +27 -21
@@ -3,7 +3,7 @@ module Fog
|
|
3
3
|
class VcloudDirector
|
4
4
|
class Real
|
5
5
|
|
6
|
-
require 'fog/vcloud_director/generators/compute/
|
6
|
+
require 'fog/vcloud_director/generators/compute/edge_gateway_service_configuration'
|
7
7
|
|
8
8
|
# Configure edge gateway services like firewall, nat and load balancer.
|
9
9
|
#
|
@@ -21,7 +21,7 @@ module Fog
|
|
21
21
|
# vCloud API Documentaion
|
22
22
|
# @since vCloud API version 5.1
|
23
23
|
def post_configure_edge_gateway_services(id, configuration)
|
24
|
-
body = Fog::Generators::Compute::VcloudDirector::
|
24
|
+
body = Fog::Generators::Compute::VcloudDirector::EdgeGatewayServiceConfiguration.new(configuration).generate_xml
|
25
25
|
|
26
26
|
request(
|
27
27
|
:body => body,
|
@@ -34,6 +34,18 @@ module Fog
|
|
34
34
|
end
|
35
35
|
|
36
36
|
end
|
37
|
+
|
38
|
+
class Mock
|
39
|
+
def post_configure_edge_gateway_services(id, configuration)
|
40
|
+
unless data[:edge_gateways][id]
|
41
|
+
raise Fog::Compute::VcloudDirector::Forbidden.new(
|
42
|
+
"No access to entity \"(com.vmware.vcloud.entity.edgegateway:#{id})\"."
|
43
|
+
)
|
44
|
+
end
|
45
|
+
data[:edge_gateways][id][:Configuration][:EdgeGatewayServiceConfiguration] = configuration
|
46
|
+
Excon::Response.new(:body => {:name => 'mock_task', :href => '/10000000000000000000000000000000' })
|
47
|
+
end
|
48
|
+
end
|
37
49
|
end
|
38
50
|
end
|
39
51
|
end
|
@@ -74,10 +74,10 @@ module Fog
|
|
74
74
|
StorageLeaseInSeconds section[:StorageLeaseInSeconds]
|
75
75
|
end
|
76
76
|
if section.key?(:DeploymentLeaseExpiration)
|
77
|
-
DeploymentLeaseExpiration section[:DeploymentLeaseExpiration].
|
77
|
+
DeploymentLeaseExpiration section[:DeploymentLeaseExpiration].strftime('%Y-%m-%dT%H:%M:%S%z')
|
78
78
|
end
|
79
79
|
if section.key?(:StorageLeaseExpiration)
|
80
|
-
StorageLeaseExpiration section[:StorageLeaseExpiration].
|
80
|
+
StorageLeaseExpiration section[:StorageLeaseExpiration].strftime('%Y-%m-%dT%H:%M:%S%z')
|
81
81
|
end
|
82
82
|
}
|
83
83
|
end
|
@@ -0,0 +1,133 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class VcloudDirector
|
4
|
+
class Real
|
5
|
+
# Create a disk.
|
6
|
+
#
|
7
|
+
# @param [String] id Object identifier of the vDC.
|
8
|
+
# @param [String] name The name of the disk.
|
9
|
+
# @param [Integer] size Size of the disk. For modify operation this is
|
10
|
+
# required only for the XSD validation it could not be changed.
|
11
|
+
# @param [Hash] options
|
12
|
+
# @option options [String] :operationKey Optional unique identifier to
|
13
|
+
# support idempotent semantics for create and delete operations.
|
14
|
+
# @option options [Integer] :busSubType Disk bus sub type.
|
15
|
+
# @option options [Integer] :busType Disk bus type.
|
16
|
+
# @option options [String] :Description Optional description.
|
17
|
+
# @return [Excon::Response]
|
18
|
+
# * body<~Hash>:
|
19
|
+
# * :href<~String> - The URI of the disk.
|
20
|
+
# * :type<~String> - The MIME type of the disk.
|
21
|
+
# * :id<~String> - The disk identifier, expressed in URN format.
|
22
|
+
# * :operationKey<~String> - Optional unique identifier to support
|
23
|
+
# idempotent semantics for create and delete operations.
|
24
|
+
# * :name<~String> - The name of the disk.
|
25
|
+
# * :status<~String> - Creation status of the disk.
|
26
|
+
# * :busSubType<~String> - Disk bus sub type.
|
27
|
+
# * :busType<~String> - Disk bus type.
|
28
|
+
# * :size<~String> - Size of the disk.
|
29
|
+
# * :Link:
|
30
|
+
# * :Description<~String> - Optional description.
|
31
|
+
# * :Tasks<~Hash>:
|
32
|
+
# * :StorageProfile<~Hash> - Storage profile of the disk.
|
33
|
+
# * :href<~String> - Contains the URI to the entity.
|
34
|
+
# * :name<~String> - Contains the name of the entity.
|
35
|
+
# * :type<~String> - Contains the type of the entity.
|
36
|
+
# * :Owner<~Hash> - Disk owner.
|
37
|
+
# * :type<~String> - The MIME type of the entity.
|
38
|
+
# * :User<~Hash> - Reference to the user who is the owner of this
|
39
|
+
# disk.
|
40
|
+
# * :href<~String> - Contains the URI to the entity.
|
41
|
+
# * :name<~String> - Contains the name of the entity.
|
42
|
+
# * :type<~String> - Contains the type of the entity.
|
43
|
+
#
|
44
|
+
# @see http://pubs.vmware.com/vcd-51/topic/com.vmware.vcloud.api.reference.doc_51/doc/operations/POST-CreateDisk.html
|
45
|
+
# @since vCloud API version 5.1
|
46
|
+
def post_upload_disk(id, name, size, options={})
|
47
|
+
body = Nokogiri::XML::Builder.new do
|
48
|
+
DiskCreateParams(:xmlns => 'http://www.vmware.com/vcloud/v1.5') {
|
49
|
+
attrs = {
|
50
|
+
:name => name,
|
51
|
+
:size => size
|
52
|
+
}
|
53
|
+
attrs[:operationKey] = options[:operationKey] if options.key?(:operationKey)
|
54
|
+
attrs[:busSubType] = options[:busSubType] if options.key?(:busSubType)
|
55
|
+
attrs[:busType] = options[:busType] if options.key?(:busType)
|
56
|
+
Disk(attrs) {
|
57
|
+
if options.key?(:Description)
|
58
|
+
Description options[:Description]
|
59
|
+
end
|
60
|
+
if options.key?(:StorageProfile)
|
61
|
+
attrs = {
|
62
|
+
:href => options[:StorageProfile][:href]
|
63
|
+
}
|
64
|
+
StorageProfile(attrs)
|
65
|
+
end
|
66
|
+
}
|
67
|
+
}
|
68
|
+
end.to_xml
|
69
|
+
|
70
|
+
request(
|
71
|
+
:body => body,
|
72
|
+
:expects => 201,
|
73
|
+
:headers => {'Content-Type' => 'application/vnd.vmware.vcloud.diskCreateParams+xml'},
|
74
|
+
:method => 'POST',
|
75
|
+
:parser => Fog::ToHashDocument.new,
|
76
|
+
:path => "vdc/#{id}/disk"
|
77
|
+
)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
class Mock
|
82
|
+
def post_upload_disk(id, name, size, options={})
|
83
|
+
unless size.to_s =~ /^\d+$/
|
84
|
+
raise Fog::Compute::VcloudDirector::BadRequest.new(
|
85
|
+
"validation error on field 'diskSpec.sizeBytes': must be greater than or equal to 0"
|
86
|
+
)
|
87
|
+
end
|
88
|
+
unless data[:vdcs][id]
|
89
|
+
raise Fog::Compute::VcloudDirector::Forbidden.new(
|
90
|
+
'No access to entity "(com.vmware.vcloud.entity.vdc:%s)".' % id
|
91
|
+
)
|
92
|
+
end
|
93
|
+
|
94
|
+
disk_id = uuid
|
95
|
+
|
96
|
+
owner = {
|
97
|
+
:href => make_href("disk/#{disk_id}"),
|
98
|
+
:type => 'application/vnd.vmware.vcloud.disk+xml'
|
99
|
+
}
|
100
|
+
task_id = enqueue_task(
|
101
|
+
"Creating Disk #{name}(#{disk_id})", 'vdcCreateDisk', owner,
|
102
|
+
:on_success => lambda do
|
103
|
+
data[:disks][disk_id][:status] = 1
|
104
|
+
end
|
105
|
+
)
|
106
|
+
|
107
|
+
disk = {
|
108
|
+
:description => options[:Description],
|
109
|
+
:name => name,
|
110
|
+
:size => size.to_i,
|
111
|
+
:status => 0,
|
112
|
+
:tasks => [task_id],
|
113
|
+
:vdc_id => id,
|
114
|
+
:vdc_storage_class => data[:vdc_storage_classes].detect {|k,v| v[:default]}.first
|
115
|
+
}
|
116
|
+
data[:disks][disk_id] = disk
|
117
|
+
|
118
|
+
body = {
|
119
|
+
:xmlns => xmlns,
|
120
|
+
:xmlns_xsi => xmlns_xsi,
|
121
|
+
:xsi_schemaLocation => xsi_schema_location
|
122
|
+
}.merge(disk_body(disk_id))
|
123
|
+
|
124
|
+
Excon::Response.new(
|
125
|
+
:status => 201,
|
126
|
+
:headers => {'Content-Type' => "#{body[:type]};version=#{api_version}"},
|
127
|
+
:body => body
|
128
|
+
)
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|
133
|
+
end
|
@@ -22,6 +22,7 @@ module Fog
|
|
22
22
|
#
|
23
23
|
# @see http://pubs.vmware.com/vcd-51/topic/com.vmware.vcloud.api.reference.doc_51/doc/operations/POST-UploadMedia.html
|
24
24
|
# @since vCloud API version 0.9
|
25
|
+
# @todo Support vDC Storage Profiles.
|
25
26
|
def post_upload_media(vdc_id, name, image_type, size, options={})
|
26
27
|
body = Nokogiri::XML::Builder.new do
|
27
28
|
attrs = {
|
@@ -38,7 +39,7 @@ module Fog
|
|
38
39
|
}
|
39
40
|
end.to_xml
|
40
41
|
|
41
|
-
request(
|
42
|
+
response = request(
|
42
43
|
:body => body,
|
43
44
|
:expects => 201,
|
44
45
|
:headers => {'Content-Type' => 'application/vnd.vmware.vcloud.media+xml'},
|
@@ -46,6 +47,8 @@ module Fog
|
|
46
47
|
:parser => Fog::ToHashDocument.new,
|
47
48
|
:path => "vdc/#{vdc_id}/media"
|
48
49
|
)
|
50
|
+
ensure_list! response.body, :Files, :File
|
51
|
+
response
|
49
52
|
end
|
50
53
|
end
|
51
54
|
|
@@ -61,14 +64,55 @@ module Fog
|
|
61
64
|
'validation error on field \'size\': must be greater than or equal to 0'
|
62
65
|
)
|
63
66
|
end
|
64
|
-
unless
|
67
|
+
unless data[:vdcs][vdc_id]
|
65
68
|
raise Fog::Compute::VcloudDirector::Forbidden.new(
|
66
69
|
"No access to entity \"(com.vmware.vcloud.entity.vdc:#{vdc_id})\"."
|
67
70
|
)
|
68
71
|
end
|
69
72
|
|
70
|
-
|
71
|
-
|
73
|
+
media_id = uuid
|
74
|
+
file_id = uuid
|
75
|
+
|
76
|
+
owner = {
|
77
|
+
:href => make_href("media/#{media_id}"),
|
78
|
+
:type => 'application/vnd.vmware.vcloud.media+xml'
|
79
|
+
}
|
80
|
+
task_id = enqueue_task(
|
81
|
+
"Importing Media File #{name}(#{file_id})", 'vdcUploadMedia', owner,
|
82
|
+
:on_success => lambda do
|
83
|
+
media = data[:medias][media_id]
|
84
|
+
media[:file][:bytes_transferred] = media[:size]
|
85
|
+
media[:status] = 1
|
86
|
+
end
|
87
|
+
)
|
88
|
+
|
89
|
+
media = {
|
90
|
+
:description => options[:Description],
|
91
|
+
:file => {
|
92
|
+
:bytes_transferred => 0,
|
93
|
+
:uuid => file_id
|
94
|
+
},
|
95
|
+
:image_type => image_type,
|
96
|
+
:name => name,
|
97
|
+
:size => size.to_i,
|
98
|
+
:status => 0,
|
99
|
+
:tasks => [task_id],
|
100
|
+
:vdc_id => vdc_id,
|
101
|
+
:vdc_storage_class => data[:vdc_storage_classes].detect {|k,v| v[:default]}.first
|
102
|
+
}
|
103
|
+
data[:medias][media_id] = media
|
104
|
+
|
105
|
+
body = {
|
106
|
+
:xmlns => xmlns,
|
107
|
+
:xmlns_xsi => xmlns_xsi,
|
108
|
+
:xsi_schemaLocation => xsi_schema_location
|
109
|
+
}.merge(media_body(media_id))
|
110
|
+
|
111
|
+
Excon::Response.new(
|
112
|
+
:status => 201,
|
113
|
+
:headers => {'Content-Type' => "#{body[:type]};version=#{api_version}"},
|
114
|
+
:body => body
|
115
|
+
)
|
72
116
|
end
|
73
117
|
end
|
74
118
|
end
|
@@ -5,50 +5,127 @@ module Fog
|
|
5
5
|
extend Fog::Deprecation
|
6
6
|
deprecate :put_vm_customization, :put_guest_customization_section_vapp
|
7
7
|
|
8
|
-
require 'fog/vcloud_director/generators/compute/customization'
|
9
|
-
|
10
8
|
# Updates the guest customization section of a VM.
|
11
9
|
#
|
12
10
|
# This operation is asynchronous and returns a task that you can
|
13
11
|
# monitor to track the progress of the request.
|
14
12
|
#
|
15
13
|
# @param [String] id Object identifier of the VM.
|
16
|
-
# @param [Hash]
|
17
|
-
# @option
|
18
|
-
#
|
19
|
-
# @option
|
20
|
-
#
|
21
|
-
# @option
|
22
|
-
#
|
23
|
-
# @option
|
24
|
-
#
|
25
|
-
#
|
26
|
-
# @option
|
27
|
-
#
|
28
|
-
# @option
|
29
|
-
#
|
30
|
-
# @option
|
14
|
+
# @param [Hash] options
|
15
|
+
# @option options [Boolean] :Enabled True if guest customization is
|
16
|
+
# enabled.
|
17
|
+
# @option options [Boolean] :ChangeSid True if customization can change
|
18
|
+
# the Windows SID of this virtual machine.
|
19
|
+
# @option options [Boolean] :JoinDomainEnabled True if this virtual
|
20
|
+
# machine can join a Windows Domain.
|
21
|
+
# @option options [Boolean] :UseOrgSettings True if customization
|
22
|
+
# should use organization settings (OrgGuestPersonalizationSettings)
|
23
|
+
# when joining a Windows Domain.
|
24
|
+
# @option options [String] :DomainName The name of the Windows Domain
|
25
|
+
# to join.
|
26
|
+
# @option options [String] :DomainUserName User name to specify when
|
27
|
+
# joining a Windows Domain.
|
28
|
+
# @option options [String] :DomainUserPassword Password to use with
|
29
|
+
# :DomainUserName.
|
30
|
+
# @option options [String] :MachineObjectOU The name of the Windows
|
31
|
+
# Domain Organizational Unit (OU) in which the computer account for
|
32
|
+
# this virtual machine will be created.
|
33
|
+
# @option options [Boolean] :AdminPassword_enabled True if guest
|
31
34
|
# customization can modify administrator password settings for this
|
32
35
|
# virtual machine.
|
33
|
-
# @option
|
34
|
-
#
|
35
|
-
#
|
36
|
+
# @option options [Boolean] :AdminPassword_auto True if the
|
37
|
+
# administrator password for this virtual machine should be
|
38
|
+
# automatically generated.
|
39
|
+
# @option options [String] :AdminPassword True if the administrator
|
40
|
+
# password for this virtual machine should be set to this string.
|
41
|
+
# (:AdminPasswordAuto must be false.)
|
42
|
+
# @option options [Boolean] :ResetPasswordRequired True if the
|
36
43
|
# administrator password for this virtual machine must be reset after
|
37
44
|
# first use.
|
38
|
-
# @option customization [String] :
|
39
|
-
#
|
40
|
-
# @option customization [String] :
|
45
|
+
# @option customization [String] :CustomizationScript Script to run on
|
46
|
+
# guest customization. The entire script must appear in this element.
|
47
|
+
# @option customization [String] :ComputerName Computer name to assign
|
41
48
|
# to this virtual machine.
|
42
49
|
# @return [Excon::Response]
|
43
50
|
# * body<~Hash>:
|
51
|
+
# * :Tasks<~Hash>:
|
52
|
+
# * :Task<~Hash>:
|
44
53
|
#
|
45
54
|
# @see http://pubs.vmware.com/vcd-51/topic/com.vmware.vcloud.api.reference.doc_51/doc/operations/PUT-GuestCustomizationSection-vApp.html
|
46
55
|
# @since vCloud API version 1.0
|
47
|
-
def put_guest_customization_section_vapp(id,
|
48
|
-
|
56
|
+
def put_guest_customization_section_vapp(id, options={})
|
57
|
+
options = options.dup
|
58
|
+
|
59
|
+
# Mutate options to new format.
|
60
|
+
deprecated = {
|
61
|
+
:enabled => :Enabled,
|
62
|
+
:change_sid => :ChangeSid,
|
63
|
+
:join_domain_enabled => :JoinDomainEnabled,
|
64
|
+
:use_org_settings => :UseOrgSettings,
|
65
|
+
:admin_password_enabled => :AdminPasswordEnabled,
|
66
|
+
:admin_password_auto => :AdminPasswordAuto,
|
67
|
+
:reset_password_required => :ResetPasswordRequired,
|
68
|
+
:customization_script => :CustomizationScript,
|
69
|
+
:computer_name => :ComputerName
|
70
|
+
}
|
71
|
+
deprecated.each do |from, to|
|
72
|
+
options[to] = options.delete(from) if options.key?(from)
|
73
|
+
end
|
74
|
+
|
75
|
+
body = Nokogiri::XML::Builder.new do
|
76
|
+
attrs = {
|
77
|
+
:xmlns => 'http://www.vmware.com/vcloud/v1.5',
|
78
|
+
'xmlns:ovf' => 'http://schemas.dmtf.org/ovf/envelope/1'
|
79
|
+
}
|
80
|
+
GuestCustomizationSection(attrs) {
|
81
|
+
self['ovf'].Info 'Specifies Guest OS Customization Settings'
|
82
|
+
if options.key?(:Enabled)
|
83
|
+
Enabled options[:Enabled]
|
84
|
+
end
|
85
|
+
if options.key?(:ChangeSid)
|
86
|
+
ChangeSid options[:ChangeSid]
|
87
|
+
end
|
88
|
+
if options.key?(:JoinDomainEnabled)
|
89
|
+
JoinDomainEnabled options[:JoinDomainEnabled]
|
90
|
+
end
|
91
|
+
if options.key?(:UseOrgSettings)
|
92
|
+
UseOrgSettings options[:UseOrgSettings]
|
93
|
+
end
|
94
|
+
if options.key?(:DomainName)
|
95
|
+
DomainName options[:DomainName]
|
96
|
+
end
|
97
|
+
if options.key?(:DomainUser)
|
98
|
+
DomainUser options[:DomainUser]
|
99
|
+
end
|
100
|
+
if options.key?(:DomainUserPassword)
|
101
|
+
DomainUserPassword options[:DomainUserPassword]
|
102
|
+
end
|
103
|
+
if options.key?(:MachineObjectOU)
|
104
|
+
MachineObjectOU options[:MachineObjectOU]
|
105
|
+
end
|
106
|
+
if options.key?(:AdminPasswordEnabled)
|
107
|
+
AdminPasswordEnabled options[:AdminPasswordEnabled]
|
108
|
+
end
|
109
|
+
if options.key?(:AdminPasswordAuto)
|
110
|
+
AdminPasswordAuto options[:AdminPasswordAuto]
|
111
|
+
end
|
112
|
+
if options.key?(:AdminPassword)
|
113
|
+
AdminPassword options[:AdminPassword]
|
114
|
+
end
|
115
|
+
if options.key?(:ResetPasswordRequired)
|
116
|
+
ResetPasswordRequired options[:ResetPasswordRequired]
|
117
|
+
end
|
118
|
+
if options.key?(:CustomizationScript)
|
119
|
+
CustomizationScript options[:CustomizationScript]
|
120
|
+
end
|
121
|
+
if options.key?(:ComputerName)
|
122
|
+
ComputerName options[:ComputerName]
|
123
|
+
end
|
124
|
+
}
|
125
|
+
end.to_xml
|
49
126
|
|
50
127
|
request(
|
51
|
-
:body =>
|
128
|
+
:body => body,
|
52
129
|
:expects => 202,
|
53
130
|
:headers => {'Content-Type' => 'application/vnd.vmware.vcloud.guestCustomizationSection+xml'},
|
54
131
|
:method => 'PUT',
|
@@ -5,51 +5,109 @@ module Fog
|
|
5
5
|
extend Fog::Deprecation
|
6
6
|
deprecate :put_vm_network, :put_network_connection_system_section_vapp
|
7
7
|
|
8
|
-
require 'fog/vcloud_director/generators/compute/vm_network'
|
9
|
-
|
10
8
|
# Update the network connection section of a VM.
|
11
9
|
#
|
12
10
|
# This operation is asynchronous and returns a task that you can
|
13
11
|
# monitor to track the progress of the request.
|
14
12
|
#
|
15
13
|
# @param [String] id Object identifier of the VM.
|
16
|
-
# @param [Hash] network
|
17
|
-
#
|
18
|
-
# @option
|
19
|
-
# slot number associated with the NIC that should be
|
20
|
-
# virtual machine's primary network connection.
|
21
|
-
#
|
22
|
-
#
|
23
|
-
#
|
24
|
-
#
|
25
|
-
#
|
26
|
-
#
|
27
|
-
#
|
28
|
-
#
|
29
|
-
#
|
30
|
-
#
|
31
|
-
#
|
32
|
-
#
|
33
|
-
#
|
34
|
-
#
|
35
|
-
#
|
36
|
-
#
|
37
|
-
#
|
38
|
-
#
|
39
|
-
#
|
40
|
-
#
|
41
|
-
#
|
42
|
-
#
|
14
|
+
# @param [Hash] options Container for the network connections of this
|
15
|
+
# virtual machine.
|
16
|
+
# @option options [Integer] :PrimaryNetworkConnectionIndex (0)
|
17
|
+
# Virtual slot number associated with the NIC that should be
|
18
|
+
# considered this virtual machine's primary network connection.
|
19
|
+
# Defaults to slot 0.
|
20
|
+
# @option options [Array<Hash>] :NetworkConnection
|
21
|
+
# * :needsCustomization<~Boolean> - True if this NIC needs
|
22
|
+
# customization.
|
23
|
+
# * :network<~String> - Name of the network to which this NIC is
|
24
|
+
# connected.
|
25
|
+
# * :NetworkConnectionIndex<~Integer> - Virtual slot number
|
26
|
+
# associated with this NIC. First slot number is 0.
|
27
|
+
# * :IpAddress<~String> - IP address assigned to this NIC.
|
28
|
+
# * :IsConnected<~Boolean> - If the virtual machine is undeployed,
|
29
|
+
# this value specifies whether the NIC should be connected upon
|
30
|
+
# deployment. If the virtual machine is deployed, this value
|
31
|
+
# reports the current status of this NIC's connection, and can be
|
32
|
+
# updated to change that connection status.
|
33
|
+
# * :MACAddress<~String> - MAC address associated with the NIC.
|
34
|
+
# * :IpAddressAllocationMode<~String> - IP address allocation mode
|
35
|
+
# for this connection. One of:
|
36
|
+
# - POOL (A static IP address is allocated automatically from a
|
37
|
+
# pool of addresses.)
|
38
|
+
# - DHCP (The IP address is obtained from a DHCP service.)
|
39
|
+
# - MANUAL (The IP address is assigned manually in the :IpAddress
|
40
|
+
# element.)
|
41
|
+
# - NONE (No IP addressing mode specified.)
|
43
42
|
# @return [Excon::Response]
|
44
43
|
# * body<~Hash>:
|
44
|
+
# * :Tasks<~Hash>:
|
45
|
+
# * :Task<~Hash>:
|
45
46
|
#
|
46
47
|
# @see http://pubs.vmware.com/vcd-51/topic/com.vmware.vcloud.api.reference.doc_51/doc/operations/PUT-NetworkConnectionSystemSection-vApp.html
|
47
48
|
# @since vCloud API version 0.9
|
48
|
-
def put_network_connection_system_section_vapp(id,
|
49
|
-
|
49
|
+
def put_network_connection_system_section_vapp(id, options={})
|
50
|
+
options = options.dup
|
51
|
+
|
52
|
+
# Mutate options to new format.
|
53
|
+
deprecated = {
|
54
|
+
:needs_customization => :needsCustomization,
|
55
|
+
:network => :network,
|
56
|
+
:network_connection_index => :NetworkConnectionIndex,
|
57
|
+
:ip_address => :IpAddress,
|
58
|
+
:is_connected => :IsConnected,
|
59
|
+
:mac_address => :MACAddress,
|
60
|
+
:ip_address_allocation_mode => :IpAddressAllocationMode
|
61
|
+
}
|
62
|
+
option = options.delete(:primary_network_connection_index)
|
63
|
+
options[:PrimaryNetworkConnectionIndex] ||= option unless option.nil?
|
64
|
+
unless options.key?(:NetworkConnection)
|
65
|
+
deprecated.each do |from, to|
|
66
|
+
if options.key?(from)
|
67
|
+
options[:NetworkConnection] ||= [{}]
|
68
|
+
options[:NetworkConnection].first[to] = options.delete(from)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
options[:NetworkConnection] = [options[:NetworkConnection]] if options[:NetworkConnection].is_a?(Hash)
|
74
|
+
|
75
|
+
body = Nokogiri::XML::Builder.new do
|
76
|
+
attrs = {
|
77
|
+
:xmlns => 'http://www.vmware.com/vcloud/v1.5',
|
78
|
+
'xmlns:ovf' => 'http://schemas.dmtf.org/ovf/envelope/1'
|
79
|
+
}
|
80
|
+
NetworkConnectionSection(attrs) {
|
81
|
+
self[:ovf].Info 'Specifies the available VM network connections'
|
82
|
+
if options.key?(:PrimaryNetworkConnectionIndex)
|
83
|
+
PrimaryNetworkConnectionIndex options[:PrimaryNetworkConnectionIndex]
|
84
|
+
end
|
85
|
+
if network_connection = options[:NetworkConnection]
|
86
|
+
network_connection.each do |nic|
|
87
|
+
attrs = {
|
88
|
+
:network => nic[:network]
|
89
|
+
}
|
90
|
+
if nic.key?(:needsCustomization)
|
91
|
+
attrs[:needsCustomization] = nic[:needsCustomization]
|
92
|
+
end
|
93
|
+
NetworkConnection(attrs) {
|
94
|
+
NetworkConnectionIndex nic[:NetworkConnectionIndex]
|
95
|
+
if nic.key?(:IpAddress)
|
96
|
+
IpAddress nic[:IpAddress]
|
97
|
+
end
|
98
|
+
IsConnected nic[:IsConnected]
|
99
|
+
if nic.key?(:MACAddress)
|
100
|
+
MACAddress nic[:MACAddress]
|
101
|
+
end
|
102
|
+
IpAddressAllocationMode nic[:IpAddressAllocationMode]
|
103
|
+
}
|
104
|
+
end
|
105
|
+
end
|
106
|
+
}
|
107
|
+
end.to_xml
|
50
108
|
|
51
109
|
request(
|
52
|
-
:body =>
|
110
|
+
:body => body,
|
53
111
|
:expects => 202,
|
54
112
|
:headers => {'Content-Type' => 'application/vnd.vmware.vcloud.networkConnectionSection+xml'},
|
55
113
|
:method => 'PUT',
|