def start(self): redis_log(MINIO_LOG_INFO, MINIO_NAME, "minio is start...") #create minio dir if (ERROR_FAILED == _minio_mkdir(MINIO_PATH, 0755)): return ERROR_FAILED
def _minio_cmd(cmd): try: exec_shell(cmd) return ERROR_SUCCESS except Exp, e: minio_log = "%s failed, %s." % (cmd, os.strerror(e.errno)) redis_log(MINIO_LOG_ERR, MINIO_NAME, minio_log) return e.errno
def stop(self): redis_log(MINIO_LOG_INFO, MINIO_NAME, "minio is stopping...") try: os.unlink(MINIO_LINK) except OSError, e: minio_log = "unlink %s failed, %s." % \ (MINIO_LINK, os.strerror(e.errno)) redis_log(MINIO_LOG_ERR, MINIO_NAME, minio_log)
def _minio_mkdir(path_name, mode=0755): try: os.mkdir(path_name, mode) except OSError, e: if (e.errno != errno.EEXIST): minio_log = "mkdir %s failed, %s." % (path_name, os.strerror(e.errno)) redis_log(MINIO_LOG_ERR, MINIO_NAME, minio_log) return ERROR_FAILED
cmd = "mount -t nfs4 127.0.0.1:%s %s" % \ (NFS_MINIO_PATH, MINIO_PATH) _minio_cmd(cmd) #create soft link /opt/minio/lminio-->/opt/minio/nfs_minio/minio minio_path = os.path.join(MINIO_PATH, MINIO_NAME) if (ERROR_FAILED == _minio_mkdir(minio_path, 0755)): return ERROR_FAILED try: os.symlink(minio_path, MINIO_LINK) except OSError, e: if (e.errno != errno.EEXIST): minio_log = "%s link to %s failed, %s." % \ (MINIO_LINK, minio_path, os.strerror(e.errno)) redis_log(MINIO_LOG_ERR, MINIO_NAME, minio_log) return ERROR_FAILED #start minio server by systemctl command cmd = "systemctl start %s" % MINIO_NAME if (ERROR_FAILED == _minio_cmd(cmd)): return ERROR_FAILED redis_log(MINIO_LOG_INFO, MINIO_NAME, "minio start success") return ERROR_SUCCESS def stop(self): redis_log(MINIO_LOG_INFO, MINIO_NAME, "minio is stopping...") try: os.unlink(MINIO_LINK)