pyvmomi操作vmware(三)获取对象的属性教程
属性
- 网络
- 存储器
- 告警
- 任务
- 告警策略
网络
对象中的属性network中有网络对象,可以获取到网络的简要信息
class DatacenterInfo(ExecutorBase):
def datacenter_container_list(self):
return self.get_container(obj_type=[vim.Datacenter])
...
def network(self):
network_list = []
for data_center in self.datacenter_container_list():
network_li = self.get_network(data_center.network, data_center._moId)
network_list += network_li
return network_list
存储器
def data_store(self):
store_list = []
for data_center in self.datacenter_container_list():
data_store_list = self.get_datastore(data_center, data_center._moId)
store_list += data_store_list
return store_list
告警
def alarm(self):
container_list = self.datacenter_container_list()
sum_alarm = []
for container in container_list:
alarm_list = self.get_alarm(container.triggeredAlarmState, container._moId)
sum_alarm += alarm_list
return sum_alarm
告警策略
def alarm_strategy(self):
alarm_list = []
for data_center in self.datacenter_container_list():
declared_alarm_states = data_center.declaredAlarmState
alarm_strategy_resource = self.get_alarm_strategy(declared_alarm_states, data_center._moId, "vcenter")
alarm_list += alarm_strategy_resource
return alarm_list
任务
def datacenter_tasks(self):
tasks = []
for data_center in self.datacenter_container_list():
task_list = self.list_task(data_center, data_center._moId)
tasks += task_list
return tasks
Aerkui发布了22 篇原创文章 · 获赞 0 · 访问量 281 私信 关注