How to use the assert-plus.uuid function in assert-plus

To help you get started, we’ve selected a few assert-plus examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github joyent / buildymcbuildface / lib / imgadm / lib / cli.js View on Github external
CLI.prototype.do_ancestry = function do_ancestry(subcmd, opts, args, cb) {
    var self = this;
    if (opts.help) {
        self.do_help('help', {}, [subcmd], cb);
        return;
    }
    if (args.length !== 1) {
        cb(new errors.UsageError(format(
            'incorrect number of args (%d): "%s"',
            args.length, args.join(' '))));
        return;
    }
    var uuid = args[0];
    assert.uuid(uuid, 'uuid');
    var zpool = opts.P || self.tool.DEFAULT_ZPOOL;
    /* JSSTYLED */
    var columns = opts.o.trim().split(/\s*,\s*/g);
    var log = self.log;
    log.debug({opts: opts, zpool: zpool, uuid: uuid}, 'ancestry');

    var ancestry = [];
    getNextAncestor(uuid);


    function getNextAncestor(aUuid) {
        var getOpts = {uuid: aUuid, zpool: zpool};
        self.tool.getImage(getOpts, function (err, imageInfo) {
            if (err) {
                cb(err);
                return;
github joyent / sdc-docker / lib / plugin-manager.js View on Github external
function modifyProvisionNetworks(opts, cb) {
    assert.object(opts, 'opts');
    assert.object(opts.account, 'opts.account');
    assert.arrayOfObject(opts.networks, 'opts.networks');
    assert.uuid(opts.req_id, 'opts.req_id');
    assert.func(cb, 'cb');

    var hooks = this.hooks.modifyProvisionNetworks;
    var funcs = hooks.map(function wrapFunc(func) {
        return function (_, next) {
            func(opts, next);
        };
    });

    // Runs every plugin (if any).
    function callfuncs() {
        if (funcs.length === 0) {
            return cb();
        }

        var func = funcs.pop();
github joyent / sdc-docker / lib / plugin-manager.js View on Github external
function findOwnerExternalNetwork(opts, cb) {
    assert.object(opts, 'opts');
    assert.object(opts.account, 'opts.account');
    assert.uuid(opts.req_id, 'opts.req_id');
    assert.func(cb, 'cb');

    var hooks = this.hooks.findOwnerExternalNetwork;

    // Runs every plugin (if any) until a plugin succeeds (doesn't return an
    // error). If that plugin returned a network, use that network for the
    // external instead of the default overlay.externalPool.
    vasync.tryEach(hooks.map(function (p) {
        return p.bind(null, opts);
    }), cb);
};
github joyent / sdc-docker / test / integration / helpers.js View on Github external
function getOrCreateFabricVLAN(client, userUuid, fabricParams, callback) {
    assert.object(client, 'napi client');
    assert.uuid(userUuid, 'user uuid');
    assert.object(fabricParams, 'fabricParams');

    client.getFabricVLAN(userUuid, fabricParams.vlan_id, {},
        function (err, vlan) {
            if (err && err.restCode !== 'ResourceNotFound') {
                return callback(err);
            } else if (vlan) {
                return callback(null, vlan);
            }
            client.createFabricVLAN(userUuid, fabricParams, callback);
        }
    );
}
github joyent / sdc-docker / lib / backends / sdc / networks.js View on Github external
function externalNetworkByName(opts, container, payload, callback) {
    assert.object(opts, 'opts');
    assert.object(opts.app, 'opts.app');
    assert.object(opts.config, 'opts.config');
    assert.object(opts.config.napi, 'opts.config.napi');
    assert.optionalString(opts.config.externalNetwork,
        'opts.config.externalNetwork');
    assert.object(opts.account, 'opts.account');
    assert.uuid(opts.account.uuid, 'opts.account.uuid');
    assert.uuid(opts.req_id, 'opts.req_id');
    assert.object(payload, 'payload');
    assert.func(callback, 'callback');

    var externalNetworkName;
    var labels = container.Labels || {};
    var log = opts.log;

    if (Object.prototype.hasOwnProperty.call(labels,
        TRITON_PUBLIC_NETWORK_LABEL))
    {
        externalNetworkName = labels[TRITON_PUBLIC_NETWORK_LABEL];
    }

    if (!payload.hasOwnProperty('networks')) {
        payload.networks = [];
github joyent / sdc-docker / lib / plugin-manager.js View on Github external
getActiveVmsForAccount: function getActiveVmsShim(opts, cb) {
            assert.object(opts, 'opts');
            assert.object(opts.account, 'opts.account');
            assert.optionalString(opts.brand, 'opts.brand');
            assert.optionalString(opts.fields, 'opts.fields');
            assert.uuid(opts.req_id, 'opts.req_id');
            assert.func(cb, 'cb');

            var args = {
                owner_uuid: opts.account.uuid,
                state: 'active'
            };

            if (opts.brand) {
                args.brand = opts.brand;
            }

            if (opts.fields) {
                args.fields = opts.fields;
            }

            var reqOpts = { headers: {'x-request-id': opts.req_id } };
github joyent / sdc-docker / plugins / filter_owner_networks.js View on Github external
return function findExternalNetworkWithOwnerUuid(opts, cb) {
        assert.object(opts, 'opts');
        assert.object(opts.account, 'opts.account');
        assert.uuid(opts.req_id, 'opts.req_id');

        log.debug('Running ' + findExternalNetworkWithOwnerUuid.name);

        var accountUuid = opts.account.uuid;
        if (cfg.accounts.indexOf(accountUuid) === -1) {
            return cb();
        }

        log.debug('Looking up external pools and networks for account',
            accountUuid);

        api.getNapiNetworksForAccount({
            accountUuid: accountUuid,
            reqId: opts.req_id,
            log: log
        }, function onAccountNetworks(err, networks) {
github joyent / sdc-docker / lib / plugin-manager.js View on Github external
getImage: function getImageShim(opts, cb) {
            assert.object(opts, 'opts');
            assert.object(opts.image, 'opts.image');
            assert.uuid(opts.image.uuid, 'opts.image.uuid');
            assert.uuid(opts.req_id, 'opts.req_id');
            assert.func(cb, 'cb');

            var reqOpts = { headers: {'x-request-id': opts.req_id } };

            clients.imgapi.getImage(opts.image.uuid, reqOpts, cb);
        },
        listImages: function listImageShim(opts, cb) {
github joyent / smartos-live / src / img / lib / cli.js View on Github external
function checkIfImageInstalled(ctx, next) {
            if (ctx.uuid) {
                next();
                return;
            }
            assert.uuid(ctx.importInfo.uuid, 'ctx.importInfo.uuid');

            var getOpts = {
                uuid: ctx.importInfo.uuid,
                zpool: zpool
            };
            self.tool.getImage(getOpts, function (getErr, ii) {
                if (getErr) {
                    next(getErr);
                    return;
                } else if (ii) {
                    var extra1 = '';
                    if (ii.manifest.name) {
                        extra1 = format(' (%s@%s)', ii.manifest.name,
                            ii.manifest.version);
                    }
                    var extra2 = '';