Skip to content
This repository has been archived by the owner on Nov 9, 2020. It is now read-only.

Commit

Permalink
Adds support for whitespace chars in Datastore names on Windows (#1745)
Browse files Browse the repository at this point in the history
This commit adds handling to correctly map volumes with whitespace characters in its name.
  • Loading branch information
venilnoronha authored and shuklanirdesh82 committed Aug 18, 2017
1 parent cf5c7b9 commit eec1d4d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
12 changes: 6 additions & 6 deletions client_plugin/utils/fs/fs_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,18 @@ const (
$instanceId = $_
$uiNum = (
Get-PnpDeviceProperty -InstanceId $instanceId -KeyName 'DEVPKEY_Device_UINumber' |
Select -expand Data -erroraction 'silentlycontinue'
Select -Expand Data -ErrorAction 'SilentlyContinue'
)
$addr = (
Get-PnpDeviceProperty -InstanceId $instanceId -KeyName 'DEVPKEY_Device_Address' |
Select -expand Data -erroraction 'silentlycontinue'
Select -Expand Data -ErrorAction 'SilentlyContinue'
)
If ($uiNum -eq '%s' -And $addr -eq '%s') {
Write-Host ""
Get-WmiObject Win32_DiskDrive |
Where-Object { $_.PNPDeviceId -eq $instanceId } |
Select-Object -ExpandProperty Index
exit
Exit
}
}
Write-Host ""
Expand Down Expand Up @@ -100,7 +100,7 @@ const (
$diskNum = $_.DiskNumber
Remove-PartitionAccessPath -DiskNumber $diskNum -PartitionNumber 1 -AccessPath "%s"
Write-Host $diskNum
exit
Exit
}
}
Write-Host "DiskNotFound"
Expand Down Expand Up @@ -275,11 +275,11 @@ func GetMountInfo(mountRoot string) (map[string]string, error) {
log.WithFields(log.Fields{"out": string(out)}).Info("List mounts script executed")

for _, line := range strings.Split(string(out), lf) {
fields := strings.Fields(line)
fields := strings.SplitN(line, " ", 2)
if len(fields) < 2 {
continue // skip empty line and lines too short to have our mount
}
for _, path := range fields[1:] {
for _, path := range strings.SplitN(fields[1], `\ `, -1) {
path = filepath.Clean(path) // remove trailing slash
if filepath.Dir(path) == mountRoot {
volumeMountMap[filepath.Base(path)] = fields[0]
Expand Down
5 changes: 3 additions & 2 deletions esx_service/vmdk_ops_test.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env python
# Copyright 2016 VMware, Inc. All Rights Reserved.
# Copyright 2016-2017 VMware, Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -75,7 +75,7 @@ def test_name_parse(self):
"""checks name parsing and error checks
'volume[@datastore]' -> volume and datastore"""
testInfo = [
# [ full_name. expected_vol_name, expected_datastore_name, expected_success? ]
# [ full_name, expected_vol_name, expected_datastore_name, expected_success? ]
["MyVolume123_a_.vol@vsanDatastore_11", "MyVolume123_a_.vol", "vsanDatastore_11", True],
["a1@x", "a1", "x", True],
["a1", "a1", None, True],
Expand All @@ -88,6 +88,7 @@ def test_name_parse(self):
"Just100Chars0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567", None, True],
["Volume.123@dots.dot", "Volume.123", "dots.dot", True],
["simple_volume", "simple_volume", None, True],
["spacesindatastore@local .3 - 0", "spacesindatastore", "local .3 - 0", True],
]
for unit in testInfo:
full_name, expected_vol_name, expected_ds_name, expected_result = unit
Expand Down

0 comments on commit eec1d4d

Please sign in to comment.