|
|
@ -1534,18 +1534,23 @@ class Role(RevMixin, AclMixin, models.Model): |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
@classmethod |
|
|
@classmethod |
|
|
def get_instance(cls, machineid, *_args, **_kwargs): |
|
|
def get_instance(cls, roleid, *_args, **_kwargs): |
|
|
"""Get the Machine instance with machineid. |
|
|
"""Get the Role instance with roleid. |
|
|
:param userid: The id |
|
|
:param userid: The id |
|
|
:return: The user |
|
|
:return: The user |
|
|
""" |
|
|
""" |
|
|
return cls.objects.get(pk=machineid) |
|
|
return cls.objects.get(pk=roleid) |
|
|
|
|
|
|
|
|
@classmethod |
|
|
@classmethod |
|
|
def interface_for_roletype(cls, roletype): |
|
|
def interface_for_roletype(cls, roletype): |
|
|
"""Return interfaces for a roletype""" |
|
|
"""Return interface for a roletype""" |
|
|
return Interface.objects.filter(role=cls.objects.filter(specific_role=roletype)) |
|
|
return Interface.objects.filter(role=cls.objects.filter(specific_role=roletype)) |
|
|
|
|
|
|
|
|
|
|
|
@classmethod |
|
|
|
|
|
def all_interfaces_for_roletype(cls, roletype): |
|
|
|
|
|
"""Return all interfaces for a roletype""" |
|
|
|
|
|
return Interface.objects.filter(machine__interface__role=cls.objects.filter(specific_role=roletype)) |
|
|
|
|
|
|
|
|
def save(self, *args, **kwargs): |
|
|
def save(self, *args, **kwargs): |
|
|
super(Role, self).save(*args, **kwargs) |
|
|
super(Role, self).save(*args, **kwargs) |
|
|
|
|
|
|
|
|
|