From 64e367e5e5a637d8b380feb7317130495f47b748 Mon Sep 17 00:00:00 2001 From: Alex Wilson Date: Sat, 22 May 2021 06:00:12 +1000 Subject: [PATCH] joyent/sdc-cloudapi#84 AddNic should accept a "primary" argument (#85) Reviewed by: Dan McDonald --- docs/index.md | 8 +++++++- lib/nics.js | 9 +++++++-- package.json | 2 +- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/docs/index.md b/docs/index.md index 76d35687..c8a272f2 100644 --- a/docs/index.md +++ b/docs/index.md @@ -12,7 +12,8 @@ markdown2extras: tables, code-friendly --> @@ -880,6 +881,10 @@ Note that a `Triton-Datacenter-Name` response header was added in 9.2.0. The section describes API changes in CloudAPI versions. +## 9.15.0 + +- Allow setting the `primary` option with the AddNic API [#84]. + ## 9.14.0 - Expose Feed of Machines Changes [#68](https://github.com/joyent/sdc-cloudapi/pull/68). @@ -9796,6 +9801,7 @@ Creates a new NIC on an instance belonging to a given account. **Field** | **Type** | **Description** --------- | -------- | --------------- network | Object or String | [Network object](#network-objects) or network UUID string. +primary | Boolean | Whether to make this NIC the new primary NIC ### Returns diff --git a/lib/nics.js b/lib/nics.js index d1cff8a7..7d9ce79a 100644 --- a/lib/nics.js +++ b/lib/nics.js @@ -5,7 +5,8 @@ */ /* - * Copyright 2020 Joyent, Inc. + * Copyright 2021 Joyent, Inc. + * Copyright 2021 The University of Queensland */ /* @@ -108,6 +109,8 @@ function addNic(req, res, next) { var login = req.account.login; var networkArg = req.params.network; var origin = req.params.origin || 'cloudapi'; + var isPrimary = req.params.primary === true || + req.params.primary === 'true'; var context = { caller: req._auditCtx }; @@ -368,6 +371,7 @@ function addNic(req, res, next) { owner_uuid: ownerUuid, state: 'provisioning', origin: origin, + primary: isPrimary, context: context }; @@ -460,7 +464,8 @@ function addNic(req, res, next) { creator_uuid: ownerUuid, macs: [nic.mac], origin: origin, - context: context + context: context, + primary: isPrimary }, { log: log, headers: headers diff --git a/package.json b/package.json index f0b0c970..517f1c65 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "cloudapi", "description": "Triton CloudAPI", - "version": "9.14.1", + "version": "9.15.0", "author": "Joyent (joyent.com)", "private": true, "engines": {