本文整理汇总了Python中ydk.services.CRUDService.create方法的典型用法代码示例。如果您正苦于以下问题:Python CRUDService.create方法的具体用法?Python CRUDService.create怎么用?Python CRUDService.create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ydk.services.CRUDService
的用法示例。
在下文中一共展示了CRUDService.create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_create_gre_tunnel_on_demand
# 需要导入模块: from ydk.services import CRUDService [as 别名]
# 或者: from ydk.services.CRUDService import create [as 别名]
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)
示例2: SanityYang
# 需要导入模块: from ydk.services import CRUDService [as 别名]
# 或者: from ydk.services.CRUDService import create [as 别名]
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)
示例3: SanityTest
# 需要导入模块: from ydk.services import CRUDService [as 别名]
# 或者: from ydk.services.CRUDService import create [as 别名]
class SanityTest(unittest.TestCase):
@classmethod
def setUpClass(self):
self.ncc = NetconfServiceProvider(
"127.0.0.1",
"admin",
"admin",
12022,
)
self.crud = CRUDService()
def setUp(self):
runner = Runner()
self.crud.delete(self.ncc, runner)
def test_delete_on_list_with_identitykey(self):
a1 = Runner.OneList.IdentityList()
a1.config.id = ChildIdentity()
a1.id_ref = a1.config.id
self.crud.create(self.ncc, a1)
k = Runner.OneList.IdentityList()
k.config.id = ChildIdentity()
k.id_ref = k.config.id
k.yfilter = YFilter.delete
self.crud.update(self.ncc, k)
runner_read = self.crud.read(self.ncc, Runner())
self.assertIsNone(runner_read)
def test_iden_list(self):
# CREATE
il = Runner.OneList.IdentityList()
il.config.id = ChildIdentity()
il.id_ref = ChildIdentity()
self.crud.create(self.ncc, il)
# READ & VALIDATE
runner_filter = Runner.OneList()
read_one = self.crud.read(self.ncc, runner_filter)
self.assertIsNotNone(read_one)
read_il = read_one.identity_list.get(ChildIdentity().to_string())
self.assertIsNotNone(read_il)
read_il.parent = None
self.assertEqual(read_il, il)
# DELETE & VALIDATE
self.crud.delete(self.ncc, il)
runner_read = self.crud.read(self.ncc, Runner())
self.assertIsNone(runner_read)
示例4: SanityTest
# 需要导入模块: from ydk.services import CRUDService [as 别名]
# 或者: from ydk.services.CRUDService import create [as 别名]
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)
示例5: urlparse
# 需要导入模块: from ydk.services import CRUDService [as 别名]
# 或者: from ydk.services.CRUDService import create [as 别名]
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()
mpls = oc_mpls.Mpls() # create object
config_mpls(mpls) # add object configuration
# create configuration on NETCONF device
crud.create(provider, mpls)
exit()
# End of script
示例6: urlparse
# 需要导入模块: from ydk.services import CRUDService [as 别名]
# 或者: from ydk.services.CRUDService import create [as 别名]
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()
global_interface_configuration = xr_ifmgr_cfg.GlobalInterfaceConfiguration() # create object
config_global_interface_configuration(global_interface_configuration) # add object configuration
# create configuration on NETCONF device
crud.create(provider, global_interface_configuration)
provider.close()
exit()
# End of script
示例7: urlparse
# 需要导入模块: from ydk.services import CRUDService [as 别名]
# 或者: from ydk.services.CRUDService import create [as 别名]
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()
telemetry_model_driven = xr_telemetry_model_driven_cfg.TelemetryModelDriven() # create object
config_telemetry_model_driven(telemetry_model_driven) # add object configuration
# create configuration on NETCONF device
crud.create(provider, telemetry_model_driven)
exit()
# End of script
示例8: urlparse
# 需要导入模块: from ydk.services import CRUDService [as 别名]
# 或者: from ydk.services.CRUDService import create [as 别名]
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()
arpgmp = xr_ipv4_arp_cfg.Arpgmp() # create object
config_arpgmp(arpgmp) # add object configuration
# create configuration on NETCONF device
crud.create(provider, arpgmp)
exit()
# End of script
示例9: urlparse
# 需要导入模块: from ydk.services import CRUDService [as 别名]
# 或者: from ydk.services.CRUDService import create [as 别名]
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
示例10: SanityTest
# 需要导入模块: from ydk.services import CRUDService [as 别名]
# 或者: from ydk.services.CRUDService import create [as 别名]
class SanityTest(unittest.TestCase):
@classmethod
def setUpClass(self):
self.ncc = NetconfServiceProvider(address='127.0.0.1',
username='admin', password='admin', port=12022)
self.crud = CRUDService()
@classmethod
def tearDownClass(self):
self.ncc.close()
def setUp(self):
print "\nIn method", self._testMethodName
runner = ysanity.Runner()
self.crud.delete(self.ncc, runner)
def tearDown(self):
runner = ysanity.Runner()
self.crud.delete(self.ncc, runner)
def _create_runner(self):
runner = ysanity.Runner()
runner.ytypes = runner.Ytypes()
runner.ytypes.built_in_t = runner.ytypes.BuiltInT()
return runner
# def test_invalids(self):
# runner = self._create_runner()
# runner.ytypes.built_in_t.name = []
# runner.ytypes.built_in_t.u_number8 = -1
# runner.ytypes.built_in_t.enum_value = ''
# self.crud.create(self.ncc, runner)
# with self.assertRaises(YPYDataValidationError):
# self.crud.create(self.ncc, runner)
def test_int8(self):
# Create Runner
runner = self._create_runner()
runner.ytypes.built_in_t.number8 = 0
self.crud.create(self.ncc, runner)
# Read into Runner2
runner1 = ysanity.Runner()
runner1 = self.crud.read(self.ncc, runner1)
# Compare runners
result = is_equal(runner, runner1)
self.assertEqual(result, True)
@unittest.skip('skip till validation in place')
def test_int8_invalid(self):
runner = self._create_runner()
runner.ytypes.built_in_t.number8 = 8.5
# self.crud.create(self.ncc, runner)
self.assertRaises(YPYDataValidationError,
self.crud.create, self.ncc, runner)
# OLD
# runner1 = ysanity.Runner()
# runner1 = self.crud.read(self.ncc, runner1)
# # invalid object is not equal
# result = is_equal(runner, runner1)
# self.assertEqual(result, False)
def test_int16(self):
runner = self._create_runner()
runner.ytypes.built_in_t.number16 = 126
self.crud.create(self.ncc, runner)
# Read into Runner2
runner1 = ysanity.Runner()
runner1 = self.crud.read(self.ncc, runner1)
# Compare runners
result = is_equal(runner, runner1)
self.assertEqual(result, True)
@unittest.skip('skip till validation in place')
def test_int16_invalid(self):
runner = self._create_runner()
runner.ytypes.built_in_t.number16 = {}
# self.crud.create(self.ncc, runner)
self.assertRaises(YPYDataValidationError,
self.crud.create, self.ncc, runner)
# OLD
# # Read into Runner2
# runner1 = ysanity.Runner()
# runner1 = self.crud.read(self.ncc, runner1)
# # Compare runners
# result = is_equal(runner, runner1)
# self.assertEqual(result, False)
def test_int32(self):
runner = self._create_runner()
#.........这里部分代码省略.........
示例11: urlparse
# 需要导入模块: from ydk.services import CRUDService [as 别名]
# 或者: from ydk.services.CRUDService import create [as 别名]
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()
vrfs = xr_infra_rsi_cfg.Vrfs() # create object
config_vrfs(vrfs) # add object configuration
# create configuration on NETCONF device
crud.create(provider, vrfs)
exit()
# End of script
示例12: urlparse
# 需要导入模块: from ydk.services import CRUDService [as 别名]
# 或者: from ydk.services.CRUDService import create [as 别名]
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()
clock = xr_infra_infra_clock_linux_cfg.Clock() # create object
config_clock(clock) # add object configuration
# create configuration on NETCONF device
crud.create(provider, clock)
exit()
# End of script
示例13: urlparse
# 需要导入模块: from ydk.services import CRUDService [as 别名]
# 或者: from ydk.services.CRUDService import create [as 别名]
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()
routing_policy = oc_routing_policy.RoutingPolicy() # create object
config_routing_policy(routing_policy) # add object configuration
# create configuration on NETCONF device
crud.create(provider, routing_policy)
exit()
# End of script
示例14: urlparse
# 需要导入模块: from ydk.services import CRUDService [as 别名]
# 或者: from ydk.services.CRUDService import create [as 别名]
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()
syslog_service = xr_infra_syslog_cfg.SyslogService() # create object
config_syslog_service(syslog_service) # add object configuration
# create configuration on NETCONF device
crud.create(provider, syslog_service)
exit()
# End of script
示例15: SanityYang
# 需要导入模块: from ydk.services import CRUDService [as 别名]
# 或者: from ydk.services.CRUDService import create [as 别名]
class SanityYang(unittest.TestCase):
PROVIDER_TYPE = "non-native"
@classmethod
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()
@classmethod
def tearDownClass(self):
self.ncc.close()
def setUp(self):
runner = ysanity.Runner()
self.crud.delete(self.ncc, runner)
def tearDown(self):
runner = ysanity.Runner()
self.crud.delete(self.ncc, runner)
def test_one_level_pos(self):
# READ
r_1, r_2 = ysanity.Runner(), ysanity.Runner()
r_1.one.number, r_1.one.name = 1, 'runner:one:name'
self.crud.create(self.ncc, r_1)
r_2 = self.crud.read(self.ncc, r_2)
self.assertEqual(is_equal(r_1, r_2), True)
# UPDATE
r_1, r_2 = ysanity.Runner(), ysanity.Runner()
r_1.one.number, r_1.one.name = 10, 'runner/one/name'
self.crud.update(self.ncc, r_1)
r_2 = self.crud.read(self.ncc, r_2)
self.assertEqual(is_equal(r_1, r_2), True)
# DELETE
r_1 = ysanity.Runner()
self.crud.delete(self.ncc, r_1)
r_2 = self.crud.read(self.ncc, r_1)
self.assertEqual(r_2._has_data(), False)
def test_two_level_pos(self):
# READ
r_1 = ysanity.Runner()
r_1.two.number, r_1.two.name, r_1.two.sub1.number = 2, 'runner:two:name', 21
self.crud.create(self.ncc, r_1)
r_2 = ysanity.Runner()
r_2 = self.crud.read(self.ncc, r_2)
self.assertEqual(is_equal(r_1, r_2), True)
# UPDATE
r_1, r_2 = ysanity.Runner(), ysanity.Runner()
r_1.two.number, r_1.two.name, r_1.two.sub1.number = 20, 'runner/two/name', 210
self.crud.update(self.ncc, r_1)
r_2 = self.crud.read(self.ncc, r_2)
self.assertEqual(is_equal(r_1, r_2), True)
# DELETE
r_1 = ysanity.Runner()
self.crud.delete(self.ncc, r_1)
r_2 = self.crud.read(self.ncc, r_1)
self.assertEqual(r_2._has_data(), False)
def test_three_level_pos(self):
# READ
r_1 = ysanity.Runner()
r_1.three.number, r_1.three.name, \
r_1.three.sub1.number, r_1.three.sub1.sub2.number = 3, 'runner:three:name', 31, 311
self.crud.create(self.ncc, r_1)
r_2 = ysanity.Runner()
r_2 = self.crud.read(self.ncc, r_2)
self.assertEqual(is_equal(r_1, r_2), True)
# UPDATE
r_1, r_2 = ysanity.Runner(), ysanity.Runner()
r_1.three.number, r_1.three.name, \
r_1.three.sub1.number, r_1.three.sub1.sub2.number = 30, 'runner/three/name', 310, 3110
self.crud.update(self.ncc, r_1)
r_2 = self.crud.read(self.ncc, r_2)
self.assertEqual(is_equal(r_1, r_2), True)
# DELETE
r_1 = ysanity.Runner()
self.crud.delete(self.ncc, r_1)
r_2 = self.crud.read(self.ncc, r_1)
self.assertEqual(r_2._has_data(), False)
def test_onelist_neg_dupkey(self):
# netsim/enxr not complaining
r_1, r_2 = ysanity.Runner(), ysanity.Runner()
e_1, e_2 = ysanity.Runner.OneList.Ldata(), ysanity.Runner.OneList.Ldata()
e_1.number = 1
e_2.name = 'foo'
e_2.number = 1
#.........这里部分代码省略.........