summaryrefslogtreecommitdiff
path: root/vmdb/plugins/files_plugin.py
diff options
context:
space:
mode:
Diffstat (limited to 'vmdb/plugins/files_plugin.py')
-rw-r--r--vmdb/plugins/files_plugin.py57
1 files changed, 9 insertions, 48 deletions
diff --git a/vmdb/plugins/files_plugin.py b/vmdb/plugins/files_plugin.py
index 40dc86c..772443c 100644
--- a/vmdb/plugins/files_plugin.py
+++ b/vmdb/plugins/files_plugin.py
@@ -37,25 +37,12 @@ class CreateFileStepRunner(vmdb.StepRunnerInterface):
root = state.tags.get_mount_point('/')
newfile = step['create-file']
contents = step['contents']
- perm = step.get('perm')
- uid = step.get('uid')
- gid = step.get('gid')
+ perm = step.get('perm', 0o644)
+ uid = step.get('uid', 0)
+ gid = step.get('gid', 0)
filename = '/'.join([root,newfile])
- if perm:
- perm = int(perm, 8)
- else:
- perm = 0o0644
- if uid:
- uid = int(uid)
- else:
- uid = 0
- if gid:
- gid = int(gid)
- else:
- gid = 0
-
logging.info('Creating file %s, uid %d, gid %d, perms %o' % (filename, uid, gid, perm))
fd = open(filename, 'w')
fd.write(contents)
@@ -74,25 +61,12 @@ class CopyFileStepRunner(vmdb.StepRunnerInterface):
root = state.tags.get_mount_point('/')
newfile = step['copy-file']
src = step['src']
- perm = step.get('perm')
- uid = step.get('uid')
- gid = step.get('gid')
+ perm = step.get('perm', 0o644)
+ uid = step.get('uid', 0)
+ gid = step.get('gid', 0)
filename = '/'.join([root,newfile])
- if perm:
- perm = int(perm, 8)
- else:
- perm = 0o0644
- if uid:
- uid = int(uid)
- else:
- uid = 0
- if gid:
- gid = int(gid)
- else:
- gid = 0
-
logging.info(
'Copying file %s to %s, uid %d, gid %d, perms %o' % (
src, filename, uid, gid, perm))
@@ -117,22 +91,9 @@ class CreateDirStepRunner(vmdb.StepRunnerInterface):
root = state.tags.get_mount_point('/')
newdir = step['create-dir']
path = '/'.join([root, newdir])
- perm = step.get('perm')
- uid = step.get('uid')
- gid = step.get('gid')
-
- if perm:
- perm = int(perm, 8)
- else:
- perm = 0o0755
- if uid:
- uid = int(uid)
- else:
- uid = 0
- if gid:
- gid = int(gid)
- else:
- gid = 0
+ perm = step.get('perm', 0o755)
+ uid = step.get('uid', 0)
+ gid = step.get('gid', 0)
logging.info('Creating directory %s, uid %d, gid %d, perms %o' % (path, uid, gid, perm))