Exemplo n.º 1
0
import sys
import os
path = os.path.realpath(__file__)
sys.path.insert(0, path[0:path.rfind('ixnetwork')])

from ixnetwork.samples.Config import Config
from ixnetwork.IxnConfigManagement import IxnConfigManagement
from ixnetwork.IxnHttp import IxnHttp
from ixnetwork.IxnQuery import IxnQuery
import time

# get an IxnHttp instance using the samples Config object
ixnhttp = Config.get_IxnHttp_instance(use_gui=True)

# management objects
config_mgmt = IxnConfigManagement(ixnhttp)

# clear the current configuration
config_mgmt.new_config()

# create two virtual ports using the low level http interface
ixnhttp.post('/vport', [{'name': 'eth-1'}, {'name': 'eth-2'}])

# get all the virtual ports using the query
query_result = IxnQuery(ixnhttp, '/') \
    .node('vport', properties=['*']) \
    .go()

# using the returned query_result print the vport names
print('All virtual port names')
for vport in query_result.vport:
Exemplo n.º 2
0
import sys
import os
path = os.path.realpath(__file__)
sys.path.insert(0, path[0:path.rfind('ixnetwork')])

from ixnetwork.samples.Config import Config
from ixnetwork.IxnHttp import IxnHttp
from ixnetwork.IxnConfigManagement import IxnConfigManagement
from ixnetwork.IxnMultivalue import IxnMultivalue

# get an IxnHttp instance using the samples Config object
ixnhttp = Config.get_IxnHttp_instance()

# management objects
config_mgmt = IxnConfigManagement(ixnhttp)

# clear the current configuration
config_mgmt.new_config()

# create an ethernet emulation host
ethernet = ixnhttp.root.create_child('topology').create_child(
    'deviceGroup').create_child('ethernet')

# ethernet mac singleValue
ethernet.attributes.mac.value.single_value = '00:00:de:ad:be:ef'
print(ethernet.attributes.mac.value.single_value)
ethernet.attributes.mac.value.dump()

# ethernet mac valueList
ethernet.attributes.mac.value.value_list = [
    '00:00:de:ad:be:ef', '00:00:fa:ce:fa:ce'