yunion.io/x/cloudmux@v0.3.10-0-alpha.1/pkg/multicloud/azure/classic_instancenic.go (about)

     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  
    15  package azure
    16  
    17  import (
    18  	"strings"
    19  
    20  	"yunion.io/x/pkg/util/netutils"
    21  
    22  	"yunion.io/x/cloudmux/pkg/cloudprovider"
    23  )
    24  
    25  type SClassicInstanceNic struct {
    26  	instance *SClassicInstance
    27  
    28  	ID       string
    29  	IP       string
    30  	Name     string
    31  	Type     string
    32  	Location string
    33  
    34  	cloudprovider.DummyICloudNic
    35  }
    36  
    37  func (self *SClassicInstanceNic) GetId() string {
    38  	return ""
    39  }
    40  
    41  func (self *SClassicInstanceNic) GetIP() string {
    42  	return self.IP
    43  }
    44  
    45  func (self *SClassicInstanceNic) Delete() error {
    46  	return cloudprovider.ErrNotImplemented
    47  }
    48  
    49  func (self *SClassicInstanceNic) GetMAC() string {
    50  	ip, _ := netutils.NewIPV4Addr(self.GetIP())
    51  	return ip.ToMac("00:16:")
    52  }
    53  
    54  func (self *SClassicInstanceNic) GetDriver() string {
    55  	return "virtio"
    56  }
    57  
    58  func (self *SClassicInstanceNic) InClassicNetwork() bool {
    59  	return true
    60  }
    61  
    62  func (self *SClassicInstanceNic) GetINetworkId() string {
    63  	return strings.ToLower(self.ID)
    64  }