Flex Appliance - curl 로 hosts 파일 변경하는 방법

인스턴스의 네트워크 설정은 아래와 같은 JSON 형태로 되어 있다. 여기서 etc-hosts 값을 수정하면 hosts 파일을 변경할 수 있다.

{
  "network": {
    "nic_ip": [
      {
        "nic": "nic0",
        "ipaddress": "192.168.3.207"
      }
    ],
    "domain-name": "",
    "name-servers": "",
    "search-domains": "",
    "etc-hosts": "192.168.3.207 hjh-11102-p\n192.168.3.208 hjh-11102-m\n192.168.3.167 nbumaster\n192.168.3.165 gts-flex",
    "default-network-interface": "nic0",
    "default-network-interface-v6": "",
    "static-routes": []
  },
  "config-version": "Hlqn"
}
  • etc-hosts 값의 각 host 항목 사이에는 꼭 \n 을 넣어야 한다.
  • config-version 값은 매번 바뀐다. 그래서 먼저 조회한 뒤 해당 값을 넣고 변경해야 한다.

curl 로 변경하는 경우

curl -X PUT "https://192.168.3.165/api/v1/instances/bJJO" -H "X-Auth-Token: <토큰 값>" -H "Content-Type: application/json" -d '{
  "network": {
    "nic_ip": [
      {
        "nic": "nic0",
        "ipaddress": "192.168.3.207"
      }
    ],
    "domain-name": "",
    "name-servers": "",
    "search-domains": "",
    "etc-hosts": "192.168.3.207 hjh-11102-p\n192.168.3.208 hjh-11102-m\n192.168.3.167 nbumaster\n192.168.3.165 gts-flex",
    "default-network-interface": "nic0",
    "default-network-interface-v6": "",
    "static-routes": []
  },
  "config-version": "Hlqn"
}'

X-Auth-Token 자리에는 로그인 후 발급받은 토큰 값을 넣으면 된다.