sentence1 stringlengths 52 3.87M | sentence2 stringlengths 1 47.2k | label stringclasses 1
value |
|---|---|---|
def create(self, name, action='permit', goto=None, finish=False,
call=None, comment=None, add_pos=None, after=None,
before=None, **match_condition):
"""
Create a route map rule. You can provide match conditions
by using keyword arguments specifying the required type... | Create a route map rule. You can provide match conditions
by using keyword arguments specifying the required types.
You can also create the route map rule and add match conditions
after.
:param str name: name for this rule
:param str action: permit or deny
:param... | entailment |
def search_rule(self, search):
"""
Search the RouteMap policy using a search string
:param str search: search string for a contains match against
the rule name and comments field
:rtype: list(RouteMapRule)
"""
return [RouteMapRule(**rule) for rule in ... | Search the RouteMap policy using a search string
:param str search: search string for a contains match against
the rule name and comments field
:rtype: list(RouteMapRule) | entailment |
def create(cls, name, certificate):
"""
Create a new external VPN CA for signing internal gateway
certificates.
:param str name: Name of VPN CA
:param str certificate: file name, path or certificate string.
:raises CreateElementFailed: Failed creating cert with r... | Create a new external VPN CA for signing internal gateway
certificates.
:param str name: Name of VPN CA
:param str certificate: file name, path or certificate string.
:raises CreateElementFailed: Failed creating cert with reason
:rtype: VPNCertificateCA | entailment |
def _create(self, common_name, public_key_algorithm='rsa',
signature_algorithm='rsa_sha_512', key_length=2048,
signing_ca=None):
"""
Internal method called as a reference from the engine.vpn
node
"""
if signing_ca is None:
signing_ca = VPNCerti... | Internal method called as a reference from the engine.vpn
node | entailment |
def create(cls, name, min_dst_port, max_dst_port=None, min_src_port=None,
max_src_port=None, protocol_agent=None, comment=None):
"""
Create the TCP service
:param str name: name of tcp service
:param int min_dst_port: minimum destination port value
:param int max_... | Create the TCP service
:param str name: name of tcp service
:param int min_dst_port: minimum destination port value
:param int max_dst_port: maximum destination port value
:param int min_src_port: minimum source port value
:param int max_src_port: maximum source port value
... | entailment |
def create(cls, name, protocol_number, protocol_agent=None, comment=None):
"""
Create the IP Service
:param str name: name of ip-service
:param int protocol_number: ip proto number for this service
:param str,ProtocolAgent protocol_agent: optional protocol agent for
... | Create the IP Service
:param str name: name of ip-service
:param int protocol_number: ip proto number for this service
:param str,ProtocolAgent protocol_agent: optional protocol agent for
this service
:param str comment: optional comment
:raises CreateElementFailed: ... | entailment |
def create(cls, name, frame_type='eth2', value1=None, comment=None):
"""
Create an ethernet service
:param str name: name of service
:param str frame_type: ethernet frame type, eth2
:param str value1: hex code representing ethertype field
:param str comment: optional com... | Create an ethernet service
:param str name: name of service
:param str frame_type: ethernet frame type, eth2
:param str value1: hex code representing ethertype field
:param str comment: optional comment
:raises CreateElementFailed: failure creating element with reason
:r... | entailment |
def custom_range(self, start_time, end_time=None):
"""
Provide a custom range for the search query. Start time and end
time are expected to be naive ``datetime`` objects converted to
milliseconds. When submitting the query, it is strongly recommended
to set the timezone matching... | Provide a custom range for the search query. Start time and end
time are expected to be naive ``datetime`` objects converted to
milliseconds. When submitting the query, it is strongly recommended
to set the timezone matching the local client making the query.
Example of finding... | entailment |
def pem_as_string(cert):
"""
Only return False if the certificate is a file path. Otherwise it
is a file object or raw string and will need to be fed to the
file open context.
"""
if hasattr(cert, 'read'): # File object - return as is
return cert
cert = cert.encode('utf-8') if isinst... | Only return False if the certificate is a file path. Otherwise it
is a file object or raw string and will need to be fed to the
file open context. | entailment |
def load_cert_chain(chain_file):
"""
Load the certificates from the chain file.
:raises IOError: Failure to read specified file
:raises ValueError: Format issues with chain file or missing entries
:return: list of cert type matches
"""
if hasattr(chain_file, 'read'):
cert_chain... | Load the certificates from the chain file.
:raises IOError: Failure to read specified file
:raises ValueError: Format issues with chain file or missing entries
:return: list of cert type matches | entailment |
def import_certificate(self, certificate):
"""
Import a valid certificate. Certificate can be either a file path
or a string of the certificate. If string certificate, it must include
the -----BEGIN CERTIFICATE----- string.
:param str certificate_file: fully qualified pa... | Import a valid certificate. Certificate can be either a file path
or a string of the certificate. If string certificate, it must include
the -----BEGIN CERTIFICATE----- string.
:param str certificate_file: fully qualified path to certificate file
:raises CertificateImportError: ... | entailment |
def import_intermediate_certificate(self, certificate):
"""
Import a valid certificate. Certificate can be either a file path
or a string of the certificate. If string certificate, it must include
the -----BEGIN CERTIFICATE----- string.
:param str certificate: fully qual... | Import a valid certificate. Certificate can be either a file path
or a string of the certificate. If string certificate, it must include
the -----BEGIN CERTIFICATE----- string.
:param str certificate: fully qualified path or string
:raises CertificateImportError: failure to imp... | entailment |
def export_intermediate_certificate(self, filename=None):
"""
Export the intermediate certificate. Returned certificate will be in
string format. If filename is provided, the certificate will also be
saved to the file specified.
:raises CertificateExportError: error expo... | Export the intermediate certificate. Returned certificate will be in
string format. If filename is provided, the certificate will also be
saved to the file specified.
:raises CertificateExportError: error exporting certificate, can occur
if no intermediate certificate is ava... | entailment |
def import_private_key(self, private_key):
"""
Import a private key. The private key can be a path to a file
or the key in string format. If in string format, the key must
start with -----BEGIN. Key types supported are PRIVATE RSA KEY
and PRIVATE KEY.
:param str ... | Import a private key. The private key can be a path to a file
or the key in string format. If in string format, the key must
start with -----BEGIN. Key types supported are PRIVATE RSA KEY
and PRIVATE KEY.
:param str private_key: fully qualified path to private key file
:... | entailment |
def get(self, rel):
"""
Get the resource by rel name
:param str rel_name: name of rel
:raises UnsupportedEntryPoint: entry point not found in this version
of the API
"""
for link in self._entry_points:
if link.get('rel') == rel:
... | Get the resource by rel name
:param str rel_name: name of rel
:raises UnsupportedEntryPoint: entry point not found in this version
of the API | entailment |
def on_open(self):
"""
Once the connection is made, start the query off and
start an event loop to wait for a signal to
stop. Results are yielded within receive().
"""
def event_loop():
logger.debug(pformat(self.query.request))
self.send(json.dumps... | Once the connection is made, start the query off and
start an event loop to wait for a signal to
stop. Results are yielded within receive(). | entailment |
def send_message(self, message):
"""
Send a message down the socket. The message is expected
to have a `request` attribute that holds the message to
be serialized and sent.
"""
if self.connected:
self.send(
json.dumps(message.request)) | Send a message down the socket. The message is expected
to have a `request` attribute that holds the message to
be serialized and sent. | entailment |
def receive(self):
"""
Generator yielding results from the web socket. Results
will come as they are received. Even though socket select
has a timeout, the SMC will not reply with a message more
than every two minutes.
"""
try:
itr = 0
whil... | Generator yielding results from the web socket. Results
will come as they are received. Even though socket select
has a timeout, the SMC will not reply with a message more
than every two minutes. | entailment |
def LoadElement(href, only_etag=False):
"""
Return an instance of a element as a ElementCache dict
used as a cache.
:rtype ElementCache
"""
request = SMCRequest(href=href)
request.exception = FetchElementFailed
result = request.read()
if only_etag:
return result.etag
... | Return an instance of a element as a ElementCache dict
used as a cache.
:rtype ElementCache | entailment |
def ElementCreator(cls, json, **kwargs):
"""
Helper method for creating elements. If the created element type is
a SubElement class type, provide href value as kwargs since that class
type does not have a direct entry point. This is a lazy load that will
provide only the meta for the element. Additi... | Helper method for creating elements. If the created element type is
a SubElement class type, provide href value as kwargs since that class
type does not have a direct entry point. This is a lazy load that will
provide only the meta for the element. Additional attribute access
will load the full data.
... | entailment |
def ElementFactory(href, smcresult=None, raise_exc=None):
"""
Factory returns an object of type Element when only
the href is provided.
:param str href: string href to fetch
:param SMCResult smcresult: optional SMCResult. If provided,
the request fetch will be skipped
:param Excepti... | Factory returns an object of type Element when only
the href is provided.
:param str href: string href to fetch
:param SMCResult smcresult: optional SMCResult. If provided,
the request fetch will be skipped
:param Exception raise_exc: exception to raise if fetch
failed | entailment |
def etag(self, href):
"""
ETag can be None if a subset of element json is using
this container, such as the case with Routing.
"""
if self and self._etag is None:
self._etag = LoadElement(href, only_etag=True)
return self._etag | ETag can be None if a subset of element json is using
this container, such as the case with Routing. | entailment |
def get_link(self, rel):
"""
Return link for specified resource
"""
if rel in self.links:
return self.links[rel]
raise ResourceNotFound('Resource requested: %r is not available '
'on this element.' % rel) | Return link for specified resource | entailment |
def get(cls, name, raise_exc=True):
"""
Get the element by name. Does an exact match by element type.
:param str name: name of element
:param bool raise_exc: optionally disable exception.
:raises ElementNotFound: if element does not exist
:rtype: Element
... | Get the element by name. Does an exact match by element type.
:param str name: name of element
:param bool raise_exc: optionally disable exception.
:raises ElementNotFound: if element does not exist
:rtype: Element | entailment |
def get_or_create(cls, filter_key=None, with_status=False, **kwargs):
"""
Convenience method to retrieve an Element or create if it does not
exist. If an element does not have a `create` classmethod, then it
is considered read-only and the request will be redirected to :meth:`~get`.
... | Convenience method to retrieve an Element or create if it does not
exist. If an element does not have a `create` classmethod, then it
is considered read-only and the request will be redirected to :meth:`~get`.
Any keyword arguments passed except the optional filter_key
will be used in a ... | entailment |
def update_or_create(cls, filter_key=None, with_status=False, **kwargs):
"""
Update or create the element. If the element exists, update it using the
kwargs provided if the provided kwargs after resolving differences from
existing values. When comparing values, strings and ints are compa... | Update or create the element. If the element exists, update it using the
kwargs provided if the provided kwargs after resolving differences from
existing values. When comparing values, strings and ints are compared
directly. If a list is provided and is a list of strings, it will be
com... | entailment |
def add_category(self, category):
"""
Category Tags are used to characterize an element by a type
identifier. They can then be searched and returned as a group
of elements. If the category tag specified does not exist, it
will be created. This change will take effect immediately.... | Category Tags are used to characterize an element by a type
identifier. They can then be searched and returned as a group
of elements. If the category tag specified does not exist, it
will be created. This change will take effect immediately.
:param list tags: list of category tag names... | entailment |
def export(self, filename='element.zip'):
"""
Export this element.
Usage::
engine = Engine('myfirewall')
extask = engine.export(filename='fooexport.zip')
while not extask.done():
extask.wait(3)
print("Finished download task: %s" %... | Export this element.
Usage::
engine = Engine('myfirewall')
extask = engine.export(filename='fooexport.zip')
while not extask.done():
extask.wait(3)
print("Finished download task: %s" % extask.message())
print("File downloaded to: %s" ... | entailment |
def referenced_by(self):
"""
Show all references for this element. A reference means that this
element is being used, for example, in a policy rule, as a member of
a group, etc.
:return: list referenced elements
:rtype: list(Element)
"""
href = fetch_entr... | Show all references for this element. A reference means that this
element is being used, for example, in a policy rule, as a member of
a group, etc.
:return: list referenced elements
:rtype: list(Element) | entailment |
def history(self):
"""
.. versionadded:: 0.5.7
Requires SMC version >= 6.3.2
Obtain the history of this element. This will not chronicle every
modification made over time, but instead a current snapshot with
historical information such as when the element was... | .. versionadded:: 0.5.7
Requires SMC version >= 6.3.2
Obtain the history of this element. This will not chronicle every
modification made over time, but instead a current snapshot with
historical information such as when the element was created, by
whom, when it was ... | entailment |
def duplicate(self, name):
"""
.. versionadded:: 0.5.8
Requires SMC version >= 6.3.2
Duplicate this element. This is a shortcut method that will make
a direct copy of the element under the new name and type.
:param str name: name for the duplicated e... | .. versionadded:: 0.5.8
Requires SMC version >= 6.3.2
Duplicate this element. This is a shortcut method that will make
a direct copy of the element under the new name and type.
:param str name: name for the duplicated element
:raises ActionCommandFailed: fai... | entailment |
def get(self, location_name):
"""
Get a contact address by location name
:param str location_name: name of location
:return: return contact address element or None
:rtype: ContactAddress
"""
location_ref = location_helper(location_name, search_only=True)
... | Get a contact address by location name
:param str location_name: name of location
:return: return contact address element or None
:rtype: ContactAddress | entailment |
def update_or_create(self, location, contact_addresses, with_status=False,
overwrite_existing=False, **kw):
"""
Update or create a contact address and location pair. If the
location does not exist it will be automatically created. If the
server already has a location assigned... | Update or create a contact address and location pair. If the
location does not exist it will be automatically created. If the
server already has a location assigned with the same name, the
contact address specified will be added if it doesn't already
exist (Management and Log Server can ... | entailment |
def contact_addresses(self):
"""
Provides a reference to contact addresses used by this server.
Obtain a reference to manipulate or iterate existing contact
addresses::
>>> from smc.elements.servers import ManagementServer
>>> mgt_server = Manage... | Provides a reference to contact addresses used by this server.
Obtain a reference to manipulate or iterate existing contact
addresses::
>>> from smc.elements.servers import ManagementServer
>>> mgt_server = ManagementServer.objects.first()
>>> for co... | entailment |
def create(cls, name, address, proxy_port=8080, username=None,
password=None, secondary=None, comment=None):
"""
Create a new HTTP Proxy service. Proxy must define at least
one primary address but can optionally also define a list
of secondary addresses.
:... | Create a new HTTP Proxy service. Proxy must define at least
one primary address but can optionally also define a list
of secondary addresses.
:param str name: Name of the proxy element
:param str address: Primary address for proxy
:param int proxy_port: proxy port (defau... | entailment |
def create(cls, name, address, time_to_live=20, update_interval=10,
secondary=None, comment=None):
"""
Create a DNS Server element.
:param str name: Name of DNS Server
:param str address: IP address for DNS Server element
:param int time_to_live: Defines h... | Create a DNS Server element.
:param str name: Name of DNS Server
:param str address: IP address for DNS Server element
:param int time_to_live: Defines how long a DNS entry can be cached
before querying the DNS server again (default: 20)
:param int update_interval: D... | entailment |
def create(cls, name, address, inspected_service, secondary=None,
balancing_mode='ha', proxy_service='generic', location=None,
comment=None, add_x_forwarded_for=False, trust_host_header=False,
**kw):
"""
Create a Proxy Server element
:param s... | Create a Proxy Server element
:param str name: name of proxy server element
:param str address: address of element. Can be a single FQDN or comma separated
list of IP addresses
:param list secondary: list of secondary IP addresses
:param str balancing_mode: how to ba... | entailment |
def flush_parent_cache(node):
"""
Flush parent cache will recurse back up the tree and
wipe the cache from each parent node reference on the
given element. This allows the objects to be reused
and a clean way to force the object to update itself
if attributes or methods are referenced after upda... | Flush parent cache will recurse back up the tree and
wipe the cache from each parent node reference on the
given element. This allows the objects to be reused
and a clean way to force the object to update itself
if attributes or methods are referenced after update. | entailment |
def from_meta(node):
"""
Helper method that reolves a routing node to element. Rather than doing
a lookup and fetch, the routing node provides the information to
build the element from meta alone.
:rtype: Element
"""
# Version SMC < 6.4
if 'related_element_type' not in node.data:
... | Helper method that reolves a routing node to element. Rather than doing
a lookup and fetch, the routing node provides the information to
build the element from meta alone.
:rtype: Element | entailment |
def route_level(root, level):
"""
Helper method to recurse the current node and return
the specified routing node level.
"""
def recurse(nodes):
for node in nodes:
if node.level == level:
routing_node.append(node)
else:
recurse(node)
... | Helper method to recurse the current node and return
the specified routing node level. | entailment |
def gateway_by_type(self, type=None, on_network=None): # @ReservedAssignment
"""
Return gateways for the specified node. You can also
specify type to find only gateways of a specific type.
Valid types are: bgp_peering, netlink, ospfv2_area.
:param RoutingNode self: the routing node to check
... | Return gateways for the specified node. You can also
specify type to find only gateways of a specific type.
Valid types are: bgp_peering, netlink, ospfv2_area.
:param RoutingNode self: the routing node to check
:param str type: bgp_peering, netlink, ospfv2_area
:param str on_network: if network... | entailment |
def _which_ip_protocol(element):
"""
Validate the protocol addresses for the element. Most elements can
have an IPv4 or IPv6 address assigned on the same element. This
allows elements to be validated and placed on the right network.
:return: boolean tuple
:rtype: tuple(ipv4, ipv6)
"""
... | Validate the protocol addresses for the element. Most elements can
have an IPv4 or IPv6 address assigned on the same element. This
allows elements to be validated and placed on the right network.
:return: boolean tuple
:rtype: tuple(ipv4, ipv6) | entailment |
def del_invalid_routes(engine, nicids):
"""
Helper method to run through and delete any routes that are tagged
as invalid or to_delete by a list of nicids. Since we could have a
list of routes, iterate from top level engine routing node to avoid
fetch exceptions. Route list should be a list of nicid... | Helper method to run through and delete any routes that are tagged
as invalid or to_delete by a list of nicids. Since we could have a
list of routes, iterate from top level engine routing node to avoid
fetch exceptions. Route list should be a list of nicids as str.
:param list nicids: list of nicid... | entailment |
def related_element_type(self):
"""
.. versionadded:: 0.6.0
Requires SMC version >= 6.4
Related element type defines the 'type' of element at this
routing or antispoofing node level.
:rtype: str
"""
if 'related_element_type' in se... | .. versionadded:: 0.6.0
Requires SMC version >= 6.4
Related element type defines the 'type' of element at this
routing or antispoofing node level.
:rtype: str | entailment |
def as_tree(self, level=0):
"""
Display the routing tree representation in string
format
:rtype: str
"""
ret = '--' * level + repr(self) + '\n'
for routing_node in self:
ret += routing_node.as_tree(level+1)
return ret | Display the routing tree representation in string
format
:rtype: str | entailment |
def get(self, interface_id):
"""
Obtain routing configuration for a specific interface by
ID.
.. note::
If interface is a VLAN, you must use a str to specify the
interface id, such as '3.13' (interface 3, VLAN 13)
:param str,int interface_id: interface i... | Obtain routing configuration for a specific interface by
ID.
.. note::
If interface is a VLAN, you must use a str to specify the
interface id, such as '3.13' (interface 3, VLAN 13)
:param str,int interface_id: interface identifier
:raises InterfaceNotFound: inva... | entailment |
def add_traffic_handler(self, netlink, netlink_gw=None, network=None):
"""
Add a traffic handler to a routing node. A traffic handler can be
either a static netlink or a multilink traffic handler. If ``network``
is not specified and the interface has multiple IP addresses, the
t... | Add a traffic handler to a routing node. A traffic handler can be
either a static netlink or a multilink traffic handler. If ``network``
is not specified and the interface has multiple IP addresses, the
traffic handler will be added to all ipv4 addresses.
Add a pre-defined netl... | entailment |
def add_ospf_area(self, ospf_area, ospf_interface_setting=None, network=None,
communication_mode='NOT_FORCED', unicast_ref=None):
"""
Add OSPF Area to this routing node.
Communication mode specifies how the interface will interact with the
adjacent OSPF environment... | Add OSPF Area to this routing node.
Communication mode specifies how the interface will interact with the
adjacent OSPF environment. Please see SMC API documentation for more
in depth information on each option.
If the interface has multiple networks nested below, all networks
... | entailment |
def add_bgp_peering(self, bgp_peering, external_bgp_peer=None,
network=None):
"""
Add a BGP configuration to this routing interface.
If the interface has multiple ip addresses, all networks will receive
the BGP peering by default unless the ``network`` parameter ... | Add a BGP configuration to this routing interface.
If the interface has multiple ip addresses, all networks will receive
the BGP peering by default unless the ``network`` parameter is
specified.
Example of adding BGP to an interface by ID::
interface = engine.routi... | entailment |
def add_static_route(self, gateway, destination, network=None):
"""
Add a static route to this route table. Destination can be any element
type supported in the routing table such as a Group of network members.
Since a static route gateway needs to be on the same network as the
i... | Add a static route to this route table. Destination can be any element
type supported in the routing table such as a Group of network members.
Since a static route gateway needs to be on the same network as the
interface, provide a value for `network` if an interface has multiple
address... | entailment |
def add_dynamic_gateway(self, networks):
"""
A dynamic gateway object creates a router object that is
attached to a DHCP interface. You can associate networks with
this gateway address to identify networks for routing on this
interface.
::
route = en... | A dynamic gateway object creates a router object that is
attached to a DHCP interface. You can associate networks with
this gateway address to identify networks for routing on this
interface.
::
route = engine.routing.get(0)
route.add_dynamic_gateway([Ne... | entailment |
def _add_gateway_node_on_tunnel(self, routing_node_gateway):
"""
Add a gateway node on a tunnel interface. Tunnel interface elements
are attached to the interface level and not directly nested under
the networks node.
:param RouteNodeGateway routing_node_gateway: routing... | Add a gateway node on a tunnel interface. Tunnel interface elements
are attached to the interface level and not directly nested under
the networks node.
:param RouteNodeGateway routing_node_gateway: routing node gateway instance
:return: Whether a change was made or not
... | entailment |
def _add_gateway_node(self, gw_type, routing_node_gateway, network=None):
"""
Add a gateway node to existing routing tree. Gateways are only added if
they do not already exist. If they do exist, check the destinations of
the existing gateway and add destinations that are not already ther... | Add a gateway node to existing routing tree. Gateways are only added if
they do not already exist. If they do exist, check the destinations of
the existing gateway and add destinations that are not already there.
A current limitation is that if a gateway doesn't exist and the
destination... | entailment |
def remove_route_gateway(self, element, network=None):
"""
Remove a route element by href or Element. Use this if you want to
remove a netlink or a routing element such as BGP or OSPF. Removing
is done from within the routing interface context.
::
interface0 ... | Remove a route element by href or Element. Use this if you want to
remove a netlink or a routing element such as BGP or OSPF. Removing
is done from within the routing interface context.
::
interface0 = engine.routing.get(0)
interface0.remove_route_gateway(StaticN... | entailment |
def add(self, element):
"""
Add an entry to this antispoofing node level.
Entry can be either href or network elements specified
in :py:class:`smc.elements.network`
::
if0 = engine.antispoofing.get(0)
if0.add(Network('foonet'))
:param Element ele... | Add an entry to this antispoofing node level.
Entry can be either href or network elements specified
in :py:class:`smc.elements.network`
::
if0 = engine.antispoofing.get(0)
if0.add(Network('foonet'))
:param Element element: entry to add, i.e. Network('mynetwork'... | entailment |
def remove(self, element):
"""
Remove a specific user added element from the antispoofing tables of
a given interface. This will not remove autogenerated or system level
entries.
:param Element element: element to remove
:return: remove element if it exists and r... | Remove a specific user added element from the antispoofing tables of
a given interface. This will not remove autogenerated or system level
entries.
:param Element element: element to remove
:return: remove element if it exists and return bool
:rtype: bool | entailment |
def create(self, source, destination, gateway_ip, comment=None):
"""
Add a new policy route to the engine.
:param str source: network address with /cidr
:param str destination: network address with /cidr
:param str gateway: IP address, must be on source network
:... | Add a new policy route to the engine.
:param str source: network address with /cidr
:param str destination: network address with /cidr
:param str gateway: IP address, must be on source network
:param str comment: optional comment | entailment |
def delete(self, **kw):
"""
Delete a policy route from the engine. You can delete using a
single field or multiple fields for a more exact match.
Use a keyword argument to delete a route by any valid attribute.
:param kw: use valid Route keyword values to delete by exact... | Delete a policy route from the engine. You can delete using a
single field or multiple fields for a more exact match.
Use a keyword argument to delete a route by any valid attribute.
:param kw: use valid Route keyword values to delete by exact match | entailment |
def create(cls, name, address=None, ipv6_address=None,
secondary=None, comment=None):
"""
Create the host element
:param str name: Name of element
:param str address: ipv4 address of host object (optional if ipv6)
:param str ipv6_address: ipv6 address (optional if... | Create the host element
:param str name: Name of element
:param str address: ipv4 address of host object (optional if ipv6)
:param str ipv6_address: ipv6 address (optional if ipv4)
:param list secondary: secondary ip addresses (optional)
:param str comment: comment (optional)
... | entailment |
def add_secondary(self, address, append_lists=False):
"""
Add secondary IP addresses to this host element. If append_list
is True, then add to existing list. Otherwise overwrite.
:param list address: ip addresses to add in IPv4 or IPv6 format
:param bool append_list: add... | Add secondary IP addresses to this host element. If append_list
is True, then add to existing list. Otherwise overwrite.
:param list address: ip addresses to add in IPv4 or IPv6 format
:param bool append_list: add to existing or overwrite (default: append)
:return: None | entailment |
def create(cls, name, ip_range, comment=None):
"""
Create an AddressRange element
:param str name: Name of element
:param str iprange: iprange of element
:param str comment: comment (optional)
:raises CreateElementFailed: element creation failed with reason
:retu... | Create an AddressRange element
:param str name: Name of element
:param str iprange: iprange of element
:param str comment: comment (optional)
:raises CreateElementFailed: element creation failed with reason
:return: instance with meta
:rtype: AddressRange | entailment |
def create(cls, name, ipv4_network=None, ipv6_network=None,
comment=None):
"""
Create the network element
:param str name: Name of element
:param str ipv4_network: network cidr (optional if ipv6)
:param str ipv6_network: network cidr (optional if ipv4)
:pa... | Create the network element
:param str name: Name of element
:param str ipv4_network: network cidr (optional if ipv6)
:param str ipv6_network: network cidr (optional if ipv4)
:param str comment: comment (optional)
:raises CreateElementFailed: element creation failed with reason
... | entailment |
def build_sub_expression(name, ne_ref=None, operator='union'):
"""
Static method to build and return the proper json for a sub-expression.
A sub-expression would be the grouping of network elements used as a
target match. For example, (network A or network B) would be considered
... | Static method to build and return the proper json for a sub-expression.
A sub-expression would be the grouping of network elements used as a
target match. For example, (network A or network B) would be considered
a sub-expression. This can be used to compound sub-expressions before
calli... | entailment |
def create(cls, name, ne_ref=None, operator='exclusion',
sub_expression=None, comment=None):
"""
Create the expression
:param str name: name of expression
:param list ne_ref: network element references for expression
:param str operator: 'exclusion' (negation), 'u... | Create the expression
:param str name: name of expression
:param list ne_ref: network element references for expression
:param str operator: 'exclusion' (negation), 'union', 'intersection'
(default: exclusion)
:param dict sub_expression: sub expression used
:param... | entailment |
def download(self, filename=None, as_type='zip'):
"""
Download the IPList. List format can be either zip, text or
json. For large lists, it is recommended to use zip encoding.
Filename is required for zip downloads.
:param str filename: Name of file to save to (required for zip)... | Download the IPList. List format can be either zip, text or
json. For large lists, it is recommended to use zip encoding.
Filename is required for zip downloads.
:param str filename: Name of file to save to (required for zip)
:param str as_type: type of format to download in: txt,json,z... | entailment |
def upload(self, filename=None, json=None, as_type='zip'):
"""
Upload an IPList to the SMC. The contents of the upload
are not incremental to what is in the existing IPList.
So if the intent is to add new entries, you should first retrieve
the existing and append to the content, ... | Upload an IPList to the SMC. The contents of the upload
are not incremental to what is in the existing IPList.
So if the intent is to add new entries, you should first retrieve
the existing and append to the content, then upload.
The only upload type that can be done without loading a fi... | entailment |
def update_or_create(cls, append_lists=True, with_status=False, **kwargs):
"""
Update or create an IPList.
:param bool append_lists: append to existing IP List
:param dict kwargs: provide at minimum the name attribute
and optionally match the create constructor value... | Update or create an IPList.
:param bool append_lists: append to existing IP List
:param dict kwargs: provide at minimum the name attribute
and optionally match the create constructor values
:raises FetchElementFailed: Reason for retrieval failure | entailment |
def create(cls, name, iplist=None, comment=None):
"""
Create an IP List. It is also possible to add entries by supplying
a list of IPs/networks, although this is optional. You can also
use upload/download to add to the iplist.
:param str name: name of ip list
:param list... | Create an IP List. It is also possible to add entries by supplying
a list of IPs/networks, although this is optional. You can also
use upload/download to add to the iplist.
:param str name: name of ip list
:param list iplist: list of ipaddress
:param str comment: optional commen... | entailment |
def update_or_create(cls, name, engine, translation_values=None, with_status=False):
"""
Update or create an Alias and it's mappings.
:param str name: name of alias
:param Engine engine: engine to modify alias translation values
:param list(str,Element) translation_value... | Update or create an Alias and it's mappings.
:param str name: name of alias
:param Engine engine: engine to modify alias translation values
:param list(str,Element) translation_values: translation values
as elements. Can be None if you want to unset any existing values
... | entailment |
def _from_engine(cls, data, alias_list):
"""
Return an alias for the engine. The data is dict provided
when calling engine.alias_resolving(). The alias list is
the list of aliases pre-fetched from Alias.objects.all().
This will return an Alias element by taking the alias_ref
... | Return an alias for the engine. The data is dict provided
when calling engine.alias_resolving(). The alias list is
the list of aliases pre-fetched from Alias.objects.all().
This will return an Alias element by taking the alias_ref
and finding the name in the alias list.
... | entailment |
def resolve(self, engine):
"""
Resolve this Alias to a specific value. Specify the
engine by name to find it's value.
::
alias = Alias('$$ Interface ID 0.ip')
alias.resolve('smcpython-fw')
:param str engine: name of engine to resolve value
:rais... | Resolve this Alias to a specific value. Specify the
engine by name to find it's value.
::
alias = Alias('$$ Interface ID 0.ip')
alias.resolve('smcpython-fw')
:param str engine: name of engine to resolve value
:raises ElementNotFound: if alias not found on engin... | entailment |
def fetch_as_element(self, **kw):
"""
Fetch the blacklist and return as an instance of Element.
:return: generator returning element instances
:rtype: BlacklistEntry
"""
clone = self.copy()
# Replace all filters with a combined filter
bldata = Tex... | Fetch the blacklist and return as an instance of Element.
:return: generator returning element instances
:rtype: BlacklistEntry | entailment |
def source_ports(self):
"""
Source ports for this blacklist entry. If no ports are specified (i.e. ALL
ports), 'ANY' is returned.
:rtype: str
"""
start_port = self.blacklist.get('BlacklistEntrySourcePort')
if start_port is not None:
return '{}... | Source ports for this blacklist entry. If no ports are specified (i.e. ALL
ports), 'ANY' is returned.
:rtype: str | entailment |
def dest_ports(self):
"""
Destination ports for this blacklist entry. If no ports are specified,
'ANY' is returned.
:rtype: str
"""
start_port = self.blacklist.get('BlacklistEntryDestinationPort')
if start_port is not None:
return '{}-{}'.form... | Destination ports for this blacklist entry. If no ports are specified,
'ANY' is returned.
:rtype: str | entailment |
def name(self):
"""
Name attribute of rule element
"""
return self._meta.name if self._meta.name else \
'Rule @%s' % self.tag | Name attribute of rule element | entailment |
def move_rule_after(self, other_rule):
"""
Add this rule after another. This process will make a copy of
the existing rule and add after the specified rule. If this
raises an exception, processing is stopped. Otherwise the original
rule is then deleted.
You must re-retrie... | Add this rule after another. This process will make a copy of
the existing rule and add after the specified rule. If this
raises an exception, processing is stopped. Otherwise the original
rule is then deleted.
You must re-retrieve the new element after running this operation
as ... | entailment |
def create_rule_section(self, name, add_pos=None, after=None, before=None):
"""
Create a rule section in a Firewall Policy. To specify a specific numbering
position for the rule section, use the `add_pos` field. If no position or
before/after is specified, the rule section will be placed... | Create a rule section in a Firewall Policy. To specify a specific numbering
position for the rule section, use the `add_pos` field. If no position or
before/after is specified, the rule section will be placed at the top which
will encapsulate all rules below.
Create a rule section for th... | entailment |
def create(self, name, sources=None, destinations=None,
services=None, action='allow', log_options=None,
authentication_options=None, connection_tracking=None,
is_disabled=False, vpn_policy=None, mobile_vpn=False,
add_pos=None, after=None, before=None,
... | Create a layer 3 firewall rule
:param str name: name of rule
:param sources: source/s for rule
:type sources: list[str, Element]
:param destinations: destination/s for rule
:type destinations: list[str, Element]
:param services: service/s for rule
:type services:... | entailment |
def create(self, name, sources=None, destinations=None,
services=None, action='allow', is_disabled=False,
logical_interfaces=None, add_pos=None,
after=None, before=None, comment=None):
"""
Create an Ethernet rule
:param str name: name of rule
... | Create an Ethernet rule
:param str name: name of rule
:param sources: source/s for rule
:type sources: list[str, Element]
:param destinations: destination/s for rule
:type destinations: list[str, Element]
:param services: service/s for rule
:type services: list[s... | entailment |
def _severity_by_name(name):
"""
Return the severity integer value by it's name. If not found,
return 'information'.
:rtype: int
"""
for intvalue, sevname in SEVERITY.items():
if name.lower() == sevname:
return intvalue
return 1 | Return the severity integer value by it's name. If not found,
return 'information'.
:rtype: int | entailment |
def situation_parameters(self):
"""
Situation parameters defining detection logic for the context.
This will return a list of SituationParameter indicating how
the detection is made, i.e. regular expression, integer value,
etc.
:rtype: list(SituationParameter)
... | Situation parameters defining detection logic for the context.
This will return a list of SituationParameter indicating how
the detection is made, i.e. regular expression, integer value,
etc.
:rtype: list(SituationParameter) | entailment |
def parameter_values(self):
"""
Parameter values for this inspection situation. This correlate to
the the situation_context.
:rtype: list(SituationParameterValue)
"""
for param in self.data.get('parameter_values', []):
cache = ElementCache(data=self.m... | Parameter values for this inspection situation. This correlate to
the the situation_context.
:rtype: list(SituationParameterValue) | entailment |
def create(cls, name, situation_context, attacker=None, target=None,
severity='information', situation_type=None, description=None,
comment=None):
"""
Create an inspection situation.
:param str name: name of the situation
:param InspectionSituationC... | Create an inspection situation.
:param str name: name of the situation
:param InspectionSituationContext situation_context: The situation
context type used to define this situation. Identifies the proper
parameter that identifies how the situation is defined (i.e. regex,... | entailment |
def create_regular_expression(self, regexp):
"""
Create a regular expression for this inspection situation
context. The inspection situation must be using an inspection
context that supports regex.
:param str regexp: regular expression string
:raises CreateElemen... | Create a regular expression for this inspection situation
context. The inspection situation must be using an inspection
context that supports regex.
:param str regexp: regular expression string
:raises CreateElementFailed: failed to modify the situation | entailment |
def download(self, filename=None):
"""
Download snapshot to filename
:param str filename: fully qualified path including filename .zip
:raises EngineCommandFailed: IOError occurred downloading snapshot
:return: None
"""
if not filename:
filename = '{}... | Download snapshot to filename
:param str filename: fully qualified path including filename .zip
:raises EngineCommandFailed: IOError occurred downloading snapshot
:return: None | entailment |
def upload(self, engine, timeout=5, wait_for_finish=False, **kw):
"""
Upload policy to specific device. Using wait for finish
returns a poller thread for monitoring progress::
policy = FirewallPolicy('_NSX_Master_Default')
poller = policy.upload('myfirewall', wait_for_fi... | Upload policy to specific device. Using wait for finish
returns a poller thread for monitoring progress::
policy = FirewallPolicy('_NSX_Master_Default')
poller = policy.upload('myfirewall', wait_for_finish=True)
while not poller.done():
poller.wait(3)
... | entailment |
def search_rule(self, search):
"""
Search a rule for a rule tag or name value
Result will be the meta data for rule (name, href, type)
Searching for a rule in specific policy::
f = FirewallPolicy(policy)
search = f.search_rule(searchable)
:param str sea... | Search a rule for a rule tag or name value
Result will be the meta data for rule (name, href, type)
Searching for a rule in specific policy::
f = FirewallPolicy(policy)
search = f.search_rule(searchable)
:param str search: search string
:return: rule elements m... | entailment |
def rule_counters(self, engine, duration_type='one_week',
duration=0, start_time=0):
"""
.. versionadded:: 0.5.6
Obtain rule counters for this policy. Requires SMC >= 6.2
Rule counters can be obtained for a given policy and duration for
those counters can... | .. versionadded:: 0.5.6
Obtain rule counters for this policy. Requires SMC >= 6.2
Rule counters can be obtained for a given policy and duration for
those counters can be provided in duration_type. A custom start
range can also be provided.
:param Engine engine: the ... | entailment |
def create(cls, name, nat=False, mobile_vpn_toplogy_mode=None,
vpn_profile=None):
"""
Create a new policy based VPN
:param name: name of vpn policy
:param bool nat: whether to apply NAT to the VPN (default False)
:param mobile_vpn_toplogy_mode: whether to allow re... | Create a new policy based VPN
:param name: name of vpn policy
:param bool nat: whether to apply NAT to the VPN (default False)
:param mobile_vpn_toplogy_mode: whether to allow remote vpn
:param VPNProfile vpn_profile: reference to VPN profile, or uses default
:rtype: PolicyVPN | entailment |
def enable_disable_nat(self):
"""
Enable or disable NAT on this policy. If NAT is disabled, it
will be enabled and vice versa.
:return: None
"""
if self.nat:
self.data['nat'] = False
else:
self.data['nat'] = True | Enable or disable NAT on this policy. If NAT is disabled, it
will be enabled and vice versa.
:return: None | entailment |
def add_mobile_gateway(self, gateway):
"""
Add a mobile VPN gateway to this policy VPN.
Example of adding or removing a mobile VPN gateway::
policy_vpn = PolicyVPN('myvpn')
policy_vpn.open()
policy_vpn.add_mobile_vpn_gateway(ExternalGateway('extgw3')... | Add a mobile VPN gateway to this policy VPN.
Example of adding or removing a mobile VPN gateway::
policy_vpn = PolicyVPN('myvpn')
policy_vpn.open()
policy_vpn.add_mobile_vpn_gateway(ExternalGateway('extgw3'))
for mobile_gateway in policy_vpn... | entailment |
def add_internal_gateway_to_vpn(internal_gateway_href, vpn_policy,
vpn_role='central'):
"""
Add an internal gateway (managed engine node) to a VPN policy
based on the internal gateway href.
:param str internal_gateway_href: href for engine internal gw... | Add an internal gateway (managed engine node) to a VPN policy
based on the internal gateway href.
:param str internal_gateway_href: href for engine internal gw
:param str vpn_policy: name of vpn policy
:param str vpn_role: central|satellite
:return: True for success
:rty... | entailment |
def enable_disable(self):
"""
Enable or disable the tunnel link between endpoints.
:raises UpdateElementFailed: failed with reason
:return: None
"""
if self.enabled:
self.update(enabled=False)
else:
self.update(enabled=True) | Enable or disable the tunnel link between endpoints.
:raises UpdateElementFailed: failed with reason
:return: None | entailment |
def prepare_blacklist(src, dst, duration=3600, src_port1=None,
src_port2=None, src_proto='predefined_tcp',
dst_port1=None, dst_port2=None,
dst_proto='predefined_tcp'):
"""
Create a blacklist entry.
A blacklist can be added directly from... | Create a blacklist entry.
A blacklist can be added directly from the engine node, or from
the system context. If submitting from the system context, it becomes
a global blacklist. This will return the properly formatted json
to submit.
:param src: source address, with cidr, i.e. 10.10.10.1... | entailment |
def add_element(self, element):
"""
Element can be href or type :py:class:`smc.base.model.Element`
::
>>> from smc.elements.other import Category
>>> category = Category('foo')
>>> category.add_element(Host('kali'))
:param str,Element element: elemen... | Element can be href or type :py:class:`smc.base.model.Element`
::
>>> from smc.elements.other import Category
>>> category = Category('foo')
>>> category.add_element(Host('kali'))
:param str,Element element: element to add to tag
:raises: ModificationFailed:... | entailment |
def add_category_tag(self, tags, append_lists=True):
"""
Add this category to a category tag (group). This provides drop down
filters in the SMC UI by category tag.
:param list tags: category tag by name
:param bool append_lists: append to existing tags or overwrite
... | Add this category to a category tag (group). This provides drop down
filters in the SMC UI by category tag.
:param list tags: category tag by name
:param bool append_lists: append to existing tags or overwrite
default: append)
:type tags: list(str)
:return: N... | entailment |
def remove_category(self, categories):
"""
Remove a category from this Category Tag (group).
:param list categories: categories to remove
:type categories: list(str,Element)
:return: None
"""
categories = element_resolver(categories)
diff = [categ... | Remove a category from this Category Tag (group).
:param list categories: categories to remove
:type categories: list(str,Element)
:return: None | entailment |
def add_entry(self, src, dst, duration=3600, src_port1=None,
src_port2=None, src_proto='predefined_tcp',
dst_port1=None, dst_port2=None,
dst_proto='predefined_tcp'):
"""
Create a blacklist entry.
A blacklist can be added directly fr... | Create a blacklist entry.
A blacklist can be added directly from the engine node, or from
the system context. If submitting from the system context, it becomes
a global blacklist. This will return the properly formatted json
to submit.
:param src: source address... | entailment |
def update_or_create(cls, append_lists=True, with_status=False,
remove_members=False, **kwargs):
"""
Update or create group entries. If the group exists, the members
will be updated. Set append_lists=True to add new members to
the list, or False to reset the list... | Update or create group entries. If the group exists, the members
will be updated. Set append_lists=True to add new members to
the list, or False to reset the list to the provided members. If
setting remove_members, this will override append_lists if set.
:param bool append_lists... | entailment |
def update_members(self, members, append_lists=False, remove_members=False):
"""
Update group members with member list. Set append=True
to append to existing members, or append=False to overwrite.
:param list members: new members for group by href or Element
:type members: list[... | Update group members with member list. Set append=True
to append to existing members, or append=False to overwrite.
:param list members: new members for group by href or Element
:type members: list[str, Element]
:param bool append_lists: whether to append
:param bool remove_memb... | entailment |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.