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

Python bundle.Bundle类代码示例

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

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



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

示例1: test_uid_invalid_certificate

 def test_uid_invalid_certificate(self, fake_read, fake_valid):
     fake_read.return_value = CERTIFICATE
     fake_valid.return_value = False
     bundle = Bundle('')
     uid = bundle.uid()
     fake_valid.assert_called_with()
     self.assertTrue(uid is None)
开发者ID:AndreaGiardini,项目名称:pulp,代码行数:7,代码来源:test_bundle.py


示例2: load_consumer_id

def load_consumer_id(context):
    """
    Returns the consumer's ID if it is registered.

    @return: consumer id if registered; None when not registered
    @rtype:  str, None
    """
    filesystem_section = context.config.get('filesystem', None)
    if filesystem_section is None:
        return None

    consumer_cert_path = filesystem_section.get('id_cert_dir', None)
    consumer_cert_filename = filesystem_section.get('id_cert_filename', None)

    if None in (consumer_cert_path, consumer_cert_filename):
        return None

    full_filename = os.path.join(consumer_cert_path, consumer_cert_filename)
    bundle = Bundle(full_filename)

    if not bundle.valid():
        return None

    content = bundle.read()
    x509 = X509.load_cert_string(content)
    subject = _subject(x509)
    return subject['CN']
开发者ID:AndreaGiardini,项目名称:pulp,代码行数:27,代码来源:consumer_utils.py


示例3: testWrite

 def testWrite(self):
     b = Bundle(CRTFILE)
     b.write(BUNDLE)
     f = open(CRTFILE)
     s = f.read()
     f.close()
     self.assertEqual(BUNDLE.strip(), s.strip())
开发者ID:AndreaGiardini,项目名称:pulp,代码行数:7,代码来源:test_bundle.py


示例4: test_cn

 def test_cn(self, fake_read, fake_valid):
     fake_read.return_value = CERTIFICATE
     fake_valid.return_value = True
     bundle = Bundle('')
     cn = bundle.cn()
     fake_valid.assert_called_with()
     fake_read.assert_called_with()
     self.assertEqual(cn, 'localhost')
开发者ID:AndreaGiardini,项目名称:pulp,代码行数:8,代码来源:test_bundle.py


示例5: __init__

 def __init__(self):
     """
     Read from file-system on construction.
     """
     cfg = Config(CONFIG_PATH)
     files = cfg['filesystem']
     path = os.path.join(files['id_cert_dir'], files['id_cert_filename'])
     Bundle.__init__(self, path)
开发者ID:kbotc,项目名称:pulp,代码行数:8,代码来源:model.py


示例6: test_uid

 def test_uid(self, fake_read, fake_valid):
     fake_read.return_value = VERIZON_CERTIFICATE
     fake_valid.return_value = True
     bundle = Bundle('')
     uid = bundle.uid()
     fake_valid.assert_called_with()
     fake_read.assert_called_with()
     self.assertEqual(uid, 'vzn-user')
开发者ID:AndreaGiardini,项目名称:pulp,代码行数:8,代码来源:test_bundle.py


示例7: run_synchronization

    def run_synchronization(self, progress, cancelled, options):
        """
        Run a repo_sync() on this repository.
        :param progress: A progress report.
        :type progress: pulp_node.progress.RepositoryProgress
        :param options: node synchronization options.
        :type options: dict
        :return: The task result.
        """
        warnings.warn(TASK_DEPRECATION_WARNING, NodeDeprecationWarning)

        bindings = resources.pulp_bindings()
        poller = TaskPoller(bindings)
        max_download = options.get(constants.MAX_DOWNLOAD_CONCURRENCY_KEYWORD, constants.DEFAULT_DOWNLOAD_CONCURRENCY)
        node_certificate = options[constants.PARENT_SETTINGS][constants.NODE_CERTIFICATE]
        key, certificate = Bundle.split(node_certificate)
        configuration = {
            importer_constants.KEY_MAX_DOWNLOADS: max_download,
            importer_constants.KEY_MAX_SPEED: options.get(constants.MAX_DOWNLOAD_BANDWIDTH_KEYWORD),
            importer_constants.KEY_SSL_CLIENT_KEY: key,
            importer_constants.KEY_SSL_CLIENT_CERT: certificate,
            importer_constants.KEY_SSL_VALIDATION: False,
        }
        http = bindings.repo_actions.sync(self.repo_id, configuration)
        if http.response_code != httplib.ACCEPTED:
            raise RepoSyncRestError(self.repo_id, http.response_code)
        # The repo sync is returned with a single sync task in the Call Report
        task = http.response_body.spawned_tasks[0]
        result = poller.join(task.task_id, progress, cancelled)
        if cancelled():
            self._cancel_synchronization(task)
        return result
