Skip to content

Commit

Permalink
Merge pull request #22 from OpenIxia/10.00-2
Browse files Browse the repository at this point in the history
10.00 2
  • Loading branch information
nutu authored May 30, 2024
2 parents d60c03d + 07b6579 commit 2055897
Show file tree
Hide file tree
Showing 24 changed files with 9,608 additions and 9,330 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
*.pyc
.vscode
.venv
launch.json
settings.json
Binary file modified RestApi/Python/RestApi_v2/Modules/bps_restpy/.DS_Store
Binary file not shown.
4 changes: 2 additions & 2 deletions RestApi/Python/RestApi_v2/Modules/bps_restpy/bps.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
*Created with Breaking Point build : 9.38v9.38.1.57"""
*Created with Breaking Point build : 9.00v9.00.108.12"""
import sys,os
#sys.path.insert(0,os.path.abspath(__file__+"/../.."))
if sys.version_info[0] >= 3:
from .restPyWrapper3 import BPS, pp
else:
from restPyWrapper import BPS, pp
from restPyWrapper import BPS, pp
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,8 @@ def waitOnSystemRecovery (self, enableRequestPrints = False):

#delete all execution results reports
def purgeReports (self,versionId, enableRequestPrints = False):
service = 'https://' + self.ipstr + '/bps/api/v1/admin/storage/operations/compact'
# APS/VE might have diffrent API: https://<bps-system>/bps/api/v1/admin/database/operations/clean
service = 'https://' + self.ipstr + '/bps/api/v1/admin/storage/operations/purge'
jheaders = {'content-type': 'application/json', 'x-api-key': self.api_key, 'Referrer Policy' : 'no-referrer-when-downgrade'}
jdata = json.dumps({'removeReports' : 'true' })
r = self.session.post(service, data=jdata, headers=jheaders, verify=False )
Expand All @@ -363,7 +364,7 @@ def purgeReports (self,versionId, enableRequestPrints = False):
print("Waiting for purgeReports to complete")
self.waitOnFinish( service )
else:
print("Uninstall failed: %s - %s" % (r, r.content))
print("Purge failed: %s - %s" % (r, r.content))
return False
return True

Expand Down
9,382 changes: 4,755 additions & 4,627 deletions RestApi/Python/RestApi_v2/Modules/bps_restpy/restPyWrapper.py

Large diffs are not rendered by default.

9,368 changes: 4,748 additions & 4,620 deletions RestApi/Python/RestApi_v2/Modules/bps_restpy/restPyWrapper3.py

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
########################################
import time, sys, os, traceback
# Add bps_restpy libpath *required if the library is not installed
sys.path.append(os.path.join(os.path.dirname(__file__), r"../lib"))
sys.path.append(os.path.join(os.path.dirname(__file__), r"../"))

from restPyWrapper3 import *

Expand All @@ -28,13 +28,13 @@
# Demo script global variables
canned_test_name = 'AppSim'
#bps system info
bps_system = '10.36.83.70'
bpsuser = 'admin'
bpspass = 'admin'
bps_system = '<BPS_BOX_IP/HOSTNAME>'
bpsuser = 'bps user'
bpspass = 'bps pass'
testGroup = 1

slot_number = 1
port_list = [1.0, 2.0]
port_list = ["1.0", "2.0"]
l47_resource = [0 , 1]
########################################

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@
bpsuser = 'bps user'
bpspass = 'bps pass'


slot_number = 2
slot_number = 1
port_list = [0, 1]

########################################
Expand All @@ -55,7 +54,6 @@
for p in port_list:
bps.topology.reserve([{'slot': slot_number, 'port': p, 'group': 2}])


########################################
print("Run test and Get Stats:")
test_id_json = bps.testmodel.run(modelname=canned_test_name, group=2)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@
bpsuser = 'bps user'
bpspass = 'bps pass'


slot_number = 2
slot_number = 3
port_list = [0, 1]

########################################
Expand All @@ -53,7 +52,7 @@
bps = BPS(bps_system, bpsuser, bpspass)
bps.login()
print("Import a test")
status = bps.testmodel.importModel(importAsTestName, bpt_filename_to_import, True)
status = bps.testmodel.importModel(importAsTestName, os.path.join(os.path.dirname(__file__), bpt_filename_to_import), True)
print(" %s " % status)

