本文整理汇总了Python中ydk.services.CRUDService.delete方法的典型用法代码示例。如果您正苦于以下问题:Python CRUDService.delete方法的具体用法?Python CRUDService.delete怎么用?Python CRUDService.delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ydk.services.CRUDService
的用法示例。
在下文中一共展示了CRUDService.delete方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setUp
# 需要导入模块: from ydk.services import CRUDService [as 别名]
# 或者: from ydk.services.CRUDService import delete [as 别名]
def setUp(self):
from ydk.services import CRUDService
crud = CRUDService()
runner = ysanity.Runner()
crud.delete(self.ncc, runner)
print '\nIn method', self._testMethodName + ':'
示例2: SanityTest
# 需要导入模块: from ydk.services import CRUDService [as 别名]
# 或者: from ydk.services.CRUDService import delete [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)
示例3: SanityYang
# 需要导入模块: from ydk.services import CRUDService [as 别名]
# 或者: from ydk.services.CRUDService import delete [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)
示例4: setUp
# 需要导入模块: from ydk.services import CRUDService [as 别名]
# 或者: from ydk.services.CRUDService import delete [as 别名]
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)
示例5: run_multiple_routing_bgp
# 需要导入模块: from ydk.services import CRUDService [as 别名]
# 或者: from ydk.services.CRUDService import delete [as 别名]
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
示例6: SanityYang
# 需要导入模块: from ydk.services import CRUDService [as 别名]
# 或者: from ydk.services.CRUDService import delete [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):
runner = ysanity.Runner()
self.crud.delete(self.ncc, runner)
print '\nIn method', self._testMethodName + ':'
def tearDown(self):
runner = ysanity.Runner()
self.crud.delete(self.ncc, runner)
def test_read_on_ref_class(self):
r_1 = ysanity.Runner()
r_1.one.number, r_1.one.name = 1, 'runner:one:name'
self.crud.create(self.ncc, r_1)
r_2 = ysanity.Runner()
r_2.one = READ()
r_2 = self.crud.read(self.ncc, r_2)
self.assertEqual(is_equal(r_1, r_2), True)
def test_read_on_leaf(self):
r_1 = ysanity.Runner()
r_1.one.number, r_1.one.name = 1, 'runner:one:name'
self.crud.create(self.ncc, r_1)
r_2 = ysanity.Runner()
r_2.one.number = READ()
r_2 = self.crud.read(self.ncc, r_2)
self.assertEqual(r_2.one.number, r_1.one.number)
# this will also read r_2.one.name, not able to read only one of them
r_2 = ysanity.Runner()
r_2.one.number = 1
r_2 = self.crud.read(self.ncc, r_2)
self.assertEqual(r_2.one.number, r_1.one.number)
# no such value, will return empty data
r_2 = ysanity.Runner()
r_2.one.number = 2
r_2 = self.crud.read(self.ncc, r_2)
self.assertNotEqual(r_2.one.number, r_1.one.number)
def test_read_on_ref_enum_class(self):
from ydk.models.ydktest.ydktest_sanity import YdkEnumTestEnum
r_1 = ysanity.Runner.Ytypes.BuiltInT()
r_1.enum_value = YdkEnumTestEnum.LOCAL
self.crud.create(self.ncc, r_1)
r_2 = ysanity.Runner.Ytypes.BuiltInT()
r_2.enum_value = READ()
r_2 = self.crud.read(self.ncc, r_2)
self.assertEqual(is_equal(r_1, r_2), True)
r_2 = ysanity.Runner.Ytypes.BuiltInT()
r_2.enum_value = YdkEnumTestEnum.LOCAL
r_2 = self.crud.read(self.ncc, r_2)
self.assertEqual(is_equal(r_1, r_2), True)
# no such value, nothing returned
r_2 = ysanity.Runner.Ytypes.BuiltInT()
r_2.enum_value = YdkEnumTestEnum.REMOTE
r_2 = self.crud.read(self.ncc, r_2)
self.assertNotEqual(is_equal(r_1, r_2), True)
def test_read_on_ref_list(self):
r_1 = ysanity.Runner.OneList()
l_1, l_2 = ysanity.Runner.OneList.Ldata(), ysanity.Runner.OneList.Ldata()
l_1.number, l_2.number = 1, 2
r_1.ldata.extend([l_1, l_2])
self.crud.create(self.ncc, r_1)
r_2 = ysanity.Runner.OneList()
r_2.ldata = READ()
r_2 = self.crud.read(self.ncc, r_2)
self.assertEqual(is_equal(r_1, r_2), True)
def test_read_on_list_with_key(self):
r_1 = ysanity.Runner.OneList()
l_1, l_2 = ysanity.Runner.OneList.Ldata(), ysanity.Runner.OneList.Ldata()
l_1.number, l_2.number = 1, 2
r_1.ldata.extend([l_1, l_2])
self.crud.create(self.ncc, r_1)
r_2 = ysanity.Runner.OneList()
r_2.ldata.extend([l_1])
r_2 = self.crud.read(self.ncc, r_2)
r_3 = ysanity.Runner.OneList()
r_3.ldata.extend([l_1])
self.assertEqual(is_equal(r_2, r_3), True)
#.........这里部分代码省略.........
示例7: SanityYang
# 需要导入模块: from ydk.services import CRUDService [as 别名]
# 或者: from ydk.services.CRUDService import delete [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
#.........这里部分代码省略.........
示例8: device
# 需要导入模块: from ydk.services import CRUDService [as 别名]
# 或者: from ydk.services.CRUDService import delete [as 别名]
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()
ntp = xr_ip_ntp_cfg.Ntp() # create object
# delete configuration on NETCONF device
crud.delete(provider, ntp)
exit()
# End of script
示例9: device
# 需要导入模块: from ydk.services import CRUDService [as 别名]
# 或者: from ydk.services.CRUDService import delete [as 别名]
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()
syslog = xr_infra_syslog_cfg.Syslog() # create object
config_syslog(syslog)
# delete configuration on NETCONF device
crud.delete(provider, syslog)
exit()
# End of script
示例10: device
# 需要导入模块: from ydk.services import CRUDService [as 别名]
# 或者: from ydk.services.CRUDService import delete [as 别名]
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
示例11: urlparse
# 需要导入模块: from ydk.services import CRUDService [as 别名]
# 或者: from ydk.services.CRUDService import delete [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.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()
router_static = xr_ip_static_cfg.RouterStatic() # create object
# delete configuration on NETCONF device
crud.delete(provider,
router_static.default_vrf.address_family.vrfipv6.vrf_unicast)
provider.close()
exit()
# End of script
示例12: device
# 需要导入模块: from ydk.services import CRUDService [as 别名]
# 或者: from ydk.services.CRUDService import delete [as 别名]
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()
syslog_service = xr_infra_syslog_cfg.SyslogService() # create object
# delete configuration on NETCONF device
crud.delete(provider, syslog_service)
exit()
# End of script
示例13: device
# 需要导入模块: from ydk.services import CRUDService [as 别名]
# 或者: from ydk.services.CRUDService import delete [as 别名]
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()
ipv4_acl_and_prefix_list = xr_ipv4_acl_cfg.Ipv4AclAndPrefixList() # create object
# delete configuration on NETCONF device
crud.delete(provider, ipv4_acl_and_prefix_list)
exit()
# End of script
示例14: device
# 需要导入模块: from ydk.services import CRUDService [as 别名]
# 或者: from ydk.services.CRUDService import delete [as 别名]
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.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()
lldp = xr_ethernet_lldp_cfg.Lldp() # create object
# delete configuration on NETCONF device
crud.delete(provider, lldp)
provider.close()
exit()
# End of script
示例15: device
# 需要导入模块: from ydk.services import CRUDService [as 别名]
# 或者: from ydk.services.CRUDService import delete [as 别名]
action="store_true")
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.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()
routing_policy = xr_policy_repository_cfg.RoutingPolicy() # create object
crud.delete(provider, routing_policy) # delete object on NETCONF device
provider.close()
exit()
# End of script