开发者ID:pulp,项目名称:pulp,代码行数:32,代码来源:model.py


示例8: load_consumer_id

def load_consumer_id(context):
    """
    Returns the consumer's ID if it is registered.

    @return: consumer id if registered; None when not registered
    @rtype:  str, None
    """
    consumer_cert_path = context.config['filesystem']['id_cert_dir']
    consumer_cert_filename = context.config['filesystem']['id_cert_filename']
    full_filename = os.path.join(consumer_cert_path, consumer_cert_filename)
    bundle = Bundle(full_filename)
    if bundle.valid():
        content = bundle.read()
        x509 = X509.load_cert_string(content)
        subject = _subject(x509)
        return subject['CN']
    else:
        return None
开发者ID:ehelms,项目名称:pulp,代码行数:18,代码来源:consumer_utils.py


示例9: register

    def register(consumer_id,
                 display_name=None,
                 description=None,
                 notes=None,
                 capabilities=None,
                 rsa_pub=None):
        """
        Registers a new Consumer

        :param consumer_id: unique identifier for the consumer
        :type  consumer_id: str
        :param rsa_pub: The consumer public key used for message authentication.
        :type rsa_pub: str
        :param display_name: user-friendly name for the consumer
        :type  display_name: str
        :param description:  user-friendly text describing the consumer
        :type  description: str
        :param notes: key-value pairs to pragmatically tag the consumer
        :type  notes: dict
        :param capabilities: operations supported on the consumer
        :type  capabilities: dict
        :raises DuplicateResource: if there is already a consumer or a used with the requested ID
        :raises InvalidValue: if any of the fields is unacceptable
        :return: A tuple of: (consumer, certificate)
        :rtype: tuple
        """
        if not is_consumer_id_valid(consumer_id):
            raise InvalidValue(['id'])

        collection = Consumer.get_collection()

        consumer = collection.find_one({'id': consumer_id})
        if consumer is not None:
            raise DuplicateResource(consumer_id)

        if notes is not None and not isinstance(notes, dict):
            raise InvalidValue(['notes'])

        if capabilities is not None and not isinstance(capabilities, dict):
            raise InvalidValue(['capabilities'])

        # Use the ID for the display name if one was not specified
        display_name = display_name or consumer_id

        # Creation
        consumer = Consumer(consumer_id, display_name, description, notes, capabilities, rsa_pub)
        _id = collection.save(consumer, safe=True)

        # Generate certificate
        cert_gen_manager = factory.cert_generation_manager()
        expiration_date = config.config.getint('security', 'consumer_cert_expiration')
        key, certificate = cert_gen_manager.make_cert(consumer_id, expiration_date, uid=str(_id))

        factory.consumer_history_manager().record_event(consumer_id, 'consumer_registered')

        return consumer, Bundle.join(key, certificate)
开发者ID:credativ,项目名称:pulp,代码行数:56,代码来源:cud.py


示例10: cn

 def cn(self):
     """
     Get the common name (CN) part of the certificate subject.
     Returns None, if the certificate is invalid.
     :return The common name (CN) part of the certificate subject or None when
         the certificate is not found or invalid.
     :rtype: str
     """
     try:
         return Bundle.cn(self)
     except X509Error:
         log.warn('certificate: %s, not valid', self.path)
开发者ID:ashcrow,项目名称:pulp,代码行数:12,代码来源:pulpplugin.py


示例11: testVerify

 def testVerify(self):
     self.assertTrue(Bundle.haskey(KEY))
     self.assertTrue(Bundle.haskey(KEY2))
     self.assertFalse(Bundle.hascrt(KEY))
     self.assertTrue(Bundle.hascrt(CERTIFICATE))
     self.assertTrue(Bundle.hascrt(CERTIFICATE))
     self.assertTrue(Bundle.hasboth(BUNDLE))
开发者ID:AndreaGiardini,项目名称:pulp,代码行数:7,代码来源:test_bundle.py


示例12: uid

 def uid(self):
     """
     Get the userid (UID) part of the certificate subject.
     Returns None, if the certificate is invalid.
     :return The userid (UID) part of the certificate subject or None when
         the certificate is not found or invalid.
     :rtype: str
     """
     try:
         return Bundle.uid(self)
     except X509Error:
         msg = _('certificate: %(p)s, not valid')
         log.warn(msg, {'p': self.path})
开发者ID:credativ,项目名称:pulp,代码行数:13,代码来源:pulpplugin.py


