From 73fcc748737132881b43699707ec4c38a818d0c2 Mon Sep 17 00:00:00 2001 From: William Durairaj Date: Mon, 24 Jun 2019 18:28:19 +0530 Subject: [PATCH] Fix chcon error -- Issue #640 (#658) * Fix Issue #534 (#576) * Fix Issue #390, Allow 'size' in snapshot options * Updated usage doc * Fix issue #534 - invalid config entry creates session leak * Fix for chcon error -- issue #640 --- hpedockerplugin/file_manager.py | 6 +++++- hpedockerplugin/hpe/utils.py | 9 +++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/hpedockerplugin/file_manager.py b/hpedockerplugin/file_manager.py index a180e707..8ccb5e1f 100644 --- a/hpedockerplugin/file_manager.py +++ b/hpedockerplugin/file_manager.py @@ -754,7 +754,11 @@ def mount_share(self, share_name, share, mount_id): self._create_mount_dir(mount_dir) LOG.info("Mounting share path %s to %s" % (share_path, mount_dir)) - sh.mount('-t', 'nfs', share_path, mount_dir) + if utils.is_host_os_rhel(): + sh.mount('-o', 'context="system_u:object_r:nfs_t:s0"', + '-t', 'nfs', share_path, mount_dir) + else: + sh.mount('-t', 'nfs', share_path, mount_dir) LOG.debug('Device: %(path)s successfully mounted on %(mount)s', {'path': share_path, 'mount': mount_dir}) diff --git a/hpedockerplugin/hpe/utils.py b/hpedockerplugin/hpe/utils.py index c2798fad..1ca68274 100644 --- a/hpedockerplugin/hpe/utils.py +++ b/hpedockerplugin/hpe/utils.py @@ -17,6 +17,7 @@ import six import string import uuid +import platform from Crypto.Cipher import AES from Crypto.Random import random @@ -156,6 +157,14 @@ def get_remote3par_rcg_name(id, array_id): six.text_type(array_id)) +def is_host_os_rhel(): + platform_type = list(platform.linux_distribution()) + if 'Red Hat Enterprise Linux Server' in platform_type: + return True + else: + return False + + class PasswordDecryptor(object): def __init__(self, backend_name, etcd): self._backend_name = backend_name