-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dynamic inputfile code v1 : Added support for virtual devices vNIC, Veth, HNV #341
Dynamic inputfile code v1 : Added support for virtual devices vNIC, Veth, HNV #341
Conversation
d019623
to
22ff947
Compare
@FarooqAbdulla02 Thanks for accommodating changes asper comments from old PR is taken care in this #332 (comment) |
for vNIC interface./pci_info.py --vnic env4 --show-info [ or ] ./pci_info.py --vnic --show-info[{'adapter_type': 'vnic', ]# ./pci_info.py --vnic env4 --create-config [io_vnic_stress_fvt] ]# ./pci_info.py --vnic env4 --additional-params device_ip=192.168.100.184,peer_ip=192.168.100.104,netmask=255.255.255.0,host_ip=192.168.100.184,netmasks=255.255.255.0,peer_ips="192.168.100.104 192.168.110.104",peer_interfaces="env4 env5",hmc_username=hscroot,hmc_pwd=abcd --create-config For PCI]# ./pci_info.py --pci-address 0152:60:00.0 --create-config [root@ tests]# ./pci_info.py --pci-address 0152:60:00.0 --additional-params device_ip=192.168.100.184,peer_ip=192.168.100.104,netmask=255.255.255.0,host_ip=192.168.100.184,netmasks=255.255.255.0,peer_ips="192.168.100.104 192.168.110.104",peer_interfaces="env4 env5",hmc_username=hscroot,hmc_pwd=abcd --create-config ./pci_info.py --pci-address 0152:60:00.0 --show-info/root/lop-test4/tests/./pci_info.py:32: DeprecationWarning: The SafeConfigParser class has been renamed to ConfigParser in Python 3.2. This alias will be removed in future versions. Use ConfigParser directly instead. For HNV[root@ tests]# ./pci_info.py --hnv --show-info [root@ tests]# ./pci_info.py --hnv bond0c2518ab --additional-params device_ip=192.168.100.184,peer_ip=192.168.100.104,netmask=255.255.255.0,host_ip=192.168.100.184,netmasks=255.255.255.0,peer_ips="192.168.100.104 192.168.110.104",peer_interfaces="env4 env5",hmc_username=hscroot,hmc_pwd=abcd --create-config For vETH[root@ tests]# ./pci_info.py --veth env7 --show-info [root@ tests]# ./pci_info.py --veth --show-info [root@ tests]# ./pci_info.py --veth env7 --create-config [root@ tests]# ./pci_info.py --veth env7 --additional-params device_ip=192.168.100.184,peer_ip=192.168.100.104,netmask=255.255.255.0,host_ip=192.168.100.184,netmasks=255.255.255.0,peer_ips="192.168.100.104 192.168.110.104",peer_interfaces="env4 env5",hmc_username=hscroot,hmc_pwd=abcd --create-config |
lib/virtual.py
Outdated
mac_address = line.split()[1] | ||
return mac_address | ||
except Exception as e: | ||
print(f'Interface not found {e}') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use logger
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@PraveenPenguin implemented logger.
lib/virtual.py
Outdated
:return: list of virtual interface names. | ||
''' | ||
veth_list = [] | ||
for input_string in runcmd("lsdevinfo -c")[1].splitlines(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is lsdevinfo
, ip
and other commands available default in the system, better to check and install else proper error handling
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@PraveenPenguin The interface extraction specific to vNIC and vETH, "lsdevinfo" utility is very handy to extract it.
implemented error catch handling for same.
lib/virtual.py
Outdated
match = re.search(pattern, input_string) | ||
if match: | ||
# Exclude net0 as its public interface. | ||
if not match.group(1) == "net0": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is net0
always an interface in the system or do we have an assumption using our use case? I feel let's have a generic way @abdhaleegit, your view, please
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@PraveenPenguin usually since "net0" or public interface also type of veth, we wanted to exclude the public interface to use it.
if none of the "veth" interfaces provided by user, then it will try to add up first available veth interface with excluding "net0".
lib/virtual.py
Outdated
hnv_interface_list.extend(bond_interfaces) | ||
return hnv_interface_list | ||
else: | ||
print("No HNV interfaces found.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logger please
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
lib/virtual.py
Outdated
if 'vnic' in input_string: | ||
pattern = r'name="([^"]+)"' | ||
match = re.search(pattern, input_string) | ||
if match: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems re
logic same and repeat in all function , let have a function which do string matching and the caller can all this function based on the param
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
lib/virtual.py
Outdated
if match: | ||
return match.group(1) | ||
except Exception as e: | ||
print(f'Interface not found {e}') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logger please
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
pci_info.py
Outdated
if args.run_test: | ||
os.system(cmd) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove this white space
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
This code commit contains library functions for vNIC, vETH and HNV. to support dynamic input file creation for Virtual Network devices. Signed-off-by: Shaik Abdulla <abdulla1@linux.vnet.ibm.com>
Added vNIC, vETH and HNV mapping parameters to generate the input file parameters. Signed-off-by: Shaik Abdulla <abdulla1@linux.vnet.ibm.com>
Added readme support and help content for virtual devices like vNIC, vETH and HNV devices. Signed-off-by: Shaik Abdulla <abdulla1@linux.vnet.ibm.com>
configuration and input files. This code supports to dynamically create "configuration file" and "input file" for virtual interface with few required parameters. Signed-off-by: Shaik Abdulla <abdulla1@linux.vnet.ibm.com>
22ff947
to
4c8c81e
Compare
Create config and input file : Dynamically generates device specific configuration and input files.
This code supports to dynamically create "configuration file" and "input file" for virtual interface with few required parameters.