Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
551cea96
Commit
551cea96
authored
Aug 17, 2016
by
Abrar Shivani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix: dynamic provisioning for vSphere
parent
46176dbe
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
54 additions
and
6 deletions
+54
-6
vsphere.go
pkg/cloudprovider/providers/vsphere/vsphere.go
+54
-6
No files found.
pkg/cloudprovider/providers/vsphere/vsphere.go
View file @
551cea96
...
@@ -34,6 +34,7 @@ import (
...
@@ -34,6 +34,7 @@ import (
"github.com/vmware/govmomi/object"
"github.com/vmware/govmomi/object"
"github.com/vmware/govmomi/property"
"github.com/vmware/govmomi/property"
"github.com/vmware/govmomi/vim25/mo"
"github.com/vmware/govmomi/vim25/mo"
"github.com/vmware/govmomi/vim25/soap"
"github.com/vmware/govmomi/vim25/types"
"github.com/vmware/govmomi/vim25/types"
"golang.org/x/net/context"
"golang.org/x/net/context"
...
@@ -46,14 +47,16 @@ const (
...
@@ -46,14 +47,16 @@ const (
ProviderName
=
"vsphere"
ProviderName
=
"vsphere"
ActivePowerState
=
"poweredOn"
ActivePowerState
=
"poweredOn"
SCSIControllerType
=
"scsi"
SCSIControllerType
=
"scsi"
LSILogicControllerType
=
"lsi
l
ogic"
LSILogicControllerType
=
"lsi
L
ogic"
BusLogicControllerType
=
"bus
l
ogic"
BusLogicControllerType
=
"bus
L
ogic"
PVSCSIControllerType
=
"pvscsi"
PVSCSIControllerType
=
"pvscsi"
LSILogicSASControllerType
=
"lsi
l
ogic-sas"
LSILogicSASControllerType
=
"lsi
L
ogic-sas"
SCSIControllerLimit
=
4
SCSIControllerLimit
=
4
SCSIControllerDeviceLimit
=
15
SCSIControllerDeviceLimit
=
15
SCSIDeviceSlots
=
16
SCSIDeviceSlots
=
16
SCSIReservedSlot
=
7
SCSIReservedSlot
=
7
ThinDiskType
=
"thin"
VolDir
=
"kubevols"
)
)
// Controller types that are currently supported for hot attach of disks
// Controller types that are currently supported for hot attach of disks
...
@@ -61,12 +64,13 @@ const (
...
@@ -61,12 +64,13 @@ const (
// it fails to remove the device from the /dev path (which should be manually done)
// it fails to remove the device from the /dev path (which should be manually done)
// making the subsequent attaches to the node to fail.
// making the subsequent attaches to the node to fail.
// TODO: Add support for lsilogic driver type
// TODO: Add support for lsilogic driver type
var
supportedSCSIControllerType
=
[]
string
{
"lsilogic-sas"
,
"pvscsi"
}
var
supportedSCSIControllerType
=
[]
string
{
strings
.
ToLower
(
LSILogicSASControllerType
),
PVSCSIControllerType
}
var
ErrNoDiskUUIDFound
=
errors
.
New
(
"No disk UUID found"
)
var
ErrNoDiskUUIDFound
=
errors
.
New
(
"No disk UUID found"
)
var
ErrNoDiskIDFound
=
errors
.
New
(
"No vSphere disk ID found"
)
var
ErrNoDiskIDFound
=
errors
.
New
(
"No vSphere disk ID found"
)
var
ErrNoDevicesFound
=
errors
.
New
(
"No devices found"
)
var
ErrNoDevicesFound
=
errors
.
New
(
"No devices found"
)
var
ErrNonSupportedControllerType
=
errors
.
New
(
"Disk is attached to non-supported controller type"
)
var
ErrNonSupportedControllerType
=
errors
.
New
(
"Disk is attached to non-supported controller type"
)
var
ErrFileAlreadyExist
=
errors
.
New
(
"File requested already exist"
)
// VSphere is an implementation of cloud provider Interface for VSphere.
// VSphere is an implementation of cloud provider Interface for VSphere.
type
VSphere
struct
{
type
VSphere
struct
{
...
@@ -778,7 +782,7 @@ func getSCSIControllers(vmDevices object.VirtualDeviceList) []*types.VirtualCont
...
@@ -778,7 +782,7 @@ func getSCSIControllers(vmDevices object.VirtualDeviceList) []*types.VirtualCont
for
_
,
device
:=
range
vmDevices
{
for
_
,
device
:=
range
vmDevices
{
devType
:=
vmDevices
.
Type
(
device
)
devType
:=
vmDevices
.
Type
(
device
)
switch
devType
{
switch
devType
{
case
SCSIControllerType
,
LSILogicControllerType
,
BusLogicControllerType
,
PVSCSIControllerType
,
LSILogicSASControllerType
:
case
SCSIControllerType
,
strings
.
ToLower
(
LSILogicControllerType
),
strings
.
ToLower
(
BusLogicControllerType
),
PVSCSIControllerType
,
strings
.
ToLower
(
LSILogicSASControllerType
)
:
if
c
,
ok
:=
device
.
(
types
.
BaseVirtualController
);
ok
{
if
c
,
ok
:=
device
.
(
types
.
BaseVirtualController
);
ok
{
scsiControllers
=
append
(
scsiControllers
,
c
.
GetVirtualController
())
scsiControllers
=
append
(
scsiControllers
,
c
.
GetVirtualController
())
}
}
...
@@ -1050,8 +1054,29 @@ func (vs *VSphere) CreateVolume(name string, size int, tags *map[string]string)
...
@@ -1050,8 +1054,29 @@ func (vs *VSphere) CreateVolume(name string, size int, tags *map[string]string)
dc
,
err
:=
f
.
Datacenter
(
ctx
,
vs
.
cfg
.
Global
.
Datacenter
)
dc
,
err
:=
f
.
Datacenter
(
ctx
,
vs
.
cfg
.
Global
.
Datacenter
)
f
.
SetDatacenter
(
dc
)
f
.
SetDatacenter
(
dc
)
ds
,
err
:=
f
.
Datastore
(
ctx
,
vs
.
cfg
.
Global
.
Datastore
)
if
err
!=
nil
{
glog
.
Errorf
(
"Failed while searching for datastore %+q. err %s"
,
vs
.
cfg
.
Global
.
Datastore
,
err
)
return
""
,
err
}
if
(
*
tags
)[
"adapterType"
]
==
""
{
(
*
tags
)[
"adapterType"
]
=
LSILogicControllerType
}
if
(
*
tags
)[
"diskType"
]
==
""
{
(
*
tags
)[
"diskType"
]
=
ThinDiskType
}
// vmdks will be created inside kubevols directory
kubeVolsPath
:=
filepath
.
Clean
(
ds
.
Path
(
VolDir
))
+
"/"
err
=
makeDirectoryInDatastore
(
c
,
dc
,
kubeVolsPath
,
false
)
if
err
!=
nil
&&
err
!=
ErrFileAlreadyExist
{
glog
.
Errorf
(
"Cannot create dir %#v. err %s"
,
kubeVolsPath
,
err
)
return
""
,
err
}
vmDiskPath
:=
kubeVolsPath
+
name
+
".vmdk"
// Create a virtual disk manager
// Create a virtual disk manager
vmDiskPath
:=
"["
+
vs
.
cfg
.
Global
.
Datastore
+
"] "
+
name
+
".vmdk"
virtualDiskManager
:=
object
.
NewVirtualDiskManager
(
c
.
Client
)
virtualDiskManager
:=
object
.
NewVirtualDiskManager
(
c
.
Client
)
// Create specification for new virtual disk
// Create specification for new virtual disk
...
@@ -1147,3 +1172,26 @@ func (vs *VSphere) NodeExists(c *govmomi.Client, nodeName string) (bool, error)
...
@@ -1147,3 +1172,26 @@ func (vs *VSphere) NodeExists(c *govmomi.Client, nodeName string) (bool, error)
return
false
,
nil
return
false
,
nil
}
}
// Creates a folder using the specified name.
// If the intermediate level folders do not exist,
// and the parameter createParents is true,
// all the non-existent folders are created.
func
makeDirectoryInDatastore
(
c
*
govmomi
.
Client
,
dc
*
object
.
Datacenter
,
path
string
,
createParents
bool
)
error
{
ctx
,
cancel
:=
context
.
WithCancel
(
context
.
Background
())
defer
cancel
()
fileManager
:=
object
.
NewFileManager
(
c
.
Client
)
err
:=
fileManager
.
MakeDirectory
(
ctx
,
path
,
dc
,
createParents
)
if
err
!=
nil
{
if
soap
.
IsSoapFault
(
err
)
{
soapFault
:=
soap
.
ToSoapFault
(
err
)
if
_
,
ok
:=
soapFault
.
VimFault
()
.
(
types
.
FileAlreadyExists
);
ok
{
return
ErrFileAlreadyExist
}
}
}
return
err
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment