summaryrefslogtreecommitdiffstats
path: root/debian/python-dmidecode.substvars
diff options
context:
space:
mode:
authornima <nima@abc39116-655e-4be6-ad55-d661dc543056>2008-10-31 14:07:22 +0000
committernima <nima@abc39116-655e-4be6-ad55-d661dc543056>2008-10-31 14:07:22 +0000
commitf120b5fa5933fef104c1f5e711581455e3980e2e (patch)
tree10408ce250b47910b385815e3bec96fe1207207c /debian/python-dmidecode.substvars
parente703746faad221f6c367e4fe5fd27ebd6b4aae54 (diff)
Implemented reading a dump to - this concludes syncing to the upstream release.
Next, exceptions should be thrown in certain places, more error checking in the python side of things, and also in relation to setting and unsetting of the alternate memory file. git-svn-id: svn://svn.autonomy.net.au/python-dmidecode@104 abc39116-655e-4be6-ad55-d661dc543056
Diffstat (limited to 'debian/python-dmidecode.substvars')
0 files changed, 0 insertions, 0 deletions
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411
/*
 * Copyright (C) 2012  Michal Minar <miminar@redhat.com>
 * Copyright (C) 2012  Radek Novacek <rnovacek@redhat.com>
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, see <http://www.gnu.org/licenses/>.
 */

#include <konkret/konkret.h>
#include <stdint.h>
#include "LMI_Fan.h"
#include "globals.h"
#include "fan.h"
static const CMPIBroker* _cb = NULL;

#include <signal.h>
#include <unistd.h>
#include <sys/wait.h>

void print_backtrace(int signal)
{
    fprintf(stderr, "BackTrace\n");
    int ppid = getpid();
    int pid = fork();
    if (pid == 0) {
        // Child process
        char *strpid;
        asprintf(&strpid, "%d", ppid);
        execl("/usr/bin/gdb", "/usr/bin/gdb", "-p", strpid, NULL);
    } else {
        int status;
        waitpid(pid, &status, 0);
        system("/usr/bin/pkill -9 sfcbd");
    }
}

static void LMI_FanInitialize()
{
    init_linux_fan_module();
    signal(SIGSEGV, print_backtrace);
}

static CMPIStatus LMI_FanCleanup(
    CMPIInstanceMI* mi,
    const CMPIContext* cc,
    CMPIBoolean term)
{
    CMReturn(CMPI_RC_OK);
}

static CMPIStatus LMI_FanEnumInstanceNames(
    CMPIInstanceMI* mi,
    const CMPIContext* cc,
    const CMPIResult* cr,
    const CMPIObjectPath* cop)
{
    return KDefaultEnumerateInstanceNames(
        _cb, mi, cc, cr, cop);
}

