def _connect_ssh(ip_address, user, password): if not network.check_tcp_port(ip_address, 22): raise ConnectionError('Port 22 closed on a HP MSA Storage.') return network.connect_ssh( ip_address, user, password, client=HPSSHClient, )
def _connect_ssh(ip): if not network.check_tcp_port(ip, 22): raise ConnectionError('Port 22 closed.') return network.connect_ssh( ip, SSH_USER, SSH_PASSWORD, client=CiscoSSHClient, )
def _connect_ssh(ip, username, password): if not network.check_tcp_port(ip, 22): raise ConnectionError('Port 22 closed.') return network.connect_ssh( ip, username, password, client=CiscoSSHClient, )
def scan_address(ip_address, **kwargs): if 'nx-os' in kwargs.get('snmp_name', '').lower(): raise NoMatchError("Incompatible Nexus found.") if 'StorageWorks' not in kwargs.get('snmp_name'): raise NoMatchError("No match") if not network.check_tcp_port(ip_address, 22): raise ConnectionError("Port 22 closed.") device = _run_ssh_p2000(ip_address) ret = { 'status': 'success', 'device': device, } tpl = get_base_result_template('ssh_hp_p2000') tpl.update(ret) return json.loads(json.dumps(tpl)) # to ensure its picklable
def scan_address(ip_address, **kwargs): if 'nx-os' in (kwargs.get('snmp_name', '') or '').lower(): raise NoMatchError('Incompatible Nexus found.') if kwargs.get('http_family', '') not in ('IBM', 'Unspecified'): raise NoMatchError('It is not IBM.') if not (kwargs.get('snmp_name', 'IBM') or 'IBM').startswith('IBM'): raise NoMatchError('It is not IBM.') if not network.check_tcp_port(ip_address, 22): raise ConnectionError('Port 22 closed on an IBM BladeServer.') messages = [] result = get_base_result_template('ssh_ibm_bladecenter', messages) device = _blade_scan(ip_address) if not device: raise DeviceError("Malformed bladecenter device: %s" % ip_address) result['device'] = device result['status'] = 'success' return result
def _get_session(base_url, user, password): s = requests.Session() data = {'username': '******'.format(user), 'password': password} try: r = requests.post('{}/access/ticket'.format(base_url), verify=False, data=data) except requests.ConnectionError: raise ConnectionError("Can't connect through API.") try: ticket = r.json()['data']['ticket'] except (KeyError, TypeError): raise AuthError("Can't get access ticket through API.") s.headers = { 'content-type': 'application/x-www-form-urlencoded', 'Connection': 'keep-alive', } s.cookies = requests.cookies.cookiejar_from_dict({'PVEAuthCookie': ticket}) s.verify = False return s
def _connect_ssh(ip_address, user, password): if not check_tcp_port(ip_address, 22): raise ConnectionError('Port 22 closed on a XEN server.') return connect_ssh(ip_address, user, password)
def _connect_ssh(ip_address, user, password): if not network.check_tcp_port(ip_address, 22): raise ConnectionError('Port 22 closed on a Proxmox server.') return network.connect_ssh(ip_address, user, password)
def _connect_ssh(ip_address, user, password): if not check_tcp_port(ip_address, 22): raise ConnectionError('Port 22 closed.') return connect_ssh(ip_address, user, password, client=SSGSSHClient)