read capacity from adminserver

This commit is contained in:
Wenkai Yin 2017-03-21 12:35:46 +08:00
parent e02dd11703
commit 383997f785
4 changed files with 10 additions and 13 deletions

View File

@ -50,6 +50,7 @@ services:
volumes:
- /data/config/:/etc/adminserver/
- /data/secretkey:/etc/adminserver/key
- /data/:/data/
depends_on:
- log
logging:

View File

@ -56,6 +56,7 @@ services:
volumes:
- /data/config/:/etc/adminserver/
- /data/secretkey:/etc/adminserver/key
- /data/:/data/
networks:
- harbor
depends_on:
@ -74,7 +75,6 @@ services:
volumes:
- ./common/config/ui/app.conf:/etc/ui/app.conf
- ./common/config/ui/private_key.pem:/etc/ui/private_key.pem
- /data:/harbor_storage
- /data/secretkey:/etc/ui/key
networks:
- harbor

View File

@ -3,9 +3,7 @@ package api
import (
"net/http"
"os"
"path/filepath"
"strings"
"syscall"
"github.com/vmware/harbor/src/common"
"github.com/vmware/harbor/src/common/api"
@ -21,7 +19,6 @@ type SystemInfoAPI struct {
isAdmin bool
}
const harborStoragePath = "/harbor_storage"
const defaultRootCert = "/harbor_storage/ca_download/ca.crt"
//SystemInfo models for system info.
@ -66,18 +63,16 @@ func (sia *SystemInfoAPI) GetVolumeInfo() {
sia.RenderError(http.StatusForbidden, "User does not have admin role.")
return
}
var stat syscall.Statfs_t
err := syscall.Statfs(filepath.Join("/", harborStoragePath), &stat)
if err != nil {
log.Errorf("Error occurred in syscall.Statfs: %v", err)
sia.CustomAbort(http.StatusInternalServerError, "Internal error.")
return
}
capacity, err := config.AdminserverClient.Capacity()
if err != nil {
log.Errorf("failed to get capacity: %v", err)
sia.CustomAbort(http.StatusInternalServerError, http.StatusText(http.StatusInternalServerError))
}
systemInfo := SystemInfo{
HarborStorage: Storage{
Total: stat.Blocks * uint64(stat.Bsize),
Free: stat.Bavail * uint64(stat.Bsize),
Total: capacity.Total,
Free: capacity.Free,
},
}

View File

@ -31,5 +31,6 @@ services:
volumes:
- /data/config/:/etc/adminserver/
- /data/secretkey:/etc/adminserver/key
- /data/:/data/
ports:
- 8888:80