コード例 #1
0
    def _write_zone_info(self):
        """Write zone into DB.

        Zone list:
            zone_a
            zone_b
            zone_c

        Just write names here.
        """
        #TODO add zone table two variables. cluster_id, storage_group_id.
        zone_list = self._cluster_info['zone']
        for zone_name in zone_list:
            zone_ref = db.\
                          zone_get_by_name(self._context, zone_name)
            if not zone_ref:
                LOG.info('Have not find zone = %s' % zone_name)
                db.zone_create(self._context,
                                               {'name': zone_name,
                                                'deleted': False})
            else:
                LOG.info('Find zone = %s in zone Table.' % zone_name)
        return True
コード例 #2
0
    def _write_zone_info(self):
        """Write zone into DB.

        Zone list:
            zone_a
            zone_b
            zone_c

        Just write names here.
        """
        #TODO add zone table two variables. cluster_id, storage_group_id.
        zone_list = self._cluster_info['zone']
        for zone_name in zone_list:
            zone_ref = db.\
                          zone_get_by_name(self._context, zone_name)
            if not zone_ref:
                LOG.info('Have not find zone = %s' % zone_name)
                db.zone_create(self._context, {
                    'name': zone_name,
                    'deleted': False
                })
            else:
                LOG.info('Find zone = %s in zone Table.' % zone_name)
        return True
コード例 #3
0
    def create_zone(self, context, values=None):
        if values is None:
            LOG.warn("Error: Empty values")
            try:
                raise exception.GetNoneError
            except exception.GetNoneError, e:
                LOG.error("%s:%s", e.code, e.message)
            return False

        res = db.zone_get_all(context)
        zone_list = []
        for item in res:
            zone_list.append(item['name'])

        if values['name'] not in zone_list:
            db.zone_create(context, values)
        else:
            LOG.info('Warnning: zone exists in table %s' % values['name'])
            return True

        return True

    def zone_get_all(self, context):
        return db.zone_get_all(context)

    def zone_get_by_id(self, context, id):
        return db.zone_get_by_id(context, id)

    def zone_get_by_name(self, context, name):
        return db.zone_get_by_name(context, name)
コード例 #4
0
    def create_zone(self, context, values=None):
        if values is None:
            LOG.warn("Error: Empty values")
            try:
                raise exception.GetNoneError
            except exception.GetNoneError, e:
                LOG.error("%s:%s", e.code, e.message)
            return False

        res = db.zone_get_all(context)
        zone_list = []
        for item in res:
            zone_list.append(item['name'])

        if values['name'] not in zone_list:
            db.zone_create(context, values)
        else:
            LOG.info('Warnning: zone exists in table %s' % values['name'])
            return True

        return True

    def zone_get_all(self, context):
        return db.zone_get_all(context)

    def zone_get_by_id(self, context, id):
        return db.zone_get_by_id(context, id)

    def zone_get_by_name(self, context, name):
        return db.zone_get_by_name(context, name)