Improve vm.is_*vm functions

Do not refer to other VM class explicitly from QubesVm
This commit is contained in:
Marek Marczykowski 2013-03-15 23:11:18 +01:00
parent 7343fea255
commit b733754165

View File

@ -592,19 +592,19 @@ class QubesVm(object):
self.create_appmenus(verbose=False)
def is_template(self):
return isinstance(self, QubesTemplateVm)
return False
def is_appvm(self):
return isinstance(self, QubesAppVm)
return False
def is_netvm(self):
return isinstance(self, QubesNetVm)
return False
def is_proxyvm(self):
return isinstance(self, QubesProxyVm)
return False
def is_disposablevm(self):
return isinstance(self, QubesDisposableVm)
return False
def get_xl_dominfo(self):
if dry_run:
@ -1729,6 +1729,9 @@ class QubesTemplateVm(QubesVm):
def updateable(self):
return True
def is_template(self):
return True
def get_firewall_defaults(self):
return { "rules": list(), "allow": False, "allowDns": False, "allowIcmp": False, "allowYumProxy": True }
@ -1910,6 +1913,9 @@ class QubesNetVm(QubesVm):
def type(self):
return "NetVM"
def is_netvm(self):
return True
@property
def gateway(self):
return self.__gateway
@ -2059,6 +2065,9 @@ class QubesProxyVm(QubesNetVm):
def type(self):
return "ProxyVM"
def is_proxyvm(self):
return True
def _set_netvm(self, new_netvm):
old_netvm = self.netvm
super(QubesProxyVm, self)._set_netvm(new_netvm)
@ -2296,6 +2305,9 @@ class QubesDisposableVm(QubesVm):
def type(self):
return "DisposableVM"
def is_disposablevm(self):
return True
@property
def ip(self):
if self.netvm is not None:
@ -2333,6 +2345,9 @@ class QubesAppVm(QubesVm):
def type(self):
return "AppVM"
def is_appvm(self):
return True
def create_on_disk(self, verbose, source_template = None):
if dry_run:
return