def osd_state_update_or_create(self, context, values, create=None):
        #LOG.info("osd_state_update_or_create---%s"%values)
        osd_ref = db.osd_state_get_by_name(context, values['osd_name'])
        if not osd_ref:
            osd_ref = db.osd_state_get_by_device_id_and_service_id_and_cluster_id(\
                 context, values['device_id'], values['service_id'],\
                 values['cluster_id'])
        if osd_ref:
            osd_state = db.osd_state_update(context, osd_ref['id'], values)
            return osd_state
        else:
            create = True

        if create is None:
            osd_state = db.osd_state_update_or_create(context, values)
        elif create == True:
            osd_state = db.osd_state_create(context, values)
        else:
            #LOG.info("osd values:%s" % values)
            osd_state_ref = db.osd_state_get_by_name(context, values['osd_name'])
            if osd_state_ref:
                values['id'] = osd_state_ref.id
                osd_state = db.osd_state_update(context,
			                      values['id'],
					      values)
            else:
                return None 
        return osd_state
Exemple #2
0
    def osd_state_update_or_create(self, context, values, create=None):
        #LOG.info("osd_state_update_or_create")
        osd_ref = db.osd_state_get_by_name(context, values['osd_name'])
        if not osd_ref:
            osd_ref = db.osd_state_get_by_device_id_and_service_id_and_cluster_id(\
                 context, values['device_id'], values['service_id'],\
                 values['cluster_id'])
        if osd_ref:
            osd_state = db.osd_state_update(context, osd_ref['id'], values)
            return osd_state
        else:
            create = True

        if create is None:
            osd_state = db.osd_state_update_or_create(context, values)
        elif create == True:
            osd_state = db.osd_state_create(context, values)
        else:
            #LOG.info("osd values:%s" % values)
            osd_state_ref = db.osd_state_get_by_name(context,
                                                     values['osd_name'])
            if osd_state_ref:
                values['id'] = osd_state_ref.id
                osd_state = db.osd_state_update(context, values['id'], values)
            else:
                return None
        return osd_state
    def osd_state_update_or_create(self, context, values, create=None):
        #LOG.info("osd_state_update_or_create")
        osd_ref = db.osd_state_get_by_name(context, values['osd_name'])
        if osd_ref:
            osd_state = db.osd_state_update(context, osd_ref['id'], values)
            return osd_state
        else:
            create = True

        if create is None:
            osd_state = db.osd_state_update_or_create(context, values)
        elif create == True:
            osd_state = db.osd_state_create(context, values)
        else:
            #LOG.info("osd values:%s" % values)
            osd_state_ref = db.osd_state_get_by_name(context, values['osd_name'])
            if osd_state_ref:
                values['id'] = osd_state_ref.id
                osd_state = db.osd_state_update(context,
			                      values['id'],
					      values)
            else:
                return None 
        return osd_state
Exemple #4
0
 def osd_state_update(self, context, values):
     #LOG.info("osd_state_update")
     osd_ref = db.osd_state_get_by_name(context, values['osd_name'])
     if osd_ref:
         osd_state = db.osd_state_update(context, osd_ref['id'], values)
         return osd_state
Exemple #5
0
 def osd_state_get_by_name(self, context, name):
     return db.osd_state_get_by_name(context, name)
 def osd_state_update(self, context, values):
     #LOG.info("osd_state_update")
     osd_ref = db.osd_state_get_by_name(context, values['osd_name'])
     if osd_ref:
         osd_state = db.osd_state_update(context, osd_ref['id'], values)
         return osd_state
 def osd_state_get_by_name(self, context, name):
     return db.osd_state_get_by_name(context, name)