示例13: register

    def register(self, id, display_name=None, description=None, notes=None, capabilities=None):
        """
        Registers a new Consumer

        @param id: unique identifier for the consumer
        @type  id: str

        @param display_name: user-friendly name for the consumer
        @type  display_name: str

        @param description: user-friendly text describing the consumer
        @type  description: str

        @param notes: key-value pairs to programmatically tag the consumer
        @type  notes: dict

        @param capabilities: operations permitted on the consumer
        @type capabilities: dict

        @raises DuplicateResource: if there is already a consumer or a used with the requested ID
        @raises InvalidValue: if any of the fields is unacceptable
        """
        if not is_consumer_id_valid(id):
            raise InvalidValue(['id'])
        
        existing_consumer = Consumer.get_collection().find_one({'id' : id})
        if existing_consumer is not None:
            raise DuplicateResource(id)
            
        if notes is not None and not isinstance(notes, dict):
            raise InvalidValue(['notes'])

        if capabilities is not None and not isinstance(capabilities, dict):
            raise InvalidValue(['capabilities'])

        # Use the ID for the display name if one was not specified
        display_name = display_name or id

        # Generate certificate
        cert_gen_manager = factory.cert_generation_manager()
        expiration_date = config.config.getint('security', 'consumer_cert_expiration')
        key, crt = cert_gen_manager.make_cert(id, expiration_date)

        # Creation
        create_me = Consumer(id, display_name, description, notes, capabilities, certificate=crt.strip())
        Consumer.get_collection().save(create_me, safe=True)

        factory.consumer_history_manager().record_event(id, 'consumer_registered')
        create_me.certificate = Bundle.join(key, crt)
        return create_me
开发者ID:jlsherrill,项目名称:pulp,代码行数:50,代码来源:cud.py


示例14: test_repository

 def test_repository(self, *mocks):
     # Setup
     repository = Repository(REPO_ID)
     progress = Mock()
     cancelled = Mock(return_value=False)
     # Test
     options = {
         constants.MAX_DOWNLOAD_CONCURRENCY_KEYWORD: MAX_CONCURRENCY,
         constants.MAX_DOWNLOAD_BANDWIDTH_KEYWORD: MAX_BANDWIDTH,
         constants.PARENT_SETTINGS: PARENT_SETTINGS,
     }
     repository.run_synchronization(progress, cancelled, options)
     binding = mocks[1]
     key, certificate = Bundle.split(NODE_CERTIFICATE)
     expected_conf = {
         importer_constants.KEY_SSL_VALIDATION: False,
         importer_constants.KEY_MAX_DOWNLOADS: MAX_CONCURRENCY,
         importer_constants.KEY_MAX_SPEED: MAX_BANDWIDTH,
         importer_constants.KEY_SSL_CLIENT_KEY: key,
         importer_constants.KEY_SSL_CLIENT_CERT: certificate,
     }
     # Verify
     binding.assert_called_with(REPO_ID, expected_conf)
开发者ID:BrnoPCmaniak,项目名称:pulp,代码行数:23,代码来源:test_model.py


示例15: __init__

 def __init__(self, user):
     path = str(os.path.join(getattr(settings,
                                     'PULP_CERTIFICATE_PATH',
                                     'certs'),
                             "%s.crt" % user))
     Bundle.__init__(self, path)
开发者ID:Tvaske,项目名称:sponge,代码行数:6,代码来源:__init__.py


示例16: __init__

 def __init__(self):
     path = os.path.join(
         cfg['filesystem']['id_cert_dir'],
         cfg['filesystem']['id_cert_filename'])
     BundleImpl.__init__(self, path)
开发者ID:skarmark,项目名称:pulp_rpm,代码行数:5,代码来源:pulp-profile-update.py


示例17: __init__

 def __init__(self):
     path = os.path.join(cfg.filesystem.id_cert_dir, cfg.filesystem.id_cert_filename)
     Bundle.__init__(self, path)
开发者ID:credativ,项目名称:pulp,代码行数:3,代码来源:pulpplugin.py


示例18: __init__

 def __init__(self):
     Bundle.__init__(self, cfg.rest.clientcert)
开发者ID:ashcrow,项目名称:pulp,代码行数:2,代码来源:pulpplugin.py


示例19: testRead

 def testRead(self):
     b = Bundle(CRTFILE)
     b.write(BUNDLE)
     s = b.read()
     self.assertEqual(BUNDLE.strip(), s.strip())
开发者ID:AndreaGiardini,项目名称:pulp,代码行数:5,代码来源:test_bundle.py


示例20: testSplit

 def testSplit(self):
     key, crt = Bundle.split(BUNDLE)
     self.assertEqual(key.strip(), KEY.strip())
     self.assertEqual(crt.strip(), CERTIFICATE.strip())
开发者ID:AndreaGiardini,项目名称:pulp,代码行数:4,代码来源:test_bundle.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python json.loads函数代码示例发布时间:2022-05-25
下一篇:
Python extensions.PulpCliSection类代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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