static CMPIStatus LMI_FanEnumInstances(
    CMPIInstanceMI* mi,
    const CMPIContext* cc,
    const CMPIResult* cr,
    const CMPIObjectPath* cop,
    const char** properties)
{
    const char *ns = KNameSpace(cop);

    char buf[200];
    struct fanlist *lptr = NULL;
    struct fanlist *fans = NULL;
    struct cim_fan *sptr;

    if (enum_all_fans(&fans)) {
        KReturn2(_cb, ERR_FAILED, "Could not list fans.");
    }

    // iterate fan list
    lptr = fans;
    while (lptr != NULL) {
        sptr = lptr->f;
        LMI_Fan w;
        LMI_Fan_Init(&w, _cb, ns);
        LMI_Fan_Set_CreationClassName(&w, "LMI_Fan");
        LMI_Fan_Set_SystemCreationClassName(&w, get_system_creation_class_name());
        LMI_Fan_Set_SystemName(&w, get_system_name());
        LMI_Fan_Set_DeviceID(&w, sptr->device_id);

        LMI_Fan_Set_Caption(&w, "Computer's fan");
        LMI_Fan_Set_Description(&w,"Computer's fan.");
        snprintf(buf, 200, "Fan \"%s\" on chip \"%s\"", sptr->name, sptr->chip_name);
        LMI_Fan_Set_ElementName(&w, buf);

        // ManagedSystemElement
        LMI_Fan_Set_Name(&w, sptr->name);
        LMI_Fan_Init_OperationalStatus(&w, 2);
        LMI_Fan_Set_OperationalStatus(&w, 0, sptr->fault ?
                LMI_Fan_OperationalStatus_Error :
                LMI_Fan_OperationalStatus_OK);
        if (sptr->alarm || sptr->alarm_min || sptr->alarm_max) {
            LMI_Fan_Set_OperationalStatus(&w, 1, LMI_Fan_OperationalStatus_Stressed);
        }

        LMI_Fan_Init_StatusDescriptions(&w, 2);
        LMI_Fan_Set_StatusDescriptions(&w, 0, sptr->fault ?
                "Chip indicates, that fan is in fault state."
                " Possible causes are open diodes, unconnected fan etc."
                " Thus the measurement for this channel should not be trusted."
                : "Fan seems to be functioning correctly.");
        if (sptr->alarm || sptr->alarm_min || sptr->alarm_max) {
            snprintf(buf, 200, "These alarm flags are set by the fan's chip:"
                     "  alarm=%s, min_alarm=%s, max_alarm=%s",
                     sptr->alarm ? "1":"0",
                     sptr->alarm_min ? "1":"0",
                     sptr->alarm_max ? "1":"0");
            LMI_Fan_Set_StatusDescriptions(&w, 1, buf);
        }


        LMI_Fan_Set_HealthState(&w, sptr->fault ?
                LMI_Fan_HealthState_Major_failure :
                LMI_Fan_HealthState_OK);

        LMI_Fan_Set_OperatingStatus(&w, sptr->fault ?
                LMI_Fan_OperatingStatus_Stopped :
                LMI_Fan_OperatingStatus_In_Service);

        LMI_Fan_Set_PrimaryStatus(&w, sptr->fault ?
                LMI_Fan_PrimaryStatus_Error :
                LMI_Fan_PrimaryStatus_OK);

        // EnabledLogicalElement
        LMI_Fan_Init_OtherIdentifyingInfo(&w, 2);
        LMI_Fan_Set_OtherIdentifyingInfo(&w, 0, sptr->chip_name);
        LMI_Fan_Set_OtherIdentifyingInfo(&w, 1, sptr->sys_path);

        LMI_Fan_Init_IdentifyingDescriptions(&w, 2);
        LMI_Fan_Set_IdentifyingDescriptions(&w, 0, "ChipName - name of fan's chip.");
        LMI_Fan_Set_IdentifyingDescriptions(&w, 1, "SysPath - system path of fan's chip.");

        LMI_Fan_Set_ActiveCooling(&w, true);

        uint32_t i = 1;
        int index = 0;
        debug("accessible_features: %d", sptr->accessible_features);
        LMI_Fan_Init_AccessibleFeatures(&w, 8);
        while (i <= CIM_FAN_AF_FEATURE_MAX) {
            if (i & sptr->accessible_features) {
                LMI_Fan_Set_AccessibleFeatures(&w, index++, i);
            }
            i = i << 1;
        }
        if (sptr->accessible_features & CIM_FAN_AF_MIN_SPEED) {
            LMI_Fan_Set_MinSpeed(&w, (uint64_t) sptr->min_speed);
        }
        if (sptr->accessible_features & CIM_FAN_AF_MAX_SPEED) {
            LMI_Fan_Set_MaxSpeed(&w, (uint64_t) sptr->max_speed);
        }
        if (sptr->accessible_features & CIM_FAN_AF_DIV) {
            LMI_Fan_Set_Divisor(&w, sptr->divisor);
        }
        if (sptr->accessible_features & CIM_FAN_AF_PULSES) {
            LMI_Fan_Set_Pulses(&w, sptr->pulses);
        }
        if (sptr->accessible_features & CIM_FAN_AF_BEEP) {
            LMI_Fan_Set_Beep(&w, sptr->beep);
        }
        if (sptr->accessible_features & CIM_FAN_AF_ALARM) {
            LMI_Fan_Set_Alarm(&w, sptr->alarm);
        }
        if (sptr->accessible_features & CIM_FAN_AF_ALARM_MIN) {
            LMI_Fan_Set_MinAlarm(&w, sptr->alarm_min);
        }
        if (sptr->accessible_features & CIM_FAN_AF_ALARM_MAX) {
            LMI_Fan_Set_MaxAlarm(&w, sptr->alarm_max);
        }

        KReturnInstance(cr, w);
        lptr = lptr->next;
    }
    free_fanlist(fans);
    KReturn(OK);
}

static CMPIStatus LMI_FanGetInstance(
    CMPIInstanceMI* mi,
    const CMPIContext* cc,
    const CMPIResult* cr,
    const CMPIObjectPath* cop,
    const char** properties)
{
    return KDefaultGetInstance(
        _cb, mi, cc, cr, cop, properties);
}

static CMPIStatus LMI_FanCreateInstance(
    CMPIInstanceMI* mi,
    const CMPIContext* cc,
    const CMPIResult* cr,
    const CMPIObjectPath* cop,
    const CMPIInstance* ci)
{
    CMReturn(CMPI_RC_ERR_NOT_SUPPORTED);
}

