def _write_storage_groups(self):
        """Write storage groups into DB.

        At here we have to write info as below:

            name, storage_class, friendly_name, rule_id, deleted,take_order.

        --------------------------------------------------------
        Important
        =========
        rule_id, in ceph system. The must be started from 0.
        Assume there are 0, 1, 2, 3 four storage groups, delete the
        iter=2 storage group, then all numbers will changed to be
        0 1 2. In fact, old {3}'s number is changed to be 2.

        For insert, we must follow one by one.
        """
        #TODO storage group need to contains cluster_id.

        stg_list = self._cluster_info['storage_group']
        for rule_id, stg in enumerate(stg_list):
            stg['rule_id'] = rule_id
            stg['status'] = FLAGS.storage_group_in
            stg['take_order'] = 0
            stg['choose_num'] = 0
            stg['choose_type'] = 'host'
            # TODO change the create_storage_group api.
            # DB create_storage_group will ignore the
            # request if the stg has exists.
            db.create_storage_group(self._context,
                        values=stg)
            LOG.info('Write storage group = %s success.' % stg['name'])
        return True
Esempio n. 2
0
    def _write_storage_groups(self):
        """Write storage groups into DB.

        At here we have to write info as below:

            name, storage_class, friendly_name, rule_id, deleted,take_order.

        --------------------------------------------------------
        Important
        =========
        rule_id, in ceph system. The must be started from 0.
        Assume there are 0, 1, 2, 3 four storage groups, delete the
        iter=2 storage group, then all numbers will changed to be
        0 1 2. In fact, old {3}'s number is changed to be 2.

        For insert, we must follow one by one.
        """
        #TODO storage group need to contains cluster_id.

        stg_list = self._cluster_info['storage_group']
        for rule_id, stg in enumerate(stg_list):
            stg['rule_id'] = rule_id
            stg['status'] = FLAGS.storage_group_in
            stg['take_order'] = 0
            stg['choose_num'] = 0
            stg['choose_type'] = 'host'
            # TODO change the create_storage_group api.
            # DB create_storage_group will ignore the
            # request if the stg has exists.
            db.create_storage_group(self._context, values=stg)
            LOG.info('Write storage group = %s success.' % stg['name'])
        return True
Esempio n. 3
0
 def create(self, req, body):
     """create zone."""
     LOG.info("CEPH_LOG storage group create body: %s" % body)
     context = req.environ['vsm.context']
     storage_group = body['storage_group']
     storage_group.update({"rule_id": -1})
     db.create_storage_group(context, storage_group)
     #self.scheduler_api.add_new_zone(context, body)
     return webob.Response(status_int=202)
 def create(self, req, body):
     """create zone."""
     LOG.info("CEPH_LOG storage group create body: %s" % body)
     context = req.environ['vsm.context']
     storage_group = body['storage_group']
     storage_group.update({"rule_id": -1})
     db.create_storage_group(context, storage_group)
     #self.scheduler_api.add_new_zone(context, body)
     return webob.Response(status_int=202)