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


Python request.ConfigRequest类代码示例

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


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

示例1: test_ConfigRequest_getUrl

 def test_ConfigRequest_getUrl(self, sessionUrl, mo, requestType):
     session = LoginSession(sessionUrl, 'admin', 'password',
                            requestFormat=requestType)
     expected = sessionUrl + '/api/mo/' + str(mo.dn) + '.' + requestType
     cr = ConfigRequest()
     cr.addMo(mo)
     assert cr.getUrl(session) == expected
开发者ID:bischatt78,项目名称:cobra,代码行数:7,代码来源:test_request.py

示例2: test_ConfigRequest_addMo_raises_not_allowed_context

 def test_ConfigRequest_addMo_raises_not_allowed_context(self):
     fvTenant = Tenant('uni', 'testing')
     fvnsVlanInstP = VlanInstP('uni/infra', 'namespace1', 'dynamic')
     cr = ConfigRequest()
     cr.addMo(fvTenant)
     with pytest.raises(ValueError):
         cr.addMo(fvnsVlanInstP)
开发者ID:bischatt78,项目名称:cobra,代码行数:7,代码来源:test_request.py

示例3: conf_NTP

def conf_NTP(modir , ntp_list):
    '''
    Function that iterates through ntp_list and creates JSON call to configure NTP providers.
    The first NTP server in ntp_list will be the prefered NTP provider.
    '''
    topDn = cobra.mit.naming.Dn.fromString('uni/fabric/time-Best_NTP_Policy')
    topParentDn = topDn.getParent()
    topMo = modir.lookupByDn(topParentDn)
    datetimePol = cobra.model.datetime.Pol(topMo, ownerKey=u'', name=u'Best_NTP_Policy', descr=u'Scripted NTP_Config', adminSt=u'enabled', ownerTag=u'')
    ntp_servers_dict={}
    ntp_prov_dict={}

    for x in range(len(ntp_list)):
        if x == 1:
            ntp_servers_dict['ntp_server_%02d' % x] = cobra.model.datetime.NtpProv(datetimePol, name=ntp_list[x], preferred=u'true')
            ntp_prov_dict['ntp_prov_%02d' % x] = cobra.model.datetime.RsNtpProvToEpg(ntp_servers_dict['ntp_server_%02d' % x], tDn=u'uni/tn-mgmt/mgmtp-default/oob-default')
        else:
            ntp_servers_dict['ntp_server_%02d' % x] = cobra.model.datetime.NtpProv(datetimePol, name=ntp_list[x])
            ntp_prov_dict['ntp_prov_%02d' % x] = cobra.model.datetime.RsNtpProvToEpg(ntp_servers_dict['ntp_server_%02d' % x], tDn=u'uni/tn-mgmt/mgmtp-default/oob-default')


    print toXMLStr(topMo)
    c = ConfigRequest()
    c.addMo(topMo)
    modir.commit(c)
开发者ID:fancyTyphoonKitty,项目名称:cisco_class,代码行数:25,代码来源:ntp.py

示例4: test_ConfigRequest_options

 def test_ConfigRequest_options(self):
     cid = '1234567890'
     expectedOptions = ''
     cr =  ConfigRequest()
     cr.id = cid
     expectedOptions += '_dc=' + cid
     assert cr.options == expectedOptions
开发者ID:bischatt78,项目名称:cobra,代码行数:7,代码来源:test_request.py

示例5: test_ConfigRequest_requestargs

 def test_ConfigRequest_requestargs(self):
     expected1 = {
                    'data': '<?xml version="1.0" encoding="UTF-8"?>\n' +
                            '<fvTenant name=\'testing\' ' +
                            'status=\'created,modified\'></fvTenant>',
                    'headers': {
                        'Cookie': 'APIC-cookie=None'
                    },
                    'timeout': 90,
                    'verify': False
                }
     expected2 = {
                    'data': '<?xml version="1.0" encoding="UTF-8"?>\n' +
                            '<fvTenant status=\'created,modified\' ' +
                            'name=\'testing\'></fvTenant>',
                    'headers': {
                        'Cookie': 'APIC-cookie=None'
                    },
                    'timeout': 90,
                    'verify': False
                }
     polUni = Uni('')
     fvTenant = Tenant(polUni, 'testing')
     session = LoginSession('http://1.1.1.1', 'admin', 'password')
     cr = ConfigRequest()
     cr.addMo(fvTenant)
     assert (cr.requestargs(session) == expected1 or
             cr.requestargs(session) == expected2)
开发者ID:bischatt78,项目名称:cobra,代码行数:28,代码来源:test_request.py

示例6: test_post_tn

 def test_post_tn(self, apics, certobject, userobject):
     apic = apics[0]
     secure = False if apics[1] == 'False' else True
     userobject.pkey = certobject.readFile(
         fileName=certobject.pkeyfile)
     session = CertSession(apic, userobject.certDn, userobject.pkey,
                           secure=secure, requestFormat='xml')
     moDir = MoDirectory(session)
     uni = Uni('')
     fvTenant = Tenant(uni, name='t')
     fvBD = BD(fvTenant, 't-bd')
     fvAp = Ap(fvTenant, 't-app')
     cr = ConfigRequest()
     #cr.subtree = 'full'
     cr.addMo(fvTenant)
     if userobject.user == 'rouser':
         with pytest.raises(RestError) as excinfo:
             r = moDir.commit(cr)
         assert ((excinfo.value.reason == ('user rouser does not have ' +
                                           'domain access to config Mo, ' +
                                           'class fvTenant')) or
                 (excinfo.value.reason == ('user rouser does not have ' +
                                           'domain access to config Mo, ' +
                                           'class fvBD')))
     elif userobject.user == 'rwuser':
         r = moDir.commit(cr)
     else:
         raise NotImplementedError
