代码仓
中
组件配置导入导出指南
更新时间: 2025/10/21
在AtomGit上查看源码

组件配置导入导出作为一种面向用户的接口,通过schema承载组件的接口数据模型,采用标准JSON Schema + 自定义扩展方式实现配置导入导出描述和校验机制。组件在配置导入导出时均需要通过schema校验,确保配置导入导出数据在业务侧和用户侧正确性。

配置schema存放在profile_schema组件仓,详情可以查阅《profile_schema》。

整体流程 ​

配置导入导出功能由oms组件承载:

  1. 导入时按照配置文件中的组件名称将对应组件的配置进行序列化,并调用bmc.kepler.MicroComponent.ConfigManage下的Import接口触发组件导入。
  2. 导出时从maca服务获取全量组件名称,具体接口为:bmc.kepler.Mdb的GetServiceNames方法,然后分别调用各个组件的Export接口,收集各个组件的导出数据,汇总后返回给用户。

资源协作接口信息如下:

shell
# 1、oms导入导出接口
busctl --user introspect bmc.kepler.oms /bmc/kepler/Managers/1/Configurations
NAME                                TYPE      SIGNATURE RESULT/VALUE       FLAGS
bmc.kepler.Managers.Configurations  interface -         -                  -
.Export                             method    a{ss}s    u                  -
.Import                             method    a{ss}s    u                  -

# 2、组件导入导出接口
busctl --user introspect bmc.kepler.license /bmc/kepler/license/MicroComponent
NAME                                   TYPE      SIGNATURE RESULT/VALUE    FLAGS
bmc.kepler.MicroComponent.ConfigManage interface -         -               -
.Export                                method    a{ss}     s               -
.Import                                method    a{ss}s    -               -

配置字段说明 ​

标准schema关键字 ​

  • type:JSON Schema的数据类型
  • properties:JSON Schema对象属性键值对

固定名称的属性 ​

  • Description:固定属性,组件描述字段
  • ConfigData:固定属性,组件配置数据字段

组件自定义数据集合名称 ​

  • Accounts(示例):Accounts自定义组件配置导入导出数据实例集合

扩展的关键字 ​

  • AttributeType: 配置数据实例对应属性的类型

    取值范围:

    • ExportOnly:仅支持导出
    • ImportAndExport:支持导入和导出;
  • HideValue: 组件导出数据时,是否需要隐藏value(不设置时默认为false)

    说明:

    • 为true时属性取值为"******",表示对该属性值进行隐藏。
    • 组件Schema中不设置该值时,导出文件中默认不隐藏value。
  • Import: 设置导出后的默认值(不设置时默认为true)

    说明:

    • 仅AttributeType为ImportAndExport可以配置该字段,true表示当前属性需要导入,false表示不需要导入。
    • 该功能类似于XML中的注释功能,false对应于对导入属性进行“注释”,导入时不生效该属性。
    • Import字段需要在组件侧Import方法中进行校验,否则不会生效

组件Schema配置示例 ​

json
{
    "type": "object",
    "properties": {
        "Description": {
            "const": "Configurations of Identity and Access Management"
        },
        "ConfigData": {
            "type": "object",
            "properties": {
                "Accounts": {
                    "type": "array",
                    "items": {
                        "type": "object",
                        "properties": {
                            "Id": {
                                "type": "number",
                                "AttributeType": "ExportOnly"
                            },
                            "UserName": {
                                "type": "string",
                                "HideValue": true,
                                "AttributeType": "ImportAndExport"
                            },
                            "Privilege": {
                                "type": "string",
                                "Import": false,
                                "AttributeType": "ImportAndExport"
                            },
                            "UserRoleId": {
                                "type": "string",
                                "AttributeType": "ImportAndExport"
                            },
                            "PermitRuleIds": {
                                "type": "number",
                                "AttributeType": "ImportAndExport"
                            },
                            "LoginInterface": {
                                "type": "array",
                                "items": {
                                    "type": "string",
                                    "enum": ["SSH", "SNMP", "Local", "Redfish", "SFTP", "Web", "IPMI"]
                                },
                                "AttributeType": "ExportOnly"
                            },
                            "IsUserEnable": {
                                "type": "boolean",
                                "AttributeType": "ExportOnly"
                            },
                            "IsUserLocked": {
                                "type": "boolean",
                                "AttributeType": "ExportOnly"
                            }
                        },
                        "required": ["Id", "UserName", "Privilege"]
                    }
                },
                "LDAPController": {
                    "type": "array",
                    "items": {
                        "type": "object",
                        "properties": {
                            "Id": {
                                "type": "number",
                                "AttributeType": "ExportOnly"
                            },
                            "BindDN": {
                                "type": "string",
                                "AttributeType": "ImportAndExport"
                            },
                            "CertVerifyEnabled": {
                                "type": "boolean",
                                "AttributeType": "ImportAndExport"
                            },
                            "CertVerifyLevel": {
                                "type": "number",
                                "AttributeType": "ImportAndExport"
                            },
                            "Enabled": {
                                "type": "boolean",
                                "AttributeType": "ImportAndExport"
                            },
                            "Folder": {
                                "type": "string",
                                "AttributeType": "ImportAndExport"
                            },
                            "HostAddr": {
                                "type": "string",
                                "AttributeType": "ImportAndExport"
                            },
                            "Port": {
                                "type": "number",
                                "AttributeType": "ImportAndExport"
                            },
                            "UserDomain": {
                                "type": "string",
                                "AttributeType": "ImportAndExport"
                            }
                        }
                    }
                }
            }
        }
    }
}

