]> git.apps.os.sepia.ceph.com Git - teuthology.git/commitdiff
openstack: do not display openstack client warnings 927/head
authorLoic Dachary <ldachary@redhat.com>
Sat, 6 Aug 2016 08:48:14 +0000 (10:48 +0200)
committerLoic Dachary <ldachary@redhat.com>
Tue, 9 Aug 2016 22:32:16 +0000 (00:32 +0200)
Because they are concatenated with the STDOUT by the sh function despite
being output on STDERR and that breaks json parsing.

Signed-off-by: Loic Dachary <ldachary@redhat.com>
teuthology/nuke.py
teuthology/openstack/__init__.py
teuthology/openstack/test/openstack-integration.py
teuthology/openstack/test/test_openstack.py
teuthology/provision/openstack.py

index 24cbb62ea662323e3e12b2d331d5e1d5d5871d93..f9b7887603c68eca7467efda9e411aa48ecadc3f 100644 (file)
@@ -450,7 +450,7 @@ def stale_openstack_volumes(ctx, volumes):
     for volume in volumes:
         volume_id = volume.get('ID') or volume['id']
         try:
-            volume = json.loads(sh("openstack volume show -f json " +
+            volume = json.loads(sh("openstack -q volume show -f json " +
                                    volume_id))
         except subprocess.CalledProcessError:
             log.debug("stale-openstack: {id} disappeared, ignored"
index f929fea2936daf4b32b55be590cd49b90d1073dc..b828452a91676866cc2db66116d2dd14c533b594 100644 (file)
@@ -66,7 +66,7 @@ class OpenStackInstance(object):
     def set_info(self):
         try:
             self.info = json.loads(
-                misc.sh("openstack server show -f json " + self.name_or_id))
+                misc.sh("openstack -q server show -f json " + self.name_or_id))
             enforce_json_dictionary(self.info)
         except CalledProcessError:
             self.info = None
@@ -142,7 +142,7 @@ class OpenStackInstance(object):
                               self.get_addresses())[0]
 
     def get_floating_ip(self):
-        ips = json.loads(misc.sh("openstack ip floating list -f json"))
+        ips = json.loads(misc.sh("openstack -q ip floating list -f json"))
         for ip in ips:
             if ip['Instance ID'] == self['id']:
                 return ip['IP']
@@ -162,13 +162,13 @@ class OpenStackInstance(object):
         if not self.exists():
             return True
         volumes = self.get_volumes()
-        misc.sh("openstack server set --name REMOVE-ME-" + self.name_or_id +
+        misc.sh("openstack -q server set --name REMOVE-ME-" + self.name_or_id +
                 " " + self['id'])
-        misc.sh("openstack server delete --wait " + self['id'] +
+        misc.sh("openstack -q server delete --wait " + self['id'] +
                 " || true")
         for volume in volumes:
-            misc.sh("openstack volume set --name REMOVE-ME " + volume + " || true")
-            misc.sh("openstack volume delete " + volume + " || true")
+            misc.sh("openstack -q volume set --name REMOVE-ME " + volume + " || true")
+            misc.sh("openstack -q volume delete " + volume + " || true")
         return True
 
 
@@ -236,7 +236,7 @@ class OpenStack(object):
         """
         Return true if the image exists in OpenStack.
         """
-        found = misc.sh("openstack image list -f json --property name='" +
+        found = misc.sh("openstack -q image list -f json --property name='" +
                         self.image_name(image) + "'")
         return len(json.loads(found)) > 0
 
@@ -244,7 +244,7 @@ class OpenStack(object):
         """
         Return the uuid of the network in OpenStack.
         """
-        r = json.loads(misc.sh("openstack network show -f json " +
+        r = json.loads(misc.sh("openstack -q network show -f json " +
                                network))
         return self.get_value(r, 'id')
 
@@ -293,7 +293,7 @@ class OpenStack(object):
         """
         Return the smallest flavor that satisfies the desired size.
         """
-        flavors_string = misc.sh("openstack flavor list -f json")
+        flavors_string = misc.sh("openstack -q flavor list -f json")
         flavors = json.loads(flavors_string)
         found = []
         for flavor in flavors:
@@ -339,14 +339,14 @@ class OpenStack(object):
     def list_instances():
         ownedby = "ownedby='" + teuth_config.openstack['ip'] + "'"
         all = json.loads(misc.sh(
-            "openstack server list -f json --long --name 'target'"))
+            "openstack -q server list -f json --long --name 'target'"))
         return filter(lambda instance: ownedby in instance['Properties'], all)
 
     @staticmethod
     def list_volumes():
         ownedby = "ownedby='" + teuth_config.openstack['ip'] + "'"
         all = json.loads(misc.sh(
-            "openstack volume list -f json --long"))
+            "openstack -q volume list -f json --long"))
         def select(volume):
             return (ownedby in volume['Properties'] and
                     volume['Display Name'].startswith('target'))
@@ -587,9 +587,9 @@ ssh access           : ssh {identity}{username}@{ip} # logs in /usr/share/nginx/
         know already.
         """
         try:
-            misc.sh("openstack flavor list | tail -2")
+            misc.sh("openstack -q flavor list | tail -2")
         except subprocess.CalledProcessError:
-            log.exception("openstack flavor list")
+            log.exception("openstack -q flavor list")
             raise Exception("verify openrc.sh has been sourced")
         self.set_provider()
 
@@ -676,7 +676,7 @@ ssh access           : ssh {identity}{username}@{ip} # logs in /usr/share/nginx/
         among instances created within the same tenant.
         """
         try:
-            misc.sh("openstack security group show teuthology")
+            misc.sh("openstack -q security group show teuthology")
             return
         except subprocess.CalledProcessError:
             pass
@@ -698,7 +698,7 @@ openstack security group rule create --proto udp --dst-port 16000:65535 teutholo
         """
         Return a floating IP address not associated with an instance or None.
         """
-        ips = json.loads(misc.sh("openstack ip floating list -f json"))
+        ips = json.loads(misc.sh("openstack -q ip floating list -f json"))
         for ip in ips:
             if not ip['Instance ID']:
                 return ip['IP']
@@ -706,13 +706,13 @@ openstack security group rule create --proto udp --dst-port 16000:65535 teutholo
 
     @staticmethod
     def create_floating_ip():
-        pools = json.loads(misc.sh("openstack ip floating pool list -f json"))
+        pools = json.loads(misc.sh("openstack -q ip floating pool list -f json"))
         if not pools:
             return None
         pool = pools[0]['Name']
         try:
             ip = json.loads(misc.sh(
-                "openstack ip floating create -f json '" + pool + "'"))
+                "openstack -q ip floating create -f json '" + pool + "'"))
             return TeuthologyOpenStack.get_value(ip, 'ip')
         except subprocess.CalledProcessError:
             log.debug("create_floating_ip: not creating a floating ip")
