Skip to content

Commit

Permalink
PUBAPI-1300 Implement CRUD volumes endpoints
Browse files Browse the repository at this point in the history
PUBAPI-1366 Volume objects should use the name "id" for the property that stores their ID, not "uuid"
PUBAPI-1373 Add support for passing a JSON predicate to the ListVolumes endpoint
PUBAPI-1369 GET volume should return 404 for a non-existing volume name/uuid
PUBAPI-1377 vm_uuid property should not be present in responses for endpoints rendering NFS shared volumes
PUBAPI-1374 Want user-friendly timestamp for volume details
PUBAPI-1379 CreateVolume endpoint should accept size as number, not as string with complex format rules
PUBAPI-1384 Machines endpoint should not expose NFS volumes' storage VMs
PUBAPI-1376 Create volume errors out when the network parameter is passed
PUBAPI-1372 CreateVolume endpoint should generate volume name if not provided in input parameters
PUBAPI-1371 List volumes should not return deleted or failed instances
VOLAPI-49 DELETE should delete
PUBAPI-1387 Add ListVolumeSizes endpoint to list available volume sizes
PUBAPI-1408 ListVolumes endpoint should validate the "predicate" parameter
PUBAPI-1407 Error message should be clearer when provisioning a NFS volume in a DC without fabric networks enabled
VOLAPI-54 Custom errors' rest codes should follow engineering guide's guidelines
PUBAPI-1416 cloudapi ListVolumes validation should match volapi
VOLAPI-62 Remove all references to state `rolling_back` in current implementation
TOOLS-1824 sdcadm update-other should not do anything for VOLAPI
VOLAPI-64 rename smartdc_role nfsserver to nfsvolumestorage
TOOLS-1830 replace sdcadm experimental nfs-volumes with cloudapi-nfs-volumes/docker-nfs-volumes subcommands
VOLAPI-72 creating volume with unsupported size should result in error, not in volume being created with closest matching size
PUBAPI-1420 Add ability to mount NFS volumes with CreateMachine endpoint
VOLAPI-85 replace smartdc_role=nfsvolumestorage with triton.system_role=nfsvolumestorage
Reviewed by: Marsell Kukuljevic <marsell@joyent.com>
Approved by: Julien Gilli <julien.gilli@joyent.com>
  • Loading branch information
Julien Gilli committed Nov 10, 2017
1 parent 945d292 commit 788a08f
Show file tree
Hide file tree
Showing 33 changed files with 4,459 additions and 273 deletions.
7 changes: 5 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#

#
# Copyright 2016 Joyent, Inc.
# Copyright 2017 Joyent, Inc.
#

#
Expand Down Expand Up @@ -33,7 +33,10 @@ TAP := ./node_modules/.bin/tape
DOC_FILES = index.md admin.md dev.md
RESTDOWN_FLAGS = --brand-dir=deps/restdown-brand-remora
EXTRA_DOC_DEPS += deps/restdown-brand-remora/.git
JS_FILES := $(shell ls *.js) $(shell find lib -maxdepth 1 -name '*.js') \
# We explicitly don't want to lint node-http-signature, as it's an external
# repository that is exceptionally bundled in this repo to ensure backward
# compatibilty when handling different signature formats.
JS_FILES := $(shell ls *.js) $(shell find lib -name '*.js' | grep -v node-http-signature) \
$(shell find test -name '*.js') $(shell find bench -name '*.js') \
$(shell find plugins -name '*.js') \
$(shell find test -name '*.javascript')
Expand Down
184 changes: 0 additions & 184 deletions etc/cloudapi.coal.cfg

This file was deleted.

40 changes: 32 additions & 8 deletions lib/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,22 @@
*
*/

var assert = require('assert');
var assert = require('assert-plus');
var fs = require('fs');
var http = require('http');
var https = require('https');
var util = require('util');
var path = require('path');

