Compare commits
7 Commits
ad8cf23ea1
...
main
Author | SHA1 | Date | |
---|---|---|---|
06da6531dd | |||
2c5800b945 | |||
767f0e8bf5 | |||
90a9a4b3a8 | |||
4c1380f9e7 | |||
406424e1ab | |||
b0c029e877 |
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}`)
|
||||
})
|
30
index.js
30
index.js
@ -1,30 +0,0 @@
|
||||
/*const apiKey = {
|
||||
tokenID: 'test@pam!fixparsec',
|
||||
secret: 'b4e53082-4891-4d36-95c6-8662bd58f2ee'
|
||||
}
|
||||
HTTP: POST /api2/json/nodes/{node}/qemu/{vmid}/status/reboot
|
||||
url -H "Authorization: test@pam!fixparsec=b4e53082-4891-4d36-95c6-8662bd58f2ee" https://192.168.1.32:8006/api2/json/*/
|
||||
|
||||
var request = require('request');
|
||||
|
||||
var headers = {
|
||||
'Authorization': 'test@pam!fixparsec=b4e53082-4891-4d36-95c6-8662bd58f2ee'
|
||||
};
|
||||
|
||||
var options = {
|
||||
url: 'https://192.168.1.32:8006/api2/json/nodes/pve1/qemu/109/status/reboot',
|
||||
headers: headers
|
||||
};
|
||||
|
||||
function callback(error, response, body) {
|
||||
if (!error && response.statusCode == 200) {
|
||||
console.log(body);
|
||||
}
|
||||
console.log(body);
|
||||
console.log(response)
|
||||
console.log(error);
|
||||
|
||||
}
|
||||
|
||||
process.env["NODE_TLS_REJECT_UNAUTHORIZED"] = 0;
|
||||
request(options, callback);
|
1134
package-lock.json
generated
1134
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
12
package.json
12
package.json
@ -1,19 +1,15 @@
|
||||
{
|
||||
"name": "fixparsec",
|
||||
"version": "1.0.0",
|
||||
"description": "small apt to resst parsec virtual machines",
|
||||
"description": "small app to reset vms used by parsec",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://git.theta42.com/ajones/fixparsec.git"
|
||||
},
|
||||
"author": "amos jones",
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"express": "^4.18.2",
|
||||
"request": "^2.88.2"
|
||||
"axios": "^1.5.1",
|
||||
"express": "^4.18.2"
|
||||
}
|
||||
}
|
||||
|
17
static/index.html
Normal file
17
static/index.html
Normal file
@ -0,0 +1,17 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<meta charset="UTF-8">
|
||||
<title>Page Title</title>
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
<link rel="stylesheet" href="">
|
||||
<style></style>
|
||||
<script src="https://code.jquery.com/jquery-3.7.1.min.js"></script>
|
||||
<script src="./static/index.js"></script>
|
||||
<body>
|
||||
|
||||
<button id="reset">RESET</button>
|
||||
<div id="result"></div>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
7
static/index.js
Executable file
7
static/index.js
Executable file
@ -0,0 +1,7 @@
|
||||
$(document).ready(function(){
|
||||
$('#reset').on('click', function(){
|
||||
$.post("http://localhost:3000/110", function( data ){
|
||||
$( "#result" ).html( data );
|
||||
});
|
||||
});
|
||||
});
|
Reference in New Issue
Block a user