本文整理汇总了Python中gns3.topology.Topology._randomize_id方法的典型用法代码示例。如果您正苦于以下问题:Python Topology._randomize_id方法的具体用法?Python Topology._randomize_id怎么用?Python Topology._randomize_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gns3.topology.Topology
的用法示例。
在下文中一共展示了Topology._randomize_id方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_randomize_id
# 需要导入模块: from gns3.topology import Topology [as 别名]
# 或者: from gns3.topology.Topology import _randomize_id [as 别名]
def test_randomize_id(project, tmpdir):
project.setTopologyFile(str(tmpdir / "test.gns3"))
project_uuid = str(uuid.uuid4())
vm_uuid1 = str(uuid.uuid4())
os.makedirs(str(tmpdir / "project-files" / "vpcs" / vm_uuid1))
open(str(tmpdir / "project-files" / "vpcs" / vm_uuid1 / "test.log"), "w+").close()
vm_uuid2 = str(uuid.uuid4())
orig_topology = {
"project_id": project_uuid,
"topology": {
"nodes": [
{
"vm_id": vm_uuid1,
},
{
"vm_id": vm_uuid2
}
]
}
}
topology = Topology()
topology.project = project
top = topology._randomize_id(orig_topology)
assert top["project_id"] != project_uuid
assert top["topology"]["nodes"][0]["vm_id"] != vm_uuid1
assert not os.path.exists(str(tmpdir / "project-files" / "vpcs" / vm_uuid1 / "test.log"))
assert os.path.exists(str(tmpdir / "project-files" / "vpcs" / top["topology"]["nodes"][0]["vm_id"] / "test.log"))
assert top["topology"]["nodes"][1]["vm_id"] != vm_uuid2
assert top["topology"]["nodes"][0]["vm_id"] != top["topology"]["nodes"][1]["vm_id"]
示例2: test_randomize_id
# 需要导入模块: from gns3.topology import Topology [as 别名]
# 或者: from gns3.topology.Topology import _randomize_id [as 别名]
def test_randomize_id():
project_uuid = str(uuid.uuid4())
vm_uuid1 = str(uuid.uuid4())
vm_uuid2 = str(uuid.uuid4())
orig_topology = {
"project_id": project_uuid,
"topology": {
"nodes": [
{
"vm_id": vm_uuid1,
},
{
"vm_id": vm_uuid2
}
]
}
}
topology = Topology()
top = topology._randomize_id(orig_topology)
assert top["project_id"] != project_uuid
assert top["topology"]["nodes"][0]["vm_id"] != vm_uuid1
assert top["topology"]["nodes"][1]["vm_id"] != vm_uuid2
assert top["topology"]["nodes"][0]["vm_id"] != top["topology"]["nodes"][1]["vm_id"]