def get_groups(ip): try: child = telnet(ip) rslt = do_some(child, 'disp cu config | in link-aggregation') close(child) except (pexpect.EOF, pexpect.TIMEOUT) as e: return ('fail', None, ip) temp = re_all(r'(group\s+\d+)\s+mode\s+(\w+)', rslt) temp1 = dict(re_all(r'(group\s+\d+)\s+description\s+(\S+ *\S*)', rslt)) rslt1 = [dict(name=x[0], mode=x[1], desc=temp1.get(x[0], None)) for x in temp] rslt3 = [update_in(x, ['mode'], lambda y: 'yes' if y == 'static' else y) for x in rslt1] return ('success', rslt3, ip)
def get_groups(ip): try: child = telnet(ip) rslt = do_some(child, 'disp cu config | in link-aggregation') close(child) except (pexpect.EOF, pexpect.TIMEOUT) as e: return ('fail', None, ip) temp = re_all(r'(group\s+\d+)\s+mode\s+(\w+)', rslt) temp1 = dict(re_all(r'(group\s+\d+)\s+description\s+(\S+ *\S*)', rslt)) rslt1 = [ dict(name=x[0], mode=x[1], desc=temp1.get(x[0], None)) for x in temp ] rslt3 = [ update_in(x, ['mode'], lambda y: 'yes' if y == 'static' else y) for x in rslt1 ] return ('success', rslt3, ip)
def remap(x): f = lambda i: vol.get_container_mount(i)['biobox_target'] return funcy.update_in(x, ['value'], f)
def _merge_in(collection, path, new_item): return update_in(collection, path, lambda x: merge(x, [new_item]))