-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make a way to change both the vm name and hostname #16
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -306,6 +306,22 @@ def vm_disk(vmid, disk, size): | |
return '', 403 | ||
|
||
|
||
@app.route("/starrs/<string:vmid>/hostname/<string:old_name>/<string:new_name>", methods=['POST']) | ||
@auth.oidc_auth | ||
def vm_disk(vmid, old_name, new_name): | ||
user = User(session['userinfo']['preferred_username']) | ||
proxmox = connect_proxmox() | ||
if user.rtp or int(vmid) in user.allowed_vms: | ||
valid, available = check_hostname(starrs, new_name) | ||
if valid and available: | ||
vm = VM(vmid) | ||
vm.rename_vm(new_name) | ||
change_hostname(starrs, old_name, new_name) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you also add a function to rename the name of the system in STARRS? Proxstar tracks systems by their system name, so changing everything but that will cause it to no longer be able to match up a STARRS record with a VM. |
||
return '', 200 | ||
else: | ||
return '', 403 | ||
|
||
|
||
@app.route("/vm/<string:vmid>/renew", methods=['POST']) | ||
@auth.oidc_auth | ||
def vm_renew(vmid): | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -891,3 +891,57 @@ $(document).on('focus click', "[id^=boot-order-]", function() { | |
} | ||
}); | ||
}); | ||
|
||
$(".rename-vm").click(function(){ | ||
const vmid = $(this).data('vmid'); | ||
const old_name = $(this).data('old_name'); | ||
swal({ | ||
title: 'Enter what you would like this VM to be renamed to:', | ||
content: { | ||
element: 'input', | ||
attributes: { | ||
type: 'string', | ||
}, | ||
}, | ||
buttons: { | ||
cancel: { | ||
text: "Cancel", | ||
visible: true, | ||
closeModal: true, | ||
className: "", | ||
}, | ||
confirm: { | ||
text: "Select", | ||
closeModal: false, | ||
} | ||
}, | ||
}) | ||
.then((new_name) => { | ||
if (new_name) { | ||
fetch(`/starrs/${vmid}/hostname/${old_name}/${new_name}`, { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Probably better to do something like |
||
credentials: 'same-origin', | ||
method: 'post' | ||
}).then((response) => { | ||
return swal(`VM Name has been changes!`, { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lowercase |
||
icon: "success", | ||
buttons: { | ||
ok: { | ||
text: "OK", | ||
closeModal: true, | ||
className: "", | ||
} | ||
} | ||
}); | ||
}).then(() => { | ||
window.location = `/vm/${vmid}`; | ||
}); | ||
} | ||
}).catch(err => { | ||
if (err) { | ||
swal("Uh oh...", `Unable to change VM Name. Please try again later.`, "error"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lowercase |
||
} else { | ||
swal.stopLoading(); | ||
swal.close(); | ||
} | ||
}); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably shouldn't be named
vm_disk