vpc.go 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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 proxmox
  15. import (
  16. api "yunion.io/x/cloudmux/pkg/apis/compute"
  17. "yunion.io/x/cloudmux/pkg/cloudprovider"
  18. "yunion.io/x/cloudmux/pkg/multicloud"
  19. )
  20. type SVpc struct {
  21. multicloud.SVpc
  22. ProxmoxTags
  23. region *SRegion
  24. }
  25. func (self *SVpc) GetName() string {
  26. return "Default"
  27. }
  28. func (self *SVpc) GetId() string {
  29. return self.region.GetId()
  30. }
  31. func (self *SVpc) GetGlobalId() string {
  32. return self.GetId()
  33. }
  34. func (self *SVpc) Delete() error {
  35. return cloudprovider.ErrNotSupported
  36. }
  37. func (self *SVpc) IsEmulated() bool {
  38. return true
  39. }
  40. func (self *SVpc) GetCidrBlock() string {
  41. return "0.0.0.0/0"
  42. }
  43. func (self *SVpc) GetIRouteTables() ([]cloudprovider.ICloudRouteTable, error) {
  44. return []cloudprovider.ICloudRouteTable{}, nil
  45. }
  46. func (self *SVpc) GetIRouteTableById(routeTableId string) (cloudprovider.ICloudRouteTable, error) {
  47. return nil, cloudprovider.ErrNotFound
  48. }
  49. func (self *SVpc) GetISecurityGroups() ([]cloudprovider.ICloudSecurityGroup, error) {
  50. return []cloudprovider.ICloudSecurityGroup{}, nil
  51. }
  52. func (self *SVpc) GetIWires() ([]cloudprovider.ICloudWire, error) {
  53. wires, err := self.region.GetWires()
  54. if err != nil {
  55. return nil, err
  56. }
  57. ret := []cloudprovider.ICloudWire{}
  58. for i := range wires {
  59. wires[i].region = self.region
  60. ret = append(ret, &wires[i])
  61. }
  62. return ret, nil
  63. }
  64. func (self *SVpc) GetIWireById(id string) (cloudprovider.ICloudWire, error) {
  65. wire, err := self.region.GetWire()
  66. if err != nil {
  67. return nil, err
  68. }
  69. wire.region = self.region
  70. return wire, nil
  71. }
  72. func (self *SVpc) GetIsDefault() bool {
  73. return true
  74. }
  75. func (self *SVpc) GetRegion() cloudprovider.ICloudRegion {
  76. return self.region
  77. }
  78. func (self *SVpc) GetStatus() string {
  79. return api.VPC_STATUS_AVAILABLE
  80. }