diff options
author | Ben Howard <ben.howard@canonical.com> | 2013-07-24 10:37:36 -0400 |
---|---|---|
committer | Scott Moser <smoser@ubuntu.com> | 2013-07-24 10:37:36 -0400 |
commit | a5a5e81077a39e91ac8a3e2990450e050cf3fff1 (patch) | |
tree | da347b002d8f8e087f7491b6857252797bd05ff5 /cloudinit/util.py | |
parent | a4310ee3db0b394dcebd4f6b49d3b25bba37fedf (diff) | |
parent | c1f3fa86b45ba8b7ca6e0f6971de171ac5fccf15 (diff) | |
download | vyos-cloud-init-a5a5e81077a39e91ac8a3e2990450e050cf3fff1.tar.gz vyos-cloud-init-a5a5e81077a39e91ac8a3e2990450e050cf3fff1.zip |
add SmartOS datasource supporting Joyent cloud
This adds a datasource designed to work on Joyent cloud (SmartOS).
Diffstat (limited to 'cloudinit/util.py')
-rw-r--r-- | cloudinit/util.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/cloudinit/util.py b/cloudinit/util.py index 47d71ef4..8542fe27 100644 --- a/cloudinit/util.py +++ b/cloudinit/util.py @@ -1751,3 +1751,22 @@ def get_mount_info(path, log=LOG): mountinfo_path = '/proc/%s/mountinfo' % os.getpid() lines = load_file(mountinfo_path).splitlines() return parse_mount_info(path, lines, log) + + +def which(program): + # Return path of program for execution if found in path + def is_exe(fpath): + return os.path.isfile(fpath) and os.access(fpath, os.X_OK) + + _fpath, _ = os.path.split(program) + if _fpath: + if is_exe(program): + return program + else: + for path in os.environ["PATH"].split(os.pathsep): + path = path.strip('"') + exe_file = os.path.join(path, program) + if is_exe(exe_file): + return exe_file + + return None |