Esempio n. 1
0
func (ci *CpImage) Validate() (err error) {
	if err := ValidateSim(ci.Sim); err != nil {
		return err
	}
	if err := ValidateNetwork(ci.Network); err != nil {
		return err
	}

	dal, err := release.NewDal()
	if err != nil {
		return fmt.Errorf("Validate dtim error")
	}
	defer dal.Close()

	var image interface{}
	switch ci.Id {
	case ota_constant.ID_ARBI, ota_constant.ID_ARB2:
		image, _ = release.FindArbiByPath(dal, ci.Path)
	case ota_constant.ID_GRBI, ota_constant.ID_GRB2:
		image, _ = release.FindGrbiByPath(dal, ci.Path)
	case ota_constant.ID_RFIC, ota_constant.ID_RFI2:
		image, _ = release.FindRficByPath(dal, ci.Path)
	}

	v := reflect.ValueOf(image)
	if v.IsNil() {
		return fmt.Errorf("Illegal image path in dtim: %s", ci.Path)
	}

	return nil
}
Esempio n. 2
0
func main() {
	dal, err := release.NewDal()
	if err != nil {
		log.Printf("New DAL failed: %s\n", err)
		panic(err)
	}
	defer dal.Close()

	counter := 0
	for {
		counter = counter + 1
		log.Printf("scan %d times ----------------------------begin\n", counter)
		for _, path := range dir_list {
			if exist, err := pathutil.IsExist(path); !exist && err == nil {
				//			pathutil.MkDir(path)
				log.Printf("scan dir error : %s\n", err)
				continue
			}

			mode := constant.PATH_TO_MODE[path]
			sim := constant.MODE_TO_SIM[mode]

			err := ScanDir(dal, path, mode, sim)
			if err != nil {
				log.Printf("Scan PANIC [%s] failed : %s\n", path, err)
				panic(err)
			}
		}
		log.Printf("scan %d times ----------------------------end\n", counter)
		time.Sleep(SCAN_INTERNAL * time.Second)
	}
}
Esempio n. 3
0
func ProcessModifyEvent(event *fsnotify.FileEvent) {
	log.Printf("Modify [%s]\n", event.Name)

	dal, err := release.NewDal()
	if err != nil {
		log.Printf("New DAL failed: %s\n", err)
		return
	}
	defer dal.Close()

	cp := getCpByRelPath(event.Name, dal)
	if cp != nil {
		if cp.Flag == constant.AVAILABLE_FLAG {
			log.Printf("CP release modified, delete arbi&grbi for updating in scanner : %s", cp)
			release.DeleteArbiByCpId(dal, cp.Id)
			release.DeleteGrbiByCpId(dal, cp.Id)
			release.DeleteRficByCpId(dal, cp.Id)
		}
	}
}
Esempio n. 4
0
File: radio.go Progetto: jsli/ota
func (c Radio) Query() revel.Result {
	result := models.NewResult()
	validator := &policy.RadioValidator{}
	dtim_info, err := validator.ValidateAndParseRadioDtim(c.Params)
	if err != nil {
		return c.Render400WithCode(result, ota_constant.ERROR_CODE_INVALIDATED_DTIM, fmt.Sprintf("%s", err))
	}

	dal, err := release.NewDal()
	if err != nil {
		return c.Render500(result, err)
	}
	defer dal.Close()

	err = c.Provider.ProvideQueryData(dal, dtim_info, result)
	if err != nil {
		return c.Render404WithCode(result, ota_constant.ERROR_CODE_NO_AVAILABLE_UPDATE, fmt.Sprintf("%s", err))
	}

	return c.RenderJson(result)
}
Esempio n. 5
0
func ProcessDeleteEvent(event *fsnotify.FileEvent) {
	log.Printf("Delete [%s]\n", event.Name)

	dal, err := release.NewDal()
	if err != nil {
		log.Printf("New DAL failed: %s\n", err)
		return
	}
	defer dal.Close()

	cp := getCpByRelPath(event.Name, dal)
	if cp != nil {
		_, err := cp.Delete(dal)
		if err != nil {
			log.Printf("Delete failed: %s\n", err)
		} else {
			log.Printf("Delete success: %s\n", cp)
			log.Printf("CP release deleted, delete arbi&grbi together : %s", cp)
			release.DeleteArbiByCpId(dal, cp.Id)
			release.DeleteGrbiByCpId(dal, cp.Id)
		}
	}
}