In [6]:
help(__IPYTHON__)
Help on bool object:
class bool(int)
| bool(x) -> bool
|
| Returns True when the argument x is true, False otherwise.
| The builtins True and False are the only two instances of the class bool.
| The class bool is a subclass of the class int, and cannot be subclassed.
|
| Method resolution order:
| bool
| int
| object
|
| Methods defined here:
|
| __and__(self, value, /)
| Return self&value.
|
| __new__(*args, **kwargs) from builtins.type
| Create and return a new object. See help(type) for accurate signature.
|
| __or__(self, value, /)
| Return self|value.
|
| __rand__(self, value, /)
| Return value&self.
|
| __repr__(self, /)
| Return repr(self).
|
| __ror__(self, value, /)
| Return value|self.
|
| __rxor__(self, value, /)
| Return value^self.
|
| __str__(self, /)
| Return str(self).
|
| __xor__(self, value, /)
| Return self^value.
|
| ----------------------------------------------------------------------
| Methods inherited from int:
|
| __abs__(self, /)
| abs(self)
|
| __add__(self, value, /)
| Return self+value.
|
| __bool__(self, /)
| self != 0
|
| __ceil__(...)
| Ceiling of an Integral returns itself.
|
| __divmod__(self, value, /)
| Return divmod(self, value).
|
| __eq__(self, value, /)
| Return self==value.
|
| __float__(self, /)
| float(self)
|
| __floor__(...)
| Flooring an Integral returns itself.
|
| __floordiv__(self, value, /)
| Return self//value.
|
| __format__(...)
|
| __ge__(...)
| __ge__=($self, value, /)
| --
|
| Return self>=value.
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __getnewargs__(...)
|
| __gt__(self, value, /)
| Return self>value.
|
| __hash__(self, /)
| Return hash(self).
|
| __index__(self, /)
| Return self converted to an integer, if self is suitablefor use as an index into a list.
|
| __int__(self, /)
| int(self)
|
| __invert__(self, /)
| ~self
|
| __le__(self, value, /)
| Return self<=value.
|
| __lshift__(self, value, /)
| Return self<<value.
|
| __lt__(self, value, /)
| Return self<value.
|
| __mod__(self, value, /)
| Return self%value.
|
| __mul__(self, value, /)
| Return self*value.
|
| __ne__(self, value, /)
| Return self!=value.
|
| __neg__(self, /)
| -self
|
| __pos__(self, /)
| +self
|
| __pow__(self, value, mod=None, /)
| Return pow(self, value, mod).
|
| __radd__(self, value, /)
| Return value+self.
|
| __rdivmod__(self, value, /)
| Return divmod(value, self).
|
| __rfloordiv__(self, value, /)
| Return value//self.
|
| __rlshift__(self, value, /)
| Return value<<self.
|
| __rmod__(self, value, /)
| Return value%self.
|
| __rmul__(self, value, /)
| Return value*self.
|
| __round__(...)
| Rounding an Integral returns itself.
| Rounding with an ndigits argument also returns an integer.
|
| __rpow__(self, value, mod=None, /)
| Return pow(value, self, mod).
|
| __rrshift__(self, value, /)
| Return value>>self.
|
| __rshift__(self, value, /)
| Return self>>value.
|
| __rsub__(self, value, /)
| Return value-self.
|
| __rtruediv__(self, value, /)
| Return value/self.
|
| __sizeof__(...)
| Returns size in memory, in bytes
|
| __sub__(self, value, /)
| Return self-value.
|
| __truediv__(self, value, /)
| Return self/value.
|
| __trunc__(...)
| Truncating an Integral returns itself.
|
| bit_length(...)
| int.bit_length() -> int
|
| Number of bits necessary to represent self in binary.
| >>> bin(37)
| '0b100101'
| >>> (37).bit_length()
| 6
|
| conjugate(...)
| Returns self, the complex conjugate of any int.
|
| from_bytes(...) from builtins.type
| int.from_bytes(bytes, byteorder, *, signed=False) -> int
|
| Return the integer represented by the given array of bytes.
|
| The bytes argument must either support the buffer protocol or be an
| iterable object producing bytes. Bytes and bytearray are examples of
| built-in objects that support the buffer protocol.
|
| The byteorder argument determines the byte order used to represent the
| integer. If byteorder is 'big', the most significant byte is at the
| beginning of the byte array. If byteorder is 'little', the most
| significant byte is at the end of the byte array. To request the native
| byte order of the host system, use `sys.byteorder' as the byte order value.
|
| The signed keyword-only argument indicates whether two's complement is
| used to represent the integer.
|
| to_bytes(...)
| int.to_bytes(length, byteorder, *, signed=False) -> bytes
|
| Return an array of bytes representing an integer.
|
| The integer is represented using length bytes. An OverflowError is
| raised if the integer is not representable with the given number of
| bytes.
|
| The byteorder argument determines the byte order used to represent the
| integer. If byteorder is 'big', the most significant byte is at the
| beginning of the byte array. If byteorder is 'little', the most
| significant byte is at the end of the byte array. To request the native
| byte order of the host system, use `sys.byteorder' as the byte order value.
|
| The signed keyword-only argument determines whether two's complement is
| used to represent the integer. If signed is False and a negative integer
| is given, an OverflowError is raised.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from int:
|
| denominator
| the denominator of a rational number in lowest terms
|
| imag
| the imaginary part of a complex number
|
| numerator
| the numerator of a rational number in lowest terms
|
| real
| the real part of a complex number
Related Scripts:
In [1]:
help('learning_lab.05_acl_list')
Help on module learning_lab.05_acl_list in learning_lab:
NAME
learning_lab.05_acl_list - Sample usage of function 'get_acl_all'.
DESCRIPTION
Print the function's documentation.
Apply the function to a network device.
Print the list of ACLs.
If no ACL found then retry with a different network device.
FUNCTIONS
demonstrate(device_name)
Apply function 'get_acl_all' to the specified device.
Return True if an ACL was found.
main()
Select a device and demonstrate.
FILE
/home/virl/git/cosc-learning-labs/src/learning_lab/05_acl_list.py
In [2]:
from importlib import import_module
script = import_module('learning_lab.05_acl_list')
from inspect import getsource
print(getsource(script.main))
def main():
''' Select a device and demonstrate.'''
print(plain(doc(get_acl_all)))
mounted_list = inventory_mounted()
if not mounted_list:
print('There are no mounted devices to examine. Demonstration cancelled.')
return 1
for device_name in mounted_list:
if demonstrate(device_name):
return 0
return 1
In [3]:
print(getsource(script.demonstrate))
def demonstrate(device_name):
''' Apply function 'get_acl_all' to the specified device.
Return True if an ACL was found.
'''
print('get_acl_all(' + device_name, end=')\n')
acl_list = get_acl_all(device_name)
if not acl_list:
print(None)
return False
else:
for acl in acl_list:
print(json.dumps(acl, sort_keys = False, indent = 2))
return True
In [4]:
run ../learning_lab/05_acl_list.py
Python Library Documentation: function get_acl_all in module basics.acl
get_acl_all(device_name)
List the ACLs of one network device.
Return a list where each element is a JSON representation of an ACL.
get_acl_all(xrvr-511-53U)
{
"access-list-name": "portdenyechoudp",
"access-list-entries": {
"access-list-entry": [
{
"sequence-number": 10,
"destination-port": {
"first-destination-port": "echo",
"destination-operator": "equal"
},
"protocol": "udp",
"grant": "deny"
},
{
"sequence-number": 20,
"grant": "permit"
}
]
}
}
In [5]:
from basics.odl_http import http_history
from basics.http import http_history_to_html
from IPython.core.display import HTML
HTML(http_history_to_html(http_history()))
Out[5]:
HTTP request/response: 1 2
Request
Method
GET
URL
http://127.0.0.1:8181/restconf/config/opendaylight-inventory:nodes
Headers
Accept
application/xml
User-Agent
python-requests/2.2.1 CPython/3.4.0 Linux/3.13.0-45-generic
Authorization
Basic YWRtaW46YWRtaW4=
Accept-Encoding
gzip, deflate, compress
Content
Response
Status Code
200
Headers
content-type
application/xml
server
Jetty(8.1.14.v20131031)
transfer-encoding
chunked
Content
<?xml version='1.0' encoding='ASCII'?>
<nodes xmlns="urn:opendaylight:inventory">
<node>
<id>xrvr-511-53U</id>
</node>
<node>
<id>controller-config</id>
</node>
</nodes>
HTTP request/response: 1 2
Request
Method
GET
URL
http://127.0.0.1:8181/restconf/config/opendaylight-inventory:nodes/node/xrvr-511-53U/yang-ext:mount/Cisco-IOS-XR-ipv4-acl-cfg:ipv4-acl-and-prefix-list/accesses
Headers
Accept
application/json
User-Agent
python-requests/2.2.1 CPython/3.4.0 Linux/3.13.0-45-generic
Authorization
Basic YWRtaW46YWRtaW4=
Accept-Encoding
gzip, deflate, compress
Content
Response
Status Code
200
Headers
content-type
application/json
server
Jetty(8.1.14.v20131031)
transfer-encoding
chunked
Content
{
"accesses": {
"access": [
{
"access-list-name": "portdenyechoudp",
"access-list-entries": {
"access-list-entry": [
{
"sequence-number": 10,
"destination-port": {
"first-destination-port": "echo",
"destination-operator": "equal"
},
"protocol": "udp",
"grant": "deny"
},
{
"sequence-number": 20,
"grant": "permit"
}
]
}
}
]
}
}
Content source: SivagnanamCiena/cosc-learning-labs
Similar notebooks: