natdtable.go 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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 qcloud
  15. import (
  16. "fmt"
  17. api "yunion.io/x/cloudmux/pkg/apis/compute"
  18. "yunion.io/x/cloudmux/pkg/cloudprovider"
  19. "yunion.io/x/cloudmux/pkg/multicloud"
  20. )
  21. type SDTable struct {
  22. multicloud.SResourceBase
  23. QcloudTags
  24. nat *SNatGateway
  25. CreatedTime string `json:"CreatedTime"`
  26. Description string `json:"Description"`
  27. IpProtocol string `json:"IpProtocol"`
  28. PrivateIpAddress string `json:"PrivateIpAddress"`
  29. PrivatePort int `json:"PrivatePort"`
  30. PublicIpAddress string `json:"PublicIpAddress"`
  31. PublicPort int `json:"PublicPort"`
  32. }
  33. func (table *SDTable) GetName() string {
  34. if len(table.Description) > 0 {
  35. return table.Description
  36. }
  37. return fmt.Sprintf("%s/%s/%d", table.PublicIpAddress, table.IpProtocol, table.PublicPort)
  38. }
  39. func (table *SDTable) GetId() string {
  40. return fmt.Sprintf("%s/%s/%d", table.nat.GetId(), table.PublicIpAddress, table.PublicPort)
  41. }
  42. func (table *SDTable) GetGlobalId() string {
  43. return table.GetId()
  44. }
  45. func (table *SDTable) GetStatus() string {
  46. return api.NAT_STAUTS_AVAILABLE
  47. }
  48. func (table *SDTable) GetExternalIp() string {
  49. return table.PublicIpAddress
  50. }
  51. func (table *SDTable) GetExternalPort() int {
  52. return table.PublicPort
  53. }
  54. func (table *SDTable) GetInternalIp() string {
  55. return table.PrivateIpAddress
  56. }
  57. func (table *SDTable) GetInternalPort() int {
  58. return table.PrivatePort
  59. }
  60. func (table *SDTable) GetIpProtocol() string {
  61. return table.IpProtocol
  62. }
  63. func (table *SDTable) Delete() error {
  64. return cloudprovider.ErrNotImplemented
  65. }