當前位置: 首頁>>代碼示例>>Python>>正文


Python ConfigRequest.addMo方法代碼示例

本文整理匯總了Python中cobra.mit.request.ConfigRequest.addMo方法的典型用法代碼示例。如果您正苦於以下問題:Python ConfigRequest.addMo方法的具體用法?Python ConfigRequest.addMo怎麽用?Python ConfigRequest.addMo使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在cobra.mit.request.ConfigRequest的用法示例。


在下文中一共展示了ConfigRequest.addMo方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: conf_NTP

# 需要導入模塊: from cobra.mit.request import ConfigRequest [as 別名]
# 或者: from cobra.mit.request.ConfigRequest import addMo [as 別名]
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,代碼行數:27,代碼來源:ntp.py

示例2: test_ConfigRequest_removeMo_no_configMos_left

# 需要導入模塊: from cobra.mit.request import ConfigRequest [as 別名]
# 或者: from cobra.mit.request.ConfigRequest import addMo [as 別名]
 def test_ConfigRequest_removeMo_no_configMos_left(self):
     fvTenant = Tenant('uni', 'testing')
     fvnsVlanInstP = VlanInstP('uni/infra', 'namespace1', 'dynamic')
     cr = ConfigRequest()
     cr.addMo(fvTenant)
     cr.removeMo(fvTenant)
     assert not cr.hasMo(fvTenant.dn)
開發者ID:bischatt78,項目名稱:cobra,代碼行數:9,代碼來源:test_request.py

示例3: test_ConfigRequest_addMo_raises_not_allowed_context

# 需要導入模塊: from cobra.mit.request import ConfigRequest [as 別名]
# 或者: from cobra.mit.request.ConfigRequest import addMo [as 別名]
 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,代碼行數:9,代碼來源:test_request.py

示例4: test_ConfigRequest_requestargs

# 需要導入模塊: from cobra.mit.request import ConfigRequest [as 別名]
# 或者: from cobra.mit.request.ConfigRequest import addMo [as 別名]
 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,代碼行數:30,代碼來源:test_request.py

示例5: test_post_tn

# 需要導入模塊: from cobra.mit.request import ConfigRequest [as 別名]
# 或者: from cobra.mit.request.ConfigRequest import addMo [as 別名]
 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,代碼行數:30,代碼來源:test_session_CertSession.py

示例6: create_contracts

# 需要導入模塊: from cobra.mit.request import ConfigRequest [as 別名]
# 或者: from cobra.mit.request.ConfigRequest import addMo [as 別名]
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,代碼行數:28,代碼來源:create_contracts.py

示例7: test_ConfigRequest_getUrl

# 需要導入模塊: from cobra.mit.request import ConfigRequest [as 別名]
# 或者: from cobra.mit.request.ConfigRequest import addMo [as 別名]
 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,代碼行數:9,代碼來源:test_request.py

示例8: test_ConfigRequest_removeMo_and_hasMo_positive

# 需要導入模塊: from cobra.mit.request import ConfigRequest [as 別名]
# 或者: from cobra.mit.request.ConfigRequest import addMo [as 別名]
 def test_ConfigRequest_removeMo_and_hasMo_positive(self):
     fvTenant = Tenant('uni', 'testing')
     fvnsVlanInstP = VlanInstP('uni/infra', 'namespace1', 'dynamic')
     cr = ConfigRequest()
     cr.addMo(fvTenant)
     cr.removeMo(fvTenant)
     cr.addMo(fvnsVlanInstP)
     assert cr.hasMo(fvnsVlanInstP.dn)
開發者ID:bischatt78,項目名稱:cobra,代碼行數:10,代碼來源:test_request.py

示例9: test_ConfigRequest_data

# 需要導入模塊: from cobra.mit.request import ConfigRequest [as 別名]
# 或者: from cobra.mit.request.ConfigRequest import addMo [as 別名]
 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,代碼行數:10,代碼來源:test_request.py

示例10: commit_change

# 需要導入模塊: from cobra.mit.request import ConfigRequest [as 別名]
# 或者: from cobra.mit.request.ConfigRequest import addMo [as 別名]
 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,代碼行數:10,代碼來源:createMo.py

示例11: create_tenant

# 需要導入模塊: from cobra.mit.request import ConfigRequest [as 別名]
# 或者: from cobra.mit.request.ConfigRequest import addMo [as 別名]
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,代碼行數:11,代碼來源:createTenant.py

示例12: test_post_cert_to_local_user

# 需要導入模塊: from cobra.mit.request import ConfigRequest [as 別名]
# 或者: from cobra.mit.request.ConfigRequest import addMo [as 別名]
 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,代碼行數:11,代碼來源:test_session_CertSession.py

示例13: test_ConfigRequest_getRootMo

# 需要導入模塊: from cobra.mit.request import ConfigRequest [as 別名]
# 或者: from cobra.mit.request.ConfigRequest import addMo [as 別名]
 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,代碼行數:12,代碼來源:test_request.py

示例14: commit

# 需要導入模塊: from cobra.mit.request import ConfigRequest [as 別名]
# 或者: from cobra.mit.request.ConfigRequest import addMo [as 別名]
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,代碼行數:12,代碼來源:sessions.py

示例15: commit_change

# 需要導入模塊: from cobra.mit.request import ConfigRequest [as 別名]
# 或者: from cobra.mit.request.ConfigRequest import addMo [as 別名]
    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,代碼行數:13,代碼來源:test.py


注:本文中的cobra.mit.request.ConfigRequest.addMo方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。