def desc(self): user = ElementTree.Element(DPNS('User')) user.extend([ _TextElement(DPNS('Name'), self.name), _TextElement(DPNS('RoleList'), self.roles), ]) return user
def desc(self): cp = ElementTree.Element(DPNS('CP'), {DPNS('introduced'):str(int(self.introduced))}) cp.extend([ _TextElement(DPNS('Name'), self.name), _TextElement(DPNS('ID'), str(self.id)), _TextElement(DPNS('RoleList'), self.roles), ]) if self.alias: cp.append(_TextElement(DPNS('Alias'), self.alias)) return cp
def desc(self): cp = ElementTree.Element( DPNS('CP'), {DPNS('introduced'): str(int(self.introduced))}) cp.extend([ _TextElement(DPNS('Name'), self.name), _TextElement(DPNS('ID'), str(self.id)), _TextElement(DPNS('RoleList'), self.roles), ]) if self.alias: cp.append(_TextElement(DPNS('Alias'), self.alias)) return cp
def GetACLData(self): acl = ElementTree.Element(DPNS('ACL'), {XSINS('schemaLocation'): DPLOC}) print[str(i) for i in Identity.all()] ElementTree.SubElement(acl, DPNS('Identities')).extend( i.desc() for i in Identity.all()) roles = ElementTree.SubElement(acl, DPNS('Roles')) for role in self._collect_roles(self._parent): ElementTree.SubElement(roles, DPNS('Role')).append( _TextElement(DPNS('Name'), role)) return utils.tostring(acl, default_namespace=DPNS.ns)
def UserLogout(self): return @acl(roles='Basic Admin', restricted_roles='Public') @action(returns=dict(ACL='A_ARG_TYPE_ACL')) def GetACLData(self): acl = ElementTree.Element(DPNS('ACL'), {XSINS('schemaLocation'):DPLOC}) print [str(i) for i in Identity.all()] ElementTree.SubElement(acl, DPNS('Identities')).extend(i.desc() for i in Identity.all()) roles = ElementTree.SubElement(acl, DPNS('Roles')) for role in self._collect_roles(self._parent): ElementTree.SubElement(roles, DPNS('Role')).append( _TextElement(DPNS('Name'), role)) return utils.tostring(acl, default_namespace=DPNS.ns) def _collect_roles(self, device): ret = Roles() for s in device.services.values(): for an in dir(s): a = getattr(s, an, None) if isinstance(a, Action): ret |= getattr(a, 'roles', None) or Roles() ret |= getattr(a, 'restricted_roles', None) or Roles() for d in device.devices.values(): ret |= self._collect_roles(d) return ret