On Wed, Apr 26, 2017 at 02:33:22PM -0400, Ron Kelley wrote:
> Running LXD 2.12 on a couple of Ubuntu 17.04 servers with a local “manager” 
> node and a remote worker node.  I started a remote CentOS 6 container on the 
> worker node then attached a network via "lxc network attach eth1 
> LXD-Server-01:centos6-testing” (the default profile does not have a network 
> interface configured).  To verify the new interface was attached properly, I 
> ran "lxc info --verbose LXD-Server-01:centos6-testing” but the network 
> details are not listed.  Here is the output:
> 
> ---------------------------------------------------
> Name: centos6-testing
> Remote: https://10.1.2.3:8443
> Architecture: x86_64
> Created: 2017/04/26 18:12 UTC
> Status: Running
> Type: persistent
> Profiles: default
> Pid: 1878
> Ips:
>   lo: inet    127.0.0.1
>   lo: inet6   ::1
> Resources:
>   Processes: 6
>   CPU usage:
>     CPU usage (in seconds): 0
>   Memory usage:
>     Memory (current): 13.57MB
>     Memory (peak): 14.88MB
>   Network usage:
>     eth0:
>       Bytes received: 0B
>       Bytes sent: 0B
>       Packets received: 0
>       Packets sent: 0
>     lo:
>       Bytes received: 0B
>       Bytes sent: 0B
>       Packets received: 0
>       Packets sent: 0
> ---------------------------------------------------
> 
> Is there any way to verify which network is currently attached to the 
> container?
> 
> Thanks.
> 
> -Ron

Not through the command line, as we list the IPs, not the interfaces, so
an interface without any IP (which is the case here) will not show up.

The API does show the information though:
```
stgraber@castiana:~/data/code/lxc$ curl -s --unix-socket 
/var/lib/lxd/unix.socket lxd/1.0/containers/test/state | jq .
{
  "type": "sync",
  "status": "Success",
  "status_code": 200,
  "operation": "",
  "error_code": 0,
  "error": "",
  "metadata": {
    "status": "Running",
    "status_code": 103,
    "disk": {
      "root": {
        "usage": 192507904
      }
    },
    "memory": {
      "usage": 149372928,
      "usage_peak": 264704000,
      "swap_usage": 339968,
      "swap_usage_peak": 0
    },
    "network": {
      "dummy0": {
        "addresses": [],
        "counters": {
          "bytes_received": 0,
          "bytes_sent": 0,
          "packets_received": 0,
          "packets_sent": 0
        },
        "hwaddr": "42:ae:bd:82:f7:58",
        "host_name": "",
        "mtu": 1500,
        "state": "down",
        "type": "broadcast"
      },
      "eth0": {
        "addresses": [
          {
            "family": "inet",
            "address": "10.204.119.27",
            "netmask": "24",
            "scope": "global"
          },
          {
            "family": "inet6",
            "address": "2001:470:b368:4242:216:3eff:fe1a:18c9",
            "netmask": "64",
            "scope": "global"
          },
          {
            "family": "inet6",
            "address": "fe80::216:3eff:fe1a:18c9",
            "netmask": "64",
            "scope": "link"
          }
        ],
        "counters": {
          "bytes_received": 57627146,
          "bytes_sent": 536186,
          "packets_received": 28616,
          "packets_sent": 5864
        },
        "hwaddr": "00:16:3e:1a:18:c9",
        "host_name": "veth5V1A0H",
        "mtu": 1500,
        "state": "up",
        "type": "broadcast"
      },
      "lo": {
        "addresses": [
          {
            "family": "inet",
            "address": "127.0.0.1",
            "netmask": "8",
            "scope": "local"
          },
          {
            "family": "inet6",
            "address": "::1",
            "netmask": "128",
            "scope": "local"
          }
        ],
        "counters": {
          "bytes_received": 0,
          "bytes_sent": 0,
          "packets_received": 0,
          "packets_sent": 0
        },
        "hwaddr": "",
        "host_name": "",
        "mtu": 65536,
        "state": "up",
        "type": "loopback"
      }
    },
    "pid": 5538,
    "processes": 27,
    "cpu": {
      "usage": 49886701563
    }
  }
}

```

In my case, I have a "dummy0" interface in that container without any
IP. My lxc info is similar to yours, but the API does show a "dummy0"
interface without any IP on it.


If interacting with the LXD command line tools, something like this
should work:

```
stgraber@castiana:~/data/code/lxc$ lxc exec test -- test -e 
/sys/class/net/dummy0 && echo yes
yes
```

Replacing dummy0 with whatever interface name you want.


-- 
Stéphane Graber
Ubuntu developer
http://www.ubuntu.com

Attachment: signature.asc
Description: PGP signature

_______________________________________________
lxc-users mailing list
lxc-users@lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-users

Reply via email to