protected override void ProcessRecord() { if (ValidateInput()) { if (isInitialized()) { try { String[] vs_list = GetiControl().LocalLBVirtualServer.get_list(); iControl.CommonEnabledState[] enabled_states = GetiControl().LocalLBVirtualServer.get_enabled_state(vs_list); // Build a list of indexes ArrayList index_list = new ArrayList(); for (int i = 0; i < vs_list.Length; i++) { if (true == matchString(vs_list[i], _name)) { index_list.Add(i); } } if (index_list.Count > 0) { String[] target_vs_list = new String[index_list.Count]; iControl.LocalLBVirtualServerVirtualServerRule[][] rule_lists = new iControl.LocalLBVirtualServerVirtualServerRule[index_list.Count][]; iControl.CommonEnabledState[] target_enabled_states = new iControl.CommonEnabledState[index_list.Count]; for (int j = 0; j < index_list.Count; j++) { int index = Convert.ToInt32(index_list[j]); target_vs_list[j] = vs_list[index]; rule_lists[j] = new iControl.LocalLBVirtualServerVirtualServerRule[1]; rule_lists[j][0] = new iControl.LocalLBVirtualServerVirtualServerRule(); rule_lists[j][0].rule_name = Rule; rule_lists[j][0].priority = 500; } GetiControl().LocalLBVirtualServer.remove_rule(target_vs_list, rule_lists); } } catch (Exception ex) { handleException(ex); } } else { handleNotInitialized(); } } }
protected override void ProcessRecord() { if (ValidateInput()) { if (isInitialized()) { try { if (null == _pool) { handleError("You must supply a pool name", "bad state"); } else if (null == _member) { handleError("You must supply a member ip:port definition", "bad state"); } else { String[] sSplit = _member.Split(new char[] { ':' }); if (2 == sSplit.Length) { String[] pool_list = new String[] { _pool }; iControl.LocalLBPoolMemberMemberObjectStatus[][] object_status_lists = GetiControl().LocalLBPoolMember.get_object_status(pool_list); iControl.LocalLBPoolMemberMemberMonitorStatus[][] monitor_status_lists = GetiControl().LocalLBPoolMember.get_monitor_status(pool_list); iControl.LocalLBPoolMemberMemberSessionState [][] session_state_lists = GetiControl().LocalLBPoolMember.get_session_enabled_state(pool_list); for (int i = 0; i < monitor_status_lists[0].Length; i++) { if (monitor_status_lists[0][i].member.address.Equals(sSplit[0]) && monitor_status_lists[0][i].member.port == Convert.ToInt32(sSplit[1])) { iControl.LocalLBMonitorStatus status = monitor_status_lists[0][i].monitor_status; iControl.CommonEnabledState state = session_state_lists[0][i].session_state; // matched the requested node. ServerStateItem ssi = new ServerStateItem(); ssi.Name = Member; if ((status == iControl.LocalLBMonitorStatus.MONITOR_STATUS_UP) && (state == iControl.CommonEnabledState.STATE_ENABLED)) { ssi.State = ServerState.SERVER_STATE_ENABLED; } else if ((status == iControl.LocalLBMonitorStatus.MONITOR_STATUS_UP) && (state == iControl.CommonEnabledState.STATE_DISABLED)) { ssi.State = ServerState.SERVER_STATE_DISABLED; } else if ((status != iControl.LocalLBMonitorStatus.MONITOR_STATUS_UP) && (state == iControl.CommonEnabledState.STATE_DISABLED)) { ssi.State = ServerState.SERVER_STATE_OFFLINE; } else { ssi.State = ServerState.SERVER_STATE_OFFLINE; } WriteObject(ssi); } } } else { handleError("Invalid member ip:port format", "bad state"); } } } catch (Exception ex) { ErrorRecord er = new ErrorRecord(ex, "2", ErrorCategory.OpenError, "error"); WriteError(er); } } else { handleError("You must first successfully call Initialize-iControl", "bad state"); } } }