11# -*- coding: UTF-8 -*-
2- from pool import Pool , PoolElement , Template
2+ from pool import Pool , PoolElement , Template , extractString
33
44
55class HostShare (Template ):
@@ -17,36 +17,46 @@ class Host(PoolElement):
1717 }
1818
1919 INIT = 0
20- MONITORING = 1
20+ MONITORING_MONITORED = 1 # Currently monitoring, previously MONITORED
2121 MONITORED = 2
2222 ERROR = 3
2323 DISABLED = 4
24- HOST_STATES = ['INIT' , 'MONITORING' , 'MONITORED' , 'ERROR' , 'DISABLED' ]
24+ MONITORING_ERROR = 5 # Currently monitoring, previously ERROR
25+ MONITORING_INIT = 6 # Currently monitoring, previously initialized
26+ MONITORING_DISABLED = 7 # Currently monitoring, previously DISABLED
27+ HOST_STATES = ['INIT' , 'MONITORING_MONITORED' , 'MONITORED' , 'ERROR' , 'DISABLED' ,
28+ 'MONITORING_ERROR' , 'MONITORING_INIT' , 'MONITORING_DISABLED' ]
2529
2630 SHORT_HOST_STATES = {
27- 'INIT' : 'on' ,
28- 'MONITORING' : 'on' ,
29- 'MONITORED' : 'on' ,
30- 'ERROR' : 'err' ,
31- 'DISABLED' : 'off'
31+ 'INIT' : 'on' ,
32+ 'MONITORING_MONITORED' : 'on' ,
33+ 'MONITORED' : 'on' ,
34+ 'ERROR' : 'err' ,
35+ 'DISABLED' : 'off' ,
36+ 'MONITORING_ERROR' : 'on' ,
37+ 'MONITORING_INIT' : 'on' ,
38+ 'MONITORING_DISABLED' : 'on' ,
3239 }
3340
3441 XML_TYPES = {
35- 'id' : int ,
36- 'name' : str ,
37- 'state' : int ,
38- 'im_mad' : str ,
39- 'vm_mad' : str ,
40- 'last_mon_time' : int ,
41- 'vm_ids' : ['VMS' , lambda vms : map (lambda vmid : int (vmid .text ), vms )],
42- 'template' : ['TEMPLATE' , Template ],
43- 'host_share' : ['HOST_SHARE' , HostShare ],
42+ 'id' : int ,
43+ 'name' : extractString ,
44+ 'state' : int ,
45+ 'im_mad' : extractString ,
46+ 'vm_mad' : extractString ,
47+ 'vn_mad' : extractString ,
48+ 'last_mon_time' : int ,
49+ 'cluster' : extractString ,
50+ 'cluster_id' : int ,
51+ 'vm_ids' : ['VMS' , lambda vms : map (lambda vmid : int (vmid .text ), vms )],
52+ 'template' : ['TEMPLATE' , Template ],
53+ 'host_share' : ['HOST_SHARE' , HostShare ],
4454 }
4555
4656 ELEMENT_NAME = 'HOST'
4757
4858 @staticmethod
49- def allocate (client , hostname , im , vmm , tm ):
59+ def allocate (client , hostname , im , vmm , tm , cluster_id = - 1 ):
5060 '''
5161 Adds a host to the host list
5262
@@ -64,7 +74,7 @@ def allocate(client, hostname, im, vmm, tm):
6474 ``tm``
6575 Transfer manager
6676 '''
67- host_id = client .call (Host .METHODS ['allocate' ], hostname , im , vmm , tm )
77+ host_id = client .call (Host .METHODS ['allocate' ], hostname , im , vmm , tm , cluster_id )
6878 return host_id
6979
7080 def __init__ (self , xml , client ):
0 commit comments