• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python mmctools.SecurityContext类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中mmc.support.mmctools.SecurityContext的典型用法代码示例。如果您正苦于以下问题:Python SecurityContext类的具体用法?Python SecurityContext怎么用?Python SecurityContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了SecurityContext类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: getContext

 def getContext(self):
     s = SecurityContext()
     s.userid = self.userid
     s.locationsCount = ComputerLocationManager().getLocationsCount()
     s.userids = ComputerLocationManager().getUsersInSameLocations(self.userid)
     s.filterType = "mine"
     return s
开发者ID:tekmans,项目名称:mmc,代码行数:7,代码来源:__init__.py


示例2: purge_removed_computers

def purge_removed_computers():
    from mmc.plugins.base.computers import ComputerManager
    from mmc.plugins.base import LdapUserGroupControl

    # Get all imaging targets
    targets = ImagingDatabase().getAllRegisteredComputers()

    # Creating root context to query ComputerManager
    ctx = SecurityContext()
    ctx.userid = 'root'
    ctx.userdn = LdapUserGroupControl().searchUserDN(ctx.userid)

    # Init to_delete computer list
    to_delete = []

    for uuid in targets:
        if ComputerManager().getComputerCount(ctx, {'uuid': uuid}) == 0:
            # If the target computer is not in ComputerManager database anymore
            # we unregister it from imaging
            to_delete.append(uuid)

    # Unregistering orphan targets without backup
    if to_delete:
        logging.getLogger().info('Orphan imaging computer(s) found')
        logging.getLogger().info('Going to purge %s' % ' '.join(to_delete))
        computersUnregister(to_delete, False)

    return True
开发者ID:neoclust,项目名称:pulse,代码行数:28,代码来源:__init__.py


示例3: get_machines_update_status

def get_machines_update_status():
    """
    Get machine update status as a dict as key
    and status string as value.
    commons status values :"unknown","up-to-date","need_update","update_available",
    "update_planned"
    """
    # Creating root context
    ctx = SecurityContext()
    ctx.userid = 'root'

    machines_status = {}
    uuids = []
    # get computer list who returned update
    machines_update = updateDatabase().get_machines()
    # get uuid for all computer
    ComputerList = ComputerManager().getComputersList(ctx, {}).keys()
    uuids = []
    for uuid in ComputerList:
        uuids.append(int(uuid.lower().replace('uuid', '')))
    #get status of all machines
    for uuid in uuids:
        if uuid in machines_update:
            if len(updateDatabase().get_neutral_updates_for_host(uuid)) == 0:
                if len(updateDatabase().get_eligible_updates_for_host(uuid)) == 0:
                    machines_status["UUID" + str(uuid)] = "up-to-date"
                else:
                    machines_status["UUID" + str(uuid)] = "update_planned"
            else:
                machines_status["UUID" + str(uuid)] = "update_available"
        else:
            machines_status["UUID" + str(uuid)] = "unknown"
    return machines_status
开发者ID:inkhey,项目名称:mmc,代码行数:33,代码来源:__init__.py


示例4: getSubscriptionInfo

def getSubscriptionInfo():
    
    # Creating root context
    ctx = SecurityContext()
    ctx.userid = 'root'
    
    # Get all machine count
    count = ComputerManager().getComputerCount(ctx)
    
    # Get license max_machines
    out, err, ec = runInShell('/usr/sbin/pulse-licensed -G /etc/pulse-licensing/installation_id -l /etc/pulse-licensing/license.dat -p /etc/pulse-licensing/license -i')
    
    if ec == 0:
        data = loads(out)
        for license in data:
            if license['alias'] == 'pulse':
                max_machines = int(license['custon_number'])
                ts_expiration = int(license['licencingtime'])
                break
        else:
            max_machines = 5
    else:
        max_machines = 5
    
    if max_machines == 5:
        ts_expiration = 0

    return [count, max_machines, ts_expiration]
开发者ID:mandriva-management-console,项目名称:pulse-on-univention,代码行数:28,代码来源:inventory.py


示例5: get_machines_update_status

def get_machines_update_status(not_supported=False):
    """
    Get machine update status as a dict as key
    and status string as value.
    commons status values :"not_supported","not_registered",
    "up-to-date","need_update","update_available","update_planned",
    "os_update_disabled".
    The "not_supported" value can be disabled with not_supported param.
    """
    # Creating root context
    ctx = SecurityContext()
    ctx.userid = 'root'

    machines_status = {}
    uuids = []

    # get computer list who returned update
    machines_update = updateDatabase().get_machines()
    # get activated os computers:
    machines_os_enabled = _get_updatable_computers(ctx, activated=True)
    # get disabled os computers:
    machines_os_disabled = _get_updatable_computers(ctx, activated=False)
    # get uuid for all computer
    ComputerList = ComputerManager().getComputersList(ctx, {}).keys()
    uuids = []
    # convert uuid as string number
    for uuid in ComputerList:
        uuids.append(int(uuid.lower().replace('uuid', '')))
    machines_os_enabled = [
        int(uuid.lower().replace('uuid', '')) for uuid in machines_os_enabled]
    machines_os_disabled = [
        int(uuid.lower().replace('uuid', '')) for uuid in machines_os_disabled]
    # get status of all machines
    for uuid in uuids:
        if uuid in machines_os_disabled:
            machines_status["UUID" + str(uuid)] = "os_update_disabled"
        elif uuid in machines_os_enabled:
            if uuid in machines_update:
                # if no neutral update not installed on this machine
                if len(updateDatabase().get_neutral_updates_for_host(uuid, 0)) == 0:
                    # if no eligible update
                    if len(updateDatabase().get_eligible_updates_for_host(uuid)) == 0:
                        machines_status["UUID" + str(uuid)] = "up-to-date"
                    else:
                        machines_status["UUID" + str(uuid)] = "update_planned"
                else:
                    machines_status["UUID" + str(uuid)] = "update_available"
            else:
                machines_status["UUID" + str(uuid)] = "not_registered"
        elif not_supported:
            machines_status["UUID" + str(uuid)] = "not_supported"

    return machines_status