@@ -729,14 +729,14 @@ openstack security group rule create --proto udp --dst-port 16000:65535 teutholo
         if not ip:
             ip = TeuthologyOpenStack.create_floating_ip()
         if ip:
-            misc.sh("openstack ip floating add " + ip + " " + name_or_id)
+            misc.sh("openstack -q ip floating add " + ip + " " + name_or_id)
 
     @staticmethod
     def get_floating_ip_id(ip):
         """
         Return the id of a floating IP
         """
-        results = json.loads(misc.sh("openstack ip floating list -f json"))
+        results = json.loads(misc.sh("openstack -q ip floating list -f json"))
         for result in results:
             if result['IP'] == ip:
                 return str(result['ID'])
@@ -754,9 +754,9 @@ openstack security group rule create --proto udp --dst-port 16000:65535 teutholo
         ip = OpenStackInstance(instance_id).get_floating_ip()
         if not ip:
             return
-        misc.sh("openstack ip floating remove " + ip + " " + instance_id)
+        misc.sh("openstack -q ip floating remove " + ip + " " + instance_id)
         ip_id = TeuthologyOpenStack.get_floating_ip_id(ip)
-        misc.sh("openstack ip floating delete " + ip_id)
+        misc.sh("openstack -q ip floating delete " + ip_id)
 
     def create_cluster(self):
         user_data = self.get_user_data()
