-
Notifications
You must be signed in to change notification settings - Fork 616
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[cinder-csi]: allow node service to run without openstack client (#2655)
- Loading branch information
Showing
4 changed files
with
206 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,144 @@ | ||
/* | ||
Copyright 2024 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 openstack | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/gophercloud/gophercloud/v2/openstack/blockstorage/v3/backups" | ||
"github.com/gophercloud/gophercloud/v2/openstack/blockstorage/v3/snapshots" | ||
"github.com/gophercloud/gophercloud/v2/openstack/blockstorage/v3/volumes" | ||
"github.com/gophercloud/gophercloud/v2/openstack/compute/v2/servers" | ||
"k8s.io/cloud-provider-openstack/pkg/util/metadata" | ||
) | ||
|
||
type NoopOpenStack struct { | ||
bsOpts BlockStorageOpts | ||
metadataOpts metadata.Opts | ||
} | ||
|
||
func (os *NoopOpenStack) CreateVolume(name string, size int, vtype, availability string, snapshotID string, sourceVolID string, sourceBackupID string, tags map[string]string) (*volumes.Volume, error) { | ||
return nil, fmt.Errorf("CreateVolume is not implemented for ephemeral storage in this configuration") | ||
} | ||
|
||
func (os *NoopOpenStack) ListVolumes(limit int, startingToken string) ([]volumes.Volume, string, error) { | ||
return nil, "", nil | ||
} | ||
|
||
func (os *NoopOpenStack) GetVolumesByName(n string) ([]volumes.Volume, error) { | ||
return nil, nil | ||
} | ||
|
||
func (os *NoopOpenStack) DeleteVolume(volumeID string) error { | ||
return nil | ||
} | ||
|
||
func (os *NoopOpenStack) GetVolume(volumeID string) (*volumes.Volume, error) { | ||
return &volumes.Volume{ID: volumeID}, nil | ||
} | ||
|
||
func (os *NoopOpenStack) AttachVolume(instanceID, volumeID string) (string, error) { | ||
return volumeID, nil | ||
} | ||
|
||
func (os *NoopOpenStack) WaitDiskAttached(instanceID string, volumeID string) error { | ||
return nil | ||
} | ||
|
||
func (os *NoopOpenStack) WaitVolumeTargetStatus(volumeID string, tStatus []string) error { | ||
return nil | ||
} | ||
|
||
func (os *NoopOpenStack) DetachVolume(instanceID, volumeID string) error { | ||
return nil | ||
} | ||
|
||
func (os *NoopOpenStack) WaitDiskDetached(instanceID string, volumeID string) error { | ||
return nil | ||
} | ||
|
||
func (os *NoopOpenStack) GetAttachmentDiskPath(instanceID, volumeID string) (string, error) { | ||
return "", nil | ||
} | ||
|
||
func (os *NoopOpenStack) ExpandVolume(volumeID string, status string, newSize int) error { | ||
return nil | ||
} | ||
|
||
func (os *NoopOpenStack) GetMaxVolLimit() int64 { | ||
if os.bsOpts.NodeVolumeAttachLimit > 0 && os.bsOpts.NodeVolumeAttachLimit <= 256 { | ||
return os.bsOpts.NodeVolumeAttachLimit | ||
} | ||
|
||
return defaultMaxVolAttachLimit | ||
} | ||
|
||
func (os *NoopOpenStack) GetBlockStorageOpts() BlockStorageOpts { | ||
return os.bsOpts | ||
} | ||
|
||
func (os *NoopOpenStack) GetMetadataOpts() metadata.Opts { | ||
return os.metadataOpts | ||
} | ||
|
||
func (os *NoopOpenStack) CreateBackup(name, volID, snapshotID, availabilityZone string, tags map[string]string) (*backups.Backup, error) { | ||
return &backups.Backup{}, nil | ||
} | ||
|
||
func (os *NoopOpenStack) BackupsAreEnabled() (bool, error) { | ||
return false, nil | ||
} | ||
|
||
func (os *NoopOpenStack) DeleteBackup(backupID string) error { | ||
return nil | ||
} | ||
|
||
func (os *NoopOpenStack) CreateSnapshot(name, volID string, tags map[string]string) (*snapshots.Snapshot, error) { | ||
return &snapshots.Snapshot{}, nil | ||
} | ||
|
||
func (os *NoopOpenStack) DeleteSnapshot(snapID string) error { | ||
return nil | ||
} | ||
|
||
func (os *NoopOpenStack) GetSnapshotByID(snapshotID string) (*snapshots.Snapshot, error) { | ||
return &snapshots.Snapshot{ID: snapshotID}, nil | ||
} | ||
|
||
func (os *NoopOpenStack) ListSnapshots(filters map[string]string) ([]snapshots.Snapshot, string, error) { | ||
return nil, "", nil | ||
} | ||
|
||
func (os *NoopOpenStack) WaitSnapshotReady(snapshotID string) (string, error) { | ||
return "", nil | ||
} | ||
|
||
func (os *NoopOpenStack) GetBackupByID(backupID string) (*backups.Backup, error) { | ||
return &backups.Backup{ID: backupID}, nil | ||
} | ||
|
||
func (os *NoopOpenStack) ListBackups(filters map[string]string) ([]backups.Backup, error) { | ||
return nil, nil | ||
} | ||
|
||
func (os *NoopOpenStack) WaitBackupReady(backupID string, snapshotSize int, backupMaxDurationSecondsPerGB int) (string, error) { | ||
return "", nil | ||
} | ||
|
||
func (os *NoopOpenStack) GetInstanceByID(instanceID string) (*servers.Server, error) { | ||
return &servers.Server{ID: instanceID}, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters