This endpoint is used by net-agent when it syncs back missing napi records, as observed in OPS-1638. The nic tag validation logic has to be tweaked for fabric nics, like in the case of ZAPI-711.
Brian Bennett commented on 2016-05-19T16:53:18.000-0400 (edited 2019-05-02T14:06:43.163-0400):
Work around for this provided by @Former user...
If the POST payload includes the network UUID, then the nic_tag can be omitted and the proper nic_tag will be filled in on the back end automatically.
E.g.:
This fails
[bbennett@headnode (us-east-1) ~]$ sdc-napi /nics -X POST -d '{
> "belongs_to_type": "zone",
> "belongs_to_uuid": "4ba7197c-3c26-c217-a623-f67912ca1116",
> "mac": "90:b8:d0:2e:34:d6",
> "owner_uuid": "21d6ac55-936f-4b12-880f-7b86a659d325",
> "state": "running",
> "ip": "192.168.128.10",
> "gateway": "192.168.128.1",
> "mtu": 8500,
> "netmask": "255.255.252.0",
> "nic_tag": "sdc_overlay/5303027",
> "resolvers": [
> "4.2.2.2",
> "216.52.1.1"
> ],
> "vlan_id": 2,
> "network_uuid": "2ac01850-5d41-4c25-bd1f-5bb0e4c4c5c3",
> "cn_uuid": "44454c4c-4400-1032-804e-b5c04f383432"
> }
> '
HTTP/1.1 422 Unprocessable Entity
Content-Type: application/json
Content-Length: 151
Date: Thu, 19 May 2016 20:17:25 GMT
Server: SmartDataCenter Networking API
x-request-id: b3c15770-1dfe-11e6-aa59-f720d14ac582
x-response-time: 7
x-server-name: 8dc3ccc8-df38-4bef-9810-3a0b4d30de39
Connection: keep-alive
{
"code": "InvalidParameters",
"message": "Invalid parameters",
"errors": [
{
"field": "nic_tag",
"code": "InvalidParameter",
"message": "nic tag does not exist"
}
]
}
This succeeds
[bbennett@headnode (us-east-1) ~]$ sdc-napi /nics -X POST -d '{
> "belongs_to_type": "zone",
> "belongs_to_uuid": "4ba7197c-3c26-c217-a623-f67912ca1116",
> "mac": "90:b8:d0:2e:34:d6",
> "owner_uuid": "21d6ac55-936f-4b12-880f-7b86a659d325",
> "state": "running",
> "ip": "192.168.128.10",
> "gateway": "192.168.128.1",
> "mtu": 8500,
> "netmask": "255.255.252.0",
> "resolvers": [
> "4.2.2.2",
> "216.52.1.1"
> ],
> "vlan_id": 2,
> "network_uuid": "2ac01850-5d41-4c25-bd1f-5bb0e4c4c5c3",
> "cn_uuid": "44454c4c-4400-1032-804e-b5c04f383432"
> }
> '
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 525
Date: Thu, 19 May 2016 20:49:53 GMT
Server: SmartDataCenter Networking API
x-request-id: 3cc9c490-1e03-11e6-aa59-f720d14ac582
x-response-time: 65
x-server-name: 8dc3ccc8-df38-4bef-9810-3a0b4d30de39
Connection: keep-alive
{
"belongs_to_type": "zone",
"belongs_to_uuid": "4ba7197c-3c26-c217-a623-f67912ca1116",
"mac": "90:b8:d0:2e:34:d6",
"owner_uuid": "21d6ac55-936f-4b12-880f-7b86a659d325",
"primary": false,
"state": "running",
"ip": "192.168.128.10",
"fabric": true,
"gateway": "192.168.128.1",
"gateway_provisioned": true,
"internet_nat": true,
"mtu": 8500,
"netmask": "255.255.252.0",
"nic_tag": "sdc_overlay/5303027",
"resolvers": [
"4.2.2.2",
"216.52.1.1"
],
"vlan_id": 2,
"network_uuid": "2ac01850-5d41-4c25-bd1f-5bb0e4c4c5c3",
"cn_uuid": "44454c4c-4400-1032-804e-b5c04f383432"
}
Former user commented on 2016-11-15T16:08:49.000-0500:
Hi @Former user,
We're talking about putting work-arounds into the migrator script to get around this so we are able to migrate instances off fabric networks and docker containers (I've built a script to handle nat zones using cody's notes which is separate from this). Just wanted to see what the estimated completion is on this bug before I figure out some logic to work around it, code it, test it, etc.....
Let me know. Thanks!
Jay
Former user commented on 2016-11-15T16:36:15.000-0500:
@Former user I believe I have a fix for this, but I haven't fully tested it yet. I hope to have something soon, though.
Former user commented on 2017-02-01T16:29:20.000-0500:
Hi @Former user,
Just wanted to check back and see where things were with this; having this functionality will enable us to migrate instances that are on fabric networks. Right now the rather painful process is to remove the fabric nic, migrate, and then re-add it.
Thanks!
Jay
Former user commented on 2017-02-07T22:01:36.000-0500:
sdc-napi commit 1d14fdb (branch master, by Cody Peter Mello)
NAPI-348#icft=NAPI-348 CreateNic endpoint does not accept fabric NIC due to improper NIC tag validation
Reviewed by: Alex Wilson <alex.wilson@joyent.com>
Approved by: Alex Wilson <alex.wilson@joyent.com>