You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

cloudStorage.go 1.1 kB

12345678910111213141516171819202122232425262728293031323334
  1. package database
  2. import (
  3. "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/scheduler/entity"
  4. "gorm.io/gorm"
  5. )
  6. type CloudStorage struct {
  7. dbEngin *gorm.DB
  8. }
  9. func NewCloudStorage(dbEngin *gorm.DB) *CloudStorage {
  10. return &CloudStorage{dbEngin: dbEngin}
  11. }
  12. func (c *CloudStorage) GetProviderParams() ([]entity.ProviderParams, error) {
  13. var proParams []entity.ProviderParams
  14. sqlstr := "SELECT SUM(a.disk_avail) as disk_avail,SUM(a.mem_avail) as mem_avail,SUM(a.cpu_total * a.cpu_usable) as cpu_avail,participant_id from (SELECT * from sc_node_avail_info where created_time in (SELECT MAX(created_time) as time from sc_node_avail_info where deleted_flag = 0 GROUP BY participant_id,node_name)) a GROUP BY a.participant_id"
  15. c.dbEngin.Raw(sqlstr).Scan(&proParams)
  16. if len(proParams) == 0 {
  17. return nil, nil
  18. }
  19. return proParams, nil
  20. }
  21. func (c *CloudStorage) FindAvailableParticipants() ([]entity.Participant, error) {
  22. var parts []entity.Participant
  23. sqlstr := "select id as participant_id, name as name from sc_participant_phy_info"
  24. c.dbEngin.Raw(sqlstr).Scan(&parts)
  25. if len(parts) == 0 {
  26. return nil, nil
  27. }
  28. return parts, nil
  29. }

PCM is positioned as Software stack over Cloud, aiming to build the standards and ecology of heterogeneous cloud collaboration for JCC in a non intrusive and autonomous peer-to-peer manner.