Skip to content

Commit

Permalink
Make QubesVM.verify_name classmethod
Browse files Browse the repository at this point in the history
This will allow to verify VM name before creating the object.

QubesOS/qubes-issues#2737
  • Loading branch information
marmarek committed Apr 20, 2017
1 parent 288c7ac commit 0dfd907
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions core-modules/000QubesVm.py
Expand Up @@ -249,7 +249,8 @@ def post_set_attr(self, attr, newvalue, oldvalue):
for hook in self.hooks_set_attr:
hook(self, attr, newvalue, oldvalue)

def __basic_parse_xml_attr(self, value):
@staticmethod
def __basic_parse_xml_attr(value):
if value is None:
return None
if value.lower() == "none":
Expand Down Expand Up @@ -561,8 +562,9 @@ def is_networked(self):
else:
return False

def verify_name(self, name):
if not isinstance(self.__basic_parse_xml_attr(name), str):
@classmethod
def verify_name(cls, name):
if not isinstance(cls.__basic_parse_xml_attr(name), str):
return False
if len(name) > 31:
return False
Expand Down

0 comments on commit 0dfd907

Please sign in to comment.