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
bab4256e
Unverified
Commit
bab4256e
authored
Jan 17, 2019
by
Kubernetes Prow Robot
Committed by
GitHub
Jan 17, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #72938 from dims/add-support-for-openstack-cinder-to-csi-translation-lib
Add support for OpenStack cinder to csi-translation-lib
parents
493d3565
05e09add
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
95 additions
and
0 deletions
+95
-0
BUILD
staging/src/k8s.io/csi-translation-lib/plugins/BUILD
+1
-0
openstack_cinder.go
...rc/k8s.io/csi-translation-lib/plugins/openstack_cinder.go
+93
-0
translate.go
staging/src/k8s.io/csi-translation-lib/translate.go
+1
-0
No files found.
staging/src/k8s.io/csi-translation-lib/plugins/BUILD
View file @
bab4256e
...
...
@@ -6,6 +6,7 @@ go_library(
"aws_ebs.go",
"gce_pd.go",
"in_tree_volume.go",
"openstack_cinder.go",
],
importmap = "k8s.io/kubernetes/vendor/k8s.io/csi-translation-lib/plugins",
importpath = "k8s.io/csi-translation-lib/plugins",
...
...
staging/src/k8s.io/csi-translation-lib/plugins/openstack_cinder.go
0 → 100644
View file @
bab4256e
/*
Copyright 2019 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package
plugins
import
(
"fmt"
"k8s.io/api/core/v1"
)
const
(
// CinderDriverName is the name of the CSI driver for Cinder
CinderDriverName
=
"cinder.csi.openstack.org"
// CinderInTreePluginName is the name of the intree plugin for Cinder
CinderInTreePluginName
=
"kubernetes.io/cinder"
)
var
_
InTreePlugin
=
(
*
osCinderCSITranslator
)(
nil
)
// osCinderCSITranslator handles translation of PV spec from In-tree Cinder to CSI Cinder and vice versa
type
osCinderCSITranslator
struct
{}
// NewOpenStackCinderCSITranslator returns a new instance of osCinderCSITranslator
func
NewOpenStackCinderCSITranslator
()
InTreePlugin
{
return
&
osCinderCSITranslator
{}
}
// TranslateInTreePVToCSI takes a PV with Cinder set from in-tree
// and converts the Cinder source to a CSIPersistentVolumeSource
func
(
t
*
osCinderCSITranslator
)
TranslateInTreePVToCSI
(
pv
*
v1
.
PersistentVolume
)
(
*
v1
.
PersistentVolume
,
error
)
{
if
pv
==
nil
||
pv
.
Spec
.
Cinder
==
nil
{
return
nil
,
fmt
.
Errorf
(
"pv is nil or Cinder not defined on pv"
)
}
cinderSource
:=
pv
.
Spec
.
Cinder
csiSource
:=
&
v1
.
CSIPersistentVolumeSource
{
Driver
:
CinderDriverName
,
VolumeHandle
:
cinderSource
.
VolumeID
,
ReadOnly
:
cinderSource
.
ReadOnly
,
FSType
:
cinderSource
.
FSType
,
VolumeAttributes
:
map
[
string
]
string
{},
}
pv
.
Spec
.
Cinder
=
nil
pv
.
Spec
.
CSI
=
csiSource
return
pv
,
nil
}
// TranslateCSIPVToInTree takes a PV with CSIPersistentVolumeSource set and
// translates the Cinder CSI source to a Cinder In-tree source.
func
(
t
*
osCinderCSITranslator
)
TranslateCSIPVToInTree
(
pv
*
v1
.
PersistentVolume
)
(
*
v1
.
PersistentVolume
,
error
)
{
if
pv
==
nil
||
pv
.
Spec
.
CSI
==
nil
{
return
nil
,
fmt
.
Errorf
(
"pv is nil or CSI source not defined on pv"
)
}
csiSource
:=
pv
.
Spec
.
CSI
cinderSource
:=
&
v1
.
CinderPersistentVolumeSource
{
VolumeID
:
csiSource
.
VolumeHandle
,
FSType
:
csiSource
.
FSType
,
ReadOnly
:
csiSource
.
ReadOnly
,
}
pv
.
Spec
.
CSI
=
nil
pv
.
Spec
.
Cinder
=
cinderSource
return
pv
,
nil
}
// CanSupport tests whether the plugin supports a given volume
// specification from the API. The spec pointer should be considered
// const.
func
(
t
*
osCinderCSITranslator
)
CanSupport
(
pv
*
v1
.
PersistentVolume
)
bool
{
return
pv
!=
nil
&&
pv
.
Spec
.
Cinder
!=
nil
}
// GetInTreePluginName returns the name of the intree plugin driver
func
(
t
*
osCinderCSITranslator
)
GetInTreePluginName
()
string
{
return
CinderInTreePluginName
}
staging/src/k8s.io/csi-translation-lib/translate.go
View file @
bab4256e
...
...
@@ -27,6 +27,7 @@ var (
inTreePlugins
=
map
[
string
]
plugins
.
InTreePlugin
{
plugins
.
GCEPDDriverName
:
&
plugins
.
GCEPD
{},
plugins
.
AWSEBSDriverName
:
&
plugins
.
AWSEBS
{},
plugins
.
CinderDriverName
:
plugins
.
NewOpenStackCinderCSITranslator
(),
}
)
...
...
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