var semver = require('semver');
var cueball = require('cueball');
var jsprim = require('jsprim');
var kang = require('kang');
var keyapi = require('keyapi');
var mahi = require('mahi');
var restify = require('restify');
var SDC = require('sdc-clients');
var semver = require('semver');
var UFDS = require('ufds');
var keyapi = require('keyapi');
var mahi = require('mahi');
var cueball = require('cueball');
var kang = require('kang');

var account = require('./account');
var analytics = require('./analytics');
Expand All @@ -42,7 +43,6 @@ var docs = require('./docs');
var keys = require('./keys');
var machines = require('./machines');
var metadata = require('./metadata');
var mod_config = require('./config');
var nics = require('./nics');
var packages = require('./packages');
var services = require('./services');
Expand All @@ -55,6 +55,7 @@ var audit = require('./audit');
var auditLogger = require('./audit_logger');
var rules = require('./rules');
var tests = require('./tests');
var volumeEndpoints = require('./endpoints/volumes');

// Account users, roles and policies:
var users = require('./users');
Expand Down Expand Up @@ -171,7 +172,7 @@ function createUfdsClient(options, callback) {


function createHTTPClients(options) {
return {
var clients = {
ca: new SDC.CA(options.ca),
vmapi: new SDC.VMAPI(options.vmapi),
napi: new SDC.NAPI(options.napi),
Expand All @@ -183,6 +184,18 @@ function createHTTPClients(options) {
mahi: (options.mahi) ? mahi.createClient(options.mahi) : null,
cns: (options.cns) ? (new SDC.CNS(options.cns)) : null
};
var volapiConfig;

if (options.volapi) {
volapiConfig = jsprim.deepCopy(options.volapi);

volapiConfig.version = '^1';
volapiConfig.userAgent = 'cloudapi';

clients.volapi = new SDC.VOLAPI(volapiConfig);
}

return clients;
}


Expand All @@ -196,6 +209,7 @@ function createClients(options, callback) {
assert.ok(options.papi);
assert.ok(options.ufds);
assert.ok(options.ufds_master);
assert.optionalObject(options.volapi, 'options.volapi');

var agent;
if (options.cueballHttpAgent) {
Expand Down Expand Up @@ -230,6 +244,11 @@ function createClients(options, callback) {
options.cns.agent = agent;
}

if (options.volapi) {
options.volapi.log = options.log.child({ component: 'volapi' });
options.volapi.agent = agent;
}

// On this case, we'll point pkg and ufds to the same UFDS server,
// given we're running into "ufds-master" headnode
var ufds_is_master = (options.ufds_master.url === 'ldaps://');
Expand Down Expand Up @@ -655,6 +674,11 @@ module.exports = {
resources.mount(server, userThrottle(config, 'resources'),
config);

if (config.experimental_cloudapi_nfs_shared_volumes === true) {
volumeEndpoints.mount(server,
userThrottle(config, 'volumes'));
}

if (config.test) {
tests.mount(server, emptyThrottle(), config);
}
Expand Down
7 changes: 3 additions & 4 deletions lib/endpoints/networks.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ function translateIp(ip, accountUuid, adminUuid) {
}
});

obj.managed = (ip.belongs_to_type === "other" ||
obj.managed = (ip.belongs_to_type === 'other' ||
ip.owner_uuid === adminUuid);

// Show users the IP but don't leak belongs_to_uuid or the admin uuid
Expand Down Expand Up @@ -623,7 +623,7 @@ function deleteFabricNetwork(req, res, next) {

if (!defaultFabricNet) {
return next(new InternalError('Could not find default fabric ' +
'network ' + 'for user'));
'network for user'));
}

req.log.info({
Expand All @@ -639,8 +639,7 @@ function deleteFabricNetwork(req, res, next) {
return req.sdc.napi.deleteFabricNetwork(req.account.uuid,
params.vlan_id, params.id, {}, reqOpts(req), function (err) {
if (err) {
next(translateErr(err));
return;
return next(translateErr(err));
}

res.send(204);
Expand Down

0 comments on commit 788a08f

Please sign in to comment.