From 47386d15d4835a38631569fd6542c22f38d14d69 Mon Sep 17 00:00:00 2001 From: Zack Cerza Date: Wed, 5 Aug 2015 10:05:17 -0600 Subject: [PATCH] Add Remote.chcon() Signed-off-by: Zack Cerza --- teuthology/orchestra/remote.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/teuthology/orchestra/remote.py b/teuthology/orchestra/remote.py index da982bdcfd..38004b0649 100644 --- a/teuthology/orchestra/remote.py +++ b/teuthology/orchestra/remote.py @@ -11,6 +11,7 @@ import re import logging from cStringIO import StringIO from teuthology import lockstatus as ls +from teuthology import misc import os import pwd import tempfile @@ -195,6 +196,23 @@ class Remote(object): args=args, ) + def chcon(self, file_path, context): + """ + Set the SELinux context of a given file. + + VMs and non-RPM-based hosts will skip this operation because ours + currently have SELinux disabled. + + :param file_path: The path to the file + :param context: The SELinux context to be used + """ + if self.os.package_type != 'rpm': + return + if misc.is_vm(self.shortname): + return + self.run(args="sudo chcon {con} {path}".format( + con=context, path=file_path)) + def _sftp_put_file(self, local_path, remote_path): """ Use the paramiko.SFTPClient to put a file. Returns the remote filename. -- 2.39.5