func UpdateMitigationScopeStatus(mitigationScopeId int64, status int) (err error) {
	engine, err := ConnectDB()
	if err != nil {
		log.Errorf("database connect error: %s", err)
		return
	}
	session := engine.NewSession()
	defer session.Close()
	err = session.Begin()
	if err != nil {
		session.Rollback()
		return
	}
	updMitigationScope := db_models.MitigationScope{ Status: status }
	_, err = session.Id(mitigationScopeId).Cols("status").Update(&updMitigationScope)
	if err != nil {
		session.Rollback()
		log.Errorf("mitigationScope status update err: %s", err)
		return
	}
	err = session.Commit()
	return
}
/*
Updates a MitigationScope status in the DB.

parameter:
mitigationScopeId int64
status            int
return:
err error
package models
import (
	"time"
	"strconv"
	"github.com/go-xorm/xorm"
	log "github.com/sirupsen/logrus"
	"github.com/nttdots/go-dots/libcoap"
	"github.com/nttdots/go-dots/dots_server/db_models"
	"github.com/nttdots/go-dots/dots_common/messages"
	"github.com/nttdots/go-dots/dots_common/types/data"
	"github.com/nttdots/go-dots/dots_server/db_models/data"
)
func CreateMitigationScope(mitigationScope MitigationScope, customer Customer, isIfMatchOption bool) (newMitigationScope db_models.MitigationScope, err error) {
	engine, err := ConnectDB()
	if err != nil {
		log.Errorf("database connect error: %s", err)
		return
	}
	log.Debugf("CreateMitigationScope mitigationScope=%+v\n", mitigationScope)
	dbMitigationScope := new(db_models.MitigationScope)
	clientIdentifier := mitigationScope.ClientIdentifier
	clientDomainIdentifier := mitigationScope.ClientDomainIdentifier
	_, err = engine.Where("customer_id = ? AND client_identifier = ? AND mitigation_id = ?", customer.Id, clientIdentifier, mitigationScope.MitigationId).Desc("id").Get(dbMitigationScope)
	if err != nil {
		log.Errorf("mitigation_scope select error: %s", err)
		return
	}
	if dbMitigationScope.Id != 0 {
		currentTime := time.Now()
		remainingLifetime := dbMitigationScope.Lifetime - int(currentTime.Sub(dbMitigationScope.Updated).Seconds())
		if remainingLifetime > 0 || dbMitigationScope.Lifetime == int(messages.INDEFINITE_LIFETIME){
			mitigationScope.MitigationScopeId = dbMitigationScope.Id
			err = UpdateMitigationScope(mitigationScope, customer, isIfMatchOption)
			return
		}
	}
	session := engine.NewSession()
	err = session.Begin()
	if err != nil {
		session.Rollback()
		return
	}
	if mitigationScope.Status == 0 { mitigationScope.Status = InProgress }
	newMitigationScope = db_models.MitigationScope{
		CustomerId:       customer.Id,
		ClientIdentifier: clientIdentifier,
		ClientDomainIdentifier: clientDomainIdentifier,
		MitigationId:     mitigationScope.MitigationId,
		Lifetime:         mitigationScope.Lifetime,
		Status:           mitigationScope.Status,
		TriggerMitigation: mitigationScope.TriggerMitigation,
	}
	_, err = session.Insert(&newMitigationScope)
	if err != nil {
		session.Rollback()
		log.Errorf("mitigationScope insert err: %s", err)
		return
	}
	if err = session.Commit(); err != nil {
		session.Rollback()
		log.Errorf("mitigationScope commit err: %s", err)
		return
	}
	session.Close()
	session = engine.NewSession()
	defer session.Close()
	err = session.Begin()
	if err != nil {
		session.Rollback()
		return
	}
	err = createMitigationScopeParameterValue(session, mitigationScope, newMitigationScope.Id)
	if err != nil {
		return
	}
	err = createMitigationScopePrefix(session, mitigationScope, newMitigationScope.Id)
	if err != nil {
		return
	}
	err = createMitigationScopePortRange(session, mitigationScope, newMitigationScope.Id)
	if err != nil {
		return
	}
	if !isIfMatchOption {
		err = createMitigationScopeCallHome(session, mitigationScope, newMitigationScope.Id)
		if err != nil {
			return
		}
	}
	if !isIfMatchOption {
		err = createControlFiltering(session, mitigationScope, newMitigationScope.Id)
		if err != nil {
			return
		}
	}
	err = session.Commit()
	AddActiveMitigationRequest(newMitigationScope.Id, newMitigationScope.Lifetime, newMitigationScope.Created)
	return
}