stop/restart on clone running container
This commit is contained in:
@@ -58,9 +58,10 @@ class ProxmoxAbstractModel(BaseModel, TaskAwareModelMixin):
|
||||
def int_fields(self):
|
||||
return []
|
||||
|
||||
def from_proxmox(self, **kwargs):
|
||||
def from_proxmox(self, write_to_db=True, **kwargs):
|
||||
"""Sets the values in DB
|
||||
Extracts csv Values into self, if given"""
|
||||
|
||||
logging.debug(f"Got {kwargs} from proxmox")
|
||||
kwkeys = list(kwargs.keys())
|
||||
params = {}
|
||||
@@ -92,7 +93,10 @@ class ProxmoxAbstractModel(BaseModel, TaskAwareModelMixin):
|
||||
v = no_int_re.sub('', _v) or 0
|
||||
params[k] = v
|
||||
logging.debug(f"No CSValues for {self}")
|
||||
return self.write(**params)
|
||||
if write_to_db:
|
||||
return self.write(**params)
|
||||
else:
|
||||
return params
|
||||
|
||||
|
||||
class Lxc(ProxmoxAbstractModel):
|
||||
@@ -205,8 +209,9 @@ class Lxc(ProxmoxAbstractModel):
|
||||
if not data:
|
||||
logging.warning(f'Could not find {self.vmid} in proxmox - deleting from local database!')
|
||||
return self.delete()
|
||||
self.from_proxmox(**data)
|
||||
super().save()
|
||||
statusdata = pm.lxc_get(f'{self.vmid}/status/current')
|
||||
data |= statusdata
|
||||
self.from_proxmox(write_to_db=True, **data)
|
||||
except Exception as e:
|
||||
logging.error(f"Could not get config for {self.vmid} - {e}")
|
||||
return self
|
||||
|
||||
Reference in New Issue
Block a user