def get_by_gid_type(cls, context, group_id, type, deleted=False): if type in [DBInstanceType.MASTER, DBInstanceType.SINGLE, DBInstanceType.STANDBY]: db_info = DBInstanceGroupItem.find_by(context=context, group_id=group_id, deleted=deleted, type=type) return db_info elif type in [DBInstanceType.READ_REPLI, DBInstanceType.PENDING]: db_info = DBInstanceGroupItem.find_all(group_id=group_id, deleted=deleted, type=type) ret_list = [] for _item in db_info: ret_list.append(_item) return ret_list else: raise TypeError()
def update_type(cls, context, item_id, type, deleted=False): if type not in [ DBInstanceType.MASTER, DBInstanceType.READ_REPLI, DBInstanceType.SINGLE, DBInstanceType.STANDBY, DBInstanceType.PENDING, ]: raise TypeError() try: item = DBInstanceGroupItem.find_by(context, id=item_id, deleted=deleted) item.type = type item.save() except exception.NotFound: raise exception.NotFound(uuid=item_id) return item
def get_by_instance_id(cls, context, instance_id, deleted=False): try: db_info = DBInstanceGroupItem.find_by(instance_id=instance_id, deleted=deleted) return db_info except exception.NotFound: raise exception.NotFound(uuid=instance_id)