inventory utils: added a oc_get_md; cleaned up master config
@@ -384,7 +384,7 @@ class Cluster(object):
if not self._master_config:
master_config_yaml = self.run_cmd_on_master("/usr/bin/cat /etc/origin/master/master-config.yaml",
strip=False)
- self._master_config = yaml.load(master_config_yaml)
+ self._master_config = yaml.safe_load(master_config_yaml)
return self._master_config
@@ -456,6 +456,33 @@ class Cluster(object):
return command_output
+ def oc_get_cmd(self, os_object, namespace=None, selector=None, json=False):
+ """
+ Run an oc command on the primary master and return the output
+
+ os_object: pod, node, ns
+ namespace: project namespace
+ selector: label selector
+ json: return in json
+ """
+
+ cmd = "oc get {}".format(os_object)
+
+ if namespace:
+ cmd += " -n {}".format(namespace)
+
+ if selector:
+ cmd += " -l {}".format(selector)
+
+ if json:
+ cmd += " -o json"
+ else:
+ cmd += " -o yaml"
+
+ command_output = self.run_cmd_on_master(cmd)
+
+ return command_output
+
def convert_inv_to_os_name(self, hostname):
""" convert ops hostname to the openshift hostname
example: free-stg-master-03fb6 -> ip-172-31-78-254.us-east-2.compute.internal