导出的配置文件字段说明 ​

  • GeneralInfo: 通用信息
    • ProductName:产品名称
    • ProductSN:产品序列号
    • Version:软件版本
    • TimeStamp:时间戳信息
  • Components: 组件全量配置信息
    • Description:组件描述信息

    • ConfigData:组件配置数据

    • Value:配置数据实例对应属性取值

    • AttributeType:配置数据实例对应属性的类型

      取值包括:

      • ExportOnly:仅支持导出;
      • ImportAndExport:支持导入和导出;
    • Import:该属性是否需要导入

      说明:

      • 仅AttributeType为ImportAndExport可以配置该字段,true表示当前属性需要导入,false表示不需要导入。
      • 在import方法中添加Import字段校验,配置导入时修改对应字段的Import属性即可选择该属性是否导入
json
{
    "GeneralInfo": {
        "ProductName": "S920X20",
        "ProductSN": "1234567890",
        "TimeStamp": "2025-02-11 10:04:49"
    },
    "Components": {
        "iam": {
            "Description": "Configurations of Identity and Access Management",
            "ConfigData": {
                "Accounts": [
                    {
                        "Id": {
                            "Value": 2,
                            "AttributeType": "ExportOnly",
                            "Import": false
                        },
                        "UserName": {
                            "Value": "******",
                            "AttributeType": "ImportAndExport",
                            "Import": false
                        },
                        "Privilege": {
                            "Value": "Administrator",
                            "AttributeType": "ImportAndExport",
                            "Import": false
                        },
                        "UserRoleId": {
                            "Value": "Administrator",
                            "AttributeType": "ImportAndExport",
                            "Import": true
                        },
                        "PermitRuleIds": {
                            "Value": 1,
                            "AttributeType": "ImportAndExport",
                            "Import": true
                        },
                        "LoginInterface": {
                            "Value": ["SSH", "SNMP", "Local", "Redfish", "SFTP", "Web", "IPMI"],
                            "AttributeType": "ExportOnly",
                            "Import": false
                        },
                        "IsUserEnable": {
                            "Value": true,
                            "AttributeType": "ExportOnly",
                            "Import": false
                        },
                        "IsUserLocked": {
                            "Value": false,
                            "AttributeType": "ExportOnly",
                            "Import": false
                        }
                    }
                ],
                "LDAPController": [
                ]
            }
        },
        "bios": {
            "Description": "Configurations of Bios",
            "ConfigData": {
                "BiosConfig": {
                    "BootTypeOrder0": {
                        "Value": "DVDROMDrive",
                        "AttributeType": "ImportAndExport",
                        "Import": true
                    },
                    "BootTypeOrder1": {
                        "Value": "PXE",
                        "AttributeType": "ImportAndExport",
                        "Import": true
                    },
                    "BootTypeOrder2": {
                        "Value": "HardDiskDrive",
                        "AttributeType": "ImportAndExport",
                        "Import": true
                    },
                    "BootTypeOrder3": {
                        "Value": "Others",
                        "AttributeType": "ImportAndExport",
                        "Import": true
                    },
                    "DDRDebugLevel": {
                        "Value": "Minimum",
                        "AttributeType": "ImportAndExport",
                        "Import": true
                    },
                    "DDRFreqLimit": {
                        "Value": "Auto",
                        "AttributeType": "ImportAndExport",
                        "Import": true
                    },
                    "DdrRefreshSupport": {
                        "Value": true,
                        "AttributeType": "ImportAndExport",
                        "Import": true
                    }
                }
            }
        },
        "storage": {
            "Description": "Configurations of Storage",
            "ConfigData": {
                "RAIDConfig": [
                    {
                        "Id": {
                            "Value": 802,
                            "AttributeType": "ExportOnly",
                            "Import": false
                        },
                        "Type": {
                            "Value": "SAS3508",
                            "AttributeType": "ExportOnly",
                            "Import": false
                        },
                        "Mode": {
                            "Value": 1,
                            "AttributeType": "ImportAndExport",
                            "Import": true
                        },
                        "CopybackEnabled": {
                            "Value": 1,
                            "AttributeType": "ImportAndExport",
                            "Import": true
                        },
                        "SMARTerCopybackEnabled": {
                            "Value": 0,
                            "AttributeType": "ImportAndExport",
                            "Import": true
                        },
                        "JBODEnabled": {
                            "Value": 0,
                            "AttributeType": "ImportAndExport",
                            "Import": true
                        },
                        "NoBatteryWriteCache": {
                            "Value": 255,
                            "AttributeType": "ImportAndExport",
                            "Import": true
                        },
                        "ReadCachePercent": {
                            "Value": 2,
                            "Import": 255,
                            "AttributeType": "ImportAndExport"
                        }
                    }
                ]
            }
        }
    }
}