コード例 #1
0
ファイル: rmm_key_generator.cpp プロジェクト: 01org/intelRSD
const std::string RmmKeyGenerator::generate_key(const Chassis& chassis, const NetworkInterface& nic) {
    const enums::ChassisType chassis_type = chassis.get_type();
    OptionalField<std::string> unique_property{};

    if (enums::ChassisType::Zone == chassis_type) {
        unique_property = nic.get_mac_address();
    }
    else {
        throw std::logic_error("Improper usage of RMM key generator.");
    }

    if (!unique_property.has_value()) {
        throw KeyValueMissingError(
            "Unique property for chassis of type " + std::string(chassis_type.to_string()) + " is missing");
    }

    return generate_key_base(chassis) + unique_property.value();
}
コード例 #2
0
ファイル: rmm_key_generator.cpp プロジェクト: 01org/intelRSD
const std::string RmmKeyGenerator::generate_key(const Chassis& chassis) {
    const enums::ChassisType chassis_type = chassis.get_type();
    OptionalField<std::string> unique_property{};

    if (enums::ChassisType::Rack == chassis_type) {
        unique_property = chassis_type.to_string();
    }
    else if (enums::ChassisType::Drawer == chassis_type) {
        unique_property = chassis.get_fru_info().get_serial_number();
    }
    else {
        throw std::logic_error("Improper usage of RMM key generator.");
    }

    if (!unique_property.has_value()) {
        throw KeyValueMissingError(
            "Unique property for chassis of type " + std::string(chassis_type.to_string()) + " is missing");
    }

    return generate_key_base(chassis) + unique_property.value();
}