nic.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 proxmox
  15. import (
  16. "fmt"
  17. "strings"
  18. "yunion.io/x/cloudmux/pkg/cloudprovider"
  19. )
  20. type SInstanceNic struct {
  21. cloudprovider.DummyICloudNic
  22. ins *SInstance
  23. MacAddr string
  24. IpAddr string
  25. NicId string
  26. Model string
  27. NetworkId string
  28. }
  29. func (self *SInstanceNic) GetId() string {
  30. return fmt.Sprintf("%d/%s", self.ins.VmID, self.NicId)
  31. }
  32. func (self *SInstanceNic) GetIP() string {
  33. return self.IpAddr
  34. }
  35. func (self *SInstanceNic) GetMAC() string {
  36. return self.MacAddr
  37. }
  38. func (self *SInstanceNic) GetDriver() string {
  39. return strings.ToLower(self.Model)
  40. }
  41. func (self *SInstanceNic) InClassicNetwork() bool {
  42. return true
  43. }
  44. func (self *SInstanceNic) GetSubAddress() ([]string, error) {
  45. return []string{}, nil
  46. }
  47. func (self *SInstanceNic) GetINetworkId() string {
  48. return self.NetworkId
  49. }
  50. func (self *SInstanceNic) AssignAddress(ipAddrs []string) error {
  51. return cloudprovider.ErrNotSupported
  52. }