disk_nvme.go 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. // Copyright 2019 Yunion
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. package storageman
  15. import (
  16. "context"
  17. "yunion.io/x/jsonutils"
  18. "yunion.io/x/pkg/errors"
  19. "yunion.io/x/pkg/util/qemuimgfmt"
  20. "yunion.io/x/onecloud/pkg/apis"
  21. api "yunion.io/x/onecloud/pkg/apis/compute"
  22. )
  23. var _ IDisk = (*SNVMEDisk)(nil)
  24. type SNVMEDisk struct {
  25. SBaseDisk
  26. }
  27. func (d *SNVMEDisk) GetSnapshotDir() string {
  28. return ""
  29. }
  30. func (d *SNVMEDisk) GetDiskDesc() jsonutils.JSONObject {
  31. var desc = jsonutils.NewDict()
  32. desc.Set("disk_id", jsonutils.NewString(d.Id))
  33. desc.Set("disk_size", jsonutils.NewInt(int64(d.Storage.GetCapacityMb())))
  34. desc.Set("format", jsonutils.NewString(string(qemuimgfmt.RAW)))
  35. desc.Set("disk_path", jsonutils.NewString(d.Storage.GetPath()))
  36. return desc
  37. }
  38. func (d *SNVMEDisk) CreateRaw(ctx context.Context, sizeMb int, diskFormat string, fsFormat string, fsFeatures *api.DiskFsFeatures, encryptInfo *apis.SEncryptInfo, diskId string, back string) (jsonutils.JSONObject, error) {
  39. // do nothing
  40. return nil, nil
  41. }
  42. func (s *SNVMEDisk) Delete(ctx context.Context, params interface{}) (jsonutils.JSONObject, error) {
  43. return nil, nil
  44. }
  45. func (d *SNVMEDisk) IsFile() bool {
  46. return false
  47. }
  48. func (d *SNVMEDisk) Probe() error {
  49. return nil
  50. }
  51. func (d *SNVMEDisk) DiskBackup(ctx context.Context, params interface{}) (jsonutils.JSONObject, error) {
  52. return nil, errors.ErrNotImplemented
  53. }
  54. func NewNVMEDisk(storage IStorage, id string) *SNVMEDisk {
  55. return &SNVMEDisk{
  56. SBaseDisk: *NewBaseDisk(storage, id),
  57. }
  58. }