print("Search for the imported test")
Expand All @@ -68,7 +67,7 @@

########################################
print("Import a Network Config")
status = bps.network.importNetwork(importAsNetworkName, networkfile_to_import, True)
status = bps.network.importNetwork(importAsNetworkName, os.path.join(os.path.dirname(__file__),networkfile_to_import), True)
print(" %s " % status)

print("Search for the imported network config.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,8 @@
bps_system = '<BPS_BOX_IP/HOSTNAME>'
bpsuser = 'bps user'
bpspass = 'bps pass'
bps_system = '10.36.81.90'
bpsuser = 'admin'
bpspass = 'admin'

slot_number = 1
slot_number = 3
port_list = [0, 1]

########################################
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
bpsuser = 'bps user'
bpspass = 'bps pass'

slot_number = 1
slot_number = 3
port_list = [0, 1]

########################################
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
bpsuser = 'bps user'
bpspass = 'bps pass'

slot_number = 5
port_list = [0, 4]
slot_number = 3
port_list = [0, 1]

########################################

Expand Down Expand Up @@ -63,7 +63,7 @@
########################################
print("Reserve Ports")
for p in port_list:
bps.topology.reserve([{'slot': slot_number, 'port': p, 'group': 20}])
bps.topology.reserve([{'slot': slot_number, 'port': p, 'group': 20, "capture": True}])


########################################
Expand Down Expand Up @@ -105,7 +105,14 @@
time.sleep(1)
print("stop progress: %s%s" % (init_progress, '%'))


#export capture
print ('Exporting the capture for the ports')
for p in port_list:
print ('Exporting tescap%s.pcap....' % p)
time.sleep(10)
bps.topology.exportCapture('tescap%s.pcap' % p ,\
{"port": p,"slot": slot_number,"dir": "both","size": 100000,"start": 0, "sizetype": "megabytes", "starttype": "megabytes" } )

#getReportContents 1st 'IP Summary' section
contents=bps.reports.getReportContents(runid=run_id)
for section in contents:
Expand All @@ -117,13 +124,6 @@
print ("%s: %s " % (tabledata[0]['Measurement'][index], tabledata[1]['Value'][index]) )
break

#export capture
print ('Exporting the capture for the ports')
for p in port_list:
print ('Exporting tescap%s.cap....' % p)
bps.topology.exportCapture('tescap%s.cap' % p ,\
{"port": p,"slot": slot_number,"dir": "both","size": 100,"start": 0, "sizetype": "megabytes", "starttype": "megabytes" } )

print("Waiting 5 secs")
time.sleep(5)
########################################
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@
bpsuser = 'bps user'
bpspass = 'bps pass'


slot_number = 1
slot_number = 3
port_list = [0, 1]

########################################
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,15 @@
test_name = "Test_Model"

#bps system info
bps_system = '10.36.66.31'
bpsuser = 'admin'
bpspass = 'admin'
bps_system = '<BPS_BOX_IP/HOSTNAME>'
bpsuser = 'bps user'
bpspass = 'bps pass'

slot_number = 9
########################################
#session inactivity - introduced in BreakingPoint 9.38
inactivityTimeout = 180

slot_number = 3
port_list = [0, 1]

########################################
Expand All @@ -42,8 +46,16 @@
########################################
# Login to BPS box
bps = BPS(bps_system, bpsuser, bpspass)
bps.login()

bps.login(inactivityTimeout = inactivityTimeout)

#session management
sessionList = bps.administration.sessions.list()
for session in sessionList:
if session['user'] == bpsuser:
print ( f'Current user : {bpsuser} session {session["session"]} with\
inactivity {session["inactivity"]} out of {session["inactivityTimeout"]} seconds')
##if needed could be closed
#session.close(session=session["session"])

########################################
print("Create a new test: ")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,8 @@
bps_system = '<BPS_BOX_IP/HOSTNAME>'
bpsuser = 'bps user'
bpspass = 'bps pass'
bps_system = '10.36.81.90'
bpsuser = 'admin'
bpspass = 'admin'

slot_number = 1
slot_number = 3
port_list = [0, 1]

########################################
Expand All @@ -70,10 +67,10 @@ def update_strikeResult(run_id, bps):
strike_variant = strike_name.split('-')[-1]
strike_name = variantMatch.group(1)
#keep history of strike results allready analyzed
if not strikeVaiantResult.has_key(strike_name):
if strike_name not in strikeVaiantResult:
strikeVaiantResult[strike_name] = {'Allowed' : False}
#print only if is a new entry
if not strikeVaiantResult[strike_name].has_key(strike_variant):
if strike_variant not in strikeVaiantResult[strike_name]:
strikeVaiantResult[strike_name][strike_variant] = {'time' : strike_time, 'result' : strike_result}
if strike_result == 'Allowed':
strikeVaiantResult[strike_name]['Allowed'] = True
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,12 @@
# Demo script global variables

#bps system info
# bps_system = '<BPS_BOX_IP/HOSTNAME>'
# bpsuser = 'bps user'
# bpspass = 'bps pass'
bps_system = '10.36.66.31'
bpsuser = 'admin'
bpspass = 'admin'

slot_number = 6
bps_system = '<BPS_BOX_IP/HOSTNAME>'
bpsuser = 'bps user'
bpspass = 'bps pass'


slot_number = 3
port_list = [0, 1]
########################################
# utility procedure to wait for long operations like card change mode, reboot, speed change
Expand Down Expand Up @@ -113,7 +111,7 @@ def waitForComplete(bps, r, key="progress", keyValue=100, timeout=1000, rate=2)

print ('setCardFanout to BPS mode--')
# The fan type represented by an integer id. For CloudStorm: 0(100G), 1(40G), 2(25G), 3(10G), 4(50G). For PerfectStorm 40G: 0(40G), 1(10G). For PerfectStorm 100G: 0(100G), 1(40G), 2(10G)
r = bps.topology.setCardFanout(board=slot_number, fanid=1)
r = bps.topology.setCardFanout(board=slot_number, fanid=0)
waitForComplete(bps, r)

bps.logout()
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@
import os
# Add bps_restpy libpath *required if the library is not installed
libpath = os.path.abspath(__file__+"/../../..")
libpath = os.path.abspath(__file__+"/../../")
sys.path.insert(0, libpath)
import logging

from restPyWrapper import BPS, pp
from restPyWrapper3 import BPS, pp
from bpsVELicense import BPSVELicenseManagement
########################################

Expand All @@ -31,10 +32,13 @@
bps_system = '<BPS_BOX_IP/HOSTNAME>'
bpsuser = 'bps user'
bpspass = 'bps pass'

bps_system = '10.36.82.74'
bpsuser = 'admin'
bpspass = 'admin'
mainLicenseServer = '<License_Server_IP/HOSTNAME>'
mainLicenseServer = "10.36.66.31"
activationCode = '<Activation_Code>'

activationCode = ""
########################################


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
3. Add components
4. Set component values
5. Clone components
6. Reserve ports
6. Reserve ports and resources
7. Run Test
8. Get live stats
9. Wait for the test to finish
10. Get test result
11. Get and print the Synopsis page from report
12. Unreserve ports
12. Unreserve ports resources
13. Logout
"""

Expand Down Expand Up @@ -45,7 +45,7 @@

SLOT_NUMBER = 1
GROUP_NUMBER = 2
PORT_LIST = [0, 1]
PORT_LIST = ["3.0", "4.0"]

########################################

Expand Down Expand Up @@ -114,6 +114,10 @@
bps.topology.reserve(
[{'group': GROUP_NUMBER, 'slot': SLOT_NUMBER, 'port': p, 'capture': True}], False)


print("Reserve L23 resources...")
for r in range(16):
bps.topology.reserveResource(group = GROUP_NUMBER, resourceId = r, resourceType = "l23")
########################################


Expand Down Expand Up @@ -183,7 +187,9 @@
for p in PORT_LIST:
bps.topology.unreserve(
[{'slot': SLOT_NUMBER, 'port': p}])

print("\nReleasing resources...")
for r in range(16):
bps.topology.releaseResource(group = GROUP_NUMBER, resourceId = r, resourceType = "l23")
########################################


Expand Down
Loading

0 comments on commit 2055897

Please sign in to comment.