diff options
author | Ćukasz 'sil2100' Zemczak <lukasz.zemczak@ubuntu.com> | 2017-01-16 10:10:41 +0100 |
---|---|---|
committer | usd-importer <ubuntu-server@lists.ubuntu.com> | 2017-01-17 17:53:13 +0000 |
commit | d064ab0bffd429382ea4fafeb144784d403848bd (patch) | |
tree | 28b0940943acfa742f484c2c0016e8f22c17124c /azurelinuxagent/common/osutil/default.py | |
parent | 63d399807de30a64456e672063e7c20babf7aadc (diff) | |
download | vyos-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/default.py')
-rw-r--r-- | azurelinuxagent/common/osutil/default.py | 27 |
1 files changed, 5 insertions, 22 deletions
diff --git a/azurelinuxagent/common/osutil/default.py b/azurelinuxagent/common/osutil/default.py index c243c85..dc73379 100644 --- a/azurelinuxagent/common/osutil/default.py +++ b/azurelinuxagent/common/osutil/default.py @@ -16,6 +16,7 @@ # Requires Python 2.4+ and Openssl 1.0+ # +import multiprocessing import os import re import shutil @@ -247,16 +248,6 @@ class DefaultOSUtil(object): else: return False - def set_selinux_enforce(self, state): - """ - Calls shell command 'setenforce' with 'state' - and returns resulting exit code. - """ - if self.is_selinux_system(): - if state: s = '1' - else: s='0' - return shellutil.run("setenforce "+s) - def set_selinux_context(self, path, con): """ Calls shell 'chcon' with 'path' and 'con' context. @@ -649,7 +640,7 @@ class DefaultOSUtil(object): return shellutil.run(cmd, chk_err=False) def get_dhcp_pid(self): - ret= shellutil.run_get_output("pidof dhclient") + ret = shellutil.run_get_output("pidof dhclient", chk_err=False) return ret[1] if ret[0] == 0 else None def set_hostname(self, hostname): @@ -761,19 +752,11 @@ class DefaultOSUtil(object): return base64.b64decode(data) def get_total_mem(self): - cmd = "grep MemTotal /proc/meminfo |awk '{print $2}'" - ret = shellutil.run_get_output(cmd) - if ret[0] == 0: - return int(ret[1])/1024 - else: - raise OSUtilError("Failed to get total memory: {0}".format(ret[1])) + # Get total memory in bytes and divide by 1024**2 to get the valu in MB. + return os.sysconf('SC_PAGE_SIZE') * os.sysconf('SC_PHYS_PAGES') / (1024**2) def get_processor_cores(self): - ret = shellutil.run_get_output("grep 'processor.*:' /proc/cpuinfo |wc -l") - if ret[0] == 0: - return int(ret[1]) - else: - raise OSUtilError("Failed to get processor cores") + return multiprocessing.cpu_count() def set_admin_access_to_ip(self, dest_ip): #This allows root to access dest_ip |