我正在设计一个类,它可以生成诸如cpu使用率、磁盘使用率、内存使用率等信息,。。。。。。
对于3个系统,假设数据中心有许多工作站,工作站有许多PCs.所以所有3个级别(数据中心、工作站、PC)都需要CPU使用率和其他参数。请建议以下课程的设计是否正确或如何设计
编辑class Datacenters:
def __init__(self,name,location,cpu,mem):
self.name=name
self.location=location
self.cpu=cpu
self.mem=mem
def getparam(self):
return self.name,self.location ,self.cpu,self.mem
def getname(self):
return self.name
class WS(Datacenters):
def __init__(self,name,location,cpu,mem,obj):
#datacentername = Datacenters.__init__(self) #To which data center it is associated
obj.getname() #To which data center it is associated
self.name=name
self.location=location
self.cpu=cpu
self.mem=mem
def getparam(self,obj):
return self.name,self.location ,self.cpu,self.mem,obj.getname()
def getpcname(self):
return self.name
class Pcs(WS):
def __init__(self,name,location,cpu,mem,obj):
obj.getpcname() #To which WS it is associated
self.name=name
self.location=location
self.cpu=cpu
self.mem=mem
def getparam(self,obj):
return self.name,self.location ,self.cpu,self.mem,obj.getpcname()
a = Datacenters("dc1","Bl1",20,30)
print a.getparam()
b = WS("WS1","Bl1",20,30,a)
print b.getparam(a)
c = Pcs("PC1","Bl1",20,30,b)
print c.getparam(b)