joyent/smartos-live — Issue #66: Adding 'primary' NIC property via "update_nics" doesn't seem to work
Author: trisk
Created: 2012-02-27 00:17:03+00:00
State: open

Current vmadmd requires the 'primary' property to be set on a NIC object (or a NIC 'gateway' propertly has to match 'default-gateway') in order for the resolver and default gateway to be set for KVM guests. Using an "update_nics" JSON payload to 'vmadm update' does not appear to add this property.
```
[root@mameshiba /tmp]# vmadm list
UUID TYPE RAM STATE ALIAS
2db5ca4c-1295-4c0f-aab1-bdb8d5dadfb2 OS 256 running -
0085b669-fade-4569-a273-937fa6f3ea39 KVM 512 stopped winxp
6f3c52cf-dbdf-4e67-be17-b66da6a78202 KVM 1024 stopped nexenta
f4763d2b-d656-4e4e-a3ae-0a16900bc9c6 KVM 4096 stopped babyshiba
[root@mameshiba /tmp]# vmadm get 6f3c52cf-dbdf-4e67-be17-b66da6a78202 | json nics
[
{
"interface": "net0",
"mac": "a2:ea:49:39:29:43",
"nic_tag": "external",
"ip": "192.168.4.208",
"netmask": "255.255.255.0",
"gateway": "192.168.4.254",
"model": "rtl8139"
}
]
[root@mameshiba /tmp]# for uuid in `vmadm list -H -o uuid`; do echo "{ \"update_nics\": [ { `vmadm get $uuid | json nics | grep mac | head -1` \"primary\": 1 } ] }"; done
{ "update_nics": [ { "mac": "a2:e2:c4:4a:0d:07", "primary": 1 } ] }
{ "update_nics": [ { "mac": "b2:04:f0:f9:ad:bd", "primary": 1 } ] }
{ "update_nics": [ { "mac": "a2:ea:49:39:29:43", "primary": 1 } ] }
{ "update_nics": [ { "mac": "a2:11:1e:dd:af:97", "primary": 1 } ] }
[root@mameshiba /tmp]# for uuid in `vmadm list -H -o uuid`; do echo "{ \"update_nics\": [ { `vmadm get $uuid | json nics | grep mac | head -1` \"primary\": 1 } ] }" | vmadm update $uuid
Successfully updated 2db5ca4c-1295-4c0f-aab1-bdb8d5dadfb2
Successfully updated 0085b669-fade-4569-a273-937fa6f3ea39
Successfully updated 6f3c52cf-dbdf-4e67-be17-b66da6a78202
Successfully updated f4763d2b-d656-4e4e-a3ae-0a16900bc9c6
[root@mameshiba /tmp]# vmadm get 6f3c52cf-dbdf-4e67-be17-b66da6a78202 | json nics
[
{
"interface": "net0",
"mac": "a2:ea:49:39:29:43",
"nic_tag": "external",
"ip": "192.168.4.208",
"netmask": "255.255.255.0",
"gateway": "192.168.4.254",
"model": "rtl8139"
}
]
```