Add num_retries configuration option

The boto library is designed for retrying failed actions automatically.

Bug #1089764

Change-Id: I4a42a87286e7d86e6569fa82c7309f2ea5fbfed9
diff --git a/etc/tempest.conf.sample b/etc/tempest.conf.sample
index 020baa1..7ff458a 100644
--- a/etc/tempest.conf.sample
+++ b/etc/tempest.conf.sample
@@ -257,6 +257,9 @@
 #TCP/IP connection timeout
 http_socket_timeout = 5
 
+#Number of retries actions on connection or 5xx error
+num_retries = 1
+
 # Status change wait timout
 build_timeout = 120
 
diff --git a/tempest/config.py b/tempest/config.py
index 60da85c..691a898 100644
--- a/tempest/config.py
+++ b/tempest/config.py
@@ -470,6 +470,11 @@
         return self.get("http_socket_timeout", "3")
 
     @property
+    def num_retries(self):
+        """boto num_retries on error"""
+        return self.get("num_retries", "1")
+
+    @property
     def build_timeout(self):
         """status change timeout"""
         return float(self.get("build_timeout", "60"))
diff --git a/tempest/services/boto/__init__.py b/tempest/services/boto/__init__.py
index 2cac843..58a2b37 100644
--- a/tempest/services/boto/__init__.py
+++ b/tempest/services/boto/__init__.py
@@ -36,6 +36,7 @@
                  *args, **kwargs):
 
         self.connection_timeout = config.boto.http_socket_timeout
+        self.num_retries = config.boto.num_retries
         self.build_timeout = config.boto.build_timeout
         # We do not need the "path":  "/token" part
         if auth_url:
@@ -63,12 +64,13 @@
             raise NotFound("Unable to get access and secret keys")
         return ec2_cred
 
-    def _config_boto_timeout(self, timeout):
+    def _config_boto_timeout(self, timeout, retries):
         try:
             boto.config.add_section("Boto")
         except DuplicateSectionError:
             pass
         boto.config.set("Boto", "http_socket_timeout", timeout)
+        boto.config.set("Boto", "num_retries", retries)
 
     def __getattr__(self, name):
         """Automatically creates methods for the allowed methods set"""
@@ -86,7 +88,7 @@
             raise AttributeError(name)
 
     def get_connection(self):
-        self._config_boto_timeout(self.connection_timeout)
+        self._config_boto_timeout(self.connection_timeout, self.num_retries)
         if not all((self.connection_data["aws_access_key_id"],
                    self.connection_data["aws_secret_access_key"])):
             if all(self.ks_cred.itervalues()):