statuf on load fixed?
This commit is contained in:
@@ -282,12 +282,9 @@
|
|||||||
$.get("{% url 'frontend:current_container_details' %}", {'ids': id}, function (container) {
|
$.get("{% url 'frontend:current_container_details' %}", {'ids': id}, function (container) {
|
||||||
container = container[0]
|
container = container[0]
|
||||||
if (container.is_low) {
|
if (container.is_low) {
|
||||||
$('[data-crow="' + id + '"]').addClass(
|
$('[data-crow="' + id + '"]')
|
||||||
'status-low'
|
.addClass('status-low')
|
||||||
).attr(
|
.attr('title', 'Low Warning: Disk: ' + container.disk_percent + '%, Memory: ' + container.mem_percent + '%');
|
||||||
'title',
|
|
||||||
'Low Warning: Disk: ' + container.disk_percent + '%, Memory: ' + container.mem_percent + '%'
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
let lxc_status = $('.lxc_status_' + id);
|
let lxc_status = $('.lxc_status_' + id);
|
||||||
let lease_status = $('.lease_status_' + id);
|
let lease_status = $('.lease_status_' + id);
|
||||||
|
|||||||
@@ -107,7 +107,11 @@ def dashboard(request):
|
|||||||
class ContainerStatus:
|
class ContainerStatus:
|
||||||
low_limit = 80
|
low_limit = 80
|
||||||
|
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, dev_container:DevContainer):
|
||||||
|
self._devcontainer = dev_container
|
||||||
|
self.vmid = dev_container.lxc.vmid
|
||||||
|
self.lxc_status = dev_container.lxc.synced_status
|
||||||
|
kwargs = dev_container.statuscache or {}
|
||||||
self.cpus = kwargs.get('cpus', 0)
|
self.cpus = kwargs.get('cpus', 0)
|
||||||
self.cpu = kwargs.get('cpu', 0)
|
self.cpu = kwargs.get('cpu', 0)
|
||||||
self.maxmem = kwargs.get('maxmem', 256)
|
self.maxmem = kwargs.get('maxmem', 256)
|
||||||
@@ -117,9 +121,7 @@ class ContainerStatus:
|
|||||||
self.maxswap = kwargs.get('maxswap', 0)
|
self.maxswap = kwargs.get('maxswap', 0)
|
||||||
self.swap = kwargs.get('swap', 0)
|
self.swap = kwargs.get('swap', 0)
|
||||||
self.status = kwargs.get('status')
|
self.status = kwargs.get('status')
|
||||||
self.vmid = kwargs.get('vmid')
|
|
||||||
self.lease_status = kwargs.get('lease_status', 'waiting')
|
self.lease_status = kwargs.get('lease_status', 'waiting')
|
||||||
self.lxc_status = kwargs.get('lxc_status', 'stopped')
|
|
||||||
|
|
||||||
def __hash__(self):
|
def __hash__(self):
|
||||||
return int(self.vmid)
|
return int(self.vmid)
|
||||||
@@ -171,7 +173,7 @@ def container_details(request):
|
|||||||
with Proxmox() as pm:
|
with Proxmox() as pm:
|
||||||
for id in ids:
|
for id in ids:
|
||||||
container = DevContainer.objects.get(internal_id=id)
|
container = DevContainer.objects.get(internal_id=id)
|
||||||
ret.append(ContainerStatus(**(container.statuscache or {})).to_json)
|
ret.append(ContainerStatus(container).to_json)
|
||||||
return HttpResponse(json.dumps(ret), content_type='application/json')
|
return HttpResponse(json.dumps(ret), content_type='application/json')
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -97,6 +97,9 @@ class ProxmoxAbstractModel(BaseModel, TaskAwareModelMixin):
|
|||||||
return self.write(**params)
|
return self.write(**params)
|
||||||
else:
|
else:
|
||||||
return params
|
return params
|
||||||
|
@property
|
||||||
|
def vmstatus(self):
|
||||||
|
raise NotImplemented('vmstatus not implemented')
|
||||||
|
|
||||||
|
|
||||||
class Lxc(ProxmoxAbstractModel):
|
class Lxc(ProxmoxAbstractModel):
|
||||||
@@ -123,6 +126,13 @@ class Lxc(ProxmoxAbstractModel):
|
|||||||
'rootfs': ('size', 'disksize', lambda x: int(no_int_re.sub('', x) or 0)),
|
'rootfs': ('size', 'disksize', lambda x: int(no_int_re.sub('', x) or 0)),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@property
|
||||||
|
def synced_status(self):
|
||||||
|
with Proxmox() as pm:
|
||||||
|
if statusresponse := pm.lxc_get(f'{self.vmid}/status/current'):
|
||||||
|
self.write(status=statusresponse['status'])
|
||||||
|
return self.status
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def proxmox_console_url(self):
|
def proxmox_console_url(self):
|
||||||
return (
|
return (
|
||||||
|
|||||||
Reference in New Issue
Block a user