]> git.apps.os.sepia.ceph.com Git - teuthology.git/commitdiff
Add Remote.chcon()
authorZack Cerza <zack@redhat.com>
Wed, 5 Aug 2015 16:05:17 +0000 (10:05 -0600)
committerZack Cerza <zack@redhat.com>
Wed, 5 Aug 2015 16:05:17 +0000 (10:05 -0600)
Signed-off-by: Zack Cerza <zack@redhat.com>
teuthology/orchestra/remote.py

index da982bdcfdd9bd825d6032c4817118c38c7906da..38004b0649acc02bfd4eaa394b6c99b43cf22bc1 100644 (file)
@@ -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.