github.com/mattyw/juju@v0.0.0-20140610034352-732aecd63861/environs/network/network.go (about) 1 // Copyright 2014 Canonical Ltd. 2 // Licensed under the AGPLv3, see LICENCE file for details. 3 4 package network 5 6 import ( 7 "fmt" 8 ) 9 10 // Id defines a provider-specific network id. 11 type Id string 12 13 // Info describes a single network interface available on an instance. 14 // For providers that support networks, this will be available at 15 // StartInstance() time. 16 type Info struct { 17 // MACAddress is the network interface's hardware MAC address 18 // (e.g. "aa:bb:cc:dd:ee:ff"). 19 MACAddress string 20 21 // CIDR of the network, in 123.45.67.89/24 format. 22 CIDR string 23 24 // NetworkName is juju-internal name of the network. 25 NetworkName string 26 27 // ProviderId is a provider-specific network id. 28 ProviderId Id 29 30 // VLANTag needs to be between 1 and 4094 for VLANs and 0 for 31 // normal networks. It's defined by IEEE 802.1Q standard. 32 VLANTag int 33 34 // InterfaceName is the raw OS-specific network device name (e.g. 35 // "eth1", even for a VLAN eth1.42 virtual interface). 36 InterfaceName string 37 38 // IsVirtual is true when the interface is a virtual device, as 39 // opposed to a physical device (e.g. a VLAN or a network alias) 40 IsVirtual bool 41 42 // Disabled is true when the interface needs to be disabled on the 43 // machine, e.g. not to configure it. 44 Disabled bool 45 } 46 47 // ActualInterfaceName returns raw interface name for raw interface (e.g. "eth0") and 48 // virtual interface name for virtual interface (e.g. "eth0.42") 49 func (i *Info) ActualInterfaceName() string { 50 if i.VLANTag > 0 { 51 return fmt.Sprintf("%s.%d", i.InterfaceName, i.VLANTag) 52 } 53 return i.InterfaceName 54 }