output stringlengths 1 928k | instruction stringlengths 7 928k | system stringlengths 0 104k |
|---|---|---|
def create(cls, name, mgmt_ip, mgmt_network,
mgmt_interface=0,
log_server_ref=None,
default_nat=False,
reverse_connection=False,
domain_server_address=None, zone_ref=None,
enable_antivirus=False, enable_gti=False,
l... | Write a Python 3 function that can
create a new NGFW firewall with management interfaces and DNS. | As a Python code translator, you convert algorithms and pseudocode into Python. |
def create_dynamic(cls, name, interface_id,
dynamic_index=1,
reverse_connection=True,
automatic_default_route=True,
domain_server_address=None,
loopback_ndi='127.0.0.1',
location_ref... | Write a Python 3 script to
create a single firewall with only a single DHCP interface. | As a Python code analyst, you investigate and solve complex coding mysteries |
Creates a new single Layer 2 firewall with management interface and inline interface. | How would you explain what the following Python 3 function does
def create(cls, name, mgmt_ip, mgmt_network,
mgmt_interface=0,
inline_interface='1-2',
logical_interface='default_eth',
log_server_ref=None,
domain_server_address=None, zone_ref=Non... | As a Python code analyst, you investigate and solve complex coding mysteries |
def create(cls, name, master_engine, virtual_resource,
interfaces, default_nat=False, outgoing_intf=0,
domain_server_address=None, enable_ospf=False,
ospf_profile=None, comment=None, **kw):
"""
Create a Layer3Virtual engine for a Master Engine. Provide interf... | Can you create a Python 3 function that
creates a Layer3 Virtual Engine for a Master Engine. | As a Python code analyst, you investigate and solve complex coding mysteries |
Creates a firewall cluster with the given interfaces. | Can you tell what is the following Python 3 function doing
def create_bulk(cls, name, interfaces=None, nodes=2, cluster_mode='balancing',
primary_mgt=None, backup_mgt=None, primary_heartbeat=None,
log_server_ref=None, domain_server_address=None, location_ref=None,
default_nat=False, ... | As a Python code analyst, you investigate and solve complex coding mysteries |
Create a new firewall cluster with the given parameters. | Can you tell what is the following Python 3 function doing
def create(cls, name, cluster_virtual, network_value, macaddress,
interface_id, nodes, vlan_id=None, cluster_mode='balancing',
backup_mgt=None, primary_heartbeat=None, log_server_ref=None,
domain_server_address=None,... | As a Python code composer, you craft elegant and concise scripts. |
Create a Master Engine with management interface. | Explain what the following Python 3 code does
def create(cls, name, master_type, mgmt_ip, mgmt_network,
mgmt_interface=0,
log_server_ref=None, zone_ref=None,
domain_server_address=None, enable_gti=False,
enable_antivirus=False, comment=None):
"""
... | As a python code expert, you are capable of creating scripts from specifications. |
def create(cls, name, master_type, macaddress, nodes, mgmt_interface=0,
log_server_ref=None, domain_server_address=None, enable_gti=False,
enable_antivirus=False, comment=None, **kw):
"""
Create Master Engine Cluster
:param str name: name of master engine engine
:param s... | Write a Python 3 function that can
create Master Engine Cluster. | As a Python code analyst, you investigate and solve complex coding mysteries |
def set_stream_logger(log_level=logging.DEBUG, format_string=None, logger_name='smc'):
"""
Stream logger convenience function to log to console
:param int log_level: A log level as specified in the `logging` module
:param str format_string: Optional format string as specified in the
`log... | Implement a function in Python 3 to
stream logger convenience function to log to console :param int log_level: A log level as specified in the `logging` module :param str format_string: Optional format string as specified in the `logging` module | You are a Python code generator, capable of creating scripts from specifications. |
This function will quickly configure any level of logging
to a file. | Make a summary of the following Python 3 code
def set_file_logger(path, log_level=logging.DEBUG, format_string=None, logger_name='smc'):
if format_string is None:
format_string = LOG_FORMAT
log = logging.getLogger(logger_name)
log.setLevel(log_level)
# create file handler and set level
... | You are a Python code architect, reviewing and designing scalable and efficient code |
def create(cls, name, ldap_server, isdefault=False, auth_method=None, comment=None):
"""
Create an External LDAP user domain. These are used as containers for
retrieving user and groups from the configured LDAP server/s. If you
have multiple authentication methods supported for your LDAP... | Write a Python 3 function that can
create an External LDAP user domain. | You are a Python code analyst, evaluating scripts for potential improvements. |
Create an internal user. | Can you tell what is the following Python 3 function doing
def create(cls, name, user_group=None, activation_date=None,
expiration_date=None, comment=None):
"""
Create an internal user.
Add a user example::
InternalUser.create(name='goog', comment='my comment')
... | As a Python code composer, you craft elegant and concise scripts. |
Create an internal group. | How would you explain what the following Python 3 function does
def create(cls, name, member=None, comment=None):
json={'name': name,
'unique_id': 'cn={},{}'.format(name, InternalUserDomain.user_dn),
'comment': comment}
if member:
json.update(member=element_resolv... | As a Python code analyst, you investigate and solve complex coding mysteries |
def get_all_loopbacks(engine):
"""
Get all loopback interfaces for a given engine
"""
data = []
if 'fw_cluster' in engine.type:
for cvi in engine.data.get('loopback_cluster_virtual_interface', []):
data.append(
LoopbackClusterInterface(cvi, engine))
for node ... | Write a Python 3 function for
getting all loopback interfaces for a given engine | You are a Python code generator, capable of creating scripts from specifications. |
Get a loopback address by it s address. | Can you tell what is the following Python 3 function doing
def get(self, address):
loopback = super(LoopbackCollection, self).get(address=address)
if loopback:
return loopback
raise InterfaceNotFound('Loopback address specified was not found') | As a Python code translator, you convert algorithms and pseudocode into Python. |
Add single physical interface with interface_id. | Can you tell what is the following Python 3 function doing
def add(self, interface_id, virtual_mapping=None,
virtual_resource_name=None, zone_ref=None, comment=None):
"""
Add single physical interface with interface_id. Use other methods
to fully add an interface configuration based ... | As a Python code composer, you craft elegant and concise scripts. |
def add_capture_interface(self, interface_id, logical_interface_ref,
inspect_unspecified_vlans=True, zone_ref=None, comment=None):
"""
Add a capture interface. Capture interfaces are supported on
Layer 2 FW and IPS engines.
..note::
Capture interface are ... | Can you implement a function in Python 3 that
adds a capture interface to the local cache. | As a Python code translator, you convert algorithms and pseudocode into Python. |
def add_layer3_interface(self, interface_id, address, network_value,
zone_ref=None, comment=None, **kw):
"""
Add a layer 3 interface on a non-clustered engine.
For Layer 2 FW and IPS engines, this interface type represents
a layer 3 routed (node dedicated) in... | Create a Python 3 function to
add a layer 3 interface on a non - clustered engine. | You are a Python code architect, reviewing and designing scalable and efficient code |
This method adds a Layer 3 VLAN interface to the specified virtual resource. | Can you generate the documentation for the following Python 3 function
def add_layer3_vlan_interface(self, interface_id, vlan_id, address=None,
network_value=None, virtual_mapping=None, virtual_resource_name=None,
zone_ref=None, comment=None, **kw):
"""
Add a Layer 3 VLAN interface. Opti... | You are a Python code architect, reviewing and designing scalable and efficient code |
def add_layer3_cluster_interface(self, interface_id, cluster_virtual=None,
network_value=None, macaddress=None, nodes=None, cvi_mode='packetdispatch',
zone_ref=None, comment=None, **kw):
"""
Add cluster virtual interface. A "CVI" interface is used as a VIP
address for clu... | How would you code a function in Python 3 to
add a cluster virtual interface to the NDI s or NDI s node. | You are a Python code architect, reviewing and designing scalable and efficient code |
Add a VLAN to a firewall cluster. | Can you generate a brief explanation for the following Python 3 code
def add_layer3_vlan_cluster_interface(self, interface_id, vlan_id,
nodes=None, cluster_virtual=None, network_value=None, macaddress=None,
cvi_mode='packetdispatch', zone_ref=None, comment=None, **kw):
"""
Add IP... | As a Python code translator, you convert algorithms and pseudocode into Python. |
This method adds an inline interface pair. This method is only for IPS or L2FW engine. | Can you generate a brief explanation for the following Python 3 code
def add_inline_interface(self, interface_id, second_interface_id,
logical_interface_ref=None, vlan_id=None, second_vlan_id=None, zone_ref=None,
second_zone_ref=None, failure_mode='normal', comment=None, **kw):
"""
Add a... | You are a Python code generator, capable of creating scripts from specifications. |
Adds an inline IPS interface to the inline IPS cache. | Given the following Python 3 function, write the documentation
def add_inline_ips_interface(self, interface_id, second_interface_id,
logical_interface_ref=None, vlan_id=None, failure_mode='normal',
zone_ref=None, second_zone_ref=None, comment=None):
"""
.. versionadded:: 0.5.6
... | As a Python code composer, you craft elegant and concise scripts. |
Adds an inline L2 FW interface to the local cache. | Here you have a function in Python 3, explain what it does
def add_inline_l2fw_interface(self, interface_id, second_interface_id,
logical_interface_ref=None, vlan_id=None, zone_ref=None,
second_zone_ref=None, comment=None):
"""
.. versionadded:: 0.5.6
Requires NGFW en... | As a python code expert, you are capable of creating scripts from specifications. |
Adds a DHCP interface on a single FW. | Can you generate the documentation for the following Python 3 function
def add_dhcp_interface(self, interface_id, dynamic_index, zone_ref=None,
vlan_id=None, comment=None):
"""
Add a DHCP interface on a single FW
:param int interface_id: interface id
:param int dynamic_index... | As a Python code composer, you craft elegant and concise scripts. |
def add_cluster_interface_on_master_engine(self, interface_id, macaddress,
nodes, zone_ref=None, vlan_id=None, comment=None):
"""
Add a cluster address specific to a master engine. Master engine
clusters will not use "CVI" interfaces like normal layer 3 FW clusters,
instead e... | Create a Python 3 function for
adding a cluster interface to a master engine. | As a python code expert, you are capable of creating scripts from specifications. |
Creates a tunnel interface for a virtual engine. | How would you explain what the following Python 3 function does
def add_tunnel_interface(self, interface_id, address, network_value,
zone_ref=None, comment=None):
"""
Creates a tunnel interface for a virtual engine.
:param str,int interface_id: the tunnel id for the... | You are a Python code analyst, evaluating scripts for potential improvements. |
Loads the SMC URL API KEY and SSL certificate from the environment variables. | How would you explain what the following Python 3 function does
def load_from_environ():
try:
from urllib.parse import urlparse
except ImportError:
from urlparse import urlparse
smc_address = os.environ.get('SMC_ADDRESS', '')
smc_apikey = os.environ.get('SMC_API_KEY', '')
smc_ti... | As a python code expert, you are capable of creating scripts from specifications. |
Load the SMC configuration file from the user home directory. | Make a summary of the following Python 3 code
def load_from_file(alt_filepath=None):
required = ['smc_address', 'smc_apikey']
bool_type = ['smc_ssl', 'verify_ssl', 'retry_on_busy'] # boolean option flag
option_names = ['smc_port',
'api_version',
'smc_ssl',
... | As a Python code analyst, you investigate and solve complex coding mysteries |
def transform_login(config):
"""
Parse login data as dict. Called from load_from_file and
also can be used when collecting information from other
sources as well.
:param dict data: data representing the valid key/value pairs
from smcrc
:return: dict dict of settings that can be sent ... | How would you code a function in Python 3 to
parse the login data as dict. Called from load_from_file and can be used to collect information from other modules. | As a Python code composer, you craft elegant and concise scripts. |
This filter adds specified networks to a filter to check
for inclusion. | Explain what the following Python 3 code does
def within_ipv4_network(self, field, values):
v = ['ipv4_net("%s")' % net for net in values]
self.update_filter('{} IN union({})'.format(field, ','.join(v))) | As a Python code translator, you convert algorithms and pseudocode into Python. |
Add an IN range network filter for relevant address fields. | Make a summary of the following Python 3 code
def within_ipv4_range(self, field, values):
v = ['ipv4("%s")' % part
for iprange in values
for part in iprange.split('-')]
self.update_filter('{} IN range({})'.format(field, ','.join(v))) | As a Python code composer, you craft elegant and concise scripts. |
An exact IPv4 match on relevant address fields. | How would you explain what the following Python 3 function does
def exact_ipv4_match(self, field, values):
if len(values) > 1:
v = ['ipv4("%s")' % ip for ip in values]
value='{} IN union({})'.format(field, ','.join(v))
else:
value='{} == ipv4("{}")'.format(field, valu... | As a Python code analyst, you investigate and solve complex coding mysteries |
def download(self, timeout=5, wait_for_finish=False):
"""
Download Package or Engine Update
:param int timeout: timeout between queries
:raises TaskRunFailed: failure during task status
:rtype: TaskOperationPoller
"""
return Task.execute(self, 'download', timeout... | Write a Python 3 function for
downloading the current version of the package or engine. | As a Python code composer, you craft elegant and concise scripts. |
def activate(self, resource=None, timeout=3, wait_for_finish=False):
"""
Activate this package on the SMC
:param list resource: node href's to activate on. Resource is only
required for software upgrades
:param int timeout: timeout between queries
:raises TaskRunF... | Can you implement a function in Python 3 that
activates this package on the SMC OID. | As a Python code composer, you craft elegant and concise scripts. |
Return all entries in the cache | Can you tell what is the following Python 3 function doing
def all(self):
attribute = self._attr[0]
return self.profile.data.get(attribute, []) | You are a Python code architect, reviewing and designing scalable and efficient code |
Create a Sandbox Service element | Explain what the following Python 3 code does
def create(cls, name, sandbox_data_center, portal_username=None, comment=None):
json = {
'name': name,
'sandbox_data_center': element_resolver(sandbox_data_center),
'portal_username': portal_username if portal_username else '',
... | As a python code expert, you are capable of creating scripts from specifications. |
def available_api_versions(base_url, timeout=10, verify=True):
"""
Get all available API versions for this SMC
:return version numbers
:rtype: list
"""
try:
r = requests.get('%s/api' % base_url, timeout=timeout,
verify=verify) # no session required
... | Write a Python 3 script to
get all available API versions for this SMC. | You are a Python code generator, capable of creating scripts from specifications. |
Get the API version specified or resolve the latest version | Can you generate a brief explanation for the following Python 3 code
def get_api_version(base_url, api_version=None, timeout=10, verify=True):
versions = available_api_versions(base_url, timeout, verify)
newest_version = max([float(i) for i in versions])
if api_version is None: # Use latest
ap... | As a python code expert, you are capable of creating scripts from specifications. |
def create(cls, sessions=None):
"""
A session manager will be mounted to the SMCRequest class through
this classmethod. If there is already an existing SessionManager,
that is returned instead.
:param list sessions: a list of Session objects
:rtype: SessionManage... | Create a Python 3 function for
creating a new session manager for the specified list of Session objects. | As a python code expert, you are capable of creating scripts from specifications. |
Returns the default session for the current node. | Make a summary of the following Python 3 code
def get_default_session(self):
if self._sessions:
return self.get_session(next(iter(self._sessions)))
return self.get_session() | As a Python code analyst, you investigate and solve complex coding mysteries |
Returns the session manager for this session
| Can you tell what is the following Python 3 function doing
def manager(self):
manager = SMCRequest._session_manager if not self._manager \
else self._manager
if not manager:
raise SessionManagerNotFound('A session manager was not found. '
'This is an initializatio... | As a Python code translator, you convert algorithms and pseudocode into Python. |
Returns the session ID in header type format. | Given the following Python 3 function, write the documentation
def session_id(self):
return None if not self.session or 'JSESSIONID' not in \
self.session.cookies else 'JSESSIONID={}'.format(
self.session.cookies['JSESSIONID']) | As a python code expert, you are capable of creating scripts from specifications. |
def name(self):
"""
Return the administrator name for this session. Can be None if
the session has not yet been established.
.. note:: The administrator name was introduced in SMC version
6.4. Previous versions will show the unique session
identifier for ... | Write a Python 3 script for
returning the administrator name for this session. Can be None | As a Python code translator, you convert algorithms and pseudocode into Python. |
Returns the currently logged on API Client user element. Requires SMC version >= 6. 4
Requires SMC version >= 6. 4
Requires SMC version >= 6. 4
Returns None | Here you have a function in Python 3, explain what it does
def current_user(self):
if self.session:
try:
response = self.session.get(self.entry_points.get('current_user'))
if response.status_code in (200, 201):
admin_href=response.json().get('value... | As a Python code analyst, you investigate and solve complex coding mysteries |
Login to the SMC API and retrieve a valid session. | Explain what the following Python 3 code does
def login(self, url=None, api_key=None, login=None, pwd=None,
api_version=None, timeout=None, verify=True, alt_filepath=None,
domain=None, **kwargs):
"""
Login to SMC API and retrieve a valid session.
Sessions use a pool conne... | You are a Python code analyst, evaluating scripts for potential improvements. |
Builds the authentication request to SMC
AttributeNames | Make a summary of the following Python 3 code
def _build_auth_request(self, verify=False, **kwargs):
json = {
'domain': self.domain
}
credential = self.credential
params = {}
if credential.provider_name.startswith('lms'):
params = dict(
... | You are a Python code analyst, evaluating scripts for potential improvements. |
def _get_session(self, request):
"""
Authenticate the request dict
:param dict request: request dict built from user input
:raises SMCConnectionError: failure to connect
:return: python requests session
:rtype: requests.Session
"""
_session = requ... | Create a Python 3 function to
authenticate the request dict and return the session object | As a python code expert, you are capable of creating scripts from specifications. |
Logout session from SMC
| Explain what the following Python 3 code does
def logout(self):
if not self.session:
self.manager._deregister(self)
return
try:
r = self.session.put(self.entry_points.get('logout'))
if r.status_code == 204:
logger.info('Logged out admin: %s... | You are a Python code analyst, evaluating scripts for potential improvements. |
Refresh session on 401. | Explain what the following Python 3 code does
def refresh(self):
if self.session and self.session_id: # Did session timeout?
logger.info('Session timed out, will try obtaining a new session using '
'previously saved credential information.')
self.logout() # Force log out ... | You are a Python code generator, capable of creating scripts from specifications. |
Switches the user to a specific domain. | Given the following Python 3 function, write the documentation
def switch_domain(self, domain):
if self.domain != domain:
if self in self.manager: # Exit current domain
self.logout()
logger.info('Switching to domain: %r and creating new session', domain)
param... | As a Python code composer, you craft elegant and concise scripts. |
def set_retry_on_busy(self, total=5, backoff_factor=0.1, status_forcelist=None, **kwargs):
"""
Mount a custom retry object on the current session that allows service level
retries when the SMC might reply with a Service Unavailable (503) message.
This can be possible in larger environmen... | How would you code a function in Python 3 to
mount a custom retry object on the current session that allows service level retries when the SMC replys with a Service Unavailable message. | As a Python code analyst, you investigate and solve complex coding mysteries |
Get the log schema for this SMC version. | Can you generate the documentation for the following Python 3 function
def _get_log_schema(self):
if self.session and self.session_id:
schema = '{}/{}/monitoring/log/schemas'.format(self.url, self.api_version)
response = self.session.get(
url=schema,
... | As a python code expert, you are capable of creating scripts from specifications. |
Returns True if this session has valid credentials. | Given the following Python 3 function, write the documentation
def has_credentials(self):
return all([
getattr(self, '_%s' % field, None) is not None
for field in self.CredentialMap.get(self.provider_name)]) | As a Python code translator, you convert algorithms and pseudocode into Python. |
def add(self, data):
"""
Add a single entry to field.
Entries can be added to a rule using the href of the element
or by loading the element directly. Element should be of type
:py:mod:`smc.elements.network`.
After modifying rule, call :py:meth:`~.save`.
Example... | How would you code a function in Python 3 to
add a single entry to the field. | As a Python code analyst, you investigate and solve complex coding mysteries |
def add_many(self, data):
"""
Add multiple entries to field. Entries should be list format.
Entries can be of types relavant to the field type. For example,
for source and destination fields, elements may be of type
:py:mod:`smc.elements.network` or be the elements direct href,
... | Write a Python 3 script for
adding multiple entries to the field. | You are a Python code generator, capable of creating scripts from specifications. |
Update the field with a list of provided elements but only if the values are different. | Here you have a function in Python 3, explain what it does
def update_field(self, elements):
changed = False
if isinstance(elements, list):
if self.is_any or self.is_none:
self.add_many(elements)
changed = True
else:
_elements = ele... | You are a Python code generator, capable of creating scripts from specifications. |
Return all elements without resolving to smc. elements. network or smc. elements. service. Just raw representation as href. | Can you generate the documentation for the following Python 3 function
def all_as_href(self):
if not self.is_any and not self.is_none:
return [element for element in self.get(self.typeof)]
return [] | You are a Python code architect, reviewing and designing scalable and efficient code |
Return all elements of this rule. | Make a summary of the following Python 3 code
def all(self):
if not self.is_any and not self.is_none:
return [Element.from_href(href)
for href in self.get(self.typeof)]
return [] | You are a Python code analyst, evaluating scripts for potential improvements. |
def create(cls, name, user=None, network_element=None, domain_name=None,
zone=None, executable=None):
"""
Create a match expression
:param str name: name of match expression
:param str user: name of user or user group
:param Element network_element: valid network ... | Write a Python 3 script for
creating a match expression with the specified name user network element domain name and zone. | You are a Python code architect, reviewing and designing scalable and efficient code |
def http_proxy(self, proxy, proxy_port, user=None, password=None):
"""
.. versionadded:: 0.5.7
Requires SMC and engine version >= 6.4
Set http proxy settings for Antivirus updates.
:param str proxy: proxy IP address
:param str,int proxy_port: proxy p... | Can you write a function in Python 3 where it
sets http proxy settings for Antivirus updates. | You are a Python code generator, capable of creating scripts from specifications. |
def enable(self):
"""
Enable antivirus on the engine
"""
self.update(antivirus_enabled=True,
virus_mirror='update.nai.com/Products/CommonUpdater' if \
not self.get('virus_mirror') else self.virus_mirror,
antivirus_update_tim... | Create a Python 3 function to
enable antivirus on the engine. | You are a Python code generator, capable of creating scripts from specifications. |
def enable(self, http_proxy=None):
"""
Enable URL Filtering on the engine. If proxy servers
are needed, provide a list of HTTPProxy elements.
:param http_proxy: list of proxies for GTI connections
:type http_proxy: list(str,HttpProxy)
"""
self.update(ts_e... | Write a Python 3 function for
enabling URL Filtering on the engine. | As a Python code translator, you convert algorithms and pseudocode into Python. |
def status(self):
"""
Status of sandbox on this engine
:rtype: bool
"""
if 'sandbox_type' in self.engine.data:
if self.engine.sandbox_type == 'none':
return False
return True
return False | Write a Python 3 script to
return True if the user is in sandbox mode False otherwise. | As a python code expert, you are capable of creating scripts from specifications. |
Disable the sandbox on this engine. | Here you have a function in Python 3, explain what it does
def disable(self):
self.engine.data.update(sandbox_type='none')
self.pop('cloud_sandbox_settings', None) #pre-6.3
self.pop('sandbox_settings', None) | As a python code expert, you are capable of creating scripts from specifications. |
def enable(self, license_key, license_token,
sandbox_type='cloud_sandbox', service='Automatic',
http_proxy=None, sandbox_data_center='Automatic'):
"""
Enable sandbox on this engine. Provide a valid license key
and license token obtained from your engine licensing.
... | Write a Python 3 function for
enabling sandbox on this engine. | As a Python code analyst, you investigate and solve complex coding mysteries |
Adds a list of TLSServerCredential to this engine. | How would you explain what the following Python 3 function does
def add_tls_credential(self, credentials):
for cred in credentials:
href = element_resolver(cred)
if href not in self.engine.server_credential:
self.engine.server_credential.append(href) | As a python code expert, you are capable of creating scripts from specifications. |
def remove_tls_credential(self, credentials):
"""
Remove a list of TLSServerCredentials on this engine.
:param credentials: list of credentials to remove from the
engine
:type credentials: list(str,TLSServerCredential)
:return: None
"""
fo... | Can you create a Python 3 function that
removes a list of TLSServerCredentials from the engine. | As a Python code analyst, you investigate and solve complex coding mysteries |
Sets the policy validation settings. This is used when policy based
tasks are created and validate_policy is set to True. | Can you generate the documentation for the following Python 3 function
def policy_validation_settings(**kwargs):
validation_settings = {
'configuration_validation_for_alert_chain': False,
'duplicate_rule_check_settings': False,
'empty_rule_check_settings': True,
'empty_rule_check_set... | You are a Python code architect, reviewing and designing scalable and efficient code |
Return a dictionary of log target types that can be used in the log tasks. | Can you generate the documentation for the following Python 3 function
def log_target_types(all_logs=False, **kwargs):
log_types = {
'for_alert_event_log': False,
'for_alert_log': False,
'for_audit_log': False,
'for_fw_log': False,
'for_ips_log': False,
'for_ips_recor... | You are a Python code generator, capable of creating scripts from specifications. |
def add_schedule(self, name, activation_date, day_period='one_time',
final_action='ALERT_FAILURE', activated=True,
minute_period='one_time', day_mask=None,
repeat_until_date=None, comment=None):
"""
Add a schedule to an existing task.
... | Can you write a function in Python 3 where it
adds a schedule to an existing task. | As a python code expert, you are capable of creating scripts from specifications. |
def create(cls, name, engines, comment=None,
validate_policy=True, **kwargs):
"""
Create a refresh policy task associated with specific
engines. A policy refresh task does not require a policy
be specified. The policy used in the refresh will be the
policy already ... | Implement a Python 3 function for
creating a refresh policy task associated with specific engines. | You are a Python code analyst, evaluating scripts for potential improvements. |
Create a new validate policy task. | Here you have a function in Python 3, explain what it does
def create(cls, name, engines, policy=None, comment=None, **kwargs):
json = {
'name': name,
'resources': [eng.href for eng in engines],
'policy': policy.href if policy is not None else policy,
'comment': c... | As a Python code translator, you convert algorithms and pseudocode into Python. |
def create(cls, name, master_engines, comment=None):
"""
Create a refresh task for master engines.
:param str name: name of task
:param master_engines: list of master engines for this task
:type master_engines: list(MasterEngine)
:param str comment: optional com... | Can you create a Python 3 function that
creates a refresh master engine policy task. | You are a Python code analyst, evaluating scripts for potential improvements. |
def create(cls, name, servers=None, time_range='yesterday', all_logs=False,
filter_for_delete=None, comment=None, **kwargs):
"""
Create a new delete log task. Provide True to all_logs to delete
all log types. Otherwise provide kwargs to specify each log by
type of interest... | Create a Python 3 function for
creating a new delete log task. | As a Python code translator, you convert algorithms and pseudocode into Python. |
def create(cls, name, servers, backup_log_data=False,
encrypt_password=None, comment=None):
"""
Create a new server backup task. This task provides the ability
to backup individual or all management and log servers under
SMC management.
:param str name: na... | Write a Python 3 script for
creating a new ServerBackupTask. | As a Python code analyst, you investigate and solve complex coding mysteries |
Create an SGInfoTask object | Can you generate a brief explanation for the following Python 3 code
def create(cls, name, engines, include_core_files=False,
include_slapcat_output=False, comment=None):
"""
Create an sginfo task.
:param str name: name of task
:param engines: list of engines to ... | As a Python code translator, you convert algorithms and pseudocode into Python. |
def send_request(user_session, method, request):
"""
Send request to SMC
:param Session user_session: session object
:param str method: method for request
:param SMCRequest request: request object
:raises SMCOperationFailure: failure with reason
:rtype: SMCResult
"""
if user_ses... | Write a Python 3 function for
sending request to SMC | As a Python code composer, you craft elegant and concise scripts. |
def file_download(user_session, request):
"""
Called when GET request specifies a filename to retrieve.
:param Session user_session: session object
:param SMCRequest request: request object
:raises SMCOperationFailure: failure with reason
:rtype: SMCResult
"""
logger.debug('Download... | Can you implement a function in Python 3 that
returns a SMCResult object with the contents of the object that is stored in the file specified by request. filename. | As a Python code translator, you convert algorithms and pseudocode into Python. |
Perform a file upload PUT or POST to SMC. | Explain what the following Python 3 code does
def file_upload(user_session, method, request):
logger.debug('Upload: %s', vars(request))
http_command = getattr(user_session.session, method.lower())
try:
response = http_command(
request.href,
params=request.params,
... | As a python code expert, you are capable of creating scripts from specifications. |
def rename(self, name):
"""
Rename this node
:param str name: new name for node
"""
self.update(name='{} node {}'.format(name, self.nodeid)) | Implement a function in Python 3 to
rename this node :param str name: new name for node | You are a Python code generator, capable of creating scripts from specifications. |
def _create(cls, name, node_type, nodeid=1,
loopback_ndi=None):
"""
Create the node/s for the engine. This isn't called directly,
instead it is used when engine.create() is called
:param str name: name of node
:param str node_type: based on engine type specified
... | How would you implement a function in Python 3 that
creates the node and its related data structures. | As a Python code translator, you convert algorithms and pseudocode into Python. |
Return a list of LoopbackInterface objects for all loopback interfaces for this node. | Here you have a function in Python 3, explain what it does
def loopback_interface(self):
for lb in self.data.get('loopback_node_dedicated_interface', []):
yield LoopbackInterface(lb, self._engine) | As a Python code composer, you craft elegant and concise scripts. |
Bind license to a new node. | Can you tell what is the following Python 3 function doing
def bind_license(self, license_item_id=None):
params = {'license_item_id': license_item_id}
self.make_request(
LicenseError,
method='create',
resource='bind',
params=params) | You are a Python code generator, capable of creating scripts from specifications. |
def initial_contact(self, enable_ssh=True, time_zone=None,
keyboard=None,
install_on_server=None,
filename=None,
as_base64=False):
"""
Allows to save the initial contact for for the specified node
:p... | Implement a function in Python 3 to
save the initial contact for the specified node. | You are a Python code analyst, evaluating scripts for potential improvements. |
Returns an iterable that provides information about the interfaces that are currently in use. | Can you tell what is the following Python 3 function doing
def interface_status(self):
result = self.make_request(
NodeCommandFailed,
resource='appliance_status')
return InterfaceStatus(result.get('interface_statuses', [])) | As a python code expert, you are capable of creating scripts from specifications. |
def hardware_status(self):
"""
Obtain hardware statistics for various areas of this node.
See :class:`~HardwareStatus` for usage.
:raises NodeCommandFailed: failure to retrieve current status
:rtype: HardwareStatus
"""
result = self.make_request(... | Create a Python 3 function to
retrieve the hardware statistics for various areas of this node. | As a python code expert, you are capable of creating scripts from specifications. |
def go_online(self, comment=None):
"""
Executes a Go-Online operation on the specified node
typically done when the node has already been forced offline
via :func:`go_offline`
:param str comment: (optional) comment to audit
:raises NodeCommandFailed: online not available... | Write a Python 3 function that can
execute a Go - Online operation on the specified node. | As a python code expert, you are capable of creating scripts from specifications. |
Executes a Go - Offline operation on the specified node. | Can you tell what is the following Python 3 function doing
def go_offline(self, comment=None):
self.make_request(
NodeCommandFailed,
method='update',
resource='go_offline',
params={'comment': comment}) | You are a Python code architect, reviewing and designing scalable and efficient code |
def go_standby(self, comment=None):
"""
Executes a Go-Standby operation on the specified node.
To get the status of the current node/s, run :func:`status`
:param str comment: optional comment to audit
:raises NodeCommandFailed: engine cannot go standby
:return: None
... | How would you implement a function in Python 3 that
executes a Go - Standby operation on the specified node. | You are a Python code generator, capable of creating scripts from specifications. |
Executes a Lock - Online operation on the specified node. | Can you generate a brief explanation for the following Python 3 code
def lock_online(self, comment=None):
self.make_request(
NodeCommandFailed,
method='update',
resource='lock_online',
params={'comment': comment}) | As a Python code analyst, you investigate and solve complex coding mysteries |
def lock_offline(self, comment=None):
"""
Executes a Lock-Offline operation on the specified node
Bring back online by running :func:`go_online`.
:param str comment: comment for audit
:raises NodeCommandFailed: lock offline failed
:return: None
"""
self.m... | Can you write a function in Python 3 where it
executes a Lock - Offline operation on the specified node. | As a Python code translator, you convert algorithms and pseudocode into Python. |
Executes a Send Reset LDAP User DB Request on this node. | Can you generate a brief explanation for the following Python 3 code
def reset_user_db(self, comment=None):
self.make_request(
NodeCommandFailed,
method='update',
resource='reset_user_db',
params={'comment': comment}) | You are a Python code generator, capable of creating scripts from specifications. |
def debug(self, filter_enabled=False):
"""
View all debug settings for this node. This will return a
debug object. View the debug object repr to identify settings
to enable or disable and submit the object to :meth:`set_debug`
to enable settings.
Add filter_enabl... | Create a Python 3 function for
viewing all debug settings for this node. This will return a debug object. View the debug object repr to identify settings to enable or disable and submit the object to :meth:`set_debug` to enable settings. Add filter_enabled=True argument to see only enabled settings :param bool filter_e... | You are a Python code analyst, evaluating scripts for potential improvements. |
Set the debug settings for this node. | Explain what the following Python 3 code does
def set_debug(self, debug):
self.make_request(
NodeCommandFailed,
method='create',
resource='send_diagnostic',
json=debug.serialize()) | As a Python code analyst, you investigate and solve complex coding mysteries |
Send reboot command to this node. | Explain what the following Python 3 code does
def reboot(self, comment=None):
self.make_request(
NodeCommandFailed,
method='update',
resource='reboot',
params={'comment': comment}) | You are a Python code generator, capable of creating scripts from specifications. |
Get the SG Info of the specified node. Optionally provide a filename otherwise default to sginfo. gz. | Make a summary of the following Python 3 code
def sginfo(self, include_core_files=False,
include_slapcat_output=False,
filename='sginfo.gz'):
"""
Get the SG Info of the specified node. Optionally provide
a filename, otherwise default to 'sginfo.gz'. Once you run
... | You are a Python code architect, reviewing and designing scalable and efficient code |
Enable or disable SSH daemonization | Can you tell what is the following Python 3 function doing
def ssh(self, enable=True, comment=None):
self.make_request(
NodeCommandFailed,
method='update',
resource='ssh',
params={'enable': enable, 'comment': comment}) | As a Python code composer, you craft elegant and concise scripts. |
Executes a change SSH password operation on the specified node. | Can you generate the documentation for the following Python 3 function
def change_ssh_pwd(self, pwd=None, comment=None):
self.make_request(
NodeCommandFailed,
method='update',
resource='change_ssh_pwd',
params={'comment': comment},
json={'value': pwd}) | As a Python code analyst, you investigate and solve complex coding mysteries |
def delete(self, location_name):
"""
Remove a given location by location name. This operation is
performed only if the given location is valid, and if so,
`update` is called automatically.
:param str location: location name or location ref
:raises UpdateElementFa... | Write a Python 3 script to
remove a given location from the set of known elements. | As a Python code composer, you craft elegant and concise scripts. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.