Exemplo n.º 1
0
    def get(self, id):
        # parser = reqparse.RequestParser()
        # parser.add_argument('id', help='This field cannot be blank', required=True)
        # data = parser.parse_args()

        # acl = AclsModel.by_id(data['id'])
        acl = AclsModel.by_id(id)
        acl_part = AclsModel.to_json(acl)
        host_group_acls = HostGroupAclsModel.by_acl_id(acl.id)
        host_group = HostGroupsModel.by_id(host_group_acls.host_group_id)
        acl_part['host_groups'] = HostGroupsModel.to_json(host_group)
        user_group_acls = UserGroupAclModel.by_acl_id(acl.id)
        user_group = UserGroupsModel.by_id(user_group_acls.user_group_id)
        acl_part['user_groups'] = UserGroupsModel.to_json(user_group)

        return acl_part
Exemplo n.º 2
0
    def get(self, name):
        host_group = HostGroupsModel.by_name(name)
        host_groups_part = HostGroupsModel.to_json(host_group)

        host_group_acls = HostGroupAclsModel.by_host_group_id(host_group.id)
        host_groups_part['acls'] = []
        for hgacls in host_group_acls:
            acl = AclsModel.by_id(hgacls.acl_id)
            host_groups_part['acls'].append(AclsModel.to_json(acl))

        host_host_groups = HostHostGroupsModel.by_host_group_id(host_group.id)
        host_groups_part['hosts'] = []
        for hhg in host_host_groups:
            host = HostsModel.by_id(hhg.host_id)
            host_groups_part['hosts'].append(
                HostsModel.to_json(host) if host else None)

        return host_groups_part
Exemplo n.º 3
0
    def get(self, name):
        usergroup = UserGroupsModel.by_name(name)

        usergroups_part = UserGroupsModel.to_json(usergroup)

        userusergroups = UserUserGroupsModel.by_user_group_id(usergroup.id)
        usergroups_part['users'] = []
        for uug in userusergroups:
            user = UserModel.by_id(uug.user_id)
            usergroups_part['users'].append(UserModel.to_json(user))

        usergroupacls = UserGroupAclModel.by_user_group_id(usergroup.id)
        usergroups_part['acls'] = []
        for uga in usergroupacls:
            acl = AclsModel.by_id(uga.acl_id)
            usergroups_part['acls'].append(AclsModel.to_json(acl))

        return usergroups_part