|
|
|
@ -4,8 +4,10 @@ module Configs{
|
|
|
|
|
|
|
|
|
|
export interface Block{
|
|
|
|
|
ip:string; //存储块的机器ip地址
|
|
|
|
|
path: string; //路径
|
|
|
|
|
status: boolean;
|
|
|
|
|
path: string; //存储块路径
|
|
|
|
|
status: boolean; //存储块的状态
|
|
|
|
|
availableSize?: number, //存储块的大小
|
|
|
|
|
usedSize?: number //存储块已使用空间
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface oracleParam{
|
|
|
|
@ -20,26 +22,65 @@ module Configs{
|
|
|
|
|
|
|
|
|
|
export interface volume{
|
|
|
|
|
name: string; //volume的名字
|
|
|
|
|
totalSize: number; //volume空间大小
|
|
|
|
|
allSize: number; //volume空间大小
|
|
|
|
|
usedSize: number; // volume已使用空间大小
|
|
|
|
|
brick: Block; //volume中的存储块
|
|
|
|
|
brick: Array<Block>; //volume中的存储块
|
|
|
|
|
folder?: Array<any>; //volume的文件
|
|
|
|
|
status: string;
|
|
|
|
|
path: string;
|
|
|
|
|
path: string;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//字节大小转换成字符大小
|
|
|
|
|
function getStringSize(size: number){
|
|
|
|
|
var result = size;
|
|
|
|
|
var suffix =["B", "KB" ,"MB", "GB", "GB", "TB"];
|
|
|
|
|
var suffix =["B", "KB" ,"MB", "GB", "TB", "PB"];
|
|
|
|
|
var count=1;
|
|
|
|
|
while(result > 1024){
|
|
|
|
|
while(result >= 1024){
|
|
|
|
|
result = result/1024;
|
|
|
|
|
count ++;
|
|
|
|
|
}
|
|
|
|
|
return result + suffix[count];
|
|
|
|
|
return result.toFixed(2) + suffix[count];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function formatVolume(volume:volume){
|
|
|
|
|
volume["formatTotalSize"] = getStringSize(volume.allSize);
|
|
|
|
|
volume["formatUsedSize"] = getStringSize(volume.usedSize);
|
|
|
|
|
angular.forEach(volume.brick, (brock) =>{
|
|
|
|
|
brock["formatUsedSize"] = getStringSize(brock.usedSize);
|
|
|
|
|
brock["formatAllSize"] = getStringSize(brock.availableSize);
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function formatVolumes(volumes:Array<volume>){
|
|
|
|
|
angular.forEach(volumes, (volume) => {
|
|
|
|
|
formatVolume(volume);
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function IsBrockEquals(brock1: Block, brock2: Block){
|
|
|
|
|
return brock1.ip == brock2.ip && brock1.path == brock2.path;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
刪除volume中指定的brock
|
|
|
|
|
*/
|
|
|
|
|
export function deleteBrock(volume:volume, brock:Block){
|
|
|
|
|
for(var i = 0; i < volume.brick.length; i++){
|
|
|
|
|
var brick = volume.brick[i];
|
|
|
|
|
if(IsBrockEquals(brick, brock)){
|
|
|
|
|
volume.brick.splice(i, 1);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
volume添加brock
|
|
|
|
|
*/
|
|
|
|
|
export function addBrock(volume:volume, brock:Block){
|
|
|
|
|
if(brock != null && brock != undefined)
|
|
|
|
|
volume.brick.push(brock);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export class ConfigsModelService{
|
|
|
|
|
public cluster: Array<volume>=[];
|
|
|
|
@ -69,7 +110,7 @@ module Configs{
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
this.cluster = result;
|
|
|
|
|
|
|
|
|
|
formatVolumes(this.cluster);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public updateCodeInfo(){
|
|
|
|
|