Revision 5bef1f49

b/snf-tools/synnefo_tools/burnin/common.py
104 104

  
105 105

  
106 106
# --------------------------------------------------------------------
107
# BurninTests class
107
# Helper Classes
108 108
# Too few public methods. pylint: disable-msg=R0903
109 109
# Too many instance attributes. pylint: disable-msg=R0902
110 110
class Clients(object):
......
126 126
    image = None
127 127
    image_url = None
128 128

  
129
    def initialize_clients(self):
130
        """Initialize all the Kamaki Clients"""
131
        self.astakos = AstakosClient(self.auth_url, self.token)
132
        self.astakos.CONNECTION_RETRY_LIMIT = self.retry
133

  
134
        self.compute_url = \
135
            self.astakos.get_service_endpoints('compute')['publicURL']
136
        self.compute = ComputeClient(self.compute_url, self.token)
137
        self.compute.CONNECTION_RETRY_LIMIT = self.retry
138

  
139
        self.cyclades = CycladesClient(self.compute_url, self.token)
140
        self.cyclades.CONNECTION_RETRY_LIMIT = self.retry
141

  
142
        self.pithos_url = self.astakos.\
143
            get_service_endpoints('object-store')['publicURL']
144
        self.pithos = PithosClient(self.pithos_url, self.token)
145
        self.pithos.CONNECTION_RETRY_LIMIT = self.retry
146

  
147
        self.image_url = \
148
            self.astakos.get_service_endpoints('image')['publicURL']
149
        self.image = ImageClient(self.image_url, self.token)
150
        self.image.CONNECTION_RETRY_LIMIT = self.retry
151

  
152

  
153
class Proper(object):
154
    """A descriptor used by tests implementing the TestCase class
155

  
156
    Since each instance of the TestCase will only be used to run a single
157
    test method (a new fixture is created for each test) the attributes can
158
    not be saved in the class instances. Instead we use descriptors.
129 159

  
160
    """
161
    def __init__(self, value=None):
162
        self.val = value
163

  
164
    def __get__(self, obj, objtype=None):
165
        return self.val
166

  
167
    def __set__(self, obj, value):
168
        self.val = value
169

  
170

  
171
# --------------------------------------------------------------------
172
# BurninTests class
130 173
# Too many public methods (45/20). pylint: disable-msg=R0904
131 174
class BurninTests(unittest.TestCase):
132 175
    """Common class that all burnin tests should implement"""
......
141 184
    flavors = None
142 185
    delete_stale = False
143 186

  
187
    quotas = Proper(value=None)
188

  
144 189
    @classmethod
145 190
    def setUpClass(cls):  # noqa
146 191
        """Initialize BurninTests"""
......
153 198
    def test_000_clients_setup(self):
154 199
        """Initializing astakos/cyclades/pithos clients"""
155 200
        # Update class attributes
201
        self.clients.initialize_clients()
156 202
        self.info("Astakos auth url is %s", self.clients.auth_url)
157
        self.clients.astakos = AstakosClient(
158
            self.clients.auth_url, self.clients.token)
159
        self.clients.astakos.CONNECTION_RETRY_LIMIT = self.clients.retry
160

  
161
        self.clients.compute_url = \
162
            self.clients.astakos.get_service_endpoints('compute')['publicURL']
163 203
        self.info("Cyclades url is %s", self.clients.compute_url)
164
        self.clients.compute = ComputeClient(
165
            self.clients.compute_url, self.clients.token)
166
        self.clients.compute.CONNECTION_RETRY_LIMIT = self.clients.retry
167

  
168
        self.clients.cyclades = CycladesClient(
169
            self.clients.compute_url, self.clients.token)
170
        self.clients.cyclades.CONNECTION_RETRY_LIMIT = self.clients.retry
171

  
172
        self.clients.pithos_url = self.clients.astakos.\
173
            get_service_endpoints('object-store')['publicURL']
174 204
        self.info("Pithos url is %s", self.clients.pithos_url)
175
        self.clients.pithos = PithosClient(
176
            self.clients.pithos_url, self.clients.token)
