Add restart vps in portal
This commit is contained in:
Binary file not shown.
@@ -62,6 +62,15 @@ class CustomerPortalVPS(CustomerPortal):
|
||||
})
|
||||
return request.render("ow_vm_management.portal_my_vps_servers", values)
|
||||
|
||||
@http.route(['/my/vps/<int:vps_id>/restart'], type='http', auth="user", website=True)
|
||||
def portal_restart_vps(self, vps_id, **kw):
|
||||
try:
|
||||
vps_sudo = request.env['vps.server'].sudo().browse(vps_id)
|
||||
vps_sudo.action_restart_from_portal()
|
||||
return request.redirect(vps_sudo.get_portal_url())
|
||||
except AccessError:
|
||||
return request.redirect('/my')
|
||||
|
||||
@http.route(['/my/vps-servers/<int:vps_server_id>'], type='http', auth="user", website=True)
|
||||
def portal_my_vps_server(self, vps_server_id=None, access_token=None, **kw):
|
||||
try:
|
||||
|
||||
Binary file not shown.
@@ -89,7 +89,11 @@ class VPSServer(models.Model):
|
||||
status = self._proxmox_request('GET', f'nodes/pve/{vm_type}/{vm_id}/status/current')
|
||||
server.state = 'running' if status['data']['status'] == 'running' else 'stopped'
|
||||
|
||||
|
||||
def action_restart_from_portal(self):
|
||||
self.ensure_one()
|
||||
if self.env.user.partner_id != self.customer_id:
|
||||
raise AccessError(_("You don't have permission to restart this VPS."))
|
||||
return self.action_reboot()
|
||||
|
||||
def action_fetch_proxmox_data(self):
|
||||
self.ensure_one()
|
||||
|
||||
@@ -70,6 +70,15 @@
|
||||
</h5>
|
||||
</t>
|
||||
<t t-set="card_body">
|
||||
<div class="row mb-4">
|
||||
<div class="col-12 text-right">
|
||||
<a t-att-href="'/my/vps/%s/restart' % vps_server.id"
|
||||
class="btn btn-primary"
|
||||
onclick="return confirm('Are you sure you want to restart this VPS?');">
|
||||
<i class="fa fa-refresh"/> Restart VPS
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-12 col-md-6">
|
||||
<strong>IPv4 Address:</strong> <span t-field="vps_server.ipv4_address"/>
|
||||
@@ -89,6 +98,9 @@
|
||||
<div class="col-12 col-md-6">
|
||||
<strong>Operating System:</strong> <span t-field="vps_server.os"/>
|
||||
</div>
|
||||
<div class="col-12 col-md-6">
|
||||
<strong>State:</strong> <span t-field="vps_server.state"/>
|
||||
</div>
|
||||
</div>
|
||||
</t>
|
||||
</t>
|
||||
|
||||
Reference in New Issue
Block a user