本文整理汇总了Python中ralph.scan.plugins.get_base_result_template函数的典型用法代码示例。如果您正苦于以下问题:Python get_base_result_template函数的具体用法?Python get_base_result_template怎么用?Python get_base_result_template使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_base_result_template函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: scan_address
def scan_address(ip_address, **kwargs):
if kwargs.get('http_family') not in ('sscccc',):
raise NoMatchError("It's not an ONStor.")
if 'nx-os' in (kwargs.get('snmp_name', '') or '').lower():
raise NoMatchError("Incompatible Nexus found.")
user = SETTINGS.get('user')
password = SETTINGS.get('password')
messages = []
result = get_base_result_template('ssh_onstor', messages)
if not user or not password:
result['status'] = 'error'
messages.append(
'Not configured. Set SSH_ONSTOR_USER and SSH_ONSTOR_PASSWORD in '
'your configuration file.',
)
else:
try:
device_info = _ssh_onstor(ip_address, user, password)
except ConnectionError as e:
result['status'] = 'error'
messages.append(unicode(e))
else:
result.update({
'status': 'success',
'device': device_info,
})
return result
开发者ID:4i60r,项目名称:ralph,代码行数:27,代码来源:ssh_onstor.py
示例2: scan_address
def scan_address(ip_address, **kwargs):
http_family = kwargs.get('http_family', '')
if http_family not in (
'Sun', 'Thomas-Krenn', 'Oracle-ILOM-Web-Server', 'IBM System X',
):
raise NoMatchError('It is not compatible device for this plugin.')
user = SETTINGS.get('user')
password = SETTINGS.get('password')
messages = []
result = get_base_result_template('ipmi', messages)
if not user or not password:
result['status'] = 'error'
messages.append('Not configured.')
else:
ipmitool = IPMITool(ip_address, user, password)
try:
device_info = _ipmi(ipmitool)
except (AuthError, Error) as e:
result['status'] = 'error'
messages.append(unicode(e))
else:
result.update({
'status': 'success',
'device': device_info,
})
return result
开发者ID:alberto-g,项目名称:ralph,代码行数:26,代码来源:ipmi.py
示例3: scan_address
def scan_address(ip_address, **kwargs):
http_family = (kwargs.get('http_family', '') or '').strip()
if http_family and http_family.lower() not in ('dell', 'embedthis-http'):
raise NoMatchError('It is not Dell.')
user = SETTINGS.get('user')
password = SETTINGS.get('password')
messages = []
result = get_base_result_template('idrac', messages)
if not user or not password:
result.update(status='error')
messages.append('Not configured.')
else:
idrac_manager = IDRAC(ip_address, user, password)
try:
device_info = idrac_device_info(idrac_manager)
except Error as e:
result.update(status='error')
messages.append(unicode(e))
else:
device_info['management_ip_addresses'] = [ip_address]
result.update({
'status': 'success',
'device': device_info,
})
return result
开发者ID:deejay1,项目名称:ralph,代码行数:25,代码来源:idrac.py
示例4: scan_address
def scan_address(ip_address, **kwargs):
http_family = (kwargs.get("http_family", "") or "").strip().lower()
snmp_name = (kwargs.get("snmp_name", "") or "").strip().lower()
if all(("esx" not in http_family, "esx" not in snmp_name, "vmware" not in snmp_name)):
raise NoMatchError("It is not VMWare.")
user = SETTINGS.get("user")
password = SETTINGS.get("password")
messages = []
result = get_base_result_template("vmware", messages)
if not user or not password:
result["status"] = "error"
messages.append("Not configured. Set VMWARE_USER and VMWARE_PASSWORD in your " "configuration file.")
else:
try:
server_conn = _connect(ip_address, user, password)
except VIApiException as e:
result["status"] = "error"
messages.append(unicode(e))
else:
try:
if "vcenter" in server_conn.get_server_type().lower():
raise NoMatchError(
"It is `VMware vCenter Server`. To save real "
"hypervisor - VM connecion you should scan only "
"VMware ESXi servers."
)
device_info = _vmware(server_conn, ip_address, messages)
finally:
server_conn.disconnect()
result.update({"status": "success", "device": device_info})
return result
开发者ID:pydubreucq,项目名称:ralph,代码行数:31,代码来源:vmware.py
示例5: scan_address
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 ('Proxmox', 'Proxmox1'):
raise NoMatchError('It is not Proxmox 1.')
user = SETTINGS.get('user')
password = SETTINGS.get('password')
messages = []
result = get_base_result_template('ssh_proxmox', messages)
if not user or not password:
result['status'] = 'error'
messages.append(
'Not configured. Set SSH_USER and SSH_PASSWORD in your '
'configuration file.',
)
else:
try:
device_info = _ssh_proxmox(ip_address, user, password)
except (ConnectionError, NoMatchError) as e:
result['status'] = 'error'
messages.append(unicode(e))
else:
result.update({
'status': 'success',
'device': device_info,
})
return result
开发者ID:4i60r,项目名称:ralph,代码行数:27,代码来源:ssh_proxmox.py
示例6: scan_address
def scan_address(ip_address, **kwargs):
snmp_name = kwargs.get("snmp_name", "") or ""
http_family = kwargs.get("http_family", "") or ""
if (snmp_name and "juniper" not in snmp_name.lower()) and (
http_family and http_family.strip().lower() not in ("juniper",)
):
raise NoMatchError("It is not Juniper.")
user = SETTINGS.get("user")
password = SETTINGS.get("password")
messages = []
result = get_base_result_template("ssh_juniper", messages)
if not user or not password:
result["status"] = "error"
messages.append("Not configured. Set SSH_SSG_USER and SSH_SSG_PASSWORD in your " "configuration file.")
else:
try:
ssh = _connect_ssh(ip_address, user, password)
except ConnectionError as e:
result["status"] = "error"
messages.append(unicode(e))
else:
try:
device_info = _ssh_juniper(ssh, ip_address)
finally:
ssh.close()
result.update({"status": "success", "device": device_info})
return result
开发者ID:deejay1,项目名称:ralph,代码行数:27,代码来源:ssh_juniper.py
示例7: scan_address
def scan_address(ip_address, **kwargs):
snmp_name = kwargs.get('snmp_name', '')
snmp_version = kwargs.get('snmp_version', '2c') or '2c'
if snmp_version == '3':
snmp_community = SETTINGS['snmp_v3_auth']
else:
snmp_community = str(kwargs['snmp_community'])
messages = []
result = get_base_result_template('snmp_macs', messages)
try:
device_info = _snmp_mac(
ip_address,
snmp_name,
snmp_community,
snmp_version,
messages,
)
except Error as e:
messages.append(unicode(e))
result.update(status="error")
else:
result.update({
'status': 'success',
'device': device_info,
})
return result
开发者ID:wmatyskiewicz,项目名称:ralph,代码行数:26,代码来源:snmp_macs.py
示例8: scan_address
def scan_address(ip_address, **kwargs):
http_family = (kwargs.get('http_family', '') or '')
if http_family and http_family.strip().lower() not in ('juniper',):
raise NoMatchError('It is not Juniper.')
user = SETTINGS.get('user')
password = SETTINGS.get('password')
messages = []
result = get_base_result_template('ssh_juniper', messages)
if not user or not password:
result['status'] = 'error'
messages.append(
'Not configured. Set SSH_SSG_USER and SSH_SSG_PASSWORD in your '
'configuration file.',
)
else:
try:
ssh = _connect_ssh(ip_address, user, password)
except ConnectionError as e:
result['status'] = 'error'
messages.append(unicode(e))
else:
try:
device_info = _ssh_juniper(ssh, ip_address)
finally:
ssh.close()
result.update({
'status': 'success',
'device': device_info,
})
return result
开发者ID:ReJeCtAll,项目名称:ralph,代码行数:30,代码来源:ssh_juniper.py
示例9: scan_address
def scan_address(ip_address, **kwargs):
if 'nx-os' in (kwargs.get('snmp_name', '') or '').lower():
raise NoMatchError('Incompatible Nexus found.')
kwargs['guessmodel'] = gvendor, gmodel = guessmodel.guessmodel(**kwargs)
if gvendor != 'Cisco' or gmodel not in ('',):
raise NoMatchError('It is not Cisco.')
if not SSH_USER or not SSH_PASS:
raise NotConfiguredError(
"SSH not configured in plugin {}.".format(__name__),
)
ssh = _connect_ssh(ip_address, SSH_USER, SSH_PASS)
try:
lines = ssh.asa_command(
"show version | grep (^Hardware|Boot microcode|^Serial|address is)"
)
finally:
ssh.close()
pairs = parse.pairs(lines=[line.strip() for line in lines])
sn = pairs.get('Serial Number', None)
model, ram, cpu = pairs['Hardware'].split(',')
boot_firmware = pairs['Boot microcode']
macs = []
for i in xrange(99):
try:
junk, label, mac = pairs['%d' % i].split(':')
except KeyError:
break
mac = mac.split(',', 1)[0]
mac = mac.replace('address is', '')
mac = mac.replace('.', '').upper().strip()
label = label.strip()
if mac.replace(':', '').upper()[:6] not in MAC_PREFIX_BLACKLIST:
macs.append(mac)
ram_size = re.search('[0-9]+', ram).group()
cpu_match = re.search('[0-9]+ MHz', cpu)
cpu_speed = cpu_match.group()[:-4]
cpu_model = cpu[:cpu_match.start()][4:].strip()
result = get_base_result_template('ssh_cisco_asa')
result.update({
'status': 'success',
'device': {
'model_name': 'Cisco ' + model,
'type': str(DeviceType.firewall),
'mac_addresses': macs,
'boot_firmware': boot_firmware,
'management_ip_addresses': [ip_address],
'memory': [{
'size': int(ram_size),
}],
'processors': [{
'model_name': cpu_model,
'speed': int(cpu_speed),
'family': cpu_model,
}],
},
})
if sn not in SERIAL_BLACKLIST:
result['device']['serial_number'] = sn
return result
开发者ID:4i60r,项目名称:ralph,代码行数:59,代码来源:ssh_cisco_asa.py
示例10: scan_address
def scan_address(ip_address, **kwargs):
snmp_name = kwargs.get("snmp_name", "") or ""
if "nx-os" in snmp_name.lower():
raise NoMatchError("Incompatible nexus found")
device = run_ssh_ganeti(ip_address)
ret = {"status": "success", "device": device}
tpl = get_base_result_template("ssh_ganeti")
tpl.update(ret)
return tpl
开发者ID:pydubreucq,项目名称:ralph,代码行数:9,代码来源:ssh_ganeti.py
示例11: scan_address
def scan_address(ip_address, **kwargs):
http_family = kwargs.get('http_family', '') or ''
messages = []
result = get_base_result_template('software', messages)
result['status'] = 'success'
software = _detect_software(ip_address, http_family)
if software:
result['installed_software'] = software
return result
开发者ID:4i60r,项目名称:ralph,代码行数:9,代码来源:software.py
示例12: scan_address
def scan_address(ip_address, **kwargs):
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
开发者ID:andrzej-jankowski,项目名称:ralph,代码行数:9,代码来源:ssh_ibm_bladecenter.py
示例13: scan_address
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 ('Unspecified', 'Cisco'):
raise NoMatchError('It is not Cisco.')
ssh = _connect_ssh(ip_address)
hostname = network.hostname(ip_address)
try:
ssh.cisco_command('terminal length 500')
mac = '\n'.join(ssh.cisco_command(
"show version | include Base ethernet MAC Address",
))
raw = '\n'.join(ssh.cisco_command("show inventory"))
subswitches = get_subswitches(
ssh.cisco_command("show version"), hostname, ip_address
)
finally:
ssh.close()
matches = re.match(
'Base ethernet MAC Address\s+:\s*([0-9aA-Z:]+)', mac)
if matches.groups():
mac = matches.groups()[0]
inventory = list(cisco_inventory(raw))
dev_inv, parts = inventory[0], inventory[1:]
sn = dev_inv['sn']
result = get_base_result_template('ssh_cisco_catalyst')
if subswitches:
# virtual switch doesn't have own unique id, reuse first from stack
sn += '-virtual'
model_name = 'Virtual Cisco Catalyst %s' % dev_inv['pid']
model_type = DeviceType.switch_stack
else:
model_name = 'Cisco Catalyst %s' % dev_inv['pid']
model_type = DeviceType.switch
result.update({
'status': 'success',
'device': {
'hostname': hostname if hostname else ip_address,
'model_name': model_name,
'type': model_type.raw,
'management_ip_addresses': [ip_address],
'parts': [{
'serial_number': part['sn'],
'name': part['name'],
'label': part['descr'],
} for part in parts],
},
})
if sn not in SERIAL_BLACKLIST:
result['device']['serial_number'] = sn
if subswitches:
result['device']['subdevices'] = subswitches
else:
result['device']['mac_addresses'] = [MACAddressField.normalize(mac)]
return result
开发者ID:ReJeCtAll,项目名称:ralph,代码行数:56,代码来源:ssh_cisco_catalyst.py
示例14: scan_address
def scan_address(ip_address, **kwargs):
if 'nx-os' in kwargs.get('snmp_name', '').lower():
raise NoMatchError("Incompatible nexus found")
device = run_ssh_ganeti(ip_address)
ret = {
'status': 'success',
'device': device,
}
tpl = get_base_result_template('ssh_ganeti')
tpl.update(ret)
return tpl
开发者ID:andrzej-jankowski,项目名称:ralph,代码行数:11,代码来源:ssh_ganeti.py
示例15: scan_address
def scan_address(address, **kwargs):
messages = []
data = get_base_result_template('dns_hostname', messages)
hostname = network.hostname(address)
if hostname:
data['device'] = {
'hostname': hostname,
}
data['status'] = 'success'
else:
data['status'] = 'error'
return data
开发者ID:4i60r,项目名称:ralph,代码行数:12,代码来源:dns_hostname.py
示例16: scan_address
def scan_address(ip_address, **kwargs):
messages = []
result = get_base_result_template('hp_oa', messages)
try:
device_info = _hp_oa(ip_address)
except (IncompatibleAnswerError, UncompleteAnswerError) as e:
messages.append(unicode(e))
result['status'] = 'error'
else:
result['status'] = 'success'
result['device'] = device_info
return result
开发者ID:andrzej-jankowski,项目名称:ralph,代码行数:12,代码来源:hp_oa.py
示例17: scan_address
def scan_address(ip_address, **kwargs):
ssh = _connect_ssh(ip_address)
try:
lines = ssh.asa_command(
"show version | grep (^Hardware|Boot microcode|^Serial|address is)"
)
raw_inventory = '\n'.join(ssh.asa_command("show inventory"))
finally:
ssh.close()
pairs = parse.pairs(lines=[line.strip() for line in lines])
sn = pairs.get('Serial Number', None)
model, ram, cpu = pairs['Hardware'].split(',')
boot_firmware = pairs['Boot microcode']
ethernets = []
macs = []
for i in xrange(99):
try:
junk, label, mac = pairs['%d' % i].split(':')
except KeyError:
break
mac = mac.split(',', 1)[0]
mac = mac.replace('address is', '')
mac = mac.replace('.', '').upper().strip()
label = label.strip()
macs.append(mac)
ram_size = re.search('[0-9]+', ram).group()
cpu_match = re.search('[0-9]+ MHz', cpu)
cpu_speed = cpu_match.group()[:-4]
cpu_model = cpu[:cpu_match.start()][4:].strip()
ret = {
'status': 'success',
'device': {
'model_name': 'Cisco ' + model,
'type': str(DeviceType.firewall),
'serial_number': sn,
'mac_adresses': macs,
'boot_firmware': boot_firmware,
'management_ip_addresses': [ip_address],
'memory': [{
'size': int(ram_size),
}],
'processors': [{
'model_name': cpu_model,
'speed': int(cpu_speed),
}],
},
}
tpl = get_base_result_template('ssh_cisco_asa')
tpl.update(ret)
return tpl
开发者ID:andrzej-jankowski,项目名称:ralph,代码行数:52,代码来源:ssh_cisco_asa.py
示例18: scan_address
def scan_address(ip_address, **kwargs):
if kwargs.get("http_family") not in ("WindRiver-WebServer",):
raise NoMatchError("It's not a HP MSA Storage.")
if "nx-os" in (kwargs.get("snmp_name", "") or "").lower():
raise NoMatchError("Incompatible Nexus found.")
user = SETTINGS.get("user")
password = SETTINGS.get("password")
messages = []
result = get_base_result_template("ssh_hp_msa", messages)
if not user or not password:
raise NotConfiguredError("Not configured. Set SSH_MSA_USER and SSH_MSA_PASSWORD in " "your configuration file.")
result.update({"status": "success", "device": _ssh_hp_msa(ip_address, user, password)})
return result
开发者ID:pydubreucq,项目名称:ralph,代码行数:13,代码来源:ssh_hp_msa.py
示例19: scan_address
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
开发者ID:andrzej-jankowski,项目名称:ralph,代码行数:15,代码来源:ssh_hp_p2000.py
示例20: scan_address
def scan_address(ip, **kwargs):
if XEN_USER is None:
raise NotConfiguredError("Xen credentials not set.")
if 'nx-os' in kwargs.get('snmp_name', '').lower():
raise NoMatchError("Incompatible Nexus found.")
if 'xen' not in kwargs.get('snmp_name', ''):
raise NoMatchError("XEN not found.")
device = run_ssh_xen(ip)
ret = {
'status': 'success',
'device': device,
}
tpl = get_base_result_template('ssh_xen')
tpl.update(ret)
return tpl
开发者ID:andrzej-jankowski,项目名称:ralph,代码行数:15,代码来源:ssh_xen.py
注:本文中的ralph.scan.plugins.get_base_result_template函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论