Beispiel #1
0
static void _set_control_state(ipmi_control_t *control,
                                void           *cb_data)
{
        struct ohoi_ctrl_info *info = cb_data;
        
        if (info->state->StateUnion.Oem.BodyLength 
                        != ipmi_control_get_num_vals(control)) {
                dbg("control number is not equal to supplied data");
                info->done = -1;
		info->err = SA_ERR_HPI_INVALID_PARAMS;
                return;
        }
                        
	if (ipmi_control_light_set_with_setting(control)) {
		ipmi_light_setting_t *setting;

		setting = ipmi_alloc_light_settings(1);
		ipmi_light_setting_set_local_control(setting, 0, 1);
		ipmi_light_setting_set_color(setting, 0,
			info->state->StateUnion.Oem.Body[0]);
		ipmi_control_set_light(control, setting,
			__set_control_state, cb_data);
		ipmi_free_light_settings(setting);
	} else {
        	ipmi_control_set_val(control, 
	/* compile error */
//                             (int *)&info->state->StateUnion.Oem.Body[0],
                             (int *)(void *)&info->state->StateUnion.Oem.Body[0],
                             __set_control_state, info);
	}
}
Beispiel #2
0
static void set_power_state_off(ipmi_control_t *control,
                            void           *cb_data)
{
	struct ohoi_power_info *power_info = cb_data;
	int rv;

        rv = ipmi_control_set_val(control, (int *)power_info->state,
				  power_done, cb_data);
	if (rv) {
	  	dbg("Failed to set control val (power off)");
		power_info->err = SA_ERR_HPI_INTERNAL_ERROR;
		power_info->done = 1;
	} else
	  	power_info->err = SA_OK;
}
Beispiel #3
0
static void set_resource_reset_state(ipmi_control_t *control,
                            void           *cb_data)
{
        struct ohoi_reset_info *info = cb_data;
	int val = 1;
	int rv;

        /* Just cold reset the entity*/
        rv = ipmi_control_set_val(control, &val, reset_resource_done, cb_data);
	if (rv) {
		dbg("ipmi_control_set_val returned err = %d", rv);
		info->err = SA_ERR_HPI_INTERNAL_ERROR;
		info->done = 1;
	}
}
Beispiel #4
0
static void _set_control_state(ipmi_control_t *control,
                                void           *cb_data)
{
        struct ohoi_control_info *info = cb_data;
        
        if (info->state->StateUnion.Oem.BodyLength 
                        != ipmi_control_get_num_vals(control)) {
                dbg("control number is not equal to supplied data");
                info->done = -1;
                return;
        }
                        
        ipmi_control_set_val(control, 
                             (int *)&info->state->StateUnion.Oem.Body[0],
                             __set_control_state, info);
}
Beispiel #5
0
static void	set_ipmi_control(zbx_ipmi_host_t *h, zbx_ipmi_control_t *c, int value)
{
	const char		*__function_name = "set_ipmi_control";
	int			ret;
	struct timeval		tv;

	zabbix_log(LOG_LEVEL_DEBUG, "In %s() control:'%s@[%s]:%d' value:%d",
			__function_name, c->c_name, h->ip, h->port, value);

	if (c->num_values == 0)
	{
		THIS_SHOULD_NEVER_HAPPEN;
		h->err = zbx_dsprintf(h->err, "no value present for control");
		h->ret = NOTSUPPORTED;
		h->done = 1;
		goto out;
	}

	if (0 == ipmi_control_is_settable(c->control))
	{
		h->err = zbx_dsprintf(h->err, "control is not settable");
		h->ret = NOTSUPPORTED;
		goto out;
	}

	c->val[0] = value;
	h->ret = SUCCEED;
	h->done = 0;

	if (0 != (ret = ipmi_control_set_val(c->control, c->val, got_control_setting, h)))
	{
		h->err = zbx_dsprintf(h->err, "Cannot set control %s. ipmi_control_set_val() return error: 0x%x",
				c->c_name, ret);
		h->ret = NOTSUPPORTED;
		goto out;
	}

	tv.tv_sec = 10;
	tv.tv_usec = 0;

	while (0 == h->done)
		os_hnd->perform_one_op(os_hnd, &tv);
out:
	zabbix_log(LOG_LEVEL_DEBUG, "End of %s():%s", __function_name, zbx_result_string(h->ret));
}
Beispiel #6
0
static void	set_ipmi_control(zbx_ipmi_host_t *h, zbx_ipmi_control_t *c, int value)
{
	int			ret;
	struct timeval		tv;

	zabbix_log(LOG_LEVEL_DEBUG, "In set_ipmi_control() %d => %s@[%s]:%d",
			value, c->c_name, h->ip, h->port);

	if (c->num_values == 0)
	{
		/* this should never happen */
		h->err = zbx_dsprintf(h->err, "No value present for control");
		h->ret = NOTSUPPORTED;
		h->done = 1;
		return;
	}

	if (0 == ipmi_control_is_settable(c->control))
	{
		h->err = zbx_dsprintf(h->err, "Control is not settable.");
		h->ret = NOTSUPPORTED;
		return;
	}

	c->val[0] = value;
	h->ret = SUCCEED;
	h->done = 0;

	if (0 != (ret = ipmi_control_set_val(c->control, c->val, got_control_setting, h)))
	{
		h->err = zbx_dsprintf(h->err, "Cannot set control %s."
				" ipmi_control_set_val() return error: 0x%x",
				c->c_name, ret);
		h->ret = NOTSUPPORTED;
		return;
	}

	tv.tv_sec = 10;
	tv.tv_usec = 0;
	while (0 == h->done)
		os_hnd->perform_one_op(os_hnd, &tv);
}