~openstack-charmers-archive/charms/precise/swift-storage/old-1501

« back to all changes in this revision

Viewing changes to hooks/charmhelpers/contrib/storage/linux/ceph.py

  • Committer: Corey Bryant
  • Date: 2014-12-18 13:30:39 UTC
  • mfrom: (51.1.1 swift-storage)
  • Revision ID: corey.bryant@canonical.com-20141218133039-fp90dyx570ela0jn
[dosaboy,r=corey.bryant] Retry crm resource check if not running.

Show diffs side-by-side

added added

removed removed

Lines of Context:
372
372
            return None
373
373
    else:
374
374
        return None
 
375
 
 
376
 
 
377
class CephBrokerRq(object):
 
378
    """Ceph broker request.
 
379
 
 
380
    Multiple operations can be added to a request and sent to the Ceph broker
 
381
    to be executed.
 
382
 
 
383
    Request is json-encoded for sending over the wire.
 
384
 
 
385
    The API is versioned and defaults to version 1.
 
386
    """
 
387
    def __init__(self, api_version=1):
 
388
        self.api_version = api_version
 
389
        self.ops = []
 
390
 
 
391
    def add_op_create_pool(self, name, replica_count=3):
 
392
        self.ops.append({'op': 'create-pool', 'name': name,
 
393
                         'replicas': replica_count})
 
394
 
 
395
    @property
 
396
    def request(self):
 
397
        return json.dumps({'api-version': self.api_version, 'ops': self.ops})
 
398
 
 
399
 
 
400
class CephBrokerRsp(object):
 
401
    """Ceph broker response.
 
402
 
 
403
    Response is json-decoded and contents provided as methods/properties.
 
404
 
 
405
    The API is versioned and defaults to version 1.
 
406
    """
 
407
    def __init__(self, encoded_rsp):
 
408
        self.api_version = None
 
409
        self.rsp = json.loads(encoded_rsp)
 
410
 
 
411
    @property
 
412
    def exit_code(self):
 
413
        return self.rsp.get('exit-code')
 
414
 
 
415
    @property
 
416
    def exit_msg(self):
 
417
        return self.rsp.get('stderr')