summaryrefslogtreecommitdiff
path: root/azurelinuxagent/common/osutil/freebsd.py
diff options
context:
space:
mode:
authorƁukasz 'sil2100' Zemczak <lukasz.zemczak@ubuntu.com>2017-01-16 10:10:41 +0100
committerusd-importer <ubuntu-server@lists.ubuntu.com>2017-01-17 17:53:13 +0000
commitd064ab0bffd429382ea4fafeb144784d403848bd (patch)
tree28b0940943acfa742f484c2c0016e8f22c17124c /azurelinuxagent/common/osutil/freebsd.py
parent63d399807de30a64456e672063e7c20babf7aadc (diff)
downloadvyos-walinuxagent-d064ab0bffd429382ea4fafeb144784d403848bd.tar.gz
vyos-walinuxagent-d064ab0bffd429382ea4fafeb144784d403848bd.zip
Import patches-unapplied version 2.2.2-0ubuntu1 to ubuntu/zesty-proposed
Imported using git-ubuntu import. Changelog parent: 63d399807de30a64456e672063e7c20babf7aadc New changelog entries: * New upstream release (LP: #1651128) - d/patches/fix-auto-update.patch, d/patches/lp1623570-adjust-walinuxagent-service-after-and-wants.patch: - Dropped as changes have been applied upstream - Refreshed debian/patches/disable_import_test.patch
Diffstat (limited to 'azurelinuxagent/common/osutil/freebsd.py')
-rw-r--r--azurelinuxagent/common/osutil/freebsd.py51
1 files changed, 49 insertions, 2 deletions
diff --git a/azurelinuxagent/common/osutil/freebsd.py b/azurelinuxagent/common/osutil/freebsd.py
index ddf8db6..54c7452 100644
--- a/azurelinuxagent/common/osutil/freebsd.py
+++ b/azurelinuxagent/common/osutil/freebsd.py
@@ -22,7 +22,7 @@ import azurelinuxagent.common.utils.textutil as textutil
import azurelinuxagent.common.logger as logger
from azurelinuxagent.common.exception import OSUtilError
from azurelinuxagent.common.osutil.default import DefaultOSUtil
-
+from azurelinuxagent.common.future import ustr
class FreeBSDOSUtil(DefaultOSUtil):
def __init__(self):
@@ -118,7 +118,7 @@ class FreeBSDOSUtil(DefaultOSUtil):
shellutil.run("route delete 255.255.255.255 -iface {0}".format(ifname), chk_err=False)
def get_dhcp_pid(self):
- ret = shellutil.run_get_output("pgrep -n dhclient")
+ ret = shellutil.run_get_output("pgrep -n dhclient", chk_err=False)
return ret[1] if ret[0] == 0 else None
def eject_dvd(self, chk_err=True):
@@ -196,3 +196,50 @@ class FreeBSDOSUtil(DefaultOSUtil):
logger.verbose("Interface info: ({0},{1},{2})", iface, inet, mac)
return iface, inet, mac
+
+ def device_for_ide_port(self, port_id):
+ """
+ Return device name attached to ide port 'n'.
+ """
+ if port_id > 3:
+ return None
+ g0 = "00000000"
+ if port_id > 1:
+ g0 = "00000001"
+ port_id = port_id - 2
+ err, output = shellutil.run_get_output('sysctl dev.storvsc | grep pnpinfo | grep deviceid=')
+ if err:
+ return None
+ g1 = "000" + ustr(port_id)
+ g0g1 = "{0}-{1}".format(g0, g1)
+ """
+ search 'X' from 'dev.storvsc.X.%pnpinfo: classid=32412632-86cb-44a2-9b5c-50d1417354f5 deviceid=00000000-0001-8899-0000-000000000000'
+ """
+ cmd_search_ide = "sysctl dev.storvsc | grep pnpinfo | grep deviceid={0}".format(g0g1)
+ err, output = shellutil.run_get_output(cmd_search_ide)
+ if err:
+ return None
+ cmd_extract_id = cmd_search_ide + "|awk -F . '{print $3}'"
+ err, output = shellutil.run_get_output(cmd_extract_id)
+ """
+ try to search 'blkvscX' and 'storvscX' to find device name
+ """
+ output = output.rstrip()
+ cmd_search_blkvsc = "camcontrol devlist -b | grep blkvsc{0} | awk '{{print $1}}'".format(output)
+ err, output = shellutil.run_get_output(cmd_search_blkvsc)
+ if err == 0:
+ output = output.rstrip()
+ cmd_search_dev="camcontrol devlist | grep {0} | awk -F \( '{{print $2}}'|awk -F , '{{print $1}}'".format(output)
+ err, output = shellutil.run_get_output(cmd_search_dev)
+ if err == 0:
+ return output.rstrip()
+
+ cmd_search_storvsc = "camcontrol devlist -b | grep storvsc{0} | awk '{{print $1}}'".format(output)
+ err, output = shellutil.run_get_output(cmd_search_storvsc)
+ if err == 0:
+ output = output.rstrip()
+ cmd_search_dev="camcontrol devlist | grep {0} | awk -F \( '{{print $2}}'|awk -F , '{{print $1}}'".format(output)
+ err, output = shellutil.run_get_output(cmd_search_dev)
+ if err == 0:
+ return output.rstrip()
+ return None