[项目] server.scripts.nc_sub.py(LOAMAW v1.0)

import subprocess

def script_nc_name(space_nc_name):
    nc_name_out = subprocess.check_output('ansible -m shell -a \'ifconfig\' %s | ifconfig | egrep flags= | awk \'{print $1}\' | awk -F\':\' \'{print $1}\''%space_nc_name, shell=True)
    return nc_name_out

def script_nc_ip(space_nc_name):
    nc_ip_out = subprocess.check_output('ansible -m shell -a \'ifconfig\' %s | egrep \"[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\" | awk \'{print $2}\''%space_nc_name, shell=True)
    return nc_ip_out