Skip to content

Commit

Permalink
Fix resource pool creation with '/' in name fog#261
Browse files Browse the repository at this point in the history
This fixes naming of resource pools which contains '/' symbol.
Bug is coused by rbvmomi transpolation '/' to '%2f' and while creating nested resource pool we can't find it in parent resource pool which contains '/'.
  • Loading branch information
rlazoryshchak authored and ezr-ondrej committed Aug 20, 2020
1 parent 1ee4ecf commit 5f76380
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions lib/fog/vsphere/requests/compute/create_resource_pool.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,19 @@ def create_resource_pool(attributes = {})
cluster = get_raw_cluster(attributes[:cluster], attributes[:datacenter])

root_resource_pool = if attributes[:root_resource_pool_name]
cluster.resourcePool.find attributes[:root_resource_pool_name]
cluster.resourcePool.find attributes[:root_resource_pool_name].gsub('/', '%2f')
else
cluster.resourcePool
end

root_resource_pool.CreateResourcePool(
raise ArgumentError, 'Root resource pool could not be found' if root_resource_pool.nil?

resource_pool = root_resource_pool.CreateResourcePool(
name: attributes[:name],
spec: get_resource_pool_spec(attributes)
)

get_resource_pool(attributes[:name], attributes[:cluster], attributes[:datacenter])
resource_pool_attributes(resource_pool, attributes[:cluster], attributes[:datacenter])
end

private
Expand Down
2 changes: 1 addition & 1 deletion lib/fog/vsphere/requests/compute/update_resource_pool.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def update_resource_pool(attributes = {})
config: get_resource_pool_spec(attributes)
)

get_resource_pool(attributes[:name], attributes[:cluster], attributes[:datacenter])
resource_pool_attributes(raw_resource_pool, attributes[:cluster], attributes[:datacenter])
end

private
Expand Down

0 comments on commit 5f76380

Please sign in to comment.