45
45
- The timeout in seconds for the upload to the datastore.
46
46
default: 10
47
47
type: int
48
+ diskformat:
49
+ description:
50
+ - Optional argument - Set a diskformat for certain uploads like stream optimized vmdks
51
+ - Example "StreamVmdk" needs to be set for stream optimized vmdks that are uploaded to vSAN storage
52
+ type: str
48
53
49
54
notes:
50
55
- "This module ought to be run from a system that can access the vCenter or the ESXi directly and has the file to transfer.
87
92
datastore: datastore2
88
93
path: other/remote/file
89
94
delegate_to: other_system
95
+
96
+ - name: Copy file to datastore using other_system
97
+ community.vmware.vsphere_copy:
98
+ hostname: '{{ vcenter_hostname }}'
99
+ username: '{{ vcenter_username }}'
100
+ password: '{{ vcenter_password }}'
101
+ src: /other/local/streamOptimized.vmdk
102
+ datacenter: DC2 Someplace
103
+ datastore: datastore2
104
+ path: disk_imports/streamOptimized.vmdk
105
+ timeout: 360
106
+ diskformat: StreamVmdk
107
+ delegate_to: other_system
90
108
'''
91
109
92
110
import atexit
103
121
from ansible_collections .community .vmware .plugins .module_utils .vmware import vmware_argument_spec
104
122
105
123
106
- def vmware_path (datastore , datacenter , path ):
124
+ def vmware_path (datastore , datacenter , path , diskformat ):
107
125
''' Constructs a URL path that vSphere accepts reliably '''
108
126
path = "/folder/%s" % quote (path .lstrip ("/" ))
109
127
# Due to a software bug in vSphere, it fails to handle ampersand in datacenter names
@@ -114,6 +132,8 @@ def vmware_path(datastore, datacenter, path):
114
132
if datacenter :
115
133
datacenter = datacenter .replace ('&' , '%26' )
116
134
params ["dcPath" ] = datacenter
135
+ if diskformat :
136
+ params ["diskFormat" ] = diskformat
117
137
params = urlencode (params )
118
138
return "%s?%s" % (path , params )
119
139
@@ -125,7 +145,8 @@ def main():
125
145
datacenter = dict (required = False ),
126
146
datastore = dict (required = True ),
127
147
path = dict (required = True , aliases = ['dest' ], type = 'str' ),
128
- timeout = dict (default = 10 , type = 'int' ))
148
+ timeout = dict (default = 10 , type = 'int' ),
149
+ diskformat = dict (required = False , type = 'str' ))
129
150
)
130
151
131
152
module = AnsibleModule (
@@ -141,6 +162,7 @@ def main():
141
162
datacenter = module .params .get ('datacenter' )
142
163
datastore = module .params .get ('datastore' )
143
164
path = module .params .get ('path' )
165
+ diskformat = module .params .get ('diskformat' )
144
166
validate_certs = module .params .get ('validate_certs' )
145
167
timeout = module .params .get ('timeout' )
146
168
@@ -156,7 +178,7 @@ def main():
156
178
data = mmap .mmap (fd .fileno (), 0 , access = mmap .ACCESS_READ )
157
179
atexit .register (data .close )
158
180
159
- remote_path = vmware_path (datastore , datacenter , path )
181
+ remote_path = vmware_path (datastore , datacenter , path , diskformat )
160
182
161
183
if not all ([hostname , username , password ]):
162
184
module .fail_json (msg = "One of following parameter is missing - hostname, username, password" )
0 commit comments