Last active
September 22, 2024 23:41
-
-
Save pandeybk/83b66ad320c0067b5d60ae1d3ac1bd25 to your computer and use it in GitHub Desktop.
nmstate-config.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interfaces: | |
- name: bond0 | |
description: Bond | |
type: bond | |
state: up | |
mtu: 1500 | |
ipv4: | |
address: | |
- ip: 192.168.7.101 | |
prefix-length: 24 | |
enabled: true | |
link-aggregation: | |
mode: balance-rr # active-backup, balance-rr, 802.3ad | |
options: | |
miimon: '100' | |
port: | |
- eno1np0 | |
- eno2np1 | |
- name: eno1np0 | |
state: up | |
type: ethernet | |
mtu: 1500 | |
- name: eno2np1 | |
state: up | |
type: ethernet | |
mtu: 1500 | |
routes: | |
config: | |
- destination: 0.0.0.0/0 | |
next-hop-address: 192.168.4.1 | |
next-hop-interface: bond0 | |
table-id: 254 | |
dns-resolver: | |
config: | |
search: | |
- example.com | |
- example.org | |
server: | |
- 75.75.75.75 | |
- 8.8.8.8 | |
# 00:00:00:00:00:d1 = eno1np0 | |
# 00:00:00:00:00:d2 = eno2np1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apiVersion: nmstate.io/v1 | |
kind: NodeNetworkConfigurationPolicy | |
metadata: | |
name: br0-bond0 | |
spec: | |
desiredState: | |
interfaces: | |
- name: br0-bond0 | |
description: Linux bridge with bond0 as a port | |
type: linux-bridge | |
state: up | |
bridge: | |
options: | |
stp: | |
enabled: false | |
port: | |
- name: bond0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apiVersion: nmstate.io/v1 | |
kind: NodeNetworkConfigurationPolicy | |
metadata: | |
name: br0-eno1np0 | |
spec: | |
desiredState: | |
interfaces: | |
- name: br0 | |
description: Linux bridge with eno1np0 as a port | |
type: linux-bridge | |
state: up | |
bridge: | |
options: | |
stp: | |
enabled: false | |
port: | |
- name: eno1np0 | |
--- | |
apiVersion: k8s.cni.cncf.io/v1 | |
kind: NetworkAttachmentDefinition | |
metadata: | |
name: bridge-network | |
annotations: | |
k8s.v1.cni.cncf.io/resourceName: bridge.network.kubevirt.io/br0 | |
spec: | |
config: | |
'{ | |
"cniVersion": "0.3.1", | |
"name": "br0-l2", | |
"plugins": [{ | |
"type": "bridge", | |
"bridge": "br0", | |
"ipam": {} | |
}] | |
}' | |
--- |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
import json | |
# Disable SSL warnings (insecure) | |
requests.packages.urllib3.disable_warnings() | |
# List of iDRAC IP addresses for multiple servers | |
idrac_ips = ["ip1", "ip2"] # Add more IPs as needed | |
# iDRAC login credentials (same for all servers) | |
username = "youruser" | |
password = "yourpassword" | |
# Function to get NIC details from a single iDRAC | |
def get_nic_details(idrac_ip): | |
print(f"\nConnecting to iDRAC: {idrac_ip}") | |
# Redfish API base URL | |
redfish_base_url = f"https://{idrac_ip}/redfish/v1" | |
# URL for Ethernet interfaces | |
system_url = f"{redfish_base_url}/Systems/System.Embedded.1/EthernetInterfaces" | |
# Send GET request to fetch the list of Ethernet interfaces | |
response = requests.get(system_url, auth=(username, password), verify=False) | |
if response.status_code == 200: | |
interfaces = response.json()["Members"] | |
print(f"NIC Information for iDRAC {idrac_ip}:") | |
# Loop through each interface to gather detailed information | |
for interface in interfaces: | |
interface_url = interface["@odata.id"] | |
interface_response = requests.get(f"https://{idrac_ip}{interface_url}", auth=(username, password), verify=False) | |
if interface_response.status_code == 200: | |
nic_data = interface_response.json() | |
# Extract and print useful NIC details | |
mac_address = nic_data.get("MACAddress", "N/A") | |
manufacturer = nic_data.get("Manufacturer", "N/A") | |
port_id = nic_data.get("PhysicalPortNumber", "N/A") | |
description = nic_data.get("Description", "N/A") | |
speed = nic_data.get("SpeedMbps", "N/A") | |
interface_name = nic_data.get("Name", "N/A") | |
integrated_chip = nic_data.get("Integrated", "N/A") # If it's an integrated NIC | |
# Print the details | |
print(f"Interface: {interface_name}") | |
print(f" MAC Address: {mac_address}") | |
print(f" Manufacturer: {manufacturer}") | |
print(f" Port ID: {port_id}") | |
print(f" Description: {description}") | |
print(f" Speed: {speed} Mbps") | |
print(f" Integrated: {integrated_chip}") | |
print("-" * 40) | |
else: | |
print(f"Failed to retrieve details for interface: {interface_url}") | |
else: | |
print(f"Failed to retrieve interfaces for iDRAC {idrac_ip}. HTTP Status code: {response.status_code}") | |
# Main function to iterate over multiple iDRAC IPs and gather NIC details | |
def main(): | |
for idrac_ip in idrac_ips: | |
get_nic_details(idrac_ip) | |
# Run the main function | |
if __name__ == "__main__": | |
main() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
apiVersion: nmstate.io/v1 | |
kind: NodeNetworkConfigurationPolicy | |
metadata: | |
name: ovs-br-ex-bridge | |
spec: | |
desiredState: | |
ovn: | |
bridge-mappings: | |
- bridge: br-ex | |
localnet: baremetal-network | |
state: present | |
nodeSelector: | |
kubernetes.io/hostname: master0 | |
--- | |
apiVersion: k8s.cni.cncf.io/v1 | |
kind: NetworkAttachmentDefinition | |
metadata: | |
annotations: | |
description: baremetal-network connection for VMs | |
name: baremetal-network | |
namespace: balk-vms | |
spec: | |
config: |- | |
{ | |
"cniVersion": "0.3.1", | |
"name": "baremetal-network", | |
"type": "ovn-k8s-cni-overlay", | |
"topology": "localnet", | |
"promiscMode": true, | |
"netAttachDefName": "balk-vms/baremetal-network", | |
"ipam": {} | |
} | |
--- | |
apiVersion: k8s.cni.cncf.io/v1 | |
kind: NetworkAttachmentDefinition | |
metadata: | |
annotations: | |
description: baremetal-network connection for VMs | |
name: baremetal-network | |
namespace: default | |
spec: | |
config: |- | |
{ | |
"cniVersion": "0.3.1", | |
"name": "baremetal-network", | |
"type": "ovn-k8s-cni-overlay", | |
"topology": "localnet", | |
"promiscMode": true, | |
"netAttachDefName": "default/baremetal-network", | |
"vlanID": 218, | |
"ipam": {} | |
} | |
--- | |
apiVersion: kubevirt.io/v1 | |
kind: VirtualMachine | |
metadata: | |
name: static-network-network-data | |
namespace: balk-vms | |
finalizers: | |
- kubevirt.io/virtualMachineControllerFinalize | |
labels: | |
app: static-network-network-data | |
os.template.kubevirt.io/fedora: 'true' | |
spec: | |
running: true | |
template: | |
metadata: | |
annotations: | |
vm.kubevirt.io/flavor: small | |
vm.kubevirt.io/os: fedora | |
vm.kubevirt.io/workload: server | |
creationTimestamp: null | |
labels: | |
kubevirt.io/domain: static-network-network-data | |
kubevirt.io/size: small | |
spec: | |
architecture: amd64 | |
domain: | |
cpu: | |
cores: 1 | |
sockets: 1 | |
threads: 1 | |
devices: | |
disks: | |
- disk: | |
bus: virtio | |
name: rootdisk | |
- disk: | |
bus: virtio | |
name: cloudinitdisk | |
interfaces: | |
- masquerade: {} | |
model: virtio | |
name: default | |
- bridge: {} | |
model: virtio | |
name: machinenetwork | |
networkInterfaceMultiqueue: true | |
rng: {} | |
features: | |
acpi: {} | |
smm: | |
enabled: true | |
firmware: | |
bootloader: | |
efi: {} | |
machine: | |
type: q35 | |
memory: | |
guest: 2Gi | |
resources: {} | |
hostname: static-network-network-data | |
networks: | |
- name: default | |
pod: {} | |
- multus: | |
networkName: baremetal-network | |
name: machinenetwork | |
terminationGracePeriodSeconds: 180 | |
volumes: | |
- containerDisk: | |
image: quay.io/containerdisks/fedora | |
name: rootdisk | |
- cloudInitNoCloud: | |
networkData: | | |
version: 2 | |
ethernets: | |
eth1: | |
addresses: | |
- 192.168.7.215/22 | |
gateway4: 192.168.4.1 | |
nameservers: | |
addresses: | |
- 75.75.75.75 | |
- 192.168.7.213 | |
routes: | |
- to: 0.0.0.0/0 | |
via: 192.168.4.1 | |
userData: |- | |
#cloud-config | |
user: fedora | |
password: fedora | |
chpasswd: { expire: False } | |
name: cloudinitdisk |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apiVersion: nmstate.io/v1 | |
kind: NodeNetworkConfigurationPolicy | |
metadata: | |
name: br0-eno1np0-static | |
spec: | |
desiredState: | |
interfaces: | |
- name: br0 | |
description: Linux bridge with eno1np0 as a port | |
type: linux-bridge | |
state: up | |
bridge: | |
options: | |
stp: | |
enabled: false | |
port: | |
- name: eno1np0 | |
--- | |
apiVersion: k8s.cni.cncf.io/v1 | |
kind: NetworkAttachmentDefinition | |
metadata: | |
name: bridge-network-static | |
annotations: | |
k8s.v1.cni.cncf.io/resourceName: bridge.network.kubevirt.io/br0 | |
spec: | |
config: | |
'{ | |
"cniVersion": "0.3.1", | |
"name": "br0-l2", | |
"plugins": [{ | |
"type": "bridge", | |
"bridge": "br0", | |
"ipam": { | |
"type": "static", | |
"addresses": [ | |
{ | |
"address": "192.168.7.214/24", | |
"gateway": "192.168.4.1" | |
} | |
], | |
"dns": { | |
"nameservers": ["75.75.75.75"] | |
} | |
} | |
}] | |
}' | |
--- |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment