sentence1
stringlengths
52
3.87M
sentence2
stringlengths
1
47.2k
label
stringclasses
1 value
def insert_group(node, target): """Insert node into in target tree, in appropriate group. Uses group and lang from target function. This assumes the node and target share a structure of a first child that determines the grouping, and a second child that will be accumulated in the group. """ gr...
Insert node into in target tree, in appropriate group. Uses group and lang from target function. This assumes the node and target share a structure of a first child that determines the grouping, and a second child that will be accumulated in the group.
entailment
def create_group(value): """Create the group wrapper node.""" node = etree.Element('div', attrib={'class': 'group-by'}) span = etree.Element('span', attrib={'class': 'group-label'}) span.text = value node.append(span) return node
Create the group wrapper node.
entailment
def _extract_sel_info(sel): """Recurse down parsed tree, return pseudo class info""" from cssselect2.parser import (CombinedSelector, CompoundSelector, PseudoClassSelector, FunctionalPseudoClassSelector) steps = [] extras = [] if ...
Recurse down parsed tree, return pseudo class info
entailment
def extract_selector_info(sel): """Return selector special pseudo class info (steps and other).""" # walk the parsed_tree, looking for pseudoClass selectors, check names # add in steps and/or deferred extras steps, extras = _extract_sel_info(sel.parsed_tree) steps = sorted(set(steps)) extras = ...
Return selector special pseudo class info (steps and other).
entailment
def _to_roman(num): """Convert integer to roman numerals.""" roman_numeral_map = ( ('M', 1000), ('CM', 900), ('D', 500), ('CD', 400), ('C', 100), ('XC', 90), ('L', 50), ('XL', 40), ('X', 10), ('IX', 9), ('V', 5), ...
Convert integer to roman numerals.
entailment
def copy_w_id_suffix(elem, suffix="_copy"): """Make a deep copy of the provided tree, altering ids.""" mycopy = deepcopy(elem) for id_elem in mycopy.xpath('//*[@id]'): id_elem.set('id', id_elem.get('id') + suffix) return mycopy
Make a deep copy of the provided tree, altering ids.
entailment
def generate_id(self): """Generate a fresh id""" if self.use_repeatable_ids: self.repeatable_id_counter += 1 return 'autobaked-{}'.format(self.repeatable_id_counter) else: return str(uuid4())
Generate a fresh id
entailment
def clear_state(self): """Clear the recipe state.""" self.state = {} self.state['steps'] = [] self.state['current_step'] = None self.state['scope'] = [] self.state['counters'] = {} self.state['strings'] = {} for step in self.matchers: self.stat...
Clear the recipe state.
entailment
def update_css(self, css_in=None, clear_css=False): """Add additional CSS rules, optionally replacing all.""" if clear_css: self.matchers = {} # CSS is changing, so clear processing state self.clear_state() if css_in is None: return try: ...
Add additional CSS rules, optionally replacing all.
entailment
def bake(self, element, last_step=None): """Apply recipes to HTML tree. Will build recipes if needed.""" if last_step is not None: try: self.state['steps'] = [s for s in self.state['steps'] if int(s) < int(last_step)] except...
Apply recipes to HTML tree. Will build recipes if needed.
entailment
def record_coverage_zero(self, rule, offset): """Add entry to coverage saying this selector was parsed""" self.coverage_lines.append('DA:{},0'.format(rule.source_line + offset))
Add entry to coverage saying this selector was parsed
entailment
def record_coverage(self, rule): """Add entry to coverage saying this selector was matched""" log(DEBUG, u'Rule ({}): {}'.format(*rule).encode('utf-8')) self.coverage_lines.append('DA:{},1'.format(rule[0]))
Add entry to coverage saying this selector was matched
entailment
def build_recipe(self, element, step, depth=0): """Construct a set of steps to collate (and number) an HTML doc. Returns a state object that contains the steps to apply to the HTML tree. CSS rules match during a recusive descent HTML tree walk. Each declaration has a method that then ru...
Construct a set of steps to collate (and number) an HTML doc. Returns a state object that contains the steps to apply to the HTML tree. CSS rules match during a recusive descent HTML tree walk. Each declaration has a method that then runs, given the current element, the decaration value...
entailment
def push_target_elem(self, element, pseudo=None): """Place target element onto action stack.""" actions = self.state[self.state['current_step']]['actions'] if len(actions) > 0 and actions[-1][0] == 'target': actions.pop() actions.append(('target', Target(element.etree_element...
Place target element onto action stack.
entailment
def push_pending_elem(self, element, pseudo): """Create and place pending target element onto stack.""" self.push_target_elem(element, pseudo) elem = etree.Element('div') actions = self.state[self.state['current_step']]['actions'] actions.append(('move', elem)) actions.ap...
Create and place pending target element onto stack.
entailment
def pop_pending_if_empty(self, element): """Remove empty wrapper element.""" actions = self.state[self.state['current_step']]['actions'] elem = self.current_target().tree if actions[-1][0] == ('target') and actions[-1][1].tree == elem: actions.pop() actions.pop() ...
Remove empty wrapper element.
entailment
def current_target(self): """Return current target.""" actions = self.state[self.state['current_step']]['actions'] for action, value in reversed(actions): if action == 'target': return value
Return current target.
entailment
def find_method(self, decl): """Find class method to call for declaration based on name.""" name = decl.name method = None try: method = getattr(self, u'do_{}'.format( (name).replace('-', '_'))) except AttributeError: if name.s...
Find class method to call for declaration based on name.
entailment
def lookup(self, vtype, vname, target_id=None): """Return value of vname from the variable store vtype. Valid vtypes are `strings` 'counters', and `pending`. If the value is not found in the current steps store, earlier steps will be checked. If not found, '', 0, or (None, None) is retu...
Return value of vname from the variable store vtype. Valid vtypes are `strings` 'counters', and `pending`. If the value is not found in the current steps store, earlier steps will be checked. If not found, '', 0, or (None, None) is returned.
entailment
def counter_style(self, val, style): """Return counter value in given style.""" if style == 'decimal-leading-zero': if val < 10: valstr = "0{}".format(val) else: valstr = str(val) elif style == 'lower-roman': valstr = _to_roman(...
Return counter value in given style.
entailment
def eval_string_value(self, element, value): """Evaluate parsed string. Returns a list of current and delayed values. """ strval = '' vals = [] for term in value: if type(term) is ast.WhitespaceToken: pass elif type(term) is ast....
Evaluate parsed string. Returns a list of current and delayed values.
entailment
def do_string_set(self, element, decl, pseudo): """Implement string-set declaration.""" args = serialize(decl.value) step = self.state[self.state['current_step']] strval = '' strname = None for term in decl.value: if type(term) is ast.WhitespaceToken: ...
Implement string-set declaration.
entailment
def do_counter_reset(self, element, decl, pseudo): """Clear specified counters.""" step = self.state[self.state['current_step']] counter_name = '' for term in decl.value: if type(term) is ast.WhitespaceToken: continue elif type(term) is ast.IdentT...
Clear specified counters.
entailment
def do_node_set(self, element, decl, pseudo): """Implement node-set declaration.""" target = serialize(decl.value).strip() step = self.state[self.state['current_step']] elem = self.current_target().tree _, valstep = self.lookup('pending', target) if not valstep: ...
Implement node-set declaration.
entailment
def do_move_to(self, element, decl, pseudo): """Implement move-to declaration.""" target = serialize(decl.value).strip() step = self.state[self.state['current_step']] elem = self.current_target().tree # Find if the current node already has a move, and remove it. actions...
Implement move-to declaration.
entailment
def do_container(self, element, decl, pseudo): """Implement setting tag for new wrapper element.""" value = serialize(decl.value).strip() if '|' in value: namespace, tag = value.split('|', 1) try: namespace = self.css_namespaces[namespace] ex...
Implement setting tag for new wrapper element.
entailment
def do_class(self, element, decl, pseudo): """Implement class declaration - pre-match.""" step = self.state[self.state['current_step']] actions = step['actions'] strval = self.eval_string_value(element, decl.value) actions.append(('attrib', ('class', strval)))
Implement class declaration - pre-match.
entailment
def do_attr_any(self, element, decl, pseudo): """Implement generic attribute setting.""" step = self.state[self.state['current_step']] actions = step['actions'] strval = self.eval_string_value(element, decl.value) actions.append(('attrib', (decl.name[5:], strval)))
Implement generic attribute setting.
entailment
def do_content(self, element, decl, pseudo): """Implement content declaration.""" # FIXME Need?: link(id) step = self.state[self.state['current_step']] actions = step['actions'] wastebin = [] elem = self.current_target().tree if elem == element.etree_element or p...
Implement content declaration.
entailment
def do_group_by(self, element, decl, pseudo): """Implement group-by declaration - pre-match.""" sort_css = groupby_css = flags = '' if ',' in decl.value: if decl.value.count(',') == 2: sort_css, groupby_css, flags = \ map(serialize, split(decl....
Implement group-by declaration - pre-match.
entailment
def do_sort_by(self, element, decl, pseudo): """Implement sort-by declaration - pre-match.""" if ',' in decl.value: css, flags = split(decl.value, ',') else: css = decl.value flags = None sort = css_to_func(serialize(css), serialize(flags or ''), ...
Implement sort-by declaration - pre-match.
entailment
def do_pass(self, element, decl, pseudo): """No longer valid way to set processing pass.""" log(WARN, u"Old-style pass as declaration not allowed.{}" .format(decl.value).encpde('utf-8'))
No longer valid way to set processing pass.
entailment
def connection_cache(func: callable): """Connection cache for SSH sessions. This is to prevent opening a new, expensive connection on every command run.""" cache = dict() lock = RLock() @wraps(func) def func_wrapper(host: str, username: str, *args, **kwargs): key = "{h}-{u}".format(h=h...
Connection cache for SSH sessions. This is to prevent opening a new, expensive connection on every command run.
entailment
def _get_connection(host, username: str, key_path: str) \ -> paramiko.Transport or None: """Return an authenticated SSH connection. :param host: host or IP of the machine :type host: str :param username: SSH username :type username: str :param key_path: path to the SSH private key for S...
Return an authenticated SSH connection. :param host: host or IP of the machine :type host: str :param username: SSH username :type username: str :param key_path: path to the SSH private key for SSH auth :type key_path: str :return: SSH connection :rtype: paramiko.Transport or None
entailment
def run_command( host, command, username=None, key_path=None, noisy=True ): """ Run a command via SSH, proxied through the mesos master :param host: host or IP of the machine to execute the command on :type host: str :param command: the command to exe...
Run a command via SSH, proxied through the mesos master :param host: host or IP of the machine to execute the command on :type host: str :param command: the command to execute :type command: str :param username: SSH username :type username: str :param key_path: p...
entailment
def run_command_on_master( command, username=None, key_path=None, noisy=True ): """ Run a command on the Mesos master """ return run_command(shakedown.master_ip(), command, username, key_path, noisy)
Run a command on the Mesos master
entailment
def run_command_on_leader( command, username=None, key_path=None, noisy=True ): """ Run a command on the Mesos leader. Important for Multi-Master. """ return run_command(shakedown.master_leader_ip(), command, username, key_path, noisy)
Run a command on the Mesos leader. Important for Multi-Master.
entailment
def run_command_on_marathon_leader( command, username=None, key_path=None, noisy=True ): """ Run a command on the Marathon leader """ return run_command(shakedown.marathon_leader_ip(), command, username, key_path, noisy)
Run a command on the Marathon leader
entailment
def run_command_on_agent( host, command, username=None, key_path=None, noisy=True ): """ Run a command on a Mesos agent, proxied through the master """ return run_command(host, command, username, key_path, noisy)
Run a command on a Mesos agent, proxied through the master
entailment
def run_dcos_command(command, raise_on_error=False, print_output=True): """ Run `dcos {command}` via DC/OS CLI :param command: the command to execute :type command: str :param raise_on_error: whether to raise a DCOSException if the return code is nonzero :type raise_on_error: bool ...
Run `dcos {command}` via DC/OS CLI :param command: the command to execute :type command: str :param raise_on_error: whether to raise a DCOSException if the return code is nonzero :type raise_on_error: bool :param print_output: whether to print the resulting stdout/stderr from ru...
entailment
def _wait_for_recv(self): """After executing a command, wait for results. Because `recv_ready()` can return False, but still have a valid, open connection, it is not enough to ensure output from a command execution is properly captured. :return: None """ ...
After executing a command, wait for results. Because `recv_ready()` can return False, but still have a valid, open connection, it is not enough to ensure output from a command execution is properly captured. :return: None
entailment
def attach_cluster(url): """Attach to an already set-up cluster :return: True if successful, else False """ with shakedown.stdchannel_redirected(sys.stderr, os.devnull): clusters = [c.dict() for c in dcos.cluster.get_clusters()] for c in clusters: if url == c['url']: try:...
Attach to an already set-up cluster :return: True if successful, else False
entailment
def dcos_version(): """Return the version of the running cluster. :return: DC/OS cluster version as a string """ url = _gen_url('dcos-metadata/dcos-version.json') response = dcos.http.request('get', url) if response.status_code == 200: return response.json()['version'] else: ...
Return the version of the running cluster. :return: DC/OS cluster version as a string
entailment
def authenticate(username, password): """Authenticate with a DC/OS cluster and return an ACS token. return: ACS token """ url = _gen_url('acs/api/v1/auth/login') creds = { 'uid': username, 'password': password } response = dcos.http.request('post', url, json=creds) if ...
Authenticate with a DC/OS cluster and return an ACS token. return: ACS token
entailment
def authenticate_oauth(oauth_token): """Authenticate by checking for a valid OAuth token. return: ACS token """ url = _gen_url('acs/api/v1/auth/login') creds = { 'token': oauth_token } response = dcos.http.request('post', url, json=creds) if response.status_code == 200: ...
Authenticate by checking for a valid OAuth token. return: ACS token
entailment
def _gen_url(url_path): """Return an absolute URL by combining DC/OS URL and url_path. :param url_path: path to append to DC/OS URL :type url_path: str :return: absolute URL :rtype: str """ from six.moves import urllib return urllib.parse.urljoin(dcos_url(), url_path)
Return an absolute URL by combining DC/OS URL and url_path. :param url_path: path to append to DC/OS URL :type url_path: str :return: absolute URL :rtype: str
entailment
def partition_master(incoming=True, outgoing=True): """ Partition master's port alone. To keep DC/OS cluster running. :param incoming: Partition incoming traffic to master process. Default True. :param outgoing: Partition outgoing traffic from master process. Default True. """ echo('Partitioning m...
Partition master's port alone. To keep DC/OS cluster running. :param incoming: Partition incoming traffic to master process. Default True. :param outgoing: Partition outgoing traffic from master process. Default True.
entailment
def get_all_masters(): """ Returns the json object that represents each of the masters. """ masters = [] for master in __master_zk_nodes_keys(): master_zk_str = get_zk_node_data(master)['str'] masters.append(json.loads(master_zk_str)) return masters
Returns the json object that represents each of the masters.
entailment
def get_public_agents_public_ip(): """Provides a list public IPs for public agents in the cluster""" public_ip_list = [] agents = get_public_agents() for agent in agents: status, public_ip = shakedown.run_command_on_agent(agent, "/opt/mesosphere/bin/detect_ip_public") public_ip_list.appe...
Provides a list public IPs for public agents in the cluster
entailment
def get_public_agents(): """Provides a list of hostnames / private IPs that are public agents in the cluster""" agent_list = [] agents = __get_all_agents() for agent in agents: for reservation in agent["reserved_resources"]: if "slave_public" in reservation: agent_lis...
Provides a list of hostnames / private IPs that are public agents in the cluster
entailment
def get_private_agents(): """Provides a list of hostnames / IPs that are private agents in the cluster""" agent_list = [] agents = __get_all_agents() for agent in agents: if(len(agent["reserved_resources"]) == 0): agent_list.append(agent["hostname"]) else: privat...
Provides a list of hostnames / IPs that are private agents in the cluster
entailment
def get_agents(): """Provides a list of hostnames / IPs of all agents in the cluster""" agent_list = [] agents = __get_all_agents() for agent in agents: agent_list.append(agent["hostname"]) return agent_list
Provides a list of hostnames / IPs of all agents in the cluster
entailment
def partition_agent(host): """ Partition a node from all network traffic except for SSH and loopback :param hostname: host or IP of the machine to partition from the cluster """ network.save_iptables(host) network.flush_all_rules(host) network.allow_all_traffic(host) network.run_iptabl...
Partition a node from all network traffic except for SSH and loopback :param hostname: host or IP of the machine to partition from the cluster
entailment
def kill_process_on_host( hostname, pattern ): """ Kill the process matching pattern at ip :param hostname: the hostname or ip address of the host on which the process will be killed :param pattern: a regular expression matching the name of the process to kill """ status, stdout = ...
Kill the process matching pattern at ip :param hostname: the hostname or ip address of the host on which the process will be killed :param pattern: a regular expression matching the name of the process to kill
entailment
def kill_process_from_pid_file_on_host(hostname, pid_file='app.pid'): """ Retrieves the PID of a process from a pid file on host and kills it. :param hostname: the hostname or ip address of the host on which the process will be killed :param pid_file: pid file to use holding the pid number to kill """ ...
Retrieves the PID of a process from a pid file on host and kills it. :param hostname: the hostname or ip address of the host on which the process will be killed :param pid_file: pid file to use holding the pid number to kill
entailment
def wait_for( predicate, timeout_seconds=120, sleep_seconds=1, ignore_exceptions=True, inverse_predicate=False, noisy=False, required_consecutive_success_count=1): """ waits or spins for a predicate, returning the result. Predicate is a function that r...
waits or spins for a predicate, returning the result. Predicate is a function that returns a truthy or falsy value. An exception in the function will be returned. A timeout will throw a TimeoutExpired Exception.
entailment
def __stringify_predicate(predicate): """ Reflection of function name and parameters of the predicate being used. """ funname = getsource(predicate).strip().split(' ')[2].rstrip(',') params = 'None' # if args dig in the stack if '()' not in funname: stack = getouterframes(currentframe()...
Reflection of function name and parameters of the predicate being used.
entailment
def time_wait( predicate, timeout_seconds=120, sleep_seconds=1, ignore_exceptions=True, inverse_predicate=False, noisy=True, required_consecutive_success_count=1): """ waits or spins for a predicate and returns the time of the wait. An exception in the function will be returned. ...
waits or spins for a predicate and returns the time of the wait. An exception in the function will be returned. A timeout will throw a TimeoutExpired Exception.
entailment
def wait_while_exceptions( predicate, timeout_seconds=120, sleep_seconds=1, noisy=False): """ waits for a predicate, ignoring exceptions, returning the result. Predicate is a function. Exceptions will trigger the sleep and retry; any non-exception result will ...
waits for a predicate, ignoring exceptions, returning the result. Predicate is a function. Exceptions will trigger the sleep and retry; any non-exception result will be returned. A timeout will throw a TimeoutExpired Exception.
entailment
def elapse_time(start, end=None, precision=3): """ Simple time calculation utility. Given a start time, it will provide an elapse time. """ if end is None: end = time_module.time() return round(end-start, precision)
Simple time calculation utility. Given a start time, it will provide an elapse time.
entailment
def pretty_duration(seconds): """ Returns a user-friendly representation of the provided duration in seconds. For example: 62.8 => "1m2.8s", or 129837.8 => "2d12h4m57.8s" """ if seconds is None: return '' ret = '' if seconds >= 86400: ret += '{:.0f}d'.format(int(seconds / 86400))...
Returns a user-friendly representation of the provided duration in seconds. For example: 62.8 => "1m2.8s", or 129837.8 => "2d12h4m57.8s"
entailment
def read_config(args): """ Read configuration options from ~/.shakedown (if exists) :param args: a dict of arguments :type args: dict :return: a dict of arguments :rtype: dict """ configfile = os.path.expanduser('~/.shakedown') if os.path.isfile(configfile): w...
Read configuration options from ~/.shakedown (if exists) :param args: a dict of arguments :type args: dict :return: a dict of arguments :rtype: dict
entailment
def set_config_defaults(args): """ Set configuration defaults :param args: a dict of arguments :type args: dict :return: a dict of arguments :rtype: dict """ defaults = { 'fail': 'fast', 'stdout': 'fail' } for key in defaults: if not args[k...
Set configuration defaults :param args: a dict of arguments :type args: dict :return: a dict of arguments :rtype: dict
entailment
def banner(): """ Display a product banner :return: a delightful Mesosphere logo rendered in unicode :rtype: str """ banner_dict = { 'a0': click.style(chr(9601), fg='magenta'), 'a1': click.style(chr(9601), fg='magenta', bold=True), 'b0': click.style(chr(9616), fg='m...
Display a product banner :return: a delightful Mesosphere logo rendered in unicode :rtype: str
entailment
def decorate(text, style): """ Console decoration style definitions :param text: the text string to decorate :type text: str :param style: the style used to decorate the string :type style: str :return: a decorated string :rtype: str """ return { 's...
Console decoration style definitions :param text: the text string to decorate :type text: str :param style: the style used to decorate the string :type style: str :return: a decorated string :rtype: str
entailment
def echo(text, **kwargs): """ Print results to the console :param text: the text string to print :type text: str :return: a string :rtype: str """ if shakedown.cli.quiet: return if not 'n' in kwargs: kwargs['n'] = True if 'd' in kwargs: te...
Print results to the console :param text: the text string to print :type text: str :return: a string :rtype: str
entailment
def add_user(uid, password, desc=None): """ Adds user to the DCOS Enterprise. If not description is provided the uid will be used for the description. :param uid: user id :type uid: str :param password: password :type password: str :param desc: description of user ...
Adds user to the DCOS Enterprise. If not description is provided the uid will be used for the description. :param uid: user id :type uid: str :param password: password :type password: str :param desc: description of user :type desc: str
entailment
def get_user(uid): """ Returns a user from the DCOS Enterprise. It returns None if none exists. :param uid: user id :type uid: str :return: User :rtype: dict """ try: acl_url = urljoin(_acl_url(), 'users/{}'.format(uid)) r = http.get(acl_url) return ...
Returns a user from the DCOS Enterprise. It returns None if none exists. :param uid: user id :type uid: str :return: User :rtype: dict
entailment
def remove_user(uid): """ Removes a user from the DCOS Enterprise. :param uid: user id :type uid: str """ try: acl_url = urljoin(_acl_url(), 'users/{}'.format(uid)) r = http.delete(acl_url) assert r.status_code == 204 except DCOSHTTPException as e: # does...
Removes a user from the DCOS Enterprise. :param uid: user id :type uid: str
entailment
def ensure_resource(rid): """ Creates or confirms that a resource is added into the DCOS Enterprise System. Example: dcos:service:marathon:marathon:services:/example-secure :param rid: resource ID :type rid: str """ try: acl_url = urljoin(_acl_url(), 'acls/{}'.format(rid)) ...
Creates or confirms that a resource is added into the DCOS Enterprise System. Example: dcos:service:marathon:marathon:services:/example-secure :param rid: resource ID :type rid: str
entailment
def set_user_permission(rid, uid, action='full'): """ Sets users permission on a given resource. The resource will be created if it doesn't exist. Actions are: read, write, update, delete, full. :param uid: user id :type uid: str :param rid: resource ID :type rid: str ...
Sets users permission on a given resource. The resource will be created if it doesn't exist. Actions are: read, write, update, delete, full. :param uid: user id :type uid: str :param rid: resource ID :type rid: str :param action: read, write, update, delete or full ...
entailment
def remove_user_permission(rid, uid, action='full'): """ Removes user permission on a given resource. :param uid: user id :type uid: str :param rid: resource ID :type rid: str :param action: read, write, update, delete or full :type action: str """ rid = rid....
Removes user permission on a given resource. :param uid: user id :type uid: str :param rid: resource ID :type rid: str :param action: read, write, update, delete or full :type action: str
entailment
def no_user(): """ Provides a context with no logged in user. """ o_token = dcos_acs_token() dcos.config.set_val('core.dcos_acs_token', '') yield dcos.config.set_val('core.dcos_acs_token', o_token)
Provides a context with no logged in user.
entailment
def new_dcos_user(user_id, password): """ Provides a context with a newly created user. """ o_token = dcos_acs_token() shakedown.add_user(user_id, password, user_id) token = shakedown.authenticate(user_id, password) dcos.config.set_val('core.dcos_acs_token', token) yield dcos.config.set...
Provides a context with a newly created user.
entailment
def dcos_user(user_id, password): """ Provides a context with user otherthan super """ o_token = dcos_acs_token() token = shakedown.authenticate(user_id, password) dcos.config.set_val('core.dcos_acs_token', token) yield dcos.config.set_val('core.dcos_acs_token', o_token)
Provides a context with user otherthan super
entailment
def add_group(id, description=None): """ Adds group to the DCOS Enterprise. If not description is provided the id will be used for the description. :param id: group id :type id: str :param desc: description of user :type desc: str """ if not description: de...
Adds group to the DCOS Enterprise. If not description is provided the id will be used for the description. :param id: group id :type id: str :param desc: description of user :type desc: str
entailment
def get_group(id): """ Returns a group from the DCOS Enterprise. It returns None if none exists. :param id: group id :type id: str :return: Group :rtype: dict """ acl_url = urljoin(_acl_url(), 'groups/{}'.format(id)) try: r = http.get(acl_url) return r.j...
Returns a group from the DCOS Enterprise. It returns None if none exists. :param id: group id :type id: str :return: Group :rtype: dict
entailment
def remove_group(id): """ Removes a group from the DCOS Enterprise. The group is removed regardless of associated users. :param id: group id :type id: str """ acl_url = urljoin(_acl_url(), 'groups/{}'.format(id)) try: r = http.delete(acl_url) print(r.status_code...
Removes a group from the DCOS Enterprise. The group is removed regardless of associated users. :param id: group id :type id: str
entailment
def add_user_to_group(uid, gid, exist_ok=True): """ Adds a user to a group within DCOS Enterprise. The group and user must exist. :param uid: user id :type uid: str :param gid: group id :type gid: str :param exist_ok: True if it is ok for the relationship to pre-exi...
Adds a user to a group within DCOS Enterprise. The group and user must exist. :param uid: user id :type uid: str :param gid: group id :type gid: str :param exist_ok: True if it is ok for the relationship to pre-exist. :type exist_ok: bool
entailment
def remove_user_from_group(uid, gid): """ Removes a user from a group within DCOS Enterprise. :param uid: user id :type uid: str :param gid: group id :type gid: str """ acl_url = urljoin(_acl_url(), 'groups/{}/users/{}'.format(gid, uid)) try: r = http.delete(acl_...
Removes a user from a group within DCOS Enterprise. :param uid: user id :type uid: str :param gid: group id :type gid: str
entailment
def easybake(css_in, html_in=sys.stdin, html_out=sys.stdout, last_step=None, coverage_file=None, use_repeatable_ids=False): """Process the given HTML file stream with the css stream.""" html_doc = etree.parse(html_in) oven = Oven(css_in, use_repeatable_ids) oven.bake(html_doc, last_step) ...
Process the given HTML file stream with the css stream.
entailment
def main(argv=None): """Commandline script wrapping Baker.""" parser = argparse.ArgumentParser(description="Process raw HTML to baked" " (embedded numbering and" " collation)") parser.add_argument('-v', '--vers...
Commandline script wrapping Baker.
entailment
def mom_version(name='marathon-user'): """Returns the version of marathon on marathon. """ if service_available_predicate(name): with marathon_on_marathon(name): return marathon_version() else: # We can either skip the corresponding test by returning False # or ra...
Returns the version of marathon on marathon.
entailment
def mom_version_less_than(version, name='marathon-user'): """ Returns True if MoM with the given {name} exists and has a version less than {version}. Note that if MoM does not exist False is returned. :param version: required version :type: string :param name: MoM name, default is '...
Returns True if MoM with the given {name} exists and has a version less than {version}. Note that if MoM does not exist False is returned. :param version: required version :type: string :param name: MoM name, default is 'marathon-user' :type: string :return: True if vers...
entailment
def marathon_on_marathon(name='marathon-user'): """ Context manager for altering the marathon client for MoM :param name: service name of MoM to use :type name: str """ toml_config_o = config.get_config() dcos_url = config.get_config_val('core.dcos_url', toml_config_o) service_name = 'servi...
Context manager for altering the marathon client for MoM :param name: service name of MoM to use :type name: str
entailment
def get_transport(host, username, key): """ Create a transport object :param host: the hostname to connect to :type host: str :param username: SSH username :type username: str :param key: key object used for authentication :type key: paramiko.RSAKey :return:...
Create a transport object :param host: the hostname to connect to :type host: str :param username: SSH username :type username: str :param key: key object used for authentication :type key: paramiko.RSAKey :return: a transport object :rtype: paramiko.Tra...
entailment
def start_transport(transport, username, key): """ Begin a transport client and authenticate it :param transport: the transport object to start :type transport: paramiko.Transport :param username: SSH username :type username: str :param key: key object used for authenticatio...
Begin a transport client and authenticate it :param transport: the transport object to start :type transport: paramiko.Transport :param username: SSH username :type username: str :param key: key object used for authentication :type key: paramiko.RSAKey :return: ...
entailment
def validate_key(key_path): """ Validate a key :param key_path: path to a key to use for authentication :type key_path: str :return: key object used for authentication :rtype: paramiko.RSAKey """ key_path = os.path.expanduser(key_path) if not os.path.isfile(key_path):...
Validate a key :param key_path: path to a key to use for authentication :type key_path: str :return: key object used for authentication :rtype: paramiko.RSAKey
entailment
def get_service( service_name, inactive=False, completed=False ): """ Get a dictionary describing a service :param service_name: the service name :type service_name: str :param inactive: whether to include inactive services :type inactive: bool :param ...
Get a dictionary describing a service :param service_name: the service name :type service_name: str :param inactive: whether to include inactive services :type inactive: bool :param completed: whether to include completed services :type completed: bool :return: a...
entailment
def get_service_framework_id( service_name, inactive=False, completed=False ): """ Get the framework ID for a service :param service_name: the service name :type service_name: str :param inactive: whether to include inactive services :type inactive: bool ...
Get the framework ID for a service :param service_name: the service name :type service_name: str :param inactive: whether to include inactive services :type inactive: bool :param completed: whether to include completed services :type completed: bool :return: a fr...
entailment
def get_service_tasks( service_name, inactive=False, completed=False ): """ Get a list of tasks associated with a service :param service_name: the service name :type service_name: str :param inactive: whether to include inactive services :type inactive: bool ...
Get a list of tasks associated with a service :param service_name: the service name :type service_name: str :param inactive: whether to include inactive services :type inactive: bool :param completed: whether to include completed services :type completed: bool :r...
entailment
def get_service_task_ids( service_name, task_predicate=None, inactive=False, completed=False ): """ Get a list of task IDs associated with a service :param service_name: the service name :type service_name: str :param task_predicate: filter function which acce...
Get a list of task IDs associated with a service :param service_name: the service name :type service_name: str :param task_predicate: filter function which accepts a task object and returns a boolean :type task_predicate: function, or None :param inactive: whether to include inac...
entailment
def get_service_task( service_name, task_name, inactive=False, completed=False ): """ Get a dictionary describing a service task, or None :param service_name: the service name :type service_name: str :param task_name: the task name :type task_name: str...
Get a dictionary describing a service task, or None :param service_name: the service name :type service_name: str :param task_name: the task name :type task_name: str :param inactive: whether to include inactive services :type inactive: bool :param completed: whet...
entailment
def get_marathon_task( task_name, inactive=False, completed=False ): """ Get a dictionary describing a named marathon task """ return get_service_task('marathon', task_name, inactive, completed)
Get a dictionary describing a named marathon task
entailment
def get_mesos_task(task_name): """ Get a mesos task with a specific task name """ tasks = get_mesos_tasks() if tasks is not None: for task in tasks: if task['name'] == task_name: return task return None
Get a mesos task with a specific task name
entailment
def get_service_ips( service_name, task_name=None, inactive=False, completed=False ): """ Get a set of the IPs associated with a service :param service_name: the service name :type service_name: str :param task_name: the task name :type task_name: str ...
Get a set of the IPs associated with a service :param service_name: the service name :type service_name: str :param task_name: the task name :type task_name: str :param inactive: wehther to include inactive services :type inactive: bool :param completed: whether t...
entailment
def service_healthy(service_name, app_id=None): """ Check whether a named service is healthy :param service_name: the service name :type service_name: str :param app_id: app_id to filter :type app_id: str :return: True if healthy, False otherwise :rtype: bool ""...
Check whether a named service is healthy :param service_name: the service name :type service_name: str :param app_id: app_id to filter :type app_id: str :return: True if healthy, False otherwise :rtype: bool
entailment
def delete_persistent_data(role, zk_node): """ Deletes any persistent data associated with the specified role, and zk node. :param role: the mesos role to delete, or None to omit this :type role: str :param zk_node: the zookeeper node to be deleted, or None to skip this deletion :ty...
Deletes any persistent data associated with the specified role, and zk node. :param role: the mesos role to delete, or None to omit this :type role: str :param zk_node: the zookeeper node to be deleted, or None to skip this deletion :type zk_node: str
entailment
def destroy_volumes(role): """ Destroys all volumes on all the slaves in the cluster for the role. """ state = dcos_agents_state() if not state or 'slaves' not in state.keys(): return False all_success = True for agent in state['slaves']: if not destroy_volume(agent, role): ...
Destroys all volumes on all the slaves in the cluster for the role.
entailment
def destroy_volume(agent, role): """ Deletes the volumes on the specific agent for the role """ volumes = [] agent_id = agent['id'] reserved_resources_full = agent.get('reserved_resources_full', None) if not reserved_resources_full: # doesn't exist return True reserved_reso...
Deletes the volumes on the specific agent for the role
entailment