开发者ID:bischatt78,项目名称:cobra,代码行数:28,代码来源:test_session_CertSession.py

示例7: create_contracts

def create_contracts(modir, tenant_name):
    policy_universe = modir.lookupByDn('uni')
    fv_tenant = Tenant(policy_universe, tenant_name)

    # create Contract for web
    vz_ct_web = BrCP(fv_tenant, CONTRACT_WEB_CT)
    vz_subj_web = Subj(vz_ct_web, 'Web')
    vz_rs_subj_filt_att_web = RsSubjFiltAtt(vz_subj_web, 'http')

    #create contract for App
    vz_ct_app = BrCP(fv_tenant, CONTRACT_APP_CT)
    vz_subj_rmi = Subj(vz_ct_app, 'RMI')
    vz_rs_subj_filt_att_rmi = RsSubjFiltAtt(vz_subj_rmi, 'rmi')

    # create filter for sql
    vz_ct_db = BrCP(fv_tenant, CONTRACT_DB_CT)
    vz_subj_db = Subj(vz_ct_db, 'DbCt')
    vz_rs_subj_filt_att_db = RsSubjFiltAtt(vz_subj_db, 'sql')

    # print the query in XML format
    print toXMLStr(policy_universe, prettyPrint=True)

    # Commit the change using a ConfigRequest object
    configReq = ConfigRequest()
    configReq.addMo(policy_universe)
    modir.commit(configReq)
开发者ID:Gansakumar,项目名称:python-lab,代码行数:26,代码来源:create_contracts.py

示例8: commit_change

 def commit_change(self, changed_object=None, print_xml=True, pretty_print=True):
     """Commit the changes to APIC"""
     changed_object = self.mo if changed_object is None else changed_object
     if print_xml:
         print_query_xml(changed_object, pretty_print=pretty_print)
     config_req = ConfigRequest()
     config_req.addMo(changed_object)
     self.modir.commit(config_req)
开发者ID:bbmorten,项目名称:ACI,代码行数:8,代码来源:createMo.py

示例9: test_ConfigRequest_data

 def test_ConfigRequest_data(self):
     expected = ('{"fvTenant": {"attributes": {"name": "test", "status": ' +
                 '"created,modified"}}}')
     polUni = Uni('')
     fvTenant = Tenant(polUni, 'test')
     cr = ConfigRequest()
     cr.addMo(fvTenant)
     assert cr.data == expected
开发者ID:bischatt78,项目名称:cobra,代码行数:8,代码来源:test_request.py

示例10: test_post_cert_to_local_user

 def test_post_cert_to_local_user(self, moDir, certobject, userobject):
     # Update the user object with the cert data
     userobject.aaaUserCert.data = certobject.readFile(
         fileName=certobject.certfile)
     # Commit the user to the APIC with the cert
     cr = ConfigRequest()
     cr.addMo(userobject.aaaUser)
     r = moDir.commit(cr)
     assert r == []
开发者ID:bischatt78,项目名称:cobra,代码行数:9,代码来源:test_session_CertSession.py

示例11: create_tenant

def create_tenant(modir, tenant_name):
    policy_universe = modir.lookupByDn('uni')

    fvTenant = Tenant(policy_universe, tenant_name)

    print toXMLStr(policy_universe,prettyPrint = True)
    configReq = ConfigRequest()
    configReq.addMo(fvTenant)
    modir.commit(configReq)
开发者ID:kevechol,项目名称:Kovarus-ACI-RP-Rotation,代码行数:9,代码来源:createTenant.py

示例12: test_ConfigRequest_getRootMo

 def test_ConfigRequest_getRootMo(self, mos, expected):
     cr = ConfigRequest()
     mos.append(expected)
     for mo in mos:
         if mo is not None:
             try:
                 cr.addMo(mo)
             except ValueError:
                 pass
     assert cr.getRootMo() == expected
开发者ID:bischatt78,项目名称:cobra,代码行数:10,代码来源:test_request.py

示例13: commit

def commit(md, mo):
    """
    Helper function to commit changes to a mo
    :param md: MoDirectory instance
    :param mo: Cobra object to be committed
    :return:
    """
    c = ConfigRequest()
    c.addMo(mo)
    return md.commit(c)
开发者ID:kecorbin,项目名称:gsx-devnet-aci,代码行数:10,代码来源:sessions.py

示例14: delete_tenant

def delete_tenant(modir, tenant_name):
    fv_tenant = modir.lookupByDn('uni/tn-' + tenant_name)
    fv_tenant.delete()

    # print the query in XML format
    print toXMLStr(fv_tenant, prettyPrint=True)

    # Commit the change using a ConfigRequest object
    configReq = ConfigRequest()
    configReq.addMo(fv_tenant)
    modir.commit(configReq)
开发者ID:Gansakumar,项目名称:python-lab,代码行数:11,代码来源:delete_tenant.py

示例15: commit_change

    def commit_change(self, changed_object=None, print_xml=True):
        """Commit the changes to APIC"""

        # config_req = ConfigRequest()
        # config_req.addMo(self.mo)
        # self.modir.commit(config_req)
        # modir.logout()
        configReq = ConfigRequest()
        configReq.addMo(self.mo)
        self.modir.commit(configReq)
        self.modir.logout()
开发者ID:GDT-Labs,项目名称:Nexus9kBUVisit,代码行数:11,代码来源:test.py


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