@@ -787,8 +787,8 @@ openstack security group rule create --proto udp --dst-port 16000:65535 teutholo
         self.ssh("sudo /etc/init.d/teuthology stop || true")
         instance_id = self.get_instance_id(self.args.name)
         self.delete_floating_ip(instance_id)
-        misc.sh("openstack server delete packages-repository || true")
-        misc.sh("openstack server delete --wait " + self.args.name)
+        misc.sh("openstack -q server delete packages-repository || true")
+        misc.sh("openstack -q server delete --wait " + self.args.name)
 
 def main(ctx, argv):
     return TeuthologyOpenStack(ctx, teuth_config, argv).main()
index 58bd919d7f85e4eed9fc613d18f45af00e0b8de4..e679967b070a23f53b7d63d4b8b34b93c6e4c589 100644 (file)
@@ -58,10 +58,10 @@ class Integration(object):
         # move that to def tearDown for debug and when it works move it
         # back in tearDownClass so it is not called on every test
         ownedby = "ownedby='" + teuth_config.openstack['ip']
-        all_instances = teuthology.misc.sh("openstack server list -f json --long")
+        all_instances = teuthology.misc.sh("openstack -q server list -f json --long")
         for instance in json.loads(all_instances):
             if ownedby in instance['Properties']:
-                teuthology.misc.sh("openstack server delete --wait " + instance['ID'])
+                teuthology.misc.sh("openstack -q server delete --wait " + instance['ID'])
 
     def setup_worker(self):
         self.logs = self.d + "/log"
@@ -192,7 +192,7 @@ class TestSchedule(Integration):
         account if the instance has less than 4GB RAM.
         """
         try:
-            teuthology.misc.sh("openstack volume list")
+            teuthology.misc.sh("openstack -q volume list")
             job = 'teuthology/openstack/test/resources_hint.yaml'
             has_cinder = True
         except subprocess.CalledProcessError:
index 107103d0ec834635d99cbf558eba06b8cefd3cbd..7b9ba750ae08fb4532bcb5479dfe58410ac66eef 100644 (file)
@@ -286,7 +286,7 @@ class TestTeuthologyOpenStack(object):
         ip = TeuthologyOpenStack.create_floating_ip()
         if ip:
             ip_id = TeuthologyOpenStack.get_floating_ip_id(ip)
-            misc.sh("openstack ip floating delete " + ip_id)
+            misc.sh("openstack -q ip floating delete " + ip_id)
             self.can_create_floating_ips = True
         else:
             self.can_create_floating_ips = False
@@ -378,4 +378,4 @@ openstack keypair delete {key_name} || true
         ip = TeuthologyOpenStack.get_unassociated_floating_ip()
         assert expected == ip
         ip_id = TeuthologyOpenStack.get_floating_ip_id(ip)
-        misc.sh("openstack ip floating delete " + ip_id)
+        misc.sh("openstack -q ip floating delete " + ip_id)
index 56d9b904823c4c9fa492e1d975213a916a36f45c..2080fde6a37fcd7cff5c65ba404a5f1e0e7980d1 100644 (file)
@@ -75,7 +75,7 @@ class ProvisionOpenStack(OpenStack):
             with safe_while(sleep=2, tries=100,
                             action="volume " + volume_name) as proceed:
                 while proceed():
-                    r = misc.sh("openstack volume show  -f json " +
+                    r = misc.sh("openstack -q volume show  -f json " +
                                 volume_name)
                     status = self.get_value(json.loads(r), 'status')
                     if status == 'available':