static CMPIStatus LMI_FanModifyInstance(
    CMPIInstanceMI* mi,
    const CMPIContext* cc,
    const CMPIResult* cr,
    const CMPIObjectPath* cop,
    const CMPIInstance* ci,
    const char** properties)
{
    CMReturn(CMPI_RC_ERR_NOT_SUPPORTED);
}

static CMPIStatus LMI_FanDeleteInstance(
    CMPIInstanceMI* mi,
    const CMPIContext* cc,
    const CMPIResult* cr,
    const CMPIObjectPath* cop)
{
    CMReturn(CMPI_RC_ERR_NOT_SUPPORTED);
}

static CMPIStatus LMI_FanExecQuery(
    CMPIInstanceMI* mi,
    const CMPIContext* cc,
    const CMPIResult* cr,
    const CMPIObjectPath* cop,
    const char* lang,
    const char* query)
{
    CMReturn(CMPI_RC_ERR_NOT_SUPPORTED);
}

CMInstanceMIStub(
    LMI_Fan,
    LMI_Fan,
    _cb,
    LMI_FanInitialize())

static CMPIStatus LMI_FanMethodCleanup(
    CMPIMethodMI* mi,
    const CMPIContext* cc,
    CMPIBoolean term)
{
    CMReturn(CMPI_RC_OK);
}

static CMPIStatus LMI_FanInvokeMethod(
    CMPIMethodMI* mi,
    const CMPIContext* cc,
    const CMPIResult* cr,
    const CMPIObjectPath* cop,
    const char* meth,
    const CMPIArgs* in,
    CMPIArgs* out)
{
    return LMI_Fan_DispatchMethod(
        _cb, mi, cc, cr, cop, meth, in, out);
}

CMMethodMIStub(
    LMI_Fan,
    LMI_Fan,
    _cb,
    LMI_FanInitialize())

KUint32 LMI_Fan_RequestStateChange(
    const CMPIBroker* cb,
    CMPIMethodMI* mi,
    const CMPIContext* context,
    const LMI_FanRef* self,
    const KUint16* RequestedState,
    KRef* Job,
    const KDateTime* TimeoutPeriod,
    CMPIStatus* status)
{
    KUint32 result = KUINT32_INIT;

    KSetStatus(status, ERR_NOT_SUPPORTED);
    return result;
}

KUint32 LMI_Fan_SetPowerState(
    const CMPIBroker* cb,
    CMPIMethodMI* mi,
    const CMPIContext* context,
    const LMI_FanRef* self,
    const KUint16* PowerState,
    const KDateTime* Time,
    CMPIStatus* status)
{
    KUint32 result = KUINT32_INIT;

    KSetStatus(status, ERR_NOT_SUPPORTED);
    return result;
}

KUint32 LMI_Fan_Reset(
    const CMPIBroker* cb,
    CMPIMethodMI* mi,
    const CMPIContext* context,
    const LMI_FanRef* self,
    CMPIStatus* status)
{
    KUint32 result = KUINT32_INIT;

    KSetStatus(status, ERR_NOT_SUPPORTED);
    return result;
}

KUint32 LMI_Fan_EnableDevice(
    const CMPIBroker* cb,
    CMPIMethodMI* mi,
    const CMPIContext* context,
    const LMI_FanRef* self,
    const KBoolean* Enabled,
    CMPIStatus* status)
{
    KUint32 result = KUINT32_INIT;

    KSetStatus(status, ERR_NOT_SUPPORTED);
    return result;
}

KUint32 LMI_Fan_OnlineDevice(
    const CMPIBroker* cb,
    CMPIMethodMI* mi,
    const CMPIContext* context,
    const LMI_FanRef* self,
    const KBoolean* Online,
    CMPIStatus* status)
{
    KUint32 result = KUINT32_INIT;

    KSetStatus(status, ERR_NOT_SUPPORTED);
    return result;
}

KUint32 LMI_Fan_QuiesceDevice(
    const CMPIBroker* cb,
    CMPIMethodMI* mi,
    const CMPIContext* context,
    const LMI_FanRef* self,
    const KBoolean* Quiesce,
    CMPIStatus* status)
{
    KUint32 result = KUINT32_INIT;

    KSetStatus(status, ERR_NOT_SUPPORTED);
    return result;
}

KUint32 LMI_Fan_SaveProperties(
    const CMPIBroker* cb,
    CMPIMethodMI* mi,
    const CMPIContext* context,
    const LMI_FanRef* self,
    CMPIStatus* status)
{
    KUint32 result = KUINT32_INIT;