177
        self.clients.pithos.CONNECTION_RETRY_LIMIT = self.clients.retry
178

  
179
        self.clients.image_url = \
180
            self.clients.astakos.get_service_endpoints('image')['publicURL']
181 205
        self.info("Image url is %s", self.clients.image_url)
182
        self.clients.image = ImageClient(
183
            self.clients.image_url, self.clients.token)
184
        self.clients.image.CONNECTION_RETRY_LIMIT = self.clients.retry
206

  
207
        self.quotas = self._get_quotas()
208
        self.info("  Disk usage is %s",
209
                  self.quotas['system']['cyclades.disk']['usage'])
210
        self.info("  VM usage is %s",
211
                  self.quotas['system']['cyclades.vm']['usage'])
212
        self.info("  DiskSpace usage is %s",
213
                  self.quotas['system']['pithos.diskspace']['usage'])
214
        self.info("  Ram usage is %s",
215
                  self.quotas['system']['cyclades.ram']['usage'])
216
        self.info("  CPU usage is %s",
217
                  self.quotas['system']['cyclades.cpu']['usage'])
218
        self.info("  Network usage is %s",
219
                  self.quotas['system']['cyclades.network.private']['usage'])
185 220

  
186 221
    # ----------------------------------
187 222
    # Loggers helper functions
......
441 476
        self.clients.pithos.container = container
442 477
        self.clients.pithos.container_put()
443 478

  
479
    # ----------------------------------
480
    # Quotas
481
    def _get_quotas(self):
482
        """Get quotas"""
483
        self.info("Getting quotas for user %s", self._get_uuid())
484
        astakos_client = self.clients.astakos.get_client()
485
        return astakos_client.get_quotas()
486

  
444 487

  
445 488
# --------------------------------------------------------------------
446 489
# Initialize Burnin
......
540 583
        return type_, val
541 584
    except ValueError:
542 585
        return None
543

  
544

  
545
class Proper(object):
546
    """A descriptor used by tests implementing the TestCase class
547

  
548
    Since each instance of the TestCase will only be used to run a single
549
    test method (a new fixture is created for each test) the attributes can
550
    not be saved in the class instances. Instead we use descriptors.
551

  
552
    """
553
    def __init__(self, value=None):
554
        self.val = value
555

  
556
    def __get__(self, obj, objtype=None):
557
        return self.val
558

  
559
    def __set__(self, obj, value):
560
        self.val = value
b/snf-tools/synnefo_tools/burnin/cyclades_common.py
167 167
                msg = "Server \"%s\" with id %s went to unexpected status %s"
168 168
                self.error(msg, server['name'], server['id'], srv['status'])
169 169
                self.fail(msg % (server['name'], server['id'], srv['status']))
170
        opmsg = "Waiting for server \"%s\" to become %s"
171
        self.info(opmsg, server['name'], new_status)
172
        opmsg = opmsg % (server['name'], new_status)
170
        opmsg = "Waiting for server \"%s\" with id %s to become %s"
171
        self.info(opmsg, server['name'], server['id'], new_status)
172
        opmsg = opmsg % (server['name'], server['id'], new_status)
173 173
        self._try_until_timeout_expires(opmsg, check_fun)
174 174

  
175 175
    def _insist_on_network_transition(self, network,
......
187 187
                self.error(msg, network['name'], network['id'], ntw['status'])
188 188
                self.fail(msg %
189 189
                          (network['name'], network['id'], ntw['status']))
190
        opmsg = "Waiting for network \"%s\" to become %s"
191
        self.info(opmsg, network['name'], new_status)
192
        opmsg = opmsg % (network['name'], new_status)
190
        opmsg = "Waiting for network \"%s\" with id %s to become %s"
191
        self.info(opmsg, network['name'], network['id'], new_status)
192
        opmsg = opmsg % (network['name'], network['id'], new_status)
193 193
        self._try_until_timeout_expires(opmsg, check_fun)
194 194

  
195 195
    def _insist_on_network_connection(self, server, network, disconnect=False):

Also available in: Unified diff