Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updating restPy migration files #123

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion RestApi/Python/Modules/ClassInheritance.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
Your scripts will be instantiating objects using your classes.
With inheritance, this allows your scripts to use all of OpenIxia functions
and use your added functions in your classes.
This allows you to keep getting OpenIxia updates without interferring with
This allows you to keep getting OpenIxia updates without interferring with
your extended functions.

"""
Expand All @@ -20,10 +20,12 @@
from IxNetRestApiPacketCapture import PacketCapture
from IxNetRestApiQuickTest import QuickTest


class Connection(Connect):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)


class Port_Mgmt(PortMgmt):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
Expand All @@ -37,14 +39,17 @@ def exportJsonConfig(self):
# For enhancement or to fix a bug in exportJsonConfig().
pass


class Traffic_Config(Traffic):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)


class Protocol_Config(Protocol):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)


class Statistics_View(Statistics):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
1,258 changes: 357 additions & 901 deletions RestApi/Python/Modules/IxNetRestApi.py

Large diffs are not rendered by default.

613 changes: 295 additions & 318 deletions RestApi/Python/Modules/IxNetRestApiClassicProtocol.py

Large diffs are not rendered by default.

590 changes: 206 additions & 384 deletions RestApi/Python/Modules/IxNetRestApiFileMgmt.py

Large diffs are not rendered by default.

35 changes: 16 additions & 19 deletions RestApi/Python/Modules/IxNetRestApiGlobals.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
import re

from IxNetRestApiProtocol import Protocol

class Globals(object):
def __init__(self, ixnObj=None):
"""
Parameters
ixnObj: <str>: The main connection object.
"""
self.ixnObj = ixnObj
self.protocolObj = Protocol(ixnObj)
self.ixNetwork = ixnObj.ixNetwork

def dhcpV4ClientStartStopRate(self, endpoint='startRate', **kwargs):
"""
Expand All @@ -19,7 +15,8 @@ def dhcpV4ClientStartStopRate(self, endpoint='startRate', **kwargs):
Parameters
endpoint: <str|object endpoint>: startRate|stopRate

**kwargs: Any attribute for the /globals/topology/dhcpv4client/startRate|stopRate endpoint.
**kwargs: Any attribute for the /globals/topology/dhcpv4client/
startRate|stopRate endpoint.
enabled = bool
interval = int
maxOutstanding = int
Expand All @@ -35,16 +32,16 @@ def dhcpV4ClientStartStopRate(self, endpoint='startRate', **kwargs):
)

"""
restApi = '/globals/topology/dhcpv4client/{0}?links=true'.format(endpoint)

response = self.ixnObj.get(self.ixnObj.sessionUrl + restApi)
for key,value in response.json().items():
if key != 'links':
if bool(re.search('multivalue', str(value))) == True:
if key in kwargs:
multiValue = response.json()[key]
self.ixnObj.patch(self.ixnObj.httpHeader+multiValue+"/singleValue", data={'value': kwargs[key]})
else:
if key in kwargs:
self.ixnObj.patch(self.ixnObj.sessionUrl + restApi, data={key: kwargs[key]})

rateObj = None

if endpoint == 'startRate':
rateObj = self.ixNetwork.Globals.Topology.Dhcpv4client.StartRate
if endpoint == 'stopRate':
rateObj = self.ixNetwork.Globals.Topology.Dhcpv4client.StopRate
for key, value in kwargs.items():
key = key[0].capitalize() + key[1:]
try:
multiValueObj = getattr(rateObj, key)
self.ixnObj.configMultivalue(multiValueObj, 'singlevalue', {'value': value})
except(ValueError, Exception):
setattr(rateObj, key, value)
313 changes: 138 additions & 175 deletions RestApi/Python/Modules/IxNetRestApiPacketCapture.py

Large diffs are not rendered by default.

Loading