1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

Added request create_folder for vsphere compute. This will create a vm folder in vsphere.

This commit is contained in:
Matthew Black 2013-01-06 21:26:48 -05:00 committed by Matthew Black
parent 9db7f34aa8
commit 83d4068227
2 changed files with 23 additions and 0 deletions

View file

@ -59,6 +59,7 @@ module Fog
request :vm_reconfig_memory
request :vm_reconfig_cpus
request :vm_config_vnc
request :create_folder
module Shared

View file

@ -0,0 +1,22 @@
module Fog
module Compute
class Vsphere
class Real
def create_folder(datacenter, path, name)
#Path cannot be nil but it can be an empty string
raise ArgumentError, "Path cannot be nil" if path.nil?
parent_folder = get_raw_vmfolder(path, datacenter)
begin
new_folder = parent_folder.CreateFolder(:name => name)
# output is cleaned up to return the new path
# new path will be path/name, example: "Production/Pool1"
new_folder.path.reject { |a| a.first.class == "Folder" }.collect { |a| a.first.name }.join("/").sub(/^\/?Datacenters\/#{datacenter}\/vm\/?/, '')
rescue => e
raise e, "failed to create folder: #{e}"
end
end
end
end
end
end