-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall-all.js
39 lines (34 loc) · 1.37 KB
/
install-all.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import {downloadLoom} from './ssh1.js'
if (!process.env.API_KEY) {
console.error('missing API_KEY')
process.exit(1)
}
const DigitalOcean = require('do-wrapper').default
const api = new DigitalOcean(process.env.API_KEY, 0)
const getAllQ = {
tag_name: '',
per_page: 25,
page: 1
}
const dropletsStatus = async () => {
const accountInfo = await api.account()
console.log('connecting to account')
if (!accountInfo.body.account.uuid) {
return console.log("can't connect to account")
}
const getAllDroplets = await api.dropletsGetAll(getAllQ)
const dropletIds = getAllDroplets.body.droplets.map(droplet => droplet.id)
const statusOfDeletedDroplets = await Promise.all(dropletIds.map(id => api.dropletsGetById(id)))
console.log('all droplet status', statusOfDeletedDroplets.map(res => res.body).map(droplet => droplet.droplet).map(droplet => ({id: droplet.id, status: droplet.status, ip4: droplet.networks.v4[0].ip_address})))
const promises = statusOfDeletedDroplets.map(res => res.body).map(droplet => droplet.droplet).map(droplet => {
const ipv4 = droplet.networks.v4[0].ip_address
return downloadLoom(ipv4).then(res => {
console.log('done installing loom on ip: ', ipv4)
})
})
Promise.all(promises).then(res => {
console.log('done installing loom on all clusters')
return setTimeout(() => process.exit(0), 5000)
})
}
dropletsStatus()