Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 12 additions & 14 deletions bin/imgapi-manta-setup
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ var async = require('async');
var sdcClients = require('sdc-clients');
var UFDS = require('ufds');
var bunyan = require('bunyan');
var netconfig = require('triton-netconfig');


//---- globals
Expand Down Expand Up @@ -163,24 +164,21 @@ function getMantaUrl(mantaUrl, sdcApp, callback) {
state: 'running'
};
vmapi.listVms(search, function (vErr, vms) {
if (vErr)
return callback(vErr);
if (vms.length === 0) {
return callback(new Error(
'no manta "loadbalancer" VMs were found'));
if (vErr) {
callback(vErr);
return;
}
var nics = vms[0].nics;
var ip;
for (var i = 0; i < nics.length; i++) {
if (nics[i].nic_tag === 'external') {
ip = nics[i].ip;
break;
}
if (vms.length === 0) {
callback(new Error('no manta "loadbalancer" VMs were found'));
return;
}

var ip = netconfig.externalIpFromVmMetadata(vms[0]);
if (!ip) {
return callback(new Error(
'no external IP on the first Manta LB'));
callback(new Error('no external IP on the first Manta LB'));
return;
}

mantaUrl = 'https://' + ip;
callback(null, mantaUrl);
});
Expand Down
19 changes: 3 additions & 16 deletions bin/imgapi-standalone-create
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# Copyright 2017 Joyent, Inc.
# Copyright 2019 Joyent, Inc.
#

#
Expand Down Expand Up @@ -161,19 +161,6 @@ else
echo "Owner ($ownerUuid) is already on the image ACL"
fi

# Network
echo "Find a suitable external network"
networkPoolJson=$(sdc-napi /network_pools?provisionable_by=$ownerUuid | json -Hc 'this.nic_tag==="external"' 0)
if [[ -z "$networkPoolJson" ]]; then
networkJson=$(sdc-napi /networks?provisionable_by=$ownerUuid\&fabric=false | json -Hc 'this.nic_tag==="external"' 0)
[[ -n "$networkJson" ]] || fatal "could not find a suitable network"
netJson="$networkJson"
else
netJson="$networkPoolJson"
fi
netUuid=$(echo "$netJson" | json uuid)
netName=$(echo "$netJson" | json name)

# Create the VM
vmUuid=$(uuid)
optMetadata=$(echo "$optMetadata" \
Expand All @@ -185,7 +172,7 @@ echo " alias: $ALIAS"
echo " owner: $ownerUuid ($ownerLogin)"
echo " image: $imageUuid ($imageName@$imageVersion)"
echo " package: $packageUuid ($packageName)"
echo " network: $netUuid ($netName)"
echo " network: external"
echo " tags: $(echo "$optTags" | json -o json-0)"
echo " metadata:"
echo "$optMetadata" | sed 's/^/ /'
Expand All @@ -196,7 +183,7 @@ sdc-vmapi /vms -X POST -d@- <<EOP | json -H | sdc-waitforjob
"alias": "$ALIAS",
"owner_uuid": "$ownerUuid",
"billing_id": "$packageUuid",
"networks": [{"uuid": "$netUuid"}],
"networks": [{"name": "external"}],
"brand": "joyent",
"image_uuid": "$imageUuid",
"delegate_dataset": true,
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "imgapi",
"description": "Image API to manage images for Triton Data Center",
"version": "4.6.1",
"version": "4.6.2",
"author": "Joyent (joyent.com)",
"private": true,
"dependencies": {
Expand Down Expand Up @@ -41,6 +41,7 @@
"through2": "2.0.3",
"trace-event": "1.2.0",
"triton-metrics": "0.1.1",
"triton-netconfig": "1.3.0",
"ufds": "1.2.0",
"uuid": "2.0.2",
"vasync": "1.6.3",
Expand Down