本文整理汇总了Python中ydk.services.CRUDService类的典型用法代码示例。如果您正苦于以下问题:Python CRUDService类的具体用法?Python CRUDService怎么用?Python CRUDService使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CRUDService类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: main
def main():
module = AnsibleModule(
argument_spec = dict(
host = dict(required=True),
username = dict(required=False, default=None),
password = dict(required=False, default=None),
),
supports_check_mode = False
)
args = module.params
# establish ssh connection
provider = NetconfServiceProvider(address=args['host'],
port=830,
username=args['username'],
password=args['password'],
protocol='ssh')
# establish CRUD service
crud = CRUDService()
# retrieve software install version
install = SoftwareInstall()
info = crud.read(provider, install)
logger = info.all_operations_log
result = dict(changed=False)
result['stdout'] = logger.summary.log
return module.exit_json(**result)
开发者ID:ios-xr,项目名称:iosxr-ansible,代码行数:29,代码来源:iosxr_show_install_log.py
示例2: test_create_gre_tunnel_on_demand
def test_create_gre_tunnel_on_demand(self):
enable_logging(logging.ERROR)
from ydk.providers import NetconfServiceProvider
from ydk.services import CRUDService
try:
from ydk.models.ydktest.ydktest_sanity import Native
except ImportError:
# bundle is generated with 'one_class_per_module' flag
from ydk.models.ydktest.ydktest_sanity.native.native import Native
provider = NetconfServiceProvider(
"127.0.0.1",
"admin",
"admin",
12022)
native = Native()
tunnel = native.interface.Tunnel()
tunnel.name = 521
tunnel.description = "test tunnel"
# Configure protocol-over-protocol tunneling
tunnel.tunnel.source = "1.2.3.4"
tunnel.tunnel.destination = "4.3.2.1"
tunnel.tunnel.bandwidth.receive = 100000
tunnel.tunnel.bandwidth.transmit = 100000
native.interface.tunnel.append(tunnel)
crud_service = CRUDService();
crud_service.create(provider, native)
开发者ID:111pontes,项目名称:ydk-gen,代码行数:33,代码来源:test_sanity_path.py
示例3: setUp
def setUp(self):
from ydk.services import CRUDService
crud = CRUDService()
runner = ysanity.Runner()
crud.delete(self.ncc, runner)
print '\nIn method', self._testMethodName + ':'
开发者ID:josearsenio,项目名称:ydk-gen,代码行数:7,代码来源:test_sanity_rpc.py
示例4: SanityYang
class SanityYang(unittest.TestCase):
@classmethod
def setUpClass(self):
self.ncc = NetconfServiceProvider(address='127.0.0.1',
username='admin',
password='admin',
protocol='ssh',
port=12022)
self.crud = CRUDService()
@classmethod
def tearDownClass(self):
self.ncc.close()
def setUp(self):
self.crud.delete(self.ncc, ietf_aug_base_1.Cpython())
self.crud.delete(self.ncc, ietf_aug_base_2.Cpython())
def tearDown(self):
self.crud.delete(self.ncc, ietf_aug_base_1.Cpython())
self.crud.delete(self.ncc, ietf_aug_base_2.Cpython())
def test_aug_base_1(self):
cpython = ietf_aug_base_1.Cpython()
cpython.doc.ydktest_aug_1.aug_one = 'aug one'
cpython.doc.ydktest_aug_2.aug_two = 'aug two'
cpython.doc.ydktest_aug_4.aug_four = 'aug four'
cpython.lib.ydktest_aug_1.ydktest_aug_nested_1.aug_one = 'aug one'
cpython.lib.ydktest_aug_2.ydktest_aug_nested_2.aug_two = 'aug two'
cpython.lib.ydktest_aug_4.ydktest_aug_nested_4.aug_four = 'aug four'
cpython.doc.disutils.four_aug_list.enabled = True
item1 = cpython.doc.disutils.four_aug_list.Ldata()
item2 = cpython.doc.disutils.four_aug_list.Ldata()
item1.name, item1.number = 'one', 1
item2.name, item1.number = 'two', 2
self.crud.create(self.ncc, cpython)
cpython_read = self.crud.read(self.ncc, ietf_aug_base_1.Cpython())
self.assertEqual(is_equal(cpython, cpython_read), True)
def test_aug_base_2(self):
cpython = ietf_aug_base_2.Cpython()
cpython.tools.aug_four = 'aug four'
self.crud.create(self.ncc, cpython)
cpython_read = self.crud.read(self.ncc, ietf_aug_base_2.Cpython())
self.assertEqual(is_equal(cpython, cpython_read), True)
开发者ID:manradhaCisco,项目名称:ydk-gen,代码行数:52,代码来源:test_sanity_bundle_aug.py
示例5: SanityTest
class SanityTest(unittest.TestCase):
@classmethod
def setUpClass(self):
# Need to keep a local reference for repo to keep it alive,
# as the first argument for OpenDaylightServiceProvider in libydk
# is a reference.
repo_path = os.path.dirname(__file__)
repo_path = os.path.join(repo_path, '..', '..', '..', 'cpp', 'core', 'tests', 'models')
self.repo = Repository(repo_path)
self.odl = OpenDaylightServiceProvider(self.repo, 'localhost', 'admin', 'admin', 12306, EncodingFormat.JSON)
self.crud = CRUDService()
def test_read_ODL(self):
bgp_filter = oc_bgp.Bgp()
node_provider = self.odl.get_node_provider('xr')
bgp_read = self.crud.read_config(node_provider, bgp_filter)
self.assertEqual(bgp_read.global_.config.as_, 65172)
self.assertEqual(bgp_read.global_.config.router_id, '1.2.3.4')
def test_create_ODL(self):
bgp = oc_bgp.Bgp()
bgp.global_.config.as_ = 65172
bgp.global_.config.router_id = '1.2.3.4'
neighbor = oc_bgp.Bgp.Neighbors.Neighbor()
neighbor.neighbor_address = '6.7.8.9'
neighbor.config.neighbor_address = '6.7.8.9'
neighbor.config.peer_as = 65001
neighbor.config.local_as = 65001
neighbor.config.peer_group = 'IBGP'
bgp.neighbors.neighbor.append(neighbor)
peer_group = oc_bgp.Bgp.PeerGroups.PeerGroup()
peer_group.peer_group_name = 'IBGP'
peer_group.config.peer_group_name = 'IBGP'
peer_group.config.description = 'test description'
peer_group.config.peer_as = 65001
peer_group.config.local_as = 65001
bgp.peer_groups.peer_group.append(peer_group)
node_provider = self.odl.get_node_provider('xr')
self.crud.create(node_provider, bgp)
bgp_read = self.crud.read_config(node_provider, oc_bgp.Bgp())
self.assertEqual(bgp_read, bgp)
开发者ID:111pontes,项目名称:ydk-gen,代码行数:49,代码来源:test_opendaylight.py
示例6: setUpClass
def setUpClass(self):
self.ncc = NetconfServiceProvider(address='127.0.0.1',
username='admin',
password='admin',
protocol='ssh',
port=12022)
self.crud = CRUDService()
开发者ID:manradhaCisco,项目名称:ydk-gen,代码行数:7,代码来源:test_sanity_bundle_aug.py
示例7: setUpClass
def setUpClass(self):
self.codec_provider = CodecServiceProvider()
self.codec = CodecService()
self.repo = Repository(get_local_repo_dir())
self.provider = gNMIServiceProvider( self.repo, "127.0.0.1", 50051, "admin", "admin")
self.schema = self.provider.get_session().get_root_schema()
self.crud = CRUDService()
开发者ID:111pontes,项目名称:ydk-gen,代码行数:7,代码来源:test_gnmi_crud.py
示例8: setUp
def setUp(self):
# start a brand new session for every single test case
# so test_close_session_rpc will not interfere with other test cases
# self.ncc = NetconfServiceProvider('127.0.0.1', 'admin', 'admin', 12022)
self.ncc = NetconfServiceProvider(
self.hostname,
self.username,
self.password,
self.port,
self.protocol,
self.on_demand,
self.common_cache,
self.timeout)
from ydk.services import CRUDService
crud = CRUDService()
runner = ysanity.Runner()
crud.delete(self.ncc, runner)
开发者ID:111pontes,项目名称:ydk-gen,代码行数:17,代码来源:test_sanity_executor_rpc.py
示例9: setUpClass
def setUpClass(self):
self.ncc = NetconfServiceProvider(
"127.0.0.1",
"admin",
"admin",
12022,
)
self.crud = CRUDService()
开发者ID:111pontes,项目名称:ydk-gen,代码行数:8,代码来源:test_non_top_operations.py
示例10: setUpClass
def setUpClass(self):
# Need to keep a local reference for repo to keep it alive,
# as the first argument for OpenDaylightServiceProvider in libydk
# is a reference.
repo_path = os.path.dirname(__file__)
repo_path = os.path.join(repo_path, '..', '..', '..', 'cpp', 'core', 'tests', 'models')
self.repo = Repository(repo_path)
self.odl = OpenDaylightServiceProvider(self.repo, 'localhost', 'admin', 'admin', 12306, EncodingFormat.JSON)
self.crud = CRUDService()
开发者ID:111pontes,项目名称:ydk-gen,代码行数:9,代码来源:test_opendaylight.py
示例11: run_multiple_routing_bgp
def run_multiple_routing_bgp(netconf_service, session):
crud = CRUDService()
codec = CodecService()
codec_provider = CodecServiceProvider()
crud.delete(session, bgp())
crud.delete(session, RoutingPolicy())
multi_cfg = _get_bgp_routing_multiple_object()
multi_payload_expected = codec.encode(codec_provider, multi_cfg)
result = netconf_service.edit_config(session, Datastore.candidate, multi_cfg)
assert 'ok' in result
multi_filter = {'bgp':bgp(), 'routing-policy':RoutingPolicy()}
multi_entity_read = netconf_service.get_config(session, Datastore.candidate, multi_filter)
multi_payload_actual = codec.encode(codec_provider, multi_entity_read)
assert multi_payload_expected == multi_payload_actual
开发者ID:mirceaulinic,项目名称:ydk-py,代码行数:20,代码来源:bgp_netconf.py
示例12: setUpClass
def setUpClass(self):
self.ncc = NetconfServiceProvider(
address='127.0.0.1',
username='admin',
password='admin',
protocol='ssh',
port=12022)
self.crud = CRUDService()
a = self.getInitEntity()
self.crud.delete(self.ncc, a)
self.crud.create(self.ncc, a)
开发者ID:ReignInChaos,项目名称:ydk-gen,代码行数:11,代码来源:test_sanity_filter_read.py
示例13: setUpClass
def setUpClass(self):
if SanityYang.PROVIDER_TYPE == "native":
self.ncc = NativeNetconfServiceProvider(address='127.0.0.1',
username='admin',
password='admin',
protocol='ssh',
port=12022)
else:
self.ncc = NetconfServiceProvider(address='127.0.0.1',
username='admin',
password='admin',
protocol='ssh',
port=12022)
self.crud = CRUDService()
开发者ID:manradhaCisco,项目名称:ydk-gen,代码行数:14,代码来源:test_sanity_levels.py
示例14: main
def main():
module = AnsibleModule(
argument_spec = dict(
host = dict(required=True),
username = dict(required=False, default=None),
password = dict(required=False, default=None),
),
supports_check_mode = False
)
args = module.params
# establish ssh connection
provider = NetconfServiceProvider(address=args['host'],
port=830,
username=args['username'],
password=args['password'],
protocol='ssh')
# establish CRUD service
crud = CRUDService()
# retrieve software install version
install = SoftwareInstall()
info = crud.read(provider, install)
result = dict(changed=False)
result['stdout'] = "no active package"
for package in info.active.active_package_info:
result['stdout'] = \
"active_packages: %sboot_partition_name: %s\nlocation: %s\n" \
"node_type: %s\nnumber_of_active_packages: %d" % \
(package.active_packages,
package.boot_partition_name,
package.location,
package.node_type,
package.number_of_active_packages)
return module.exit_json(**result)
开发者ID:ios-xr,项目名称:iosxr-ansible,代码行数:37,代码来源:iosxr_show_install_active.py
示例15: setUpClass
def setUpClass(self):
if SanityYang.PROVIDER_TYPE == "native":
self.ncc = NativeNetconfServiceProvider(address='127.0.0.1',
username='admin',
password='admin',
protocol='ssh',
port=12022)
else:
self.ncc = NetconfServiceProvider(address='127.0.0.1',
username='admin',
password='admin',
protocol='ssh',
port=12022)
self.crud = CRUDService()
# config device with entity a
a = self.getInitEntity()
self.crud.delete(self.ncc, a)
self.crud.create(self.ncc, a)
开发者ID:manradhaCisco,项目名称:ydk-gen,代码行数:18,代码来源:test_sanity_filter_read.py
示例16: NetconfServiceProvider
device = urllib.parse.urlparse(args.device)
# log debug messages if verbose argument specified
if args.verbose:
logger = logging.getLogger("ydk")
logger.setLevel(logging.INFO)
handler = logging.StreamHandler()
formatter = logging.Formatter(("%(asctime)s - %(name)s - "
"%(levelname)s - %(message)s"))
handler.setFormatter(formatter)
logger.addHandler(handler)
# create NETCONF provider
provider = NetconfServiceProvider(address=device.hostname,
port=device.port,
username=device.username,
password=device.password,
protocol=device.scheme)
# create CRUD service
crud = CRUDService()
# BGP configuration
bgp = oc_bgp.Bgp()
config_bgp_peer(bgp, args.local_as, args.peer_address, args.peer_as, args.peer_group)
# create configuration on NETCONF device
crud.create(provider, bgp)
exit()
# End of script
开发者ID:111pontes,项目名称:ydk-py-samples,代码行数:30,代码来源:config_bgp_peer.py
示例17: urlparse
args = parser.parse_args()
device = urlparse(args.device)
# log debug messages if verbose argument specified
if args.verbose:
logger = logging.getLogger("ydk")
logger.setLevel(logging.INFO)
handler = logging.StreamHandler()
formatter = logging.Formatter(("%(asctime)s - %(name)s - "
"%(levelname)s - %(message)s"))
handler.setFormatter(formatter)
logger.addHandler(handler)
# create NETCONF provider
provider = NetconfServiceProvider(address=device.hostname,
port=device.port,
username=device.username,
password=device.password,
protocol=device.scheme)
# create CRUD service
crud = CRUDService()
sr = xr_segment_routing_ms_cfg.Sr() # create object
config_sr(sr) # add object configuration
# create configuration on NETCONF device
crud.create(provider, sr)
exit()
# End of script
开发者ID:111pontes,项目名称:ydk-py-samples,代码行数:30,代码来源:nc-create-xr-segment-routing-ms-cfg-22-ydk.py
示例18: device
parser.add_argument("device",
help="NETCONF device (ssh://user:[email protected]:port)")
args = parser.parse_args()
device = urlparse(args.device)
# log debug messages if verbose argument specified
if args.verbose:
logger = logging.getLogger("ydk")
logger.setLevel(logging.INFO)
handler = logging.StreamHandler()
formatter = logging.Formatter(("%(asctime)s - %(name)s - "
"%(levelname)s - %(message)s"))
handler.setFormatter(formatter)
logger.addHandler(handler)
# create NETCONF provider
provider = NetconfServiceProvider(address=device.hostname,
port=device.port,
username=device.username,
password=device.password,
protocol=device.scheme)
# create CRUD service
crud = CRUDService()
bgp = oc_bgp.Bgp() # create object
# delete configuration on NETCONF device
crud.delete(provider, bgp)
exit()
# End of script
开发者ID:111pontes,项目名称:ydk-py-samples,代码行数:30,代码来源:nc-delete-oc-bgp-20-ydk.py
示例19: urlparse
device = urlparse(args.device)
# log debug messages if verbose argument specified
if args.verbose:
logger = logging.getLogger("ydk")
logger.setLevel(logging.DEBUG)
handler = logging.StreamHandler()
formatter = logging.Formatter(("%(asctime)s - %(name)s - "
"%(levelname)s - %(message)s"))
handler.setFormatter(formatter)
logger.addHandler(handler)
# create NETCONF provider
provider = NetconfServiceProvider(address=device.hostname,
port=device.port,
username=device.username,
password=device.password,
protocol=device.scheme)
# create CRUD service
crud = CRUDService()
locale = xr_infra_infra_locale_cfg.Locale() # create object
# read data from NETCONF device
locale = crud.read(provider, locale)
print(process_locale(locale)) # process object data
provider.close()
exit()
# End of script
开发者ID:abhikeshav,项目名称:ydk-py-samples,代码行数:30,代码来源:nc-read-xr-infra-infra-locale-cfg-20-ydk.py
示例20: urlparse
args = parser.parse_args()
device = urlparse(args.device)
# log debug messages if verbose argument specified
if args.verbose:
logger = logging.getLogger("ydk")
logger.setLevel(logging.INFO)
handler = logging.StreamHandler()
formatter = logging.Formatter(("%(asctime)s - %(name)s - "
"%(levelname)s - %(message)s"))
handler.setFormatter(formatter)
logger.addHandler(handler)
# create NETCONF provider
provider = NetconfServiceProvider(address=device.hostname,
port=device.port,
username=device.username,
password=device.password,
protocol=device.scheme)
# create CRUD service
crud = CRUDService()
ntp = xr_ip_ntp_cfg.Ntp() # create object
config_ntp(ntp) # add object configuration
# create configuration on NETCONF device
crud.create(provider, ntp)
exit()
# End of script
开发者ID:111pontes,项目名称:ydk-py-samples,代码行数:30,代码来源:nc-create-xr-ip-ntp-cfg-22-ydk.py
注:本文中的ydk.services.CRUDService类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论