当前位置: 首页>>代码示例>>Python>>正文


Python SecurityContext.userid方法代码示例

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


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

示例1: getContext

# 需要导入模块: from mmc.support.mmctools import SecurityContext [as 别名]
# 或者: from mmc.support.mmctools.SecurityContext import userid [as 别名]
 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,代码行数:9,代码来源:__init__.py

示例2: purge_removed_computers

# 需要导入模块: from mmc.support.mmctools import SecurityContext [as 别名]
# 或者: from mmc.support.mmctools.SecurityContext import userid [as 别名]
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,代码行数:30,代码来源:__init__.py

示例3: get_machines_update_status

# 需要导入模块: from mmc.support.mmctools import SecurityContext [as 别名]
# 或者: from mmc.support.mmctools.SecurityContext import userid [as 别名]
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,代码行数:35,代码来源:__init__.py

示例4: getSubscriptionInfo

# 需要导入模块: from mmc.support.mmctools import SecurityContext [as 别名]
# 或者: from mmc.support.mmctools.SecurityContext import userid [as 别名]
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,代码行数:30,代码来源:inventory.py

示例5: get_machines_update_status

# 需要导入模块: from mmc.support.mmctools import SecurityContext [as 别名]
# 或者: from mmc.support.mmctools.SecurityContext import userid [as 别名]
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,代码行数:55,代码来源:__init__.py

示例6: create_update_commands

# 需要导入模块: from mmc.support.mmctools import SecurityContext [as 别名]
# 或者: from mmc.support.mmctools.SecurityContext import userid [as 别名]
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,代码行数:54,代码来源:__init__.py

示例7: create_update_commands

# 需要导入模块: from mmc.support.mmctools import SecurityContext [as 别名]
# 或者: from mmc.support.mmctools.SecurityContext import userid [as 别名]
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,代码行数:21,代码来源:__init__.py

示例8: _get_updates_for_group

# 需要导入模块: from mmc.support.mmctools import SecurityContext [as 别名]
# 或者: from mmc.support.mmctools.SecurityContext import userid [as 别名]
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,代码行数:22,代码来源:__init__.py

示例9: getLicensesCount

# 需要导入模块: from mmc.support.mmctools import SecurityContext [as 别名]
# 或者: from mmc.support.mmctools.SecurityContext import userid [as 别名]
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,代码行数:26,代码来源:__init__.py

示例10: getContext

# 需要导入模块: from mmc.support.mmctools import SecurityContext [as 别名]
# 或者: from mmc.support.mmctools.SecurityContext import userid [as 别名]
 def getContext(self):
     s = SecurityContext()
     s.userid = self.userid
     return s
开发者ID:zentyal,项目名称:mmc,代码行数:6,代码来源:__init__.py

示例11: getContext

# 需要导入模块: from mmc.support.mmctools import SecurityContext [as 别名]
# 或者: from mmc.support.mmctools.SecurityContext import userid [as 别名]
 def getContext(self):
     s = SecurityContext()
     s.userid = self.userid
     s.userdn = LdapUserGroupControl().searchUserDN(self.userid)
     return s
开发者ID:jkerihuel,项目名称:mmc,代码行数:7,代码来源:__init__.py


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