text_prompt stringlengths 100 17.7k ⌀ | code_prompt stringlengths 7 9.86k ⌀ |
|---|---|
<SYSTEM_TASK:>
Add anycast gateway under interface ve.
<END_TASK>
<USER_TASK:>
Description:
def ip_anycast_gateway(self, **kwargs):
"""
Add anycast gateway under interface ve.
Args:
int_type: L3 interface type on which the anycast ip
needs to be configured.
... |
int_type = kwargs.pop('int_type').lower()
name = kwargs.pop('name')
anycast_ip = kwargs.pop('anycast_ip', '')
enable = kwargs.pop('enable', True)
get = kwargs.pop('get', False)
rbridge_id = kwargs.pop('rbridge_id', '1')
callback = kwargs.pop('callback', self._ca... |
<SYSTEM_TASK:>
Enable Arp Suppression on a Vlan.
<END_TASK>
<USER_TASK:>
Description:
def arp_suppression(self, **kwargs):
"""
Enable Arp Suppression on a Vlan.
Args:
name:Vlan name on which the Arp suppression needs to be enabled.
enable (bool): If arp suppression shoul... |
name = kwargs.pop('name')
enable = kwargs.pop('enable', True)
get = kwargs.pop('get', False)
callback = kwargs.pop('callback', self._callback)
method_class = self._interface
arp_args = dict(name=name)
if name:
if not pynos.utilities.valid_vlan_id(nam... |
<SYSTEM_TASK:>
Add "Duplicate MAC max count" under evpn instance.
<END_TASK>
<USER_TASK:>
Description:
def evpn_instance_mac_timer_max_count(self, **kwargs):
"""
Add "Duplicate MAC max count" under evpn instance.
Args:
evpn_instance_name: Instance name for evpn
max_count... |
evpn_instance_name = kwargs.pop('evpn_instance_name', '')
max_count = kwargs.pop('max_count', '5')
enable = kwargs.pop('enable', True)
get = kwargs.pop('get', False)
rbridge_id = kwargs.pop('rbridge_id', '1')
callback = kwargs.pop('callback', self._callback)
evp... |
<SYSTEM_TASK:>
Add RD auto under EVPN instance.
<END_TASK>
<USER_TASK:>
Description:
def evpn_instance_rd_auto(self, **kwargs):
"""
Add RD auto under EVPN instance.
Args:
rbridge_id: Rbrdige id .
instance_name: EVPN instance name.
Returns:
True if c... |
config = ET.Element("config")
rbridge_id = ET.SubElement(config, "rbridge-id",
xmlns="urn:brocade.com"
":mgmt:brocade-rbridge")
rbridge_id_key = ET.SubElement(rbridge_id, "rbridge-id")
rbridge_id_key.text = kwar... |
<SYSTEM_TASK:>
Set nsx-controller IP
<END_TASK>
<USER_TASK:>
Description:
def set_nsxcontroller_ip(self, **kwargs):
"""
Set nsx-controller IP
Args:
IP (str): IPV4 address.
callback (function): A function executed upon completion of the
method.
R... |
name = kwargs.pop('name')
ip_addr = str((kwargs.pop('ip_addr', None)))
nsxipaddress = ip_interface(unicode(ip_addr))
if nsxipaddress.version != 4:
raise ValueError('NSX Controller ip must be IPV4')
ip_args = dict(name=name, address=ip_addr)
method_name = 'ns... |
<SYSTEM_TASK:>
Activate NSX Controller
<END_TASK>
<USER_TASK:>
Description:
def activate_nsxcontroller(self, **kwargs):
"""
Activate NSX Controller
Args:
name (str): nsxcontroller name
callback (function): A function executed upon completion of the
metho... |
name = kwargs.pop('name')
name_args = dict(name=name)
method_name = 'nsx_controller_activate'
method_class = self._brocade_tunnels
nsxcontroller_attr = getattr(method_class, method_name)
config = nsxcontroller_attr(**name_args)
output = self._callback(config)
... |
<SYSTEM_TASK:>
Set Nsx Controller pot on the switch
<END_TASK>
<USER_TASK:>
Description:
def set_nsxcontroller_port(self, **kwargs):
"""
Set Nsx Controller pot on the switch
Args:
port (int): 1 to 65535.
callback (function): A function executed upon completion of the
... |
name = kwargs.pop('name')
port = str(kwargs.pop('port'))
port_args = dict(name=name, port=port)
method_name = 'nsx_controller_connection_addr_port'
method_class = self._brocade_tunnels
nsxcontroller_attr = getattr(method_class, method_name)
config = nsxcontroller... |
<SYSTEM_TASK:>
Load tasks from entry points.
<END_TASK>
<USER_TASK:>
Description:
def load_entry_points(self):
"""Load tasks from entry points.""" |
if self.entry_point_group:
task_packages = {}
for item in pkg_resources.iter_entry_points(
group=self.entry_point_group):
# Celery 4.2 requires autodiscover to be called with
# related_name for Python 2.7.
try:
... |
<SYSTEM_TASK:>
Return a list of current active Celery queues.
<END_TASK>
<USER_TASK:>
Description:
def get_queues(self):
"""Return a list of current active Celery queues.""" |
res = self.celery.control.inspect().active_queues() or dict()
return [result.get('name') for host in res.values() for result in host] |
<SYSTEM_TASK:>
Suspend Celery queues and wait for running tasks to complete.
<END_TASK>
<USER_TASK:>
Description:
def suspend_queues(self, active_queues, sleep_time=10.0):
"""Suspend Celery queues and wait for running tasks to complete.""" |
for queue in active_queues:
self.disable_queue(queue)
while self.get_active_tasks():
time.sleep(sleep_time) |
<SYSTEM_TASK:>
Initialises the Negotiate extension for the given application.
<END_TASK>
<USER_TASK:>
Description:
def init_app(self, app):
"""
Initialises the Negotiate extension for the given application.
""" |
if not hasattr(app, 'extensions'):
app.extensions = {}
service_name = app.config.get('GSSAPI_SERVICE_NAME', 'HTTP')
hostname = app.config.get('GSSAPI_HOSTNAME', socket.getfqdn())
principal = '{}@{}'.format(service_name, hostname)
name = gssapi.Name(principal, gssapi... |
<SYSTEM_TASK:>
Attempts to authenticate the user if a token was provided.
<END_TASK>
<USER_TASK:>
Description:
def authenticate(self):
"""Attempts to authenticate the user if a token was provided.""" |
if request.headers.get('Authorization', '').startswith('Negotiate '):
in_token = base64.b64decode(request.headers['Authorization'][10:])
try:
creds = current_app.extensions['gssapi']['creds']
except KeyError:
raise RuntimeError('flask-gssapi ... |
<SYSTEM_TASK:>
Parse option name.
<END_TASK>
<USER_TASK:>
Description:
def parse(self, name, description):
"""
Parse option name.
:param name: option's name
:param description: option's description
Parsing acceptable names:
* -f: shortname
* --force: lo... |
name = name.strip()
if '<' in name:
self.required = True
self.boolean = False
name = name[:name.index('<')].strip()
elif '[' in name:
self.required = False
self.boolean = False
name = name[:name.index('[')].strip()
... |
<SYSTEM_TASK:>
Transform the option value to python data.
<END_TASK>
<USER_TASK:>
Description:
def to_python(self, value=None):
"""
Transform the option value to python data.
""" |
if value is None:
return self.default
if self.resolve:
return self.resolve(value)
return value |
<SYSTEM_TASK:>
Get parsed result.
<END_TASK>
<USER_TASK:>
Description:
def get(self, key):
"""
Get parsed result.
After :func:`parse` the argv, we can get the parsed results::
# command.option('-f', 'description of -f')
command.get('-f')
command.get('verbos... |
value = self._results.get(key)
if value is not None:
return value
# get from option default value
option = list(filter(lambda o: o.key == key, self._option_list))
if not option:
raise ValueError('No such option: %s' % key)
option = option[0]
... |
<SYSTEM_TASK:>
Add or get option.
<END_TASK>
<USER_TASK:>
Description:
def option(self, name, description=None, action=None, resolve=None):
"""
Add or get option.
Here are some examples::
command.option('-v, --verbose', 'show more log')
command.option('--tag <tag>', 'ta... |
if isinstance(name, Option):
option = name
else:
name = name.strip()
option = Option(
name=name, description=description,
action=action, resolve=resolve,
)
self._option_list.append(option)
return self |
<SYSTEM_TASK:>
Parse options with the argv
<END_TASK>
<USER_TASK:>
Description:
def parse_options(self, arg):
"""
Parse options with the argv
:param arg: one arg from argv
""" |
if not arg.startswith('-'):
return False
value = None
if '=' in arg:
arg, value = arg.split('=')
for option in self._option_list:
if arg not in (option.shortname, option.longname):
continue
action = option.action
... |
<SYSTEM_TASK:>
Parse argv of terminal
<END_TASK>
<USER_TASK:>
Description:
def parse(self, argv=None):
"""
Parse argv of terminal
:param argv: default is sys.argv
""" |
if not argv:
argv = sys.argv
elif isinstance(argv, str):
argv = argv.split()
self._argv = argv[1:]
if not self._argv:
self.validate_options()
if self._command_func:
self._command_func(**self._results)
retu... |
<SYSTEM_TASK:>
Print the program version.
<END_TASK>
<USER_TASK:>
Description:
def print_version(self):
"""
Print the program version.
""" |
if not self._version:
return self
if not self._title:
print(' %s %s' % (self._name, self._version))
return self
print(' %s (%s %s)' % (self._title, self._name, self._version))
return self |
<SYSTEM_TASK:>
Print the help menu.
<END_TASK>
<USER_TASK:>
Description:
def print_help(self):
"""
Print the help menu.
""" |
print('\n %s %s' % (self._title or self._name, self._version or ''))
if self._usage:
print('\n %s' % self._usage)
else:
cmd = self._name
if hasattr(self, '_parent') and isinstance(self._parent, Command):
cmd = '%s %s' % (self._parent._name... |
<SYSTEM_TASK:>
Configures device's Router ID.
<END_TASK>
<USER_TASK:>
Description:
def router_id(self, **kwargs):
"""Configures device's Router ID.
Args:
router_id (str): Router ID for the device.
rbridge_id (str): The rbridge ID of the device on which BGP will be
... |
router_id = kwargs.pop('router_id')
rbridge_id = kwargs.pop('rbridge_id', '1')
callback = kwargs.pop('callback', self._callback)
rid_args = dict(rbridge_id=rbridge_id, router_id=router_id)
config = self._rbridge.rbridge_id_ip_rtm_config_router_id(**rid_args)
return callb... |
<SYSTEM_TASK:>
Configures device's rbridge ID. Setting this property will need
<END_TASK>
<USER_TASK:>
Description:
def rbridge_id(self, **kwargs):
"""Configures device's rbridge ID. Setting this property will need
a switch reboot
Args:
rbridge_id (str): The rbridge ID of the device... |
is_get_config = kwargs.pop('get', False)
if not is_get_config:
rbridge_id = kwargs.pop('rbridge_id')
else:
rbridge_id = ''
callback = kwargs.pop('callback', self._callback)
rid_args = dict(rbridge_id=rbridge_id)
rid = getattr(self._rbridge,
... |
<SYSTEM_TASK:>
Add the HW map only if it doesn't exist for a given key, and no address collisions
<END_TASK>
<USER_TASK:>
Description:
def add(self, new_hw_map):
"""
Add the HW map only if it doesn't exist for a given key, and no address collisions
""" |
new_route = new_hw_map.route
if new_route in self.raw_maps:
raise KeyError("HW Map already exists: {0:s}".format(new_hw_map.route))
common_addresses = set(self).intersection(new_hw_map)
if common_addresses:
raise ValueError("An address in {0:s} already exists in... |
<SYSTEM_TASK:>
Remove the route entirely.
<END_TASK>
<USER_TASK:>
Description:
def subtract(self, route):
"""
Remove the route entirely.
""" |
for address in self.raw_maps.pop(route, NullHardwareMap()).iterkeys():
self.pop(address, NullHardwareNode()) |
<SYSTEM_TASK:>
Watches for filesystem changes and compiles SCSS to CSS
<END_TASK>
<USER_TASK:>
Description:
def watch(source_path, dest_path):
"""Watches for filesystem changes and compiles SCSS to CSS
This is an async function.
:param str source_path: The source directory to watch. All .scss files are
... |
# Setup Watchdog
handler = FileSystemEvents(source_path, dest_path)
# Always run initial compile
handler.compile_scss()
observer = Observer(timeout=5000)
observer.schedule(handler, path=source_path, recursive=True)
observer.start() |
<SYSTEM_TASK:>
Add VLAN Interface. VLAN interfaces are required for VLANs even when
<END_TASK>
<USER_TASK:>
Description:
def add_vlan_int(self, vlan_id):
"""
Add VLAN Interface. VLAN interfaces are required for VLANs even when
not wanting to use the interface for any L3 features.
Args:
... |
config = ET.Element('config')
vlinterface = ET.SubElement(config, 'interface-vlan',
xmlns=("urn:brocade.com:mgmt:"
"brocade-interface"))
interface = ET.SubElement(vlinterface, 'interface')
vlan = ET.SubElemen... |
<SYSTEM_TASK:>
Change an interface's operation to L3.
<END_TASK>
<USER_TASK:>
Description:
def disable_switchport(self, inter_type, inter):
"""
Change an interface's operation to L3.
Args:
inter_type: The type of interface you want to configure. Ex.
tengigabitetherne... |
config = ET.Element('config')
interface = ET.SubElement(config, 'interface',
xmlns=("urn:brocade.com:mgmt:"
"brocade-interface"))
int_type = ET.SubElement(interface, inter_type)
name = ET.SubElement(int_type, 'na... |
<SYSTEM_TASK:>
Add a L2 Interface to a specific VLAN.
<END_TASK>
<USER_TASK:>
Description:
def access_vlan(self, inter_type, inter, vlan_id):
"""
Add a L2 Interface to a specific VLAN.
Args:
inter_type: The type of interface you want to configure. Ex.
tengigabitether... |
config = ET.Element('config')
interface = ET.SubElement(config, 'interface',
xmlns=("urn:brocade.com:mgmt:"
"brocade-interface"))
int_type = ET.SubElement(interface, inter_type)
name = ET.SubElement(int_type, 'na... |
<SYSTEM_TASK:>
Set IP address of a L3 interface.
<END_TASK>
<USER_TASK:>
Description:
def set_ip(self, inter_type, inter, ip_addr):
"""
Set IP address of a L3 interface.
Args:
inter_type: The type of interface you want to configure. Ex.
tengigabitethernet, gigabiteth... |
config = ET.Element('config')
interface = ET.SubElement(config, 'interface',
xmlns=("urn:brocade.com:mgmt:"
"brocade-interface"))
intert = ET.SubElement(interface, inter_type)
name = ET.SubElement(intert, 'name')... |
<SYSTEM_TASK:>
Remove a port channel interface.
<END_TASK>
<USER_TASK:>
Description:
def remove_port_channel(self, **kwargs):
"""
Remove a port channel interface.
Args:
port_int (str): port-channel number (1, 2, 3, etc).
callback (function): A function executed upon comp... |
port_int = kwargs.pop('port_int')
callback = kwargs.pop('callback', self._callback)
if re.search('^[0-9]{1,4}$', port_int) is None:
raise ValueError('%s must be in the format of x for port channel '
'interfaces.' % repr(port_int))
port_channel ... |
<SYSTEM_TASK:>
Set IP Address on an Interface.
<END_TASK>
<USER_TASK:>
Description:
def ip_address(self, **kwargs):
"""
Set IP Address on an Interface.
Args:
int_type (str): Type of interface. (gigabitethernet,
tengigabitethernet etc).
name (str): Name o... |
int_type = str(kwargs.pop('int_type').lower())
name = str(kwargs.pop('name'))
ip_addr = str(kwargs.pop('ip_addr'))
delete = kwargs.pop('delete', False)
rbridge_id = kwargs.pop('rbridge_id', '1')
callback = kwargs.pop('callback', self._callback)
valid_int_types =... |
<SYSTEM_TASK:>
Get IP Addresses already set on an Interface.
<END_TASK>
<USER_TASK:>
Description:
def get_ip_addresses(self, **kwargs):
"""
Get IP Addresses already set on an Interface.
Args:
int_type (str): Type of interface. (gigabitethernet,
tengigabitethernet et... |
int_type = str(kwargs.pop('int_type').lower())
name = str(kwargs.pop('name'))
version = int(kwargs.pop('version'))
callback = kwargs.pop('callback', self._callback)
valid_int_types = ['gigabitethernet', 'tengigabitethernet',
'fortygigabitethernet', 'h... |
<SYSTEM_TASK:>
Set interface description.
<END_TASK>
<USER_TASK:>
Description:
def description(self, **kwargs):
"""Set interface description.
Args:
int_type (str): Type of interface. (gigabitethernet,
tengigabitethernet, etc)
name (str): Name of interface. (1/0/5... |
int_type = str(kwargs.pop('int_type').lower())
name = str(kwargs.pop('name'))
desc = str(kwargs.pop('desc'))
callback = kwargs.pop('callback', self._callback)
int_types = [
'gigabitethernet',
'tengigabitethernet',
'fortygigabitethernet',
... |
<SYSTEM_TASK:>
Add a secondary PVLAN to a primary PVLAN.
<END_TASK>
<USER_TASK:>
Description:
def vlan_pvlan_association_add(self, **kwargs):
"""Add a secondary PVLAN to a primary PVLAN.
Args:
name (str): VLAN number (1-4094).
sec_vlan (str): The secondary PVLAN.
cal... |
name = kwargs.pop('name')
sec_vlan = kwargs.pop('sec_vlan')
callback = kwargs.pop('callback', self._callback)
if not pynos.utilities.valid_vlan_id(name):
raise InvalidVlanId("Incorrect name value.")
if not pynos.utilities.valid_vlan_id(sec_vlan):
raise I... |
<SYSTEM_TASK:>
Set interface PVLAN association.
<END_TASK>
<USER_TASK:>
Description:
def pvlan_host_association(self, **kwargs):
"""Set interface PVLAN association.
Args:
int_type (str): Type of interface. (gigabitethernet,
tengigabitethernet, etc)
name (str): Na... |
int_type = kwargs.pop('int_type').lower()
name = kwargs.pop('name')
pri_vlan = kwargs.pop('pri_vlan')
sec_vlan = kwargs.pop('sec_vlan')
callback = kwargs.pop('callback', self._callback)
int_types = ['gigabitethernet', 'tengigabitethernet',
'fortygig... |
<SYSTEM_TASK:>
Set tagging of native VLAN on trunk.
<END_TASK>
<USER_TASK:>
Description:
def tag_native_vlan(self, **kwargs):
"""Set tagging of native VLAN on trunk.
Args:
int_type (str): Type of interface. (gigabitethernet,
tengigabitethernet, etc)
name (str): N... |
int_type = kwargs.pop('int_type').lower()
name = kwargs.pop('name')
enabled = kwargs.pop('enabled', True)
callback = kwargs.pop('callback', self._callback)
int_types = ['gigabitethernet', 'tengigabitethernet',
'fortygigabitethernet', 'hundredgigabitethernet... |
<SYSTEM_TASK:>
Switchport private VLAN mapping.
<END_TASK>
<USER_TASK:>
Description:
def switchport_pvlan_mapping(self, **kwargs):
"""Switchport private VLAN mapping.
Args:
int_type (str): Type of interface. (gigabitethernet,
tengigabitethernet, etc)
name (str): ... |
int_type = kwargs.pop('int_type').lower()
name = kwargs.pop('name')
pri_vlan = kwargs.pop('pri_vlan')
sec_vlan = kwargs.pop('sec_vlan')
callback = kwargs.pop('callback', self._callback)
int_types = ['gigabitethernet', 'tengigabitethernet',
'fortygiga... |
<SYSTEM_TASK:>
Set interface mtu.
<END_TASK>
<USER_TASK:>
Description:
def mtu(self, **kwargs):
"""Set interface mtu.
Args:
int_type (str): Type of interface. (gigabitethernet,
tengigabitethernet, etc)
name (str): Name of interface. (1/0/5, 1/0/10, etc)
... |
int_type = kwargs.pop('int_type').lower()
name = kwargs.pop('name')
mtu = kwargs.pop('mtu')
callback = kwargs.pop('callback', self._callback)
int_types = [
'gigabitethernet',
'tengigabitethernet',
'fortygigabitethernet',
'hundredg... |
<SYSTEM_TASK:>
Set fabric ISL state.
<END_TASK>
<USER_TASK:>
Description:
def fabric_isl(self, **kwargs):
"""Set fabric ISL state.
Args:
int_type (str): Type of interface. (gigabitethernet,
tengigabitethernet, etc)
name (str): Name of interface. (1/0/5, 1/0/10, e... |
int_type = str(kwargs.pop('int_type').lower())
name = str(kwargs.pop('name'))
enabled = kwargs.pop('enabled', True)
callback = kwargs.pop('callback', self._callback)
int_types = [
'tengigabitethernet',
'fortygigabitethernet',
'hundredgigabite... |
<SYSTEM_TASK:>
Disable IPv6 Router Advertisements
<END_TASK>
<USER_TASK:>
Description:
def v6_nd_suppress_ra(self, **kwargs):
"""Disable IPv6 Router Advertisements
Args:
int_type (str): Type of interface. (gigabitethernet,
tengigabitethernet, etc)
name (str): Nam... |
int_type = str(kwargs.pop('int_type').lower())
name = str(kwargs.pop('name'))
callback = kwargs.pop('callback', self._callback)
int_types = [
'gigabitethernet',
'tengigabitethernet',
'fortygigabitethernet',
'hundredgigabitethernet',
... |
<SYSTEM_TASK:>
Set VRRP priority.
<END_TASK>
<USER_TASK:>
Description:
def vrrp_priority(self, **kwargs):
"""Set VRRP priority.
Args:
int_type (str): Type of interface. (gigabitethernet,
tengigabitethernet, etc).
name (str): Name of interface. (1/0/5, 1/0/10, etc... |
int_type = kwargs.pop('int_type').lower()
name = kwargs.pop('name')
vrid = kwargs.pop('vrid')
priority = kwargs.pop('priority')
ip_version = int(kwargs.pop('ip_version'))
rbridge_id = kwargs.pop('rbridge_id', '1')
callback = kwargs.pop('callback', self._callback)... |
<SYSTEM_TASK:>
Set minimum number of links in a port channel.
<END_TASK>
<USER_TASK:>
Description:
def port_channel_minimum_links(self, **kwargs):
"""Set minimum number of links in a port channel.
Args:
name (str): Port-channel number. (1, 5, etc)
minimum_links (str): Minimum nu... |
name = str(kwargs.pop('name'))
minimum_links = str(kwargs.pop('minimum_links'))
callback = kwargs.pop('callback', self._callback)
min_links_args = dict(name=name, minimum_links=minimum_links)
if not pynos.utilities.valid_interface('port_channel', name):
raise Value... |
<SYSTEM_TASK:>
set channel group mode.
<END_TASK>
<USER_TASK:>
Description:
def channel_group(self, **kwargs):
"""set channel group mode.
args:
int_type (str): type of interface. (gigabitethernet,
tengigabitethernet, etc)
name (str): name of interface. (1/0/5, 1/... |
int_type = kwargs.pop('int_type').lower()
name = kwargs.pop('name')
channel_type = kwargs.pop('channel_type')
port_int = kwargs.pop('port_int')
mode = kwargs.pop('mode')
delete = kwargs.pop('delete', False)
callback = kwargs.pop('callback', self._callback)
... |
<SYSTEM_TASK:>
Ignore VLAG Split.
<END_TASK>
<USER_TASK:>
Description:
def port_channel_vlag_ignore_split(self, **kwargs):
"""Ignore VLAG Split.
Args:
name (str): Port-channel number. (1, 5, etc)
enabled (bool): Is ignore split enabled? (True, False)
callback (functi... |
name = str(kwargs.pop('name'))
enabled = bool(kwargs.pop('enabled', True))
callback = kwargs.pop('callback', self._callback)
vlag_ignore_args = dict(name=name)
if not pynos.utilities.valid_interface('port_channel', name):
raise ValueError("`name` must match x")
... |
<SYSTEM_TASK:>
Configure VLAN Transport Service.
<END_TASK>
<USER_TASK:>
Description:
def transport_service(self, **kwargs):
"""Configure VLAN Transport Service.
Args:
vlan (str): The VLAN ID.
service_id (str): The transport-service ID.
callback (function): A functio... |
vlan = kwargs.pop('vlan')
service_id = kwargs.pop('service_id')
callback = kwargs.pop('callback', self._callback)
if not pynos.utilities.valid_vlan_id(vlan, extended=True):
raise InvalidVlanId("vlan must be between `1` and `8191`")
service_args = dict(name=vlan, tr... |
<SYSTEM_TASK:>
Set lacp timeout.
<END_TASK>
<USER_TASK:>
Description:
def lacp_timeout(self, **kwargs):
"""Set lacp timeout.
Args:
int_type (str): Type of interface. (gigabitethernet,
tengigabitethernet, etc)
timeout (str): Timeout length. (short, long)
... |
int_type = kwargs.pop('int_type').lower()
name = kwargs.pop('name')
timeout = kwargs.pop('timeout')
callback = kwargs.pop('callback', self._callback)
int_types = [
'gigabitethernet',
'tengigabitethernet',
'fortygigabitethernet',
'... |
<SYSTEM_TASK:>
Set interface switchport status.
<END_TASK>
<USER_TASK:>
Description:
def switchport(self, **kwargs):
"""Set interface switchport status.
Args:
int_type (str): Type of interface. (gigabitethernet,
tengigabitethernet, etc)
name (str): Name of interf... |
int_type = kwargs.pop('int_type').lower()
name = kwargs.pop('name')
enabled = kwargs.pop('enabled', True)
callback = kwargs.pop('callback', self._callback)
int_types = ['gigabitethernet', 'tengigabitethernet',
'fortygigabitethernet', 'hundredgigabitethernet'... |
<SYSTEM_TASK:>
Set access VLAN on a port.
<END_TASK>
<USER_TASK:>
Description:
def acc_vlan(self, **kwargs):
"""Set access VLAN on a port.
Args:
int_type (str): Type of interface. (gigabitethernet,
tengigabitethernet, etc)
name (str): Name of interface. (1/0/5, 1... |
int_type = kwargs.pop('int_type')
name = kwargs.pop('name')
vlan = kwargs.pop('vlan')
callback = kwargs.pop('callback', self._callback)
int_types = ['gigabitethernet', 'tengigabitethernet',
'fortygigabitethernet', 'hundredgigabitethernet',
... |
<SYSTEM_TASK:>
Creates a new Netconf request based on the last received
<END_TASK>
<USER_TASK:>
Description:
def get_interface_detail_request(last_interface_name,
last_interface_type):
""" Creates a new Netconf request based on the last received
interface name and ty... |
request_interface = ET.Element(
'get-interface-detail',
xmlns="urn:brocade.com:mgmt:brocade-interface-ext"
)
if last_interface_name != '':
last_received_int = ET.SubElement(request_interface,
"last-rcvd-interface... |
<SYSTEM_TASK:>
Creates a new Netconf request based on the last received
<END_TASK>
<USER_TASK:>
Description:
def get_vlan_brief_request(last_vlan_id):
""" Creates a new Netconf request based on the last received
vlan id when the hasMore flag is true
""" |
request_interface = ET.Element(
'get-vlan-brief',
xmlns="urn:brocade.com:mgmt:brocade-interface-ext"
)
if last_vlan_id != '':
last_received_int_el = ET.SubElement(request_interface,
"last-rcvd-vlan-id")
... |
<SYSTEM_TASK:>
Creates a new Netconf request based on the last received
<END_TASK>
<USER_TASK:>
Description:
def get_port_chann_detail_request(last_aggregator_id):
""" Creates a new Netconf request based on the last received
aggregator id when the hasMore flag is true
""" |
port_channel_ns = 'urn:brocade.com:mgmt:brocade-lag'
request_port_channel = ET.Element('get-port-channel-detail',
xmlns=port_channel_ns)
if last_aggregator_id != '':
last_received_port_chann_el = ET.SubElement(request_port_channel,
... |
<SYSTEM_TASK:>
Set vrrpe short path forwarding to default.
<END_TASK>
<USER_TASK:>
Description:
def vrrpe_spf_basic(self, **kwargs):
"""Set vrrpe short path forwarding to default.
Args:
int_type (str): Type of interface. (gigabitethernet,
tengigabitethernet, etc).
... |
int_type = kwargs.pop('int_type').lower()
name = kwargs.pop('name')
vrid = kwargs.pop('vrid')
enable = kwargs.pop('enable', True)
get = kwargs.pop('get', False)
rbridge_id = kwargs.pop('rbridge_id', '1')
callback = kwargs.pop('callback', self._callback)
... |
<SYSTEM_TASK:>
Set vrrpe VIP.
<END_TASK>
<USER_TASK:>
Description:
def vrrpe_vip(self, **kwargs):
"""Set vrrpe VIP.
Args:
int_type (str): Type of interface. (gigabitethernet,
tengigabitethernet, ve, etc).
name (str): Name of interface. (1/0/5, 1/0/10, VE name etc... |
int_type = kwargs.pop('int_type').lower()
name = kwargs.pop('name',)
vip = kwargs.pop('vip', '')
get = kwargs.pop('get', False)
delete = kwargs.pop('delete', False)
callback = kwargs.pop('callback', self._callback)
valid_int_types = ['gigabitethernet', 'tengigab... |
<SYSTEM_TASK:>
Creates a new Netconf request based on the rbridge_id specifed
<END_TASK>
<USER_TASK:>
Description:
def _get_intf_rb_id(rbridge_id):
""" Creates a new Netconf request based on the rbridge_id specifed
""" |
intf_rb_id = ET.Element(
'get-ip-interface',
xmlns="urn:brocade.com:mgmt:brocade-interface-ext"
)
if rbridge_id is not None:
rbridge_el = ET.SubElement(intf_rb_id, "rbridge-id")
rbridge_el.text = rbridge_id
return intf_rb_id |
<SYSTEM_TASK:>
Enable conversational mac learning on vdx switches
<END_TASK>
<USER_TASK:>
Description:
def conversational_mac(self, **kwargs):
"""Enable conversational mac learning on vdx switches
Args:
get (bool): Get config instead of editing config. (True, False)
delete (bool... |
callback = kwargs.pop('callback', self._callback)
mac_learning = getattr(self._mac_address_table,
'mac_address_table_learning_mode')
config = mac_learning(learning_mode='conversational')
if kwargs.pop('get', False):
output = callback(config, ... |
<SYSTEM_TASK:>
Configure Name of Overlay Gateway on vdx switches
<END_TASK>
<USER_TASK:>
Description:
def overlay_gateway_name(self, **kwargs):
"""Configure Name of Overlay Gateway on vdx switches
Args:
gw_name: Name of Overlay Gateway
get (bool): Get config instead of editing c... |
callback = kwargs.pop('callback', self._callback)
get_config = kwargs.pop('get', False)
if not get_config:
gw_name = kwargs.pop('gw_name')
overlay_gw = getattr(self._tunnels, 'overlay_gateway_name')
config = overlay_gw(name=gw_name)
if get_config:
... |
<SYSTEM_TASK:>
Activates the Overlay Gateway Instance on VDX switches
<END_TASK>
<USER_TASK:>
Description:
def overlay_gateway_activate(self, **kwargs):
"""Activates the Overlay Gateway Instance on VDX switches
Args:
gw_name: Name of Overlay Gateway
get (bool): Get config instea... |
callback = kwargs.pop('callback', self._callback)
get_config = kwargs.pop('get', False)
if not get_config:
gw_name = kwargs.pop('gw_name')
overlay_gw = getattr(self._tunnels, 'overlay_gateway_activate')
config = overlay_gw(name=gw_name)
if get_confi... |
<SYSTEM_TASK:>
Configure Overlay Gateway Type on vdx switches
<END_TASK>
<USER_TASK:>
Description:
def overlay_gateway_type(self, **kwargs):
"""Configure Overlay Gateway Type on vdx switches
Args:
gw_name: Name of Overlay Gateway
gw_type: Type of Overlay Gateway(hardware-vtep/
... |
callback = kwargs.pop('callback', self._callback)
get_config = kwargs.pop('get', False)
if not get_config:
gw_name = kwargs.pop('gw_name')
gw_type = kwargs.pop('gw_type')
gw_args = dict(name=gw_name, gw_type=gw_type)
overlay_gw = getattr(self._tu... |
<SYSTEM_TASK:>
Configure Overlay Gateway ip interface loopback
<END_TASK>
<USER_TASK:>
Description:
def overlay_gateway_loopback_id(self, **kwargs):
"""Configure Overlay Gateway ip interface loopback
Args:
gw_name: Name of Overlay Gateway <WORD:1-32>
loopback_id: Loopback inte... |
callback = kwargs.pop('callback', self._callback)
get_config = kwargs.pop('get', False)
if not get_config:
gw_name = kwargs.pop('gw_name')
loopback_id = kwargs.pop('loopback_id')
gw_args = dict(name=gw_name, loopback_id=loopback_id)
overlay_gw = ... |
<SYSTEM_TASK:>
Configure Overlay Gateway attach rbridge id
<END_TASK>
<USER_TASK:>
Description:
def overlay_gateway_attach_rbridge_id(self, **kwargs):
"""Configure Overlay Gateway attach rbridge id
Args:
gw_name: Name of Overlay Gateway <WORD:1-32>
rbridge_id: Single or range ... |
callback = kwargs.pop('callback', self._callback)
get_config = kwargs.pop('get', False)
delete = kwargs.pop('delete', False)
if not get_config:
gw_name = kwargs.pop('gw_name')
rbridge_id = kwargs.pop('rbridge_id')
if delete is True:
g... |
<SYSTEM_TASK:>
Configure ipv6 link local address on interfaces on vdx switches
<END_TASK>
<USER_TASK:>
Description:
def ipv6_link_local(self, **kwargs):
"""Configure ipv6 link local address on interfaces on vdx switches
Args:
int_type: Interface type on which the ipv6 link local needs to be... |
int_type = kwargs.pop('int_type').lower()
ve_name = kwargs.pop('name')
rbridge_id = kwargs.pop('rbridge_id', '1')
callback = kwargs.pop('callback', self._callback)
valid_int_types = ['loopback', 've']
if int_type not in valid_int_types:
raise ValueError('`in... |
<SYSTEM_TASK:>
Configures maintenance mode on the device
<END_TASK>
<USER_TASK:>
Description:
def maintenance_mode(self, **kwargs):
"""Configures maintenance mode on the device
Args:
rbridge_id (str): The rbridge ID of the device on which
Maintenance mode
will be... |
is_get_config = kwargs.pop('get', False)
delete = kwargs.pop('delete', False)
rbridge_id = kwargs.pop('rbridge_id')
callback = kwargs.pop('callback', self._callback)
rid_args = dict(rbridge_id=rbridge_id)
rid = getattr(self._rbridge,
'rbridge_id_sys... |
<SYSTEM_TASK:>
Callback for NETCONF calls.
<END_TASK>
<USER_TASK:>
Description:
def _callback_main(self, call, handler='edit_config', target='running',
source='startup'):
"""
Callback for NETCONF calls.
Args:
call: An Element Tree element containing the XML of... |
try:
if handler == 'get_config':
call = ET.tostring(call.getchildren()[0])
return self._mgr.get(filter=('subtree', call))
call = ET.tostring(call)
if handler == 'get':
call_element = xml_.to_ele(call)
return ET... |
<SYSTEM_TASK:>
Reconnect session with device.
<END_TASK>
<USER_TASK:>
Description:
def reconnect(self):
"""
Reconnect session with device.
Args:
None
Returns:
bool: True if reconnect succeeds, False if not.
Raises:
None
""" |
if self._auth_method is "userpass":
self._mgr = manager.connect(host=self._conn[0],
port=self._conn[1],
username=self._auth[0],
password=self._auth[1],
... |
<SYSTEM_TASK:>
Find the interface through which a MAC can be reached.
<END_TASK>
<USER_TASK:>
Description:
def find_interface_by_mac(self, **kwargs):
"""Find the interface through which a MAC can be reached.
Args:
mac_address (str): A MAC address in 'xx:xx:xx:xx:xx:xx' format.
Retu... |
mac = kwargs.pop('mac_address')
results = [x for x in self.mac_table if x['mac_address'] == mac]
return results |
<SYSTEM_TASK:>
Solve a puzzle constrained by board dimensions and pieces.
<END_TASK>
<USER_TASK:>
Description:
def solve(ctx, length, height, silent, profile, **pieces):
""" Solve a puzzle constrained by board dimensions and pieces. """ |
# Check that at least one piece is provided.
if not sum(pieces.values()):
context = click.get_current_context()
raise BadParameter('No piece provided.', ctx=context, param_hint=[
'--{}'.format(label) for label in PIECE_LABELS])
# Setup the optionnal profiler.
profiler = BPr... |
<SYSTEM_TASK:>
Run a benchmarking suite and measure time taken by the solver.
<END_TASK>
<USER_TASK:>
Description:
def benchmark():
""" Run a benchmarking suite and measure time taken by the solver.
Each scenario is run in an isolated process, and results are appended to
CSV file.
""" |
# Use all cores but one on multi-core CPUs.
pool_size = multiprocessing.cpu_count() - 1
if pool_size < 1:
pool_size = 1
# Start a pool of workers. Only allow 1 task per child, to force flushing
# of solver's internal caches.
pool = multiprocessing.Pool(processes=pool_size, maxtasksperc... |
<SYSTEM_TASK:>
Reuse standard integer validator but add checks on sign and zero.
<END_TASK>
<USER_TASK:>
Description:
def convert(self, value, param, ctx):
""" Reuse standard integer validator but add checks on sign and zero.
""" |
value = super(PositiveInt, self).convert(value, param, ctx)
if value < 0:
self.fail('%s is not positive' % value, param, ctx)
if not self.allow_zero and not value:
self.fail('%s is not greater than 0' % value, param, ctx)
return value |
<SYSTEM_TASK:>
Enable or Disable VRRP.
<END_TASK>
<USER_TASK:>
Description:
def vrrp(self, **kwargs):
"""Enable or Disable VRRP.
Args:
ip_version (str): The IP version ('4' or '6') for which VRRP should
be enabled/disabled. Default: `4`.
enabled (bool): If VRRP ... |
ip_version = kwargs.pop('ip_version', '4')
enabled = kwargs.pop('enabled', True)
rbridge_id = kwargs.pop('rbridge_id', '1')
callback = kwargs.pop('callback', self._callback)
vrrp_args = dict(rbridge_id=rbridge_id)
vrrp_method = 'rbridge_id_protocol_hide_vrrp_holder_vrrp'... |
<SYSTEM_TASK:>
Run one scenario and returns execution time and number of solutions.
<END_TASK>
<USER_TASK:>
Description:
def run_scenario(params):
""" Run one scenario and returns execution time and number of solutions.
Also returns initial parameters in the response to keep the results
associated with the... |
solver = SolverContext(**params)
start = time.time()
count = sum(1 for _ in solver.solve())
execution_time = time.time() - start
params.update({
'solutions': count,
'execution_time': execution_time})
return params |
<SYSTEM_TASK:>
Load old benchmark results from CSV.
<END_TASK>
<USER_TASK:>
Description:
def load_csv(self):
""" Load old benchmark results from CSV. """ |
if path.exists(self.csv_filepath):
self.results = self.results.append(
pandas.read_csv(self.csv_filepath)) |
<SYSTEM_TASK:>
Dump all results to CSV.
<END_TASK>
<USER_TASK:>
Description:
def save_csv(self):
""" Dump all results to CSV. """ |
# Sort results so we can start to see patterns right in the raw CSV.
self.results.sort_values(by=self.column_ids, inplace=True)
# Gotcha: integers seems to be promoted to float64 because of
# reindexation. See: https://pandas.pydata.org/pandas-docs/stable
# /gotchas.html#na-type... |
<SYSTEM_TASK:>
Graph n-queens problem for the current version and context.
<END_TASK>
<USER_TASK:>
Description:
def nqueen_graph(self):
""" Graph n-queens problem for the current version and context. """ |
# Filters out boards with pieces other than queens.
nqueens = self.results
for piece_label in set(PIECE_LABELS).difference(['queen']):
nqueens = nqueens[nqueens[piece_label].map(pandas.isnull)]
# Filters out non-square boards whose dimension are not aligned to the
#... |
<SYSTEM_TASK:>
Experimental neighbor method.
<END_TASK>
<USER_TASK:>
Description:
def neighbor(self, **kwargs):
"""Experimental neighbor method.
Args:
ip_addr (str): IP Address of BGP neighbor.
remote_as (str): Remote ASN of BGP neighbor.
rbridge_id (str): The rbridg... |
ip_addr = ip_interface(unicode(kwargs.pop('ip_addr')))
rbridge_id = kwargs.pop('rbridge_id', '1')
delete = kwargs.pop('delete', False)
callback = kwargs.pop('callback', self._callback)
remote_as = kwargs.pop('remote_as', None)
get_config = kwargs.pop('get', False)
... |
<SYSTEM_TASK:>
Activate EVPN AFI for a peer.
<END_TASK>
<USER_TASK:>
Description:
def evpn_afi_peer_activate(self, **kwargs):
"""
Activate EVPN AFI for a peer.
Args:
ip_addr (str): IP Address of BGP neighbor.
rbridge_id (str): The rbridge ID of the device on which BGP wi... |
peer_ip = kwargs.pop('peer_ip')
callback = kwargs.pop('callback', self._callback)
evpn_activate = getattr(self._rbridge,
'rbridge_id_router_router_bgp_address_family_'
'l2vpn_evpn_neighbor_evpn_neighbor_ipv4_'
... |
<SYSTEM_TASK:>
Configure next hop unchanged for an EVPN neighbor.
<END_TASK>
<USER_TASK:>
Description:
def evpn_next_hop_unchanged(self, **kwargs):
"""Configure next hop unchanged for an EVPN neighbor.
You probably don't want this method. You probably want to configure
an EVPN neighbor using `... |
callback = kwargs.pop('callback', self._callback)
args = dict(rbridge_id=kwargs.pop('rbridge_id', '1'),
evpn_neighbor_ipv4_address=kwargs.pop('ip_addr'))
next_hop_unchanged = getattr(self._rbridge,
'rbridge_id_router_router_bgp_address_'
... |
<SYSTEM_TASK:>
BFD enable for each specified peer.
<END_TASK>
<USER_TASK:>
Description:
def enable_peer_bfd(self, **kwargs):
"""BFD enable for each specified peer.
Args:
rbridge_id (str): Rbridge to configure. (1, 225, etc)
peer_ip (str): Peer IPv4 address for BFD setting.
... |
method_name = 'rbridge_id_router_router_bgp_router_bgp_attributes_' \
'neighbor_neighbor_ips_neighbor_addr_bfd_bfd_enable'
bfd_enable = getattr(self._rbridge, method_name)
kwargs['router_bgp_neighbor_address'] = kwargs.pop('peer_ip')
callback = kwargs.pop('callback... |
<SYSTEM_TASK:>
Get and merge the `bfd` config from global BGP.
<END_TASK>
<USER_TASK:>
Description:
def _peer_get_bfd(self, tx, rx, multiplier):
"""Get and merge the `bfd` config from global BGP.
You should not use this method.
You probably want `BGP.bfd`.
Args:
tx: XML doc... |
tx = self._callback(tx, handler='get_config')
rx = self._callback(rx, handler='get_config')
multiplier = self._callback(multiplier, handler='get_config')
tx = pynos.utilities.return_xml(str(tx))
rx = pynos.utilities.return_xml(str(rx))
multiplier = pynos.utilities.return... |
<SYSTEM_TASK:>
Set BGP max paths property on VRF address family.
<END_TASK>
<USER_TASK:>
Description:
def vrf_max_paths(self, **kwargs):
"""Set BGP max paths property on VRF address family.
Args:
vrf (str): The VRF for this BGP process.
rbridge_id (str): The rbridge ID of the de... |
afi = kwargs.pop('afi', 'ipv4')
vrf = kwargs.pop('vrf', 'default')
get_config = kwargs.pop('get', False)
callback = kwargs.pop('callback', self._callback)
if afi not in ['ipv4', 'ipv6']:
raise AttributeError('Invalid AFI.')
if "ipv4" in afi:
if no... |
<SYSTEM_TASK:>
Set BGP max paths property on default VRF address family.
<END_TASK>
<USER_TASK:>
Description:
def default_vrf_max_paths(self, **kwargs):
"""Set BGP max paths property on default VRF address family.
Args:
rbridge_id (str): The rbridge ID of the device on which BGP will be
... |
afi = kwargs.pop('afi', 'ipv4')
callback = kwargs.pop('callback', self._callback)
get_config = kwargs.pop('get', False)
if afi not in ['ipv4', 'ipv6']:
raise AttributeError('Invalid AFI.')
if not get_config:
args = dict(rbridge_id=kwargs.pop('rbridge_id',... |
<SYSTEM_TASK:>
Decorator to define a command.
<END_TASK>
<USER_TASK:>
Description:
def command(*args, **kwargs):
"""Decorator to define a command.
The arguments to this decorator are those of the
`ArgumentParser <https://docs.python.org/3/library/argparse.html\
#argumentparser-objects>`_
object constru... |
def decorator(f):
if 'description' not in kwargs:
kwargs['description'] = f.__doc__
if 'parents' in kwargs:
if not hasattr(f, '_argnames'): # pragma: no cover
f._argnames = []
for p in kwargs['parents']:
f._argnames += p._argnames... |
<SYSTEM_TASK:>
Decorator to define a subcommand.
<END_TASK>
<USER_TASK:>
Description:
def _subcommand(group, *args, **kwargs):
"""Decorator to define a subcommand.
This decorator is used for the group's @command decorator.
""" |
def decorator(f):
if 'help' not in kwargs:
kwargs['help'] = f.__doc__
_parser_class = group._subparsers._parser_class
if 'parser' in kwargs:
# use a copy of the given parser
group._subparsers._parser_class = _CopiedArgumentParser
if 'parents' in k... |
<SYSTEM_TASK:>
Decorator to define a subgroup.
<END_TASK>
<USER_TASK:>
Description:
def _subgroup(group, *args, **kwargs):
"""Decorator to define a subgroup.
This decorator is used for the group's @group decorator.
""" |
def decorator(f):
f.required = kwargs.pop('required', True)
if 'parents' in kwargs:
if not hasattr(f, '_argnames'): # pragma: no cover
f._argnames = []
for p in kwargs['parents']:
f._argnames += p._argnames if hasattr(p, '_argnames') else []
... |
<SYSTEM_TASK:>
Decorator to define a command group.
<END_TASK>
<USER_TASK:>
Description:
def group(*args, **kwargs):
"""Decorator to define a command group.
The arguments to this decorator are those of the
`ArgumentParser <https://docs.python.org/3/library/argparse.html\
#argumentparser-objects>`_
obje... |
def decorator(f):
f.required = kwargs.pop('required', True)
if 'parents' in kwargs:
if not hasattr(f, '_argnames'): # pragma: no cover
f._argnames = []
for p in kwargs['parents']:
f._argnames += p._argnames if hasattr(p, '_argnames') else []
... |
<SYSTEM_TASK:>
Duplicate argument names processing logic from argparse.
<END_TASK>
<USER_TASK:>
Description:
def _get_dest(*args, **kwargs): # pragma: no cover
"""
Duplicate argument names processing logic from argparse.
argparse stores the variable in the namespace using the provided dest name,
the f... |
prefix_chars = kwargs.get('prefix_chars', '-')
# determine short and long option strings
option_strings = []
long_option_strings = []
for option_string in args:
# strings starting with two prefix characters are long options
option_strings.append(option_string)
if option_str... |
<SYSTEM_TASK:>
Decorator to define an argparse option or argument.
<END_TASK>
<USER_TASK:>
Description:
def argument(*args, **kwargs):
"""Decorator to define an argparse option or argument.
The arguments to this decorator are the same as the
`ArgumentParser.add_argument <https://docs.python.org/3/library/\... |
def decorator(f):
if not hasattr(f, '_arguments'):
f._arguments = []
if not hasattr(f, '_argnames'):
f._argnames = []
f._arguments.append((args, kwargs))
f._argnames.append(_get_dest(*args, **kwargs))
return f
return decorator |
<SYSTEM_TASK:>
Download firmware to device
<END_TASK>
<USER_TASK:>
Description:
def download(self, protocol, host, user, password,
file_name, rbridge='all'):
"""
Download firmware to device
""" |
urn = "{urn:brocade.com:mgmt:brocade-firmware}"
request_fwdl = self.get_firmware_download_request(protocol, host,
user, password,
file_name, rbridge)
response = self._callback(req... |
<SYSTEM_TASK:>
Add vCenter on the switch
<END_TASK>
<USER_TASK:>
Description:
def add_vcenter(self, **kwargs):
"""
Add vCenter on the switch
Args:
id(str) : Name of an established vCenter
url (bool) : vCenter URL
username (str): Username of the vCenter
... |
config = ET.Element("config")
vcenter = ET.SubElement(config, "vcenter",
xmlns="urn:brocade.com:mgmt:brocade-vswitch")
id = ET.SubElement(vcenter, "id")
id.text = kwargs.pop('id')
credentials = ET.SubElement(vcenter, "credentials")
url = E... |
<SYSTEM_TASK:>
Activate vCenter on the switch
<END_TASK>
<USER_TASK:>
Description:
def activate_vcenter(self, **kwargs):
"""
Activate vCenter on the switch
Args:
name: (str) : Name of an established vCenter
activate (bool) : Activates the vCenter if activate=True
... |
name = kwargs.pop('name')
activate = kwargs.pop('activate', True)
vcenter_args = dict(id=name)
method_class = self._brocade_vswitch
if activate:
method_name = 'vcenter_activate'
vcenter_attr = getattr(method_class, method_name)
config = vcente... |
<SYSTEM_TASK:>
Get vCenter hosts on the switch
<END_TASK>
<USER_TASK:>
Description:
def get_vcenter(self, **kwargs):
"""
Get vCenter hosts on the switch
Args:
callback (function): A function executed upon completion of the
method.
Returns:
Retur... |
config = ET.Element("config")
urn = "urn:brocade.com:mgmt:brocade-vswitch"
ET.SubElement(config, "vcenter", xmlns=urn)
output = self._callback(config, handler='get_config')
result = []
element = ET.fromstring(str(output))
for vcenter in element.iter('{%s}vcenter'... |
<SYSTEM_TASK:>
Perform authentication on the incoming request.
<END_TASK>
<USER_TASK:>
Description:
def perform_authentication(self):
"""
Perform authentication on the incoming request.
""" |
if not self.authenticators:
return
request.user = None
request.auth = None
for authenticator in self.authenticators:
auth_tuple = authenticator.authenticate()
if auth_tuple:
request.user = auth_tuple[0]
request.auth... |
<SYSTEM_TASK:>
Convert the virtualbox config file values for clone_mode into the integers the API requires
<END_TASK>
<USER_TASK:>
Description:
def map_clonemode(vm_info):
"""
Convert the virtualbox config file values for clone_mode into the integers the API requires
""" |
mode_map = {
'state': 0,
'child': 1,
'all': 2
}
if not vm_info:
return DEFAULT_CLONE_MODE
if 'clonemode' not in vm_info:
return DEFAULT_CLONE_MODE
if vm_info['clonemode'] in mode_map:
return mode_map[vm_info['clonemode']]
else:
raise SaltCl... |
<SYSTEM_TASK:>
Stop a running machine.
<END_TASK>
<USER_TASK:>
Description:
def stop(name, call=None):
"""
Stop a running machine.
@param name: Machine to stop
@type name: str
@param call: Must be "action"
@type call: str
""" |
if call != 'action':
raise SaltCloudSystemExit(
'The instance action must be called with -a or --action.'
)
log.info("Stopping machine: %s", name)
vb_stop_vm(name)
machine = vb_get_machine(name)
del machine["name"]
return treat_machine_dict(machine) |
<SYSTEM_TASK:>
Show the details of an image
<END_TASK>
<USER_TASK:>
Description:
def show_image(kwargs, call=None):
"""
Show the details of an image
""" |
if call != 'function':
raise SaltCloudSystemExit(
'The show_image action must be called with -f or --function.'
)
name = kwargs['image']
log.info("Showing image %s", name)
machine = vb_get_machine(name)
ret = {
machine["name"]: treat_machine_dict(machine)
}... |
<SYSTEM_TASK:>
Reshard a kinesis stream. Each call to this function will wait until the stream is ACTIVE,
<END_TASK>
<USER_TASK:>
Description:
def reshard(stream_name, desired_size, force=False,
region=None, key=None, keyid=None, profile=None):
"""
Reshard a kinesis stream. Each call to this funct... |
conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile)
r = {}
stream_response = get_stream_when_active(stream_name, region, key, keyid, profile)
if 'error' in stream_response:
return stream_response
stream_details = stream_response['result']["StreamDescription"]
min_ha... |
<SYSTEM_TASK:>
Render the roster file
<END_TASK>
<USER_TASK:>
Description:
def _render(roster_file, **kwargs):
"""
Render the roster file
""" |
renderers = salt.loader.render(__opts__, {})
domain = __opts__.get('roster_domain', '')
try:
result = salt.template.compile_template(roster_file,
renderers,
__opts__['renderer'],
... |
<SYSTEM_TASK:>
Generates a random password.
<END_TASK>
<USER_TASK:>
Description:
def password(
self,
length=10,
special_chars=True,
digits=True,
upper_case=True,
lower_case=True):
"""
Generates a random password.
@param leng... |
choices = ""
required_tokens = []
if special_chars:
required_tokens.append(
self.generator.random.choice("!@#$%^&*()_+"))
choices += "!@#$%^&*()_+"
if digits:
required_tokens.append(self.generator.random.choice(string.digits))
... |
<SYSTEM_TASK:>
Calculates and returns a control digit for given list of characters basing on Identity Card Number standards.
<END_TASK>
<USER_TASK:>
Description:
def checksum_identity_card_number(characters):
"""
Calculates and returns a control digit for given list of characters basing on Identity Card Number ... |
weights_for_check_digit = [7, 3, 1, 0, 7, 3, 1, 7, 3]
check_digit = 0
for i in range(3):
check_digit += weights_for_check_digit[i] * (ord(characters[i]) - 55)
for i in range(4, 9):
check_digit += weights_for_check_digit[i] * characters[i]
check_digit %= 10
return check_digit |
<SYSTEM_TASK:>
A simple method that runs a Command.
<END_TASK>
<USER_TASK:>
Description:
def execute_from_command_line(argv=None):
"""A simple method that runs a Command.""" |
if sys.stdout.encoding is None:
print('please set python env PYTHONIOENCODING=UTF-8, example: '
'export PYTHONIOENCODING=UTF-8, when writing to stdout',
file=sys.stderr)
exit(1)
command = Command(argv)
command.execute() |
<SYSTEM_TASK:>
Validates a french catch phrase.
<END_TASK>
<USER_TASK:>
Description:
def _is_catch_phrase_valid(self, catch_phrase):
"""
Validates a french catch phrase.
:param catch_phrase: The catch phrase to validate.
""" |
for word in self.words_which_should_not_appear_twice:
# Fastest way to check if a piece of word does not appear twice.
begin_pos = catch_phrase.find(word)
end_pos = catch_phrase.find(word, begin_pos + 1)
if begin_pos != -1 and begin_pos != end_pos:
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.