2 #property("summary", "Manage Health Checks - date: [2013-05-13 4]")
\r
4 ## Manage Health Checks
\r
6 #parse("openstack_l4/openstack_common.vm")
\r
8 #param("group_id", "int", "in", "prompt=Group ID")
\r
9 #param("curr_hm_uuid_array", "string[]", "in", "prompt=Current Health monitors UUID array")
\r
10 #param("curr_hm_type_array", "string[]", "in", "prompt=Current Health monitors type array")
\r
11 #param("hm_uuid_array", "string[]", "in", "prompt=Health monitors UUID array")
\r
12 #param("hm_type_array", "string[]", "in", "prompt=Health monitors type array")
\r
13 #param("hm_delay_array", "int[]", "in", "prompt=Health monitors delay array")
\r
14 #param("hm_timeout_array", "int[]", "in", "prompt=Health monitors timeout array")
\r
15 #param("hm_max_retries_array", "int[]", "in", "prompt=Health monitors max retries array")
\r
16 #param("hm_admin_state_up_array", "bool[]", "in", "prompt=Health monitors admin state array")
\r
17 #param("hm_url_path_array", "string[]", "in", "prompt=Health monitors url path array")
\r
18 #param("hm_http_method_array", "string[]", "in", "prompt=Health monitors http method array")
\r
19 #param("hm_expected_codes_array", "string[]", "in", "prompt=Health monitor expected codes_array")
\r
21 #if($hm_uuid_array.size() > $HC_MAX_HCS_PER_GROUP)
\r
22 #error("Got $hm_uuid_array.length ammount of health monitors which is more than the supported $HC_MAX_HCS_PER_GROUP health monitors per pool with alteon id $group_id on device $adc")
\r
25 ## -----------------------------------------------------------------------------
\r
26 ## perpare a map of hcs connected to the group with their ref count
\r
27 ## -----------------------------------------------------------------------------
\r
30 #foreach ($hcUUID in $curr_hm_uuid_array)
\r
31 #if($hcUUID != $NONE)
\r
32 #set($hcType=$curr_hm_type_array[$counter])
\r
33 #set($refCountRetArray=[-1])
\r
34 #os_get_ref_count_for_hc($hcUUID, $hcType, $refCountRetArray)
\r
35 ##consider raising error if ref count is 0
\r
36 #set($not_in_use=$currHCs.put($hcUUID, $refCountRetArray[0]))
\r
37 #set($counter=$counter+1)
\r
41 ## ----------------------------------------------------
\r
42 ## prepare map of hcs to be connected to the group
\r
43 ## ----------------------------------------------------
\r
46 #foreach ($hcUUID in $hm_uuid_array)
\r
48 #set($not_in_use=$newHCs.put($hcUUID, $hcrIndex))
\r
50 #set($hcrIndex=$hcrIndex+1)
\r
53 ## ---------------------------------------
\r
54 ## handle the hcs that should be updated
\r
55 ## ---------------------------------------
\r
56 #set($toUpdateHCs={})
\r
57 #set($not_in_use=$toUpdateHCs.putAll($currHCs))
\r
58 #set($not_in_use=$toUpdateHCs.keySet().retainAll($newHCs.keySet()))
\r
59 #log("Health monitors to be updated: $toUpdateHCs")
\r
60 #foreach ($entry in $toUpdateHCs.entrySet())
\r
61 #set($hcRefCount=$entry.getValue())
\r
62 #set($hcUUID=$entry.getKey())
\r
63 #set($hcIndex=$newHCs.get($hcUUID))
\r
64 #set($hcType=$hm_type_array[$hcIndex])
\r
65 #set($hcDelay=$hm_delay_array[$hcIndex])
\r
66 #set($hcTimeout=$hm_timeout_array[$hcIndex])
\r
67 #set($hcMxRetries=$hm_max_retries_array[$hcIndex])
\r
68 #set($hcAdminStateUp=$hm_admin_state_up_array[$hcIndex])
\r
69 #set($hcUrlPath=$hm_url_path_array[$hcIndex])
\r
70 #set($hcHttpMethod=$hm_http_method_array[$hcIndex])
\r
71 #set($hcExpectedCodes=$hm_expected_codes_array[$hcIndex])
\r
72 #os_print_hc_config($hcType, $hcUUID,$hcRefCount,$hcMxRetries,$hcDelay, $hcTimeout,$hcUrlPath,$hcExpectedCodes)
\r
75 ## ---------------------------------------
\r
76 ## handle the hcs that should be created
\r
77 ## ---------------------------------------
\r
78 #set($toCreateHCs={})
\r
79 #set($not_in_use=$toCreateHCs.putAll($newHCs))
\r
80 #set($not_in_use=$toCreateHCs.keySet().removeAll($currHCs.keySet()))
\r
81 #log("Health monitors to be created: $toCreateHCs")
\r
82 #foreach ($entry in $toCreateHCs.entrySet())
\r
83 #set($hcUUID=$entry.getKey())
\r
84 #set($hcIndex=$newHCs.get($hcUUID))
\r
85 #set($hcType=$hm_type_array[$hcIndex])
\r
86 #set($hcDelay=$hm_delay_array[$hcIndex])
\r
87 #set($hcTimeout=$hm_timeout_array[$hcIndex])
\r
88 #set($hcMxRetries=$hm_max_retries_array[$hcIndex])
\r
89 #set($hcAdminStateUp=$hm_admin_state_up_array[$hcIndex])
\r
90 #set($hcUrlPath=$hm_url_path_array[$hcIndex])
\r
91 #set($hcHttpMethod=$hm_http_method_array[$hcIndex])
\r
92 #set($hcExpectedCodes=$hm_expected_codes_array[$hcIndex])
\r
95 #set($refCountRetArray=[-1])
\r
96 ## query the device and check how many references this hc has already
\r
97 #os_get_ref_count_for_hc($hcUUID, $hcType, $refCountRetArray)
\r
98 #set($hcRefCount=$hcRefCount+$refCountRetArray[0])
\r
100 #os_print_hc_config($hcType, $hcUUID,$hcRefCount,$hcMxRetries,$hcDelay, $hcTimeout,$hcUrlPath,$hcExpectedCodes)
\r
103 ## ---------------------------------------
\r
104 ## handle the hcs that should be deleted
\r
105 ## ---------------------------------------
\r
107 #set($not_in_use=$toDelHCs.putAll($currHCs))
\r
108 #set($not_in_use=$toDelHCs.keySet().removeAll($newHCs.keySet()))
\r
109 #log("Health monitors to be deleted: $toDelHCs")
\r
110 #foreach ($entry in $toDelHCs.entrySet())
\r
111 #set($hcUUID=$entry.getKey())
\r
112 #set($hcRefCount=$entry.getValue())
\r
113 #set($hcRefCount=$hcRefCount - 1)
\r
114 #os_print_health_check_header($NONE, $hcUUID)
\r
115 ## if we still have positive ref count - keep the hc, else - remove it
\r
116 #if($hcRefCount > 0)
\r
123 ## ------------------------------
\r
124 ## handle the logexp config block
\r
125 ## ------------------------------
\r
128 #if($hm_uuid_array.size() > 0)
\r
129 #foreach($hcUUID in $hm_uuid_array)
\r
130 #if($hm_admin_state_up_array[$counter] && $hcUUID != $NONE)
\r
131 #set($stripped_uuid=[-1])
\r
132 #os_strip_uuid($hcUUID,$stripped_uuid)
\r
133 #set($_log_exp_uuid=$stripped_uuid[0])
\r
134 #set($logExp=$logExp + $_log_exp_uuid + "&")
\r
136 #set($counter=$counter+1)
\r
138 #if($logExp.length() > 0)
\r
139 #set($len=$logExp.length() - 1)
\r
140 #set($logExp=$logExp.substring(0,$len))
\r
142 #set($logExp=$DEFAULT_HEALTH_MONITOR_TYPE)
\r
145 #set($logExp=$DEFAULT_HEALTH_MONITOR_TYPE)
\r
148 /c/slb/advhc/health HC_Group_$group_id LOGEXP
\r
151 /c/slb/group $group_id
\r
152 health HC_Group_$group_id
\r