this solves issues 2 & 3
This commit is contained in:
40
app.js
Normal file
40
app.js
Normal file
@@ -0,0 +1,40 @@
|
||||
const axios = require('axios');
|
||||
const express = require('express')
|
||||
const app = express()
|
||||
const port = 3000
|
||||
const path = require('path');
|
||||
|
||||
async function resetvm(vmid){
|
||||
try {
|
||||
let res = await axios.post(`https://stor.asura.vm42.us/api2/json/nodes/stor/qemu/${vmid}/status/reboot`,{}, {
|
||||
headers:{
|
||||
"Authorization": 'PVEAPIToken=ajones@pam!dev=229fe029-caa5-4a35-9c5d-d74a5d0f4233'
|
||||
}
|
||||
})
|
||||
console.log(res)
|
||||
return res;
|
||||
|
||||
}catch(error){
|
||||
console.log(error)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
app.use('/static', express.static(path.join(__dirname, 'static')));
|
||||
|
||||
app.get('/', function(req, res) {
|
||||
res.sendFile(path.join(__dirname, '/static/index.html'));
|
||||
});
|
||||
|
||||
app.post('/:id', async (req, res) => {
|
||||
let apiCall = await resetvm(req.params.id)
|
||||
if(apiCall){
|
||||
res.send(`the vm ${req.params.id} has been reset`)
|
||||
}else{
|
||||
res.send('something went wrong')
|
||||
}
|
||||
})
|
||||
|
||||
app.listen(port, () => {
|
||||
console.log(`App listening on port ${port}`)
|
||||
})
|
||||
Reference in New Issue
Block a user