ambariPath.py 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. #!/usr/bin/env python
  2. """
  3. Licensed to the Apache Software Foundation (ASF) under one
  4. or more contributor license agreements. See the NOTICE file
  5. distributed with this work for additional information
  6. regarding copyright ownership. The ASF licenses this file
  7. to you under the Apache License, Version 2.0 (the
  8. "License"); you may not use this file except in compliance
  9. with the License. You may obtain a copy of the License at
  10. http://www.apache.org/licenses/LICENSE-2.0
  11. Unless required by applicable law or agreed to in writing, software
  12. distributed under the License is distributed on an "AS IS" BASIS,
  13. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. See the License for the specific language governing permissions and
  15. limitations under the License.
  16. Ambari Agent
  17. """
  18. import os
  19. AMBARI_SERVER_ROOT_ENV_VARIABLE = "ROOT"
  20. class AmbariPath():
  21. root_directory = os.environ[AMBARI_SERVER_ROOT_ENV_VARIABLE]
  22. @staticmethod
  23. def get(path):
  24. """
  25. Any paths which to ambari-server files, should be wrapped with this function call.
  26. Which is needed for the situations when ambari-server installed not in / but in other folder like /opt.
  27. Not ambari paths like /var/run/postgresql SHOULD NOT wrapped by this call though.
  28. """
  29. return os.path.realpath(AmbariPath.root_directory + os.sep + path)