#!/bin/bash
#########################
# 更新配置中心离线缓存
#########################


url='http://uconf.service.ucloud.cn:8080/configfiles/json/1'
SHELL_FOLDER=$(cd "$(dirname "$0")";pwd)

namespace_fw='firmware fw_version fwupdate HARDDISK NIC RAID BMC BIOS'
namespace_gpu='gpu gpu_test_success gpu_machinetype_name gpu_name_pciid'
namespace='nvmesize initregion kernelversion regiontimezone nicorder regioninfo imageversion ovsconfig gpu gpu_test_success gpu_machinetype_name gpu_name_pciid machinetype_numa_number'

for i in $namespace
do
    echo get uconf usa-init uops.$i
    curl -s ${url}/usa-init/uops.${i} |jq . > $SHELL_FOLDER/apollo/$i.json
done

for i in $namespace_fw
do
    echo get uconf fw uops.$i
    curl -s ${url}/fw/uops.${i} |jq . > $SHELL_FOLDER/apollo/$i.json
done

for i in $namespace_gpu
do
    echo get uconf gpu uops.$i
    curl -s ${url}/gpu/uops.${i} |jq . > $SHELL_FOLDER/apollo/$i.json
done

echo get cmdb cmdb_raid-info
curl -s 'http://api-gw.service.ucloud.cn/cmdb/v2/machine-types/raid-info' -H 'api-key: ebd9f8ee5a7b402389e43234499d46be' | jq . > $SHELL_FOLDER/cmdb/cmdb_raid-info.json
