instancenic.go 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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 ctyun
  15. import (
  16. "yunion.io/x/cloudmux/pkg/cloudprovider"
  17. "yunion.io/x/pkg/util/netutils"
  18. )
  19. type SInstanceNic struct {
  20. instance *SInstance
  21. IPv4Address string
  22. IPv6Address []string
  23. IsMaster bool
  24. SubnetCidr string
  25. NetworkCardId string
  26. Gateway string
  27. SecurityGroup []string
  28. SubnetId string
  29. cloudprovider.DummyICloudNic
  30. }
  31. type FixedIP struct {
  32. IPAddress string `json:"ip_address"`
  33. SubnetID string `json:"subnet_id"`
  34. }
  35. func (self *SInstanceNic) GetIP() string {
  36. return self.IPv4Address
  37. }
  38. func (self *SInstanceNic) GetMAC() string {
  39. ip, _ := netutils.NewIPV4Addr(self.GetIP())
  40. return ip.ToMac("fa:16:")
  41. }
  42. func (self *SInstanceNic) GetId() string {
  43. return self.NetworkCardId
  44. }
  45. func (self *SInstanceNic) GetDriver() string {
  46. return "virtio"
  47. }
  48. func (self *SInstanceNic) InClassicNetwork() bool {
  49. return false
  50. }
  51. func (self *SInstanceNic) GetINetworkId() string {
  52. return self.SubnetId
  53. }