summaryrefslogtreecommitdiff
path: root/azurelinuxagent/common/conf.py
diff options
context:
space:
mode:
Diffstat (limited to 'azurelinuxagent/common/conf.py')
-rw-r--r--azurelinuxagent/common/conf.py37
1 files changed, 25 insertions, 12 deletions
diff --git a/azurelinuxagent/common/conf.py b/azurelinuxagent/common/conf.py
index 7911699..5422784 100644
--- a/azurelinuxagent/common/conf.py
+++ b/azurelinuxagent/common/conf.py
@@ -21,13 +21,15 @@
Module conf loads and parses configuration file
"""
import os
+import os.path
+
import azurelinuxagent.common.utils.fileutil as fileutil
from azurelinuxagent.common.exception import AgentConfigError
class ConfigurationProvider(object):
"""
- Parse amd store key:values in /etc/waagent.conf.
+ Parse and store key:values in /etc/waagent.conf.
"""
def __init__(self):
@@ -38,12 +40,12 @@ class ConfigurationProvider(object):
raise AgentConfigError("Can't not parse empty configuration")
for line in content.split('\n'):
if not line.startswith("#") and "=" in line:
- parts = line.split()[0].split('=')
+ parts = line.split('=')
+ if len(parts) < 2:
+ continue
+ key = parts[0].strip()
value = parts[1].strip("\" ")
- if value != "None":
- self.values[parts[0]] = value
- else:
- self.values[parts[0]] = None
+ self.values[key] = value if value != "None" else None
def get(self, key, default_val):
val = self.values.get(key)
@@ -113,38 +115,49 @@ def get_agent_pid_file_path(conf=__conf__):
def get_ext_log_dir(conf=__conf__):
return conf.get("Extension.LogDir", "/var/log/azure")
+def get_fips_enabled(conf=__conf__):
+ return conf.get_switch("OS.EnableFIPS", False)
def get_openssl_cmd(conf=__conf__):
return conf.get("OS.OpensslPath", "/usr/bin/openssl")
+def get_ssh_dir(conf=__conf__):
+ return conf.get("OS.SshDir", "/etc/ssh")
def get_home_dir(conf=__conf__):
return conf.get("OS.HomeDir", "/home")
-
def get_passwd_file_path(conf=__conf__):
return conf.get("OS.PasswordPath", "/etc/shadow")
-
def get_sudoers_dir(conf=__conf__):
return conf.get("OS.SudoersDir", "/etc/sudoers.d")
-
def get_sshd_conf_file_path(conf=__conf__):
- return conf.get("OS.SshdConfigPath", "/etc/ssh/sshd_config")
+ return os.path.join(get_ssh_dir(conf), "sshd_config")
+def get_ssh_key_glob(conf=__conf__):
+ return os.path.join(get_ssh_dir(conf), 'ssh_host_*key*')
+
+def get_ssh_key_private_path(conf=__conf__):
+ return os.path.join(get_ssh_dir(conf),
+ 'ssh_host_{0}_key'.format(get_ssh_host_keypair_type(conf)))
+
+def get_ssh_key_public_path(conf=__conf__):
+ return os.path.join(get_ssh_dir(conf),
+ 'ssh_host_{0}_key.pub'.format(get_ssh_host_keypair_type(conf)))
def get_root_device_scsi_timeout(conf=__conf__):
return conf.get("OS.RootDeviceScsiTimeout", None)
-
def get_ssh_host_keypair_type(conf=__conf__):
return conf.get("Provisioning.SshHostKeyPairType", "rsa")
-
def get_provision_enabled(conf=__conf__):
return conf.get_switch("Provisioning.Enabled", True)
+def get_provision_cloudinit(conf=__conf__):
+ return conf.get_switch("Provisioning.UseCloudInit", False)
def get_allow_reset_sys_user(conf=__conf__):
return conf.get_switch("Provisioning.AllowResetSysUser", False)