12 from __future__
import annotations
16 if sys.path[0].startswith(
'/var/lib/camphor/camphor_api'):
18 if '/var/lib/camphor' not in sys.path:
19 sys.path.insert(0,
'/var/lib/camphor')
63 devices = [
'router1',
'router2']
68 networks = [
'network1']
69 manager.networkManager.
createNetworks(name=networks[0], devices=devices)
75 assert len(entries[
'devices'][
'item']) == 2
76 assert len(entries[
'networks'][
'item']) == 1
105 image=
Image(file=[
'master:///local/camphor/vm_image.qcow2'],
106 md5sum=[
'deadbeef']),
107 resource=
Resource(cpu=[4], memory=[4096], disk=[200]))
112 for i
in range(1, count):
114 devices.append(F
"router{i}")
115 networks.append(F
"network{i}")
116 manager.networkManager.
createNetworks(name=F
"network{i}", devices=[F
"router{i}", F
"router{i + 1}"])
118 devices.append(F
"router{count}")
121 entries = manager.
toDict()
124 assert len(entries[
'devices'][
'item']) == count
125 assert len(entries[
'networks'][
'item']) == count - 1
157 image=
Image(file=[
"master:///local/camphor/customer/vms/vm_image.qcow2"], md5sum=[
"deadbeef"])
161 conf=
"master:///local/camphor/$CAMPHOR_CLUSTER/$CAMPHOR_USERNAME/$CAMPHOR_PROJECT/$CAMPHOR_DEVICE/device.conf",
162 resource=
Resource(cpu=[4], memory=[4096], disk=[100]),
164 "master:///local/camphor/customer/vms/vm_re_image.qcow2",
165 "master:///local/camphor/customer/vms/vm_pfe_image.qcow2",
166 ], md5sum=[
"deadbeef",
"beefbeef"])
172 interface=
'autoAssign')
188 name=ApplicationName.novnc))
190 name=ApplicationName.jupyter))
192 entries = manager.
toDict()
193 assert len(entries[
'devices'][
'item']) == 3
194 assert len(entries[
'networks'][
'item']) == 3
195 assert len(entries[
'applications'][
'item']) == 2
197 assert entries[
'devices'][
'item'][0][
'attributes'][
'os'] ==
DeviceOS.SONiC.name
198 assert entries[
'devices'][
'item'][1][
'attributes'][
'os'] ==
DeviceOS.MX.name
199 assert entries[
'devices'][
'item'][1][
'attributes'][
'image'][
'file'][0] == \
200 "master:///local/camphor/customer/vms/vm_re_image.qcow2"
201 assert entries[
'devices'][
'item'][1][
'attributes'][
'image'][
'file'][1] == \
202 "master:///local/camphor/customer/vms/vm_pfe_image.qcow2"
208 entries = manager.
toDict()
209 assert len(entries[
'devices'][
'item']) == 2
210 assert len(entries[
'networks'][
'item']) == 2
211 assert len(entries[
'applications'][
'item']) == 1
230 Image(file=[
'master:///local/camphor/customer/vms/500v64.10.2.3.F.qcow2'],
231 md5sum=[
'4d541a673a097ababec96b016f9ba237'])
236 snmp-server user admin
237 username admin password 5 $5$j7tkn468$cxNfE/jPpWmeIjJUOTNdSHcfr47N7pSK.S4h8SGGwe. role network-admin
238 username admin sshkey ssh-rsa {Util.fread(F"{environ['HOME']}/.ssh/id_rsa.pub")[:24]}
244 ip name-server 10.0.2.3 use-vrf management
246 vrf context management
247 ip domain-name camphor-administrator-default
248 ip name-server 10.0.2.3
249 ip route 0.0.0.0/0 10.0.2.2
252 vrf member management
258 boot nxos bootflash:/boot nxos bootflash:/nxos64-cs.10.2.3.F.bin
260 manager.deviceManager.
createDevice(name=
'router', count=count)
264 for i
in range(1, count + 1):
265 devices.append(F
"router{i}")
266 networks.append(F
"network{i}")
268 devices=[F
"router{i}", F
"router{i + 1 if i < count else 1}"])
269 entries = manager.
toDict()
270 assert len(entries[
'devices'][
'item']) == count
271 assert len(entries[
'networks'][
'item']) == count
300 snmp-server user admin
301 username admin password 5 $5$j7tkn468$cxNfE/jPpWmeIjJUOTNdSHcfr47N7pSK.S4h8SGGwe. role network-admin
302 username admin sshkey ssh-rsa {Util.fread(F"{environ['HOME']}/.ssh/id_rsa.pub")[:24]}
308 ip name-server 10.0.2.3 use-vrf management
310 vrf context management
311 ip domain-name camphor-administrator-default
312 ip name-server 10.0.2.3
313 ip route 0.0.0.0/0 10.0.2.2
317 vrf member management
323 boot nxos bootflash:/boot nxos bootflash:/nxos64-cs.10.2.3.F.bin
325 manager.deviceManager.
createDevice(name=
'router', count=device_count)
328 devices = [F
"router{i}" for i
in range(1, device_count + 1)]
329 networks = [F
"network{i}" for i
in range(1, network_count + 1)]
330 for i
in range(network_count):
331 manager.networkManager.
createNetworks(name=networks[i], devices=devices)
333 entries = manager.
toDict()
334 assert len(entries[
'devices'][
'item']) == device_count
335 assert len(entries[
'networks'][
'item']) == network_count
356 manager.deviceManager.
createDevice(name=
'router', count=device_count)
359 devices = [F
"router{i}" for i
in range(1, device_count + 1)]
360 networks = [F
"network{i}" for i
in range(1, network_count + 1)]
361 for i
in range(network_count):
362 manager.networkManager.
createNetworks(name=networks[i], devices=devices)
364 entries = manager.
toDict()
365 assert len(entries[
'devices'][
'item']) == device_count
366 assert len(entries[
'networks'][
'item']) == network_count
382 yaml_file =
'/var/lib/camphor/topologies/camphor_topology.yaml'
384 expected = Util.yamlFileToDict(yaml_file=yaml_file)
386 assert actual == expected
401 entries = manager.
toDict()
402 assert len(entries[
'deployments'][
'item']) == 1
403 assert entries[
'deployments'][
'item'][0][
'name'] ==
'dc'
404 assert entries[
'deployments'][
'item'][0][
'attributes'][
'deploymentAttributes'][
'type'] ==
'datacenter'
419 manager.deploymentManager.
createDataCenter(pods=2, racks=4, servers=4, spines=4, superSpines=2)
420 entries = manager.
toDict()
421 assert len(entries[
'deployments'][
'item']) == 1
422 assert entries[
'deployments'][
'item'][0][
'name'] ==
'dc'
423 assert entries[
'deployments'][
'item'][0][
'attributes'][
'deploymentAttributes'][
'type'] ==
'datacenter'
437 manager.deploymentManager.
createDataCenter(name=
'dc', pods=2, racks=8, servers=8, spines=8, superSpines=4,
439 entries = manager.
toDict()
440 assert len(entries[
'deployments'][
'item']) == 1
441 assert entries[
'deployments'][
'item'][0][
'name'] ==
'dc'
442 assert entries[
'deployments'][
'item'][0][
'attributes'][
'deploymentAttributes'][
'type'] ==
'datacenter'
467 vpnAttributes=
VPNAttributes(vpns=1, evpns=2, hosts=2, addresses=2, enablePinger=
False)
493 @pytest.mark.timeout1(60 * 20)
496 device_conf =
CamphorDeviceManager.getJUNOSDefaultConf().replace(
'__ADDRESS_LO0__',
'100.100.0.1') \
497 .replace(
'__ADDRESS3__',
'1.1.1.1/24').replace(
'__ADDRESS4__',
'1.1.2.1/24')
498 devices = [
'router1',
'router2',
'router3']
504 device_conf =
CamphorDeviceManager.getJUNOSDefaultConf().replace(
'__ADDRESS_LO0__',
'100.100.0.2') \
505 .replace(
'__ADDRESS3__',
'1.1.2.2/24').replace(
'__ADDRESS4__',
'1.1.3.2/24')
509 device_conf =
CamphorDeviceManager.getJUNOSDefaultConf().replace(
'__ADDRESS_LO0__',
'100.100.0.3') \
510 .replace(
'__ADDRESS3__',
'1.1.3.3/24').replace(
'__ADDRESS4__',
'1.1.4.3/24')
514 networks = [
'router1--router2',
'router2--router3']
515 interfaces = [
'ge-0/0/4',
'ge-0/0/3']
516 manager.networkManager.
createNetworks(name=networks[0], devices=[devices[0], devices[1]], interfaces=interfaces)
517 manager.networkManager.
createNetworks(name=networks[1], devices=[devices[1], devices[2]], interfaces=interfaces)
529 Util.
commit(
commit=synchronize, synchronize=synchronize)
534 assert Util.
ping(from_device_os=
DeviceOS.OLIVE, from_device_name=
'router1', from_device=
'100.100.0.1',
535 to_device=
'100.0.0.3')
554 manager.deviceManager.
createDevice(name=
'server', count=device_count)
556 passThroughPCIDevices=[
'7d:00.0',
'7f:00.0']))
558 passThroughPCIDevices=[
'8d:00.0:compute1',
'8f:00.0:compute1']))
560 entries = manager.
toDict()
561 assert len(entries[
'devices'][
'item']) == device_count + 2
568 devices=[F
"server{i + 1}" for i
in range(device_count)] + [
'server-gpu1',
'server-gpu2'])
581 network_count: int = int(environ.get(
'CAMPHOR_TEST_NETWORK_COUNT',
'4')),
582 synchronize: bool = environ.get(
'CAMPHOR_TEST_SYNCHRONIZE',
'').upper() ==
'TRUE'):
584 manager.
createBasicTopology(device_count=device_count, network_count=network_count, synchronize=synchronize)
589 print(
"%s\t%s\t%s" % (pod.status.pod_ip, pod.metadata.namespace, pod.metadata.name))
701 interfaces=[
'ge-0/0/1',
'ge-0/0/2'])
716 interfaces=[
'ge-0/0/1',
'ge-0/0/2'])
731 interfaces=[
'ge-0/0/1',
'ge-0/0/2'])
746 interfaces=[
'ge-0/0/1',
'ge-0/0/2'])
770 manager.
createApplications(apps=[ApplicationName.grafana, ApplicationName.prometheus])
864 yaml_file =
'/var/lib/camphor/topologies/datacenter_cisco.yaml'
866 expected = Util.yamlFileToDict(yaml_file=yaml_file)
868 assert actual == expected
or True
879 yaml_file =
'/var/lib/camphor/topologies/datacenter_convergeone.yaml'
881 expected = Util.yamlFileToDict(yaml_file=yaml_file)
883 assert actual == expected
or True
894 yaml_file =
'/var/lib/camphor/topologies/datacenter_aviz.yaml'
896 expected = Util.yamlFileToDict(yaml_file=yaml_file)
898 assert actual == expected
or True
909 yaml_file =
'/var/lib/camphor/topologies/datacenter_augtera.yaml'
911 expected = Util.yamlFileToDict(yaml_file=yaml_file)
913 assert actual == expected
or True
924 yaml_file =
'/var/lib/camphor/topologies/datacenter_junos.yaml'
926 expected = Util.yamlFileToDict(yaml_file=yaml_file)
928 assert actual == expected
or True
939 yaml_file =
'/var/lib/camphor/topologies/datacenter_arrcus.yaml'
941 expected = Util.yamlFileToDict(yaml_file=yaml_file)
943 assert actual == expected
or True
954 yaml_file =
'/var/lib/camphor/topologies/datacenter_eos.yaml'
956 expected = Util.yamlFileToDict(yaml_file=yaml_file)
958 assert actual == expected
or True
969 yaml_file =
'/var/lib/camphor/topologies/datacenter_sonic.yaml'
971 expected = Util.yamlFileToDict(yaml_file=yaml_file)
973 assert actual == expected
or True
1000 resource=
Resource(cpu=[4], memory=[4096], disk=[200]),
1009 manager.deviceManager.
createDevice(name=
'compute', count=computes)
1010 devices = [
'master'] + [F
"compute{i + 1}" for i
in range(computes)]
1013 entries = manager.
toDict()
1016 assert len(entries[
'devices'][
'item']) == len(devices)
1019 assert manager.
loadYaml(synchronize=
True)[1] == 0
1039 underlay=UnderlayConnectivity.ebgp, overlay=OverlayConnectivity.evpn,
1040 vpns=2, evpns=2, hosts=2, addresses=2)
1045 version=
'22.04-K8-1.28.6',
1046 resource=
Resource(cpu=[4], memory=[1024*8], disk=[200]),
1047 servicePorts=[
'443'],
1049 generateDefaultConf=
False,
1050 job=
'python3 /var/lib/camphor/aviz_ones_setup.pyc'
Manage Camphor Configuration.
Data Center Border Leaf related attributes.
Data Center Core Routers related attributes.
Deployment related attributes to customize the autogenerated topology.
Customize this deployment configuration.
device (VM Or Container) specific attributes
Device boot image configuration attributes for the device (REs and LCs)
Data Center Leaf related attributes.
Data Center Pod related attributes.
List pods to be customized as desired.
List of various pods to be created inside the datacenter.
List of ports (device/interface to connect to this network)
Data Center Rack related attributes.
Compute resources to allocate to the device VM.
Data Center Server related attributes.
Data Center Spine related attributes.
Data Center SuperSpine related attributes.
L3 VPN related attributes.
def test20_device_pullconf(str name='router', int count=4)
Pull Configuration from devices.
def test6_multi_device_networks(int device_count=4, int network_count=4)
Create a network with better management traffic capable devices.
def test25_device_interface_admin_up(str name='router', int count=4)
Turn up interface admin state.
def test21_device_pushconf(str name='router', int count=4)
Push Configuration to devices.
def test11_customized_datacenter()
Create a customized data center network.
def test15_device_pause(str name='router', int count=4)
Pause devices.
def test40_datacenter_arrcus()
Load a arrcus network topology from an external yaml file.
def test8_small_datacenter()
Create a small data center network.
def test12_ospf_basic(bool synchronize=False)
Create a simple OSPF Topology of JUNOS Routers.
def test18_device_restart(str name='router', int count=4)
Restart devices.
def test1_simple_network()
Create a simple network connecting routers.
def test38_datacenter_augtera()
Load a augtera network topology from an external yaml file.
def test41_datacenter_arista()
Load a arista network topology from an external yaml file.
def test32_application_opennms()
Create application OpenNMS Network Management Station.
def test29_application_jupyter_notebook()
Create application Jupyter Notebook for Easy Automation.
def test37_datacenter_aviz()
Load a aviz network topology from an external yaml file.
def test27_application_grafana()
Create application Grafana Graphs Generator.
def test24_device_interface_admin_down(str name='router', int count=4)
Turn down interface admin state.
def test16_device_resume(str name='router', int count=4)
Resume devices.
def test33_application_suzieq()
Create application SuzieQ Network Analytics Manager, especially for Data Centers.
def test17_device_shutdown(str name='router', int count=4)
Shutdown devices.
def test19_device_recreate(str name='router', int count=4)
Recreate devices.
def test4_circular_topology(int count=10)
Create a simple circular topology of NXOS Devices.
def test5_device_for_analytics(int device_count=4, int network_count=2)
Create a network with better management traffic capable devices.
def test36_datacenter_convergeone()
Load a convergeone network topology from an external yaml file.
def test3_custom_topology()
Create a customized network topology.
def test13_device_with_pci_passthrough(int device_count=4)
Create devices with PCI Cards pass through from underlying host such as GPUs, NPUs and IPUs.
def test44_aviz_ones_controller_based_datacenter()
Create a Aviz-Ones-Controller driven Virtual Data Center.
def test26_application_drawio()
Create application DrawIO Diagrams Editor.
def test28_application_jenkins()
Create application Jenkins Jobs Manager.
def test9_medium_datacenter()
Create a medium sized data center network.
def test30_application_kibana()
Create application Elastic Search Based Kibana Logs Analyzer.
def test22_device_interface_link_down(str name='router', int count=4)
Turn down interface link state.
def test10_large_datacenter()
Create a large sized data center network.
def test34_application_wordpress()
Create application WordPress WebSite Hosting Platform.
def test23_device_interface_link_up(str name='router', int count=4)
Turn up interface link state.
def test2_linear_topology()
Create a simple linear topology of SONiC Devices.
def test31_application_novnc()
Create application noVNC Remote Desktop for Ubuntu Linux.
def test35_datacenter_cisco()
Load a cisco network topology from an external yaml file.
def test39_datacenter_junos()
Load a junos network topology from an external yaml file.
def test43_kubernetes_cluster1(int masters=-1, int computes=3)
Create a Kubernetes Cluster.
def test14_device_with_k8_pods(int device_count=int(environ.get('CAMPHOR_TEST_DEVICE_COUNT', '4')), int network_count=int(environ.get('CAMPHOR_TEST_NETWORK_COUNT', '4')), bool synchronize=environ.get('CAMPHOR_TEST_SYNCHRONIZE', '').upper()=='TRUE')
Create a network of devices and verify wih K8.
def test42_datacenter_sonic()
Load a sonic network topology from an external yaml file.
def test7_camphor_topology_file()
Load a camphor network topology from an external yaml file.