Issue in accessing the ip address of EFlowVm from python script running on admin privileged command prompt or Windows Powershell

Athira Gopinath(UST,IN) 96 Reputation points
2024-04-19T09:08:20.24+00:00

Hi,

As part of an R&D,we have enabled the IoT Edge Runtime on Windows through EFlowVm where one of the module is acting as server.Inorder to send data to server module, we are using the eth0 ip address of EFlowVm. Client module is running on the host machine with admin privilege.For getting the ip address we are using the following python script.This is working as expected for certain windows machine .But it is not working for all windows machine.The error we are capturing while running the code in admin privileged windows powershell or cmd is copied.

Please suggest some solution to resolve this issue.

Error:
Invoke-EflowVmCommand : The 'Invoke-EflowVmCommand' command was found in the module 'AzureEFLOW', but the module could not be loaded. For more information, run
'Import-Module AzureEFLOW'.
At line:1 char:1
+ Invoke-EflowVmCommand -command ip addr show eth0
+ ~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Invoke-EflowVmCommand:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CouldNotAutoloadMatchingModule

import subprocess

import re

# Define the PowerShell command to execute

command = r"powershell Invoke-EflowVmCommand -command 'ip addr show eth0'"

# Execute the command and capture its output

output = subprocess.check_output(command, shell=True, text=True,input='R\n').strip()

# Use regex to find the IPv4 address

ipv4_address = re.findall(r'inet (\d+\.\d+\.\d+\.\d+)', output)

# Check if the IPv4 address is found

if ipv4_address:

    # Extract the matched IPv4 address

    print("IPv4 Address:", ipv4_address[0],"type:",type(ipv4_address[0]))

else:

    print("IPv4 Address not found.")


Azure IoT Edge
Azure IoT Edge
An Azure service that is used to deploy cloud workloads to run on internet of things (IoT) edge devices via standard containers.
540 questions
Windows 10
Windows 10
A Microsoft operating system that runs on personal computers and tablets.
10,642 questions
0 comments No comments
{count} votes