开发者ID:pruebagit,项目名称:mmc,代码行数:53,代码来源:__init__.py


示例6: create_update_commands

def create_update_commands():
    # TODO: ensure that this method is called by taskmanager
    # and not directly by XMLRPC

    # Creating root context
    ctx = SecurityContext()
    ctx.userid = 'root'
    # Get active computer manager
    computer_manager = ComputerManager().getManagerName()

    if computer_manager == 'inventory':
        dyngroup_pattern = '%d==inventory::Hardware/OperatingSystem==%s'
    elif computer_manager == 'glpi':
        dyngroup_pattern = '%d==glpi::Operating system==%s'
    else:
        logging.getLogger().error(
            'Update module: Unsupported computer manager %s' %
            computer_manager)
        return False

    # Get all enabled os_classes
    os_classes = updateDatabase().get_os_classes({'filters': {'enabled': 1}})

    # Create update command for enabled os_classes
    for os_class in os_classes['data']:

        patterns = os_class['pattern'].split('||')
        request = []
        equ_bool = []

        for i in xrange(len(patterns)):
            request.append(dyngroup_pattern % (i + 1, patterns[i]))
            equ_bool.append(str(i + 1))

        request = '||'.join(request)
        equ_bool = 'OR(%s)' % ','.join(equ_bool)

        targets = ComputerManager().getComputersList(
            ctx, {
                'request': request, 'equ_bool': equ_bool}).keys()

        # Fetching all targets
        for uuid in targets:
            machine_id = int(uuid.lower().replace('uuid', ''))
            updates = updateDatabase().get_eligible_updates_for_host(
                machine_id)

            update_list = [update['uuid'] for update in updates]

            # Create update command for this host with update_list
            create_update_command(ctx, [uuid], update_list)
    return True
开发者ID:inkhey,项目名称:mmc,代码行数:52,代码来源:__init__.py


示例7: create_update_commands

def create_update_commands():
    # TODO: ensure that this method is called by taskmanager
    # and not directly by XMLRPC

    # Creating root context
    ctx = SecurityContext()
    ctx.userid = 'root'
    targets = _get_updatable_computers(ctx)
    # Fetching all targets
    for uuid in targets:
        machine_id = int(uuid.lower().replace('uuid', ''))
        updates = updateDatabase().get_eligible_updates_for_host(
            machine_id)

        update_list = [update['uuid'] for update in updates]

        # Create update command for this host with update_list
        create_update_command(ctx, [uuid], update_list)
    return True
开发者ID:pruebagit,项目名称:mmc,代码行数:19,代码来源:__init__.py


示例8: _get_updates_for_group

def _get_updates_for_group(params):
    """
    Get updates from uuids list if params['uuids'] is a correct list of uuid
    and from group if params['gid'] is a correct group id
    """
    if 'gid' in params:
        params['uuids'] = []
        # Creating root context
        ctx = SecurityContext()
        ctx.userid = 'root'

        # get uuid for all computer of this group
        ComputerList = ComputerGroupManager().get_group_results(
            ctx, params['gid'], 0, -1, {})
        for uuid in ComputerList:
            params['uuids'].append(int(uuid.lower().replace('uuid', '')))

    # get updates for this group
    updates = updateDatabase().get_updates_for_group(params)
    return updates
开发者ID:pruebagit,项目名称:mmc,代码行数:20,代码来源:__init__.py


示例9: getLicensesCount

def getLicensesCount(vendor, software, version):
    ctx = SecurityContext()
    ctx.userid = "root"

    def replace_splat(param):
        if '*' in param:
            return param.replace('*', '%')
        return param

    def check_param(param):
        if param == '' or param == '*' or param == '%':
            return None
        return replace_splat(param)

    software = check_param(software)
    vendor = check_param(vendor)
    version = check_param(version)
    if software is None:
        software = '%'
    return xmlrpcCleanup(Inventory().getAllSoftwaresImproved(ctx,
                                                     software,
                                                     vendor=vendor,
                                                     version=version,
                                                     count=1))
开发者ID:AnatomicJC,项目名称:mmc,代码行数:24,代码来源:__init__.py


示例10: getContext

 def getContext(self):
     s = SecurityContext()
     s.userid = self.userid
     return s
开发者ID:zentyal,项目名称:mmc,代码行数:4,代码来源:__init__.py


示例11: getContext

 def getContext(self):
     s = SecurityContext()
     s.userid = self.userid
     s.userdn = LdapUserGroupControl().searchUserDN(self.userid)
     return s
开发者ID:jkerihuel,项目名称:mmc,代码行数:5,代码来源:__init__.py



注:本文中的mmc.support.mmctools.SecurityContext类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python common_graph.Node类代码示例发布时间:2022-05-27
下一篇:
Python mmctools.xmlrpcCleanup函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap