Comments (2)
Hi,
The session that is opened is a System object. So, the network properties can be a bit confusing. You can access the primary ethernet adaptor properties via the system properties. For example,
def get_network_settings(target_name: str, username: str, password: str):
nisystem = {}
print("Trying to connect to target: " + target_name)
with nisyscfg.Session(target=target_name, username=username, password=password) as session:
print("Succesfully connected to target: " + str(session.resource.name))
print("session.resource dir: " + str(dir(session)) + "\n\n")
nisystem["serial_number"] = str(session.serial_number)
nisystem["ip_address"] = str(session.ip_address)
nisystem["subnet_mask"] = str(session.subnet_mask)
nisystem["gateway"] = str(session.gateway)
nisystem["dns_server"] = str(session.dns_server)
print(nisystem)
However, the resource properties of the system do not contain the most of the network properties.
If you want to configure the network adaptors directly, use net interfaces returned by find_hardware()
. The following example prints out a report similar to the network settings tab found in NI MAX:
import textwrap
import nisyscfg
def print_network_settings():
with nisyscfg.Session() as session:
print("Network Adapters")
for resource in session.find_hardware():
if nisyscfg.enums.ServiceType.LOCAL_NET_INTERFACE in resource.service_type:
print("")
print(textwrap.dedent(
f"""
{resource.name}{' (Primary)' if resource.is_primary_adapter else ''}
Adapter Mode: {resource.name}
MAC Address: {resource.mac_address}
IPv4 Address Mode: {repr(resource.tcp_ip_request_mode)}
IPv4 Address: {resource.tcp_ip_v4_address}
Subnet Mask: {resource.tcp_ip_v4_subnet}
Gateway: {resource.tcp_ip_v4_gateway}
DNS Server: {resource.tcp_ip_v4_dns_server}
""").strip() )
from nisyscfg-python.
I assume the question has been answered.
from nisyscfg-python.
Related Issues (10)
- Please upload this project to PyPI HOT 1
- nisyscfg resource.is_device query for PXIe-4309 is not working as expected HOT 12
- how to use nisyscfg PY API to read version of NI-DAQmx Device Driver? HOT 8
- [question] Getting some crashes in Ubuntu 20.04 while the code works in Windows 10 HOT 5
- authorship question HOT 3
- session.get_installed_software_components() output format HOT 2
- resource.external_calibration_last_time and resource.current_temp not works for PXI-4309 card HOT 12
- Creating a Python API for PXI Chassis Fan Speed Control HOT 3
- Self-Calibrate HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nisyscfg-python.