More octal literal fixes.
This commit is contained in:
parent
239519a75d
commit
a9e2cb1613
@ -468,7 +468,7 @@ class Distro(object):
|
|||||||
util.make_header(base="added"),
|
util.make_header(base="added"),
|
||||||
"#includedir %s" % (path), '']
|
"#includedir %s" % (path), '']
|
||||||
sudoers_contents = "\n".join(lines)
|
sudoers_contents = "\n".join(lines)
|
||||||
util.write_file(sudo_base, sudoers_contents, 0440)
|
util.write_file(sudo_base, sudoers_contents, 0o440)
|
||||||
else:
|
else:
|
||||||
lines = ['', util.make_header(base="added"),
|
lines = ['', util.make_header(base="added"),
|
||||||
"#includedir %s" % (path), '']
|
"#includedir %s" % (path), '']
|
||||||
@ -478,7 +478,7 @@ class Distro(object):
|
|||||||
except IOError as e:
|
except IOError as e:
|
||||||
util.logexc(LOG, "Failed to write %s", sudo_base)
|
util.logexc(LOG, "Failed to write %s", sudo_base)
|
||||||
raise e
|
raise e
|
||||||
util.ensure_dir(path, 0750)
|
util.ensure_dir(path, 0o750)
|
||||||
|
|
||||||
def write_sudo_rules(self, user, rules, sudo_file=None):
|
def write_sudo_rules(self, user, rules, sudo_file=None):
|
||||||
if not sudo_file:
|
if not sudo_file:
|
||||||
@ -506,7 +506,7 @@ class Distro(object):
|
|||||||
content,
|
content,
|
||||||
]
|
]
|
||||||
try:
|
try:
|
||||||
util.write_file(sudo_file, "\n".join(contents), 0440)
|
util.write_file(sudo_file, "\n".join(contents), 0o440)
|
||||||
except IOError as e:
|
except IOError as e:
|
||||||
util.logexc(LOG, "Failed to write sudoers file %s", sudo_file)
|
util.logexc(LOG, "Failed to write sudoers file %s", sudo_file)
|
||||||
raise e
|
raise e
|
||||||
|
@ -396,7 +396,7 @@ c: 4
|
|||||||
|
|
||||||
mock_write = self.mocker.replace("cloudinit.util.write_file",
|
mock_write = self.mocker.replace("cloudinit.util.write_file",
|
||||||
passthrough=False)
|
passthrough=False)
|
||||||
mock_write(ci.paths.get_ipath("cloud_config"), "", 0600)
|
mock_write(ci.paths.get_ipath("cloud_config"), "", 0o600)
|
||||||
self.mocker.replay()
|
self.mocker.replay()
|
||||||
|
|
||||||
log_file = self.capture_log(logging.WARNING)
|
log_file = self.capture_log(logging.WARNING)
|
||||||
@ -415,8 +415,8 @@ c: 4
|
|||||||
outpath = os.path.join(ci.paths.get_ipath_cur("scripts"), "part-001")
|
outpath = os.path.join(ci.paths.get_ipath_cur("scripts"), "part-001")
|
||||||
mock_write = self.mocker.replace("cloudinit.util.write_file",
|
mock_write = self.mocker.replace("cloudinit.util.write_file",
|
||||||
passthrough=False)
|
passthrough=False)
|
||||||
mock_write(ci.paths.get_ipath("cloud_config"), "", 0600)
|
mock_write(ci.paths.get_ipath("cloud_config"), "", 0o600)
|
||||||
mock_write(outpath, script, 0700)
|
mock_write(outpath, script, 0o700)
|
||||||
self.mocker.replay()
|
self.mocker.replay()
|
||||||
|
|
||||||
log_file = self.capture_log(logging.WARNING)
|
log_file = self.capture_log(logging.WARNING)
|
||||||
@ -435,8 +435,8 @@ c: 4
|
|||||||
outpath = os.path.join(ci.paths.get_ipath_cur("scripts"), "part-001")
|
outpath = os.path.join(ci.paths.get_ipath_cur("scripts"), "part-001")
|
||||||
mock_write = self.mocker.replace("cloudinit.util.write_file",
|
mock_write = self.mocker.replace("cloudinit.util.write_file",
|
||||||
passthrough=False)
|
passthrough=False)
|
||||||
mock_write(ci.paths.get_ipath("cloud_config"), "", 0600)
|
mock_write(ci.paths.get_ipath("cloud_config"), "", 0o600)
|
||||||
mock_write(outpath, script, 0700)
|
mock_write(outpath, script, 0o700)
|
||||||
self.mocker.replay()
|
self.mocker.replay()
|
||||||
|
|
||||||
log_file = self.capture_log(logging.WARNING)
|
log_file = self.capture_log(logging.WARNING)
|
||||||
@ -455,8 +455,8 @@ c: 4
|
|||||||
outpath = os.path.join(ci.paths.get_ipath_cur("scripts"), "part-001")
|
outpath = os.path.join(ci.paths.get_ipath_cur("scripts"), "part-001")
|
||||||
mock_write = self.mocker.replace("cloudinit.util.write_file",
|
mock_write = self.mocker.replace("cloudinit.util.write_file",
|
||||||
passthrough=False)
|
passthrough=False)
|
||||||
mock_write(outpath, script, 0700)
|
mock_write(outpath, script, 0o700)
|
||||||
mock_write(ci.paths.get_ipath("cloud_config"), "", 0600)
|
mock_write(ci.paths.get_ipath("cloud_config"), "", 0o600)
|
||||||
self.mocker.replay()
|
self.mocker.replay()
|
||||||
|
|
||||||
log_file = self.capture_log(logging.WARNING)
|
log_file = self.capture_log(logging.WARNING)
|
||||||
|
@ -66,12 +66,12 @@ def _write_user_data_files(mount_dir, value):
|
|||||||
udfile = open(deltacloud_user_data_file, 'w')
|
udfile = open(deltacloud_user_data_file, 'w')
|
||||||
udfile.write(value)
|
udfile.write(value)
|
||||||
udfile.close()
|
udfile.close()
|
||||||
os.chmod(deltacloud_user_data_file, 0664)
|
os.chmod(deltacloud_user_data_file, 0o664)
|
||||||
|
|
||||||
udfile = open(user_data_file, 'w')
|
udfile = open(user_data_file, 'w')
|
||||||
udfile.write(value)
|
udfile.write(value)
|
||||||
udfile.close()
|
udfile.close()
|
||||||
os.chmod(user_data_file, 0664)
|
os.chmod(user_data_file, 0o664)
|
||||||
|
|
||||||
|
|
||||||
def _remove_user_data_files(mount_dir,
|
def _remove_user_data_files(mount_dir,
|
||||||
|
@ -112,7 +112,7 @@ class TestNetCfgDistro(MockerTestCase):
|
|||||||
self.assertIn('/etc/network/interfaces', write_bufs)
|
self.assertIn('/etc/network/interfaces', write_bufs)
|
||||||
write_buf = write_bufs['/etc/network/interfaces']
|
write_buf = write_bufs['/etc/network/interfaces']
|
||||||
self.assertEquals(str(write_buf).strip(), BASE_NET_CFG.strip())
|
self.assertEquals(str(write_buf).strip(), BASE_NET_CFG.strip())
|
||||||
self.assertEquals(write_buf.mode, 0644)
|
self.assertEquals(write_buf.mode, 0o644)
|
||||||
|
|
||||||
def assertCfgEquals(self, blob1, blob2):
|
def assertCfgEquals(self, blob1, blob2):
|
||||||
b1 = dict(SysConf(blob1.strip().splitlines()))
|
b1 = dict(SysConf(blob1.strip().splitlines()))
|
||||||
@ -136,7 +136,7 @@ class TestNetCfgDistro(MockerTestCase):
|
|||||||
|
|
||||||
write_bufs = {}
|
write_bufs = {}
|
||||||
|
|
||||||
def replace_write(filename, content, mode=0644, omode="wb"):
|
def replace_write(filename, content, mode=0o644, omode="wb"):
|
||||||
buf = WriteBuffer()
|
buf = WriteBuffer()
|
||||||
buf.mode = mode
|
buf.mode = mode
|
||||||
buf.omode = omode
|
buf.omode = omode
|
||||||
@ -169,7 +169,7 @@ DEVICE="lo"
|
|||||||
ONBOOT=yes
|
ONBOOT=yes
|
||||||
'''
|
'''
|
||||||
self.assertCfgEquals(expected_buf, str(write_buf))
|
self.assertCfgEquals(expected_buf, str(write_buf))
|
||||||
self.assertEquals(write_buf.mode, 0644)
|
self.assertEquals(write_buf.mode, 0o644)
|
||||||
|
|
||||||
self.assertIn('/etc/sysconfig/network-scripts/ifcfg-eth0', write_bufs)
|
self.assertIn('/etc/sysconfig/network-scripts/ifcfg-eth0', write_bufs)
|
||||||
write_buf = write_bufs['/etc/sysconfig/network-scripts/ifcfg-eth0']
|
write_buf = write_bufs['/etc/sysconfig/network-scripts/ifcfg-eth0']
|
||||||
@ -183,7 +183,7 @@ GATEWAY="192.168.1.254"
|
|||||||
BROADCAST="192.168.1.0"
|
BROADCAST="192.168.1.0"
|
||||||
'''
|
'''
|
||||||
self.assertCfgEquals(expected_buf, str(write_buf))
|
self.assertCfgEquals(expected_buf, str(write_buf))
|
||||||
self.assertEquals(write_buf.mode, 0644)
|
self.assertEquals(write_buf.mode, 0o644)
|
||||||
|
|
||||||
self.assertIn('/etc/sysconfig/network-scripts/ifcfg-eth1', write_bufs)
|
self.assertIn('/etc/sysconfig/network-scripts/ifcfg-eth1', write_bufs)
|
||||||
write_buf = write_bufs['/etc/sysconfig/network-scripts/ifcfg-eth1']
|
write_buf = write_bufs['/etc/sysconfig/network-scripts/ifcfg-eth1']
|
||||||
@ -193,7 +193,7 @@ BOOTPROTO="dhcp"
|
|||||||
ONBOOT=yes
|
ONBOOT=yes
|
||||||
'''
|
'''
|
||||||
self.assertCfgEquals(expected_buf, str(write_buf))
|
self.assertCfgEquals(expected_buf, str(write_buf))
|
||||||
self.assertEquals(write_buf.mode, 0644)
|
self.assertEquals(write_buf.mode, 0o644)
|
||||||
|
|
||||||
self.assertIn('/etc/sysconfig/network', write_bufs)
|
self.assertIn('/etc/sysconfig/network', write_bufs)
|
||||||
write_buf = write_bufs['/etc/sysconfig/network']
|
write_buf = write_bufs['/etc/sysconfig/network']
|
||||||
@ -202,7 +202,7 @@ ONBOOT=yes
|
|||||||
NETWORKING=yes
|
NETWORKING=yes
|
||||||
'''
|
'''
|
||||||
self.assertCfgEquals(expected_buf, str(write_buf))
|
self.assertCfgEquals(expected_buf, str(write_buf))
|
||||||
self.assertEquals(write_buf.mode, 0644)
|
self.assertEquals(write_buf.mode, 0o644)
|
||||||
|
|
||||||
def test_write_ipv6_rhel(self):
|
def test_write_ipv6_rhel(self):
|
||||||
rh_distro = self._get_distro('rhel')
|
rh_distro = self._get_distro('rhel')
|
||||||
@ -215,7 +215,7 @@ NETWORKING=yes
|
|||||||
|
|
||||||
write_bufs = {}
|
write_bufs = {}
|
||||||
|
|
||||||
def replace_write(filename, content, mode=0644, omode="wb"):
|
def replace_write(filename, content, mode=0o644, omode="wb"):
|
||||||
buf = WriteBuffer()
|
buf = WriteBuffer()
|
||||||
buf.mode = mode
|
buf.mode = mode
|
||||||
buf.omode = omode
|
buf.omode = omode
|
||||||
@ -248,7 +248,7 @@ DEVICE="lo"
|
|||||||
ONBOOT=yes
|
ONBOOT=yes
|
||||||
'''
|
'''
|
||||||
self.assertCfgEquals(expected_buf, str(write_buf))
|
self.assertCfgEquals(expected_buf, str(write_buf))
|
||||||
self.assertEquals(write_buf.mode, 0644)
|
self.assertEquals(write_buf.mode, 0o644)
|
||||||
|
|
||||||
self.assertIn('/etc/sysconfig/network-scripts/ifcfg-eth0', write_bufs)
|
self.assertIn('/etc/sysconfig/network-scripts/ifcfg-eth0', write_bufs)
|
||||||
write_buf = write_bufs['/etc/sysconfig/network-scripts/ifcfg-eth0']
|
write_buf = write_bufs['/etc/sysconfig/network-scripts/ifcfg-eth0']
|
||||||
@ -265,7 +265,7 @@ IPV6ADDR="2607:f0d0:1002:0011::2"
|
|||||||
IPV6_DEFAULTGW="2607:f0d0:1002:0011::1"
|
IPV6_DEFAULTGW="2607:f0d0:1002:0011::1"
|
||||||
'''
|
'''
|
||||||
self.assertCfgEquals(expected_buf, str(write_buf))
|
self.assertCfgEquals(expected_buf, str(write_buf))
|
||||||
self.assertEquals(write_buf.mode, 0644)
|
self.assertEquals(write_buf.mode, 0o644)
|
||||||
self.assertIn('/etc/sysconfig/network-scripts/ifcfg-eth1', write_bufs)
|
self.assertIn('/etc/sysconfig/network-scripts/ifcfg-eth1', write_bufs)
|
||||||
write_buf = write_bufs['/etc/sysconfig/network-scripts/ifcfg-eth1']
|
write_buf = write_bufs['/etc/sysconfig/network-scripts/ifcfg-eth1']
|
||||||
expected_buf = '''
|
expected_buf = '''
|
||||||
@ -281,7 +281,7 @@ IPV6ADDR="2607:f0d0:1002:0011::3"
|
|||||||
IPV6_DEFAULTGW="2607:f0d0:1002:0011::1"
|
IPV6_DEFAULTGW="2607:f0d0:1002:0011::1"
|
||||||
'''
|
'''
|
||||||
self.assertCfgEquals(expected_buf, str(write_buf))
|
self.assertCfgEquals(expected_buf, str(write_buf))
|
||||||
self.assertEquals(write_buf.mode, 0644)
|
self.assertEquals(write_buf.mode, 0o644)
|
||||||
|
|
||||||
self.assertIn('/etc/sysconfig/network', write_bufs)
|
self.assertIn('/etc/sysconfig/network', write_bufs)
|
||||||
write_buf = write_bufs['/etc/sysconfig/network']
|
write_buf = write_bufs['/etc/sysconfig/network']
|
||||||
@ -292,7 +292,7 @@ NETWORKING_IPV6=yes
|
|||||||
IPV6_AUTOCONF=no
|
IPV6_AUTOCONF=no
|
||||||
'''
|
'''
|
||||||
self.assertCfgEquals(expected_buf, str(write_buf))
|
self.assertCfgEquals(expected_buf, str(write_buf))
|
||||||
self.assertEquals(write_buf.mode, 0644)
|
self.assertEquals(write_buf.mode, 0o644)
|
||||||
|
|
||||||
def test_simple_write_freebsd(self):
|
def test_simple_write_freebsd(self):
|
||||||
fbsd_distro = self._get_distro('freebsd')
|
fbsd_distro = self._get_distro('freebsd')
|
||||||
@ -319,7 +319,7 @@ IPV6_AUTOCONF=no
|
|||||||
'/etc/resolv.conf': '',
|
'/etc/resolv.conf': '',
|
||||||
}
|
}
|
||||||
|
|
||||||
def replace_write(filename, content, mode=0644, omode="wb"):
|
def replace_write(filename, content, mode=0o644, omode="wb"):
|
||||||
buf = WriteBuffer()
|
buf = WriteBuffer()
|
||||||
buf.mode = mode
|
buf.mode = mode
|
||||||
buf.omode = omode
|
buf.omode = omode
|
||||||
@ -355,4 +355,4 @@ ifconfig_vtnet1="DHCP"
|
|||||||
defaultrouter="192.168.1.254"
|
defaultrouter="192.168.1.254"
|
||||||
'''
|
'''
|
||||||
self.assertCfgEquals(expected_buf, str(write_buf))
|
self.assertCfgEquals(expected_buf, str(write_buf))
|
||||||
self.assertEquals(write_buf.mode, 0644)
|
self.assertEquals(write_buf.mode, 0o644)
|
||||||
|
@ -171,7 +171,7 @@ class TestAddCaCerts(MockerTestCase):
|
|||||||
mock_load = self.mocker.replace(util.load_file, passthrough=False)
|
mock_load = self.mocker.replace(util.load_file, passthrough=False)
|
||||||
|
|
||||||
mock_write("/usr/share/ca-certificates/cloud-init-ca-certs.crt",
|
mock_write("/usr/share/ca-certificates/cloud-init-ca-certs.crt",
|
||||||
cert, mode=0644)
|
cert, mode=0o644)
|
||||||
|
|
||||||
mock_load("/etc/ca-certificates.conf")
|
mock_load("/etc/ca-certificates.conf")
|
||||||
self.mocker.result(ca_certs_content)
|
self.mocker.result(ca_certs_content)
|
||||||
@ -192,7 +192,7 @@ class TestAddCaCerts(MockerTestCase):
|
|||||||
mock_load = self.mocker.replace(util.load_file, passthrough=False)
|
mock_load = self.mocker.replace(util.load_file, passthrough=False)
|
||||||
|
|
||||||
mock_write("/usr/share/ca-certificates/cloud-init-ca-certs.crt",
|
mock_write("/usr/share/ca-certificates/cloud-init-ca-certs.crt",
|
||||||
expected_cert_file, mode=0644)
|
expected_cert_file, mode=0o644)
|
||||||
|
|
||||||
ca_certs_content = "line1\nline2\nline3"
|
ca_certs_content = "line1\nline2\nline3"
|
||||||
mock_load("/etc/ca-certificates.conf")
|
mock_load("/etc/ca-certificates.conf")
|
||||||
@ -233,7 +233,7 @@ class TestRemoveDefaultCaCerts(MockerTestCase):
|
|||||||
|
|
||||||
mock_delete_dir_contents("/usr/share/ca-certificates/")
|
mock_delete_dir_contents("/usr/share/ca-certificates/")
|
||||||
mock_delete_dir_contents("/etc/ssl/certs/")
|
mock_delete_dir_contents("/etc/ssl/certs/")
|
||||||
mock_write("/etc/ca-certificates.conf", "", mode=0644)
|
mock_write("/etc/ca-certificates.conf", "", mode=0o644)
|
||||||
mock_subp(('debconf-set-selections', '-'),
|
mock_subp(('debconf-set-selections', '-'),
|
||||||
"ca-certificates ca-certificates/trust_new_crts select no")
|
"ca-certificates ca-certificates/trust_new_crts select no")
|
||||||
self.mocker.replay()
|
self.mocker.replay()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user