Compare commits

...

5 Commits

Author SHA1 Message Date
06da6531dd Merge pull request 'issue2' (#9) from issue2 into main
Reviewed-on: #9
2023-11-13 17:35:06 +00:00
2c5800b945 this solves issues 2 & 3 2023-11-13 10:32:56 -07:00
767f0e8bf5 this closes issue #2 2023-10-10 19:28:47 -06:00
90a9a4b3a8 #1 complete 2023-10-09 09:26:51 -06:00
4c1380f9e7 #1 complete 2023-10-09 09:26:22 -06:00
8 changed files with 106 additions and 2303 deletions

0
README.md Normal file → Executable file
View File

40
app.js Normal file
View 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}`)
})

View File

@ -1,30 +0,0 @@
/*const apiKey = {
tokenID: 'ajones@pam!fixparsec',
secret: '887ec723-b31a-43ca-be50-82ace6697536'
}
HTTP: POST /api2/json/nodes/{node}/qemu/{vmid}/status/reboot
curl -H "Authorization: ajones@pam!fixparsec=887ec723-b31a-43ca-be50-82ace6697536" https://192.168.1.32:8006/api2/json/nodes/pve1/qemu/109/status/reboot*/
var request = require('request');
var headers = {
'Authorization': 'ajones@pam!fixparsec=887ec723-b31a-43ca-be50-82ace6697536'
};
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);

1169
log.txt

File diff suppressed because it is too large Load Diff

1134
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -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
View 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
View File

@ -0,0 +1,7 @@
$(document).ready(function(){
$('#reset').on('click', function(){
$.post("http://localhost:3000/110", function( data ){
$( "#result" ).html( data );
});
});
});