|
| 1 | +/* |
| 2 | +Copyright 2024 The Kubernetes Authors. |
| 3 | +
|
| 4 | +Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +you may not use this file except in compliance with the License. |
| 6 | +You may obtain a copy of the License at |
| 7 | +
|
| 8 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +
|
| 10 | +Unless required by applicable law or agreed to in writing, software |
| 11 | +distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +See the License for the specific language governing permissions and |
| 14 | +limitations under the License. |
| 15 | +*/ |
| 16 | + |
| 17 | +package openstack |
| 18 | + |
| 19 | +import ( |
| 20 | + "fmt" |
| 21 | + |
| 22 | + "github.com/gophercloud/gophercloud/v2/openstack/blockstorage/v3/backups" |
| 23 | + "github.com/gophercloud/gophercloud/v2/openstack/blockstorage/v3/snapshots" |
| 24 | + "github.com/gophercloud/gophercloud/v2/openstack/blockstorage/v3/volumes" |
| 25 | + "github.com/gophercloud/gophercloud/v2/openstack/compute/v2/servers" |
| 26 | + "k8s.io/cloud-provider-openstack/pkg/util/metadata" |
| 27 | +) |
| 28 | + |
| 29 | +type NoopOpenStack struct { |
| 30 | + bsOpts BlockStorageOpts |
| 31 | + metadataOpts metadata.Opts |
| 32 | +} |
| 33 | + |
| 34 | +func (os *NoopOpenStack) CreateVolume(name string, size int, vtype, availability string, snapshotID string, sourceVolID string, sourceBackupID string, tags map[string]string) (*volumes.Volume, error) { |
| 35 | + return nil, fmt.Errorf("CreateVolume is not implemented for ephemeral storage in this configuration") |
| 36 | +} |
| 37 | + |
| 38 | +func (os *NoopOpenStack) ListVolumes(limit int, startingToken string) ([]volumes.Volume, string, error) { |
| 39 | + return nil, "", nil |
| 40 | +} |
| 41 | + |
| 42 | +func (os *NoopOpenStack) GetVolumesByName(n string) ([]volumes.Volume, error) { |
| 43 | + return nil, nil |
| 44 | +} |
| 45 | + |
| 46 | +func (os *NoopOpenStack) DeleteVolume(volumeID string) error { |
| 47 | + return nil |
| 48 | +} |
| 49 | + |
| 50 | +func (os *NoopOpenStack) GetVolume(volumeID string) (*volumes.Volume, error) { |
| 51 | + return &volumes.Volume{ID: volumeID}, nil |
| 52 | +} |
| 53 | + |
| 54 | +func (os *NoopOpenStack) AttachVolume(instanceID, volumeID string) (string, error) { |
| 55 | + return volumeID, nil |
| 56 | +} |
| 57 | + |
| 58 | +func (os *NoopOpenStack) WaitDiskAttached(instanceID string, volumeID string) error { |
| 59 | + return nil |
| 60 | +} |
| 61 | + |
| 62 | +func (os *NoopOpenStack) WaitVolumeTargetStatus(volumeID string, tStatus []string) error { |
| 63 | + return nil |
| 64 | +} |
| 65 | + |
| 66 | +func (os *NoopOpenStack) DetachVolume(instanceID, volumeID string) error { |
| 67 | + return nil |
| 68 | +} |
| 69 | + |
| 70 | +func (os *NoopOpenStack) WaitDiskDetached(instanceID string, volumeID string) error { |
| 71 | + return nil |
| 72 | +} |
| 73 | + |
| 74 | +func (os *NoopOpenStack) GetAttachmentDiskPath(instanceID, volumeID string) (string, error) { |
| 75 | + return "", nil |
| 76 | +} |
| 77 | + |
| 78 | +func (os *NoopOpenStack) ExpandVolume(volumeID string, status string, newSize int) error { |
| 79 | + return nil |
| 80 | +} |
| 81 | + |
| 82 | +func (os *NoopOpenStack) GetMaxVolLimit() int64 { |
| 83 | + if os.bsOpts.NodeVolumeAttachLimit > 0 && os.bsOpts.NodeVolumeAttachLimit <= 256 { |
| 84 | + return os.bsOpts.NodeVolumeAttachLimit |
| 85 | + } |
| 86 | + |
| 87 | + return defaultMaxVolAttachLimit |
| 88 | +} |
| 89 | + |
| 90 | +func (os *NoopOpenStack) GetBlockStorageOpts() BlockStorageOpts { |
| 91 | + return os.bsOpts |
| 92 | +} |
| 93 | + |
| 94 | +func (os *NoopOpenStack) GetMetadataOpts() metadata.Opts { |
| 95 | + return os.metadataOpts |
| 96 | +} |
| 97 | + |
| 98 | +func (os *NoopOpenStack) CreateBackup(name, volID, snapshotID, availabilityZone string, tags map[string]string) (*backups.Backup, error) { |
| 99 | + return &backups.Backup{}, nil |
| 100 | +} |
| 101 | + |
| 102 | +func (os *NoopOpenStack) BackupsAreEnabled() (bool, error) { |
| 103 | + return false, nil |
| 104 | +} |
| 105 | + |
| 106 | +func (os *NoopOpenStack) DeleteBackup(backupID string) error { |
| 107 | + return nil |
| 108 | +} |
| 109 | + |
| 110 | +func (os *NoopOpenStack) CreateSnapshot(name, volID string, tags map[string]string) (*snapshots.Snapshot, error) { |
| 111 | + return &snapshots.Snapshot{}, nil |
| 112 | +} |
| 113 | + |
| 114 | +func (os *NoopOpenStack) DeleteSnapshot(snapID string) error { |
| 115 | + return nil |
| 116 | +} |
| 117 | + |
| 118 | +func (os *NoopOpenStack) GetSnapshotByID(snapshotID string) (*snapshots.Snapshot, error) { |
| 119 | + return &snapshots.Snapshot{ID: snapshotID}, nil |
| 120 | +} |
| 121 | + |
| 122 | +func (os *NoopOpenStack) ListSnapshots(filters map[string]string) ([]snapshots.Snapshot, string, error) { |
| 123 | + return nil, "", nil |
| 124 | +} |
| 125 | + |
| 126 | +func (os *NoopOpenStack) WaitSnapshotReady(snapshotID string) (string, error) { |
| 127 | + return "", nil |
| 128 | +} |
| 129 | + |
| 130 | +func (os *NoopOpenStack) GetBackupByID(backupID string) (*backups.Backup, error) { |
| 131 | + return &backups.Backup{ID: backupID}, nil |
| 132 | +} |
| 133 | + |
| 134 | +func (os *NoopOpenStack) ListBackups(filters map[string]string) ([]backups.Backup, error) { |
| 135 | + return nil, nil |
| 136 | +} |
| 137 | + |
| 138 | +func (os *NoopOpenStack) WaitBackupReady(backupID string, snapshotSize int, backupMaxDurationSecondsPerGB int) (string, error) { |
| 139 | + return "", nil |
| 140 | +} |
| 141 | + |
| 142 | +func (os *NoopOpenStack) GetInstanceByID(instanceID string) (*servers.Server, error) { |
| 143 | + return &servers.Server{ID: instanceID}, nil |
| 144 | +} |
0 commit comments