instancenic.go 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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 ecloud
  15. import (
  16. "time"
  17. "yunion.io/x/cloudmux/pkg/cloudprovider"
  18. )
  19. type SInstanceNic struct {
  20. cloudprovider.DummyICloudNic
  21. SInstanceNicDetail
  22. instance *SInstance
  23. Id string `json:"id,omitempty"` // 网卡ID(等同 PortId)
  24. PrivateIp string `json:"-"`
  25. FipAddress string `json:"-"`
  26. FipBandwidthSize int `json:"-"`
  27. PortId string `json:"portId,omitempty"` // 兼容旧字段
  28. PortName string `json:"portName,omitempty"` // 兼容旧字段
  29. FixedIpDetails []SFixedIpDetail `json:"-"`
  30. RouterId string `json:"routerId,omitempty"`
  31. }
  32. type SInstanceNicDetail struct {
  33. MacAddress string `json:"macAddress,omitempty"`
  34. SecurityGroups []SSecurityGroupRef `json:"securityGroups,omitempty"`
  35. Status int `json:"status,omitempty"`
  36. ResourceId string `json:"resourceId,omitempty"`
  37. // CreateTime 正确拼写;保留旧字段 CreaetTime 以兼容历史引用
  38. CreateTime time.Time `json:"createTime,omitempty"`
  39. CreaetTime time.Time `json:"-"`
  40. PublicIp string `json:"publicIp,omitempty"`
  41. IpId string `json:"ipId,omitempty"`
  42. NetworkId string `json:"networkId,omitempty"`
  43. }
  44. type SSecurityGroupRef struct {
  45. Id string `json:"id,omitempty"`
  46. Name string `json:"name,omitempty"`
  47. }
  48. type SFixedIpDetail struct {
  49. IpAddress string `json:"ipAddress,omitempty"`
  50. IpVersion string `json:"ipVersion,omitempty"`
  51. PublicIp string `json:"publicIp,omitempty"`
  52. BandWidthSize int `json:"bandWidthSize,omitempty"`
  53. BandWidthType string `json:"bandWidthType,omitempty"`
  54. SubnetId string `json:"subnetId,omitempty"`
  55. SubnetName string `json:"subnetName,omitempty"`
  56. }
  57. func (in *SInstanceNic) GetIP() string {
  58. return in.PrivateIp
  59. }
  60. func (in *SInstanceNic) GetMAC() string {
  61. return in.MacAddress
  62. }
  63. func (in *SInstanceNic) GetId() string {
  64. return in.PortId
  65. }
  66. func (in *SInstanceNic) GetDriver() string {
  67. return "virtio"
  68. }
  69. func (in *SInstanceNic) InClassicNetwork() bool {
  70. return false
  71. }
  72. func (in *SInstanceNic) GetINetworkId() string {
  73. return in.NetworkId
  74. }