Manage a pool of nodes for a distributed test infrastructure
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

plugin.sh 24KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825
  1. #!/bin/bash
  2. #
  3. # Copyright 2015 Hewlett-Packard Development Company, L.P.
  4. #
  5. # Licensed under the Apache License, Version 2.0 (the "License"); you may
  6. # not use this file except in compliance with the License. You may obtain
  7. # a copy of the License at
  8. #
  9. # http://www.apache.org/licenses/LICENSE-2.0
  10. #
  11. # Unless required by applicable law or agreed to in writing, software
  12. # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  13. # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  14. # License for the specific language governing permissions and limitations
  15. # under the License.
  16. NODEPOOL_KEY=$HOME/.ssh/id_nodepool
  17. NODEPOOL_KEY_NAME=root
  18. NODEPOOL_PUBKEY=$HOME/.ssh/id_nodepool.pub
  19. NODEPOOL_INSTALL=$HOME/nodepool-venv
  20. NODEPOOL_CACHE_GET_PIP=/opt/stack/cache/files/get-pip.py
  21. function install_diskimage_builder {
  22. if use_library_from_git "diskimage-builder"; then
  23. GITREPO["diskimage-builder"]=$DISKIMAGE_BUILDER_REPO_URL
  24. GITDIR["diskimage-builder"]=$DEST/diskimage-builder
  25. GITBRANCH["diskimage-builder"]=$DISKIMAGE_BUILDER_REPO_REF
  26. git_clone_by_name "diskimage-builder"
  27. setup_dev_lib "diskimage-builder"
  28. $NODEPOOL_INSTALL/bin/pip install $DEST/diskimage-builder
  29. fi
  30. }
  31. function install_glean {
  32. if use_library_from_git "glean"; then
  33. GITREPO["glean"]=$GLEAN_REPO_URL
  34. GITDIR["glean"]=$DEST/glean
  35. GITBRANCH["glean"]=$GLEAN_REPO_REF
  36. git_clone_by_name "glean"
  37. setup_dev_lib "glean"
  38. $NODEPOOL_INSTALL/bin/pip install $DEST/glean
  39. fi
  40. }
  41. function install_openstacksdk {
  42. if use_library_from_git "openstacksdk"; then
  43. git_clone_by_name "openstacksdk"
  44. $NODEPOOL_INSTALL/bin/pip install $DEST/openstacksdk
  45. fi
  46. }
  47. # Install nodepool code
  48. function install_nodepool {
  49. VENV="virtualenv -p python3"
  50. $VENV $NODEPOOL_INSTALL
  51. install_diskimage_builder
  52. install_glean
  53. setup_develop $DEST/nodepool
  54. $NODEPOOL_INSTALL/bin/pip install $DEST/nodepool
  55. # TODO(mordred) Install openstacksdk after nodepool so that if we're
  56. # in the -src job we don't re-install from the requirement.
  57. # We should make this more resilient, probably using install-siblings.
  58. install_openstacksdk
  59. $NODEPOOL_INSTALL/bin/pbr freeze
  60. }
  61. # requires some globals from devstack, which *might* not be stable api
  62. # points. If things break, investigate changes in those globals first.
  63. function nodepool_create_keypairs {
  64. if [[ ! -f $NODEPOOL_KEY ]]; then
  65. ssh-keygen -f $NODEPOOL_KEY -P ""
  66. fi
  67. cat > /tmp/ssh_wrapper <<EOF
  68. #!/bin/bash -ex
  69. sudo -H -u stack ssh -o StrictHostKeyChecking=no -i $NODEPOOL_KEY root@\$@
  70. EOF
  71. sudo chmod 0755 /tmp/ssh_wrapper
  72. }
  73. function nodepool_write_elements {
  74. sudo mkdir -p $(dirname $NODEPOOL_CONFIG)/elements/nodepool-setup/install.d
  75. sudo mkdir -p $(dirname $NODEPOOL_CONFIG)/elements/nodepool-setup/root.d
  76. cat > /tmp/40-nodepool-setup <<EOF
  77. sudo mkdir -p /etc/nodepool
  78. # Make it world writeable so nodepool can write here later.
  79. sudo chmod 777 /etc/nodepool
  80. EOF
  81. cat > /tmp/50-apt-allow-unauthenticated <<EOF
  82. if [ -d "\$TARGET_ROOT/etc/apt/apt.conf.d" ]; then
  83. echo "APT::Get::AllowUnauthenticated \"true\";" | sudo tee \$TARGET_ROOT/etc/apt/apt.conf.d/95allow-unauthenticated
  84. echo "Acquire::AllowInsecureRepositories \"true\";" | sudo tee -a \$TARGET_ROOT/etc/apt/apt.conf.d/95allow-unauthenticated
  85. fi
  86. EOF
  87. sudo mv /tmp/40-nodepool-setup \
  88. $(dirname $NODEPOOL_CONFIG)/elements/nodepool-setup/install.d/40-nodepool-setup
  89. sudo chmod a+x \
  90. $(dirname $NODEPOOL_CONFIG)/elements/nodepool-setup/install.d/40-nodepool-setup
  91. sudo mv /tmp/50-apt-allow-unauthenticated \
  92. $(dirname $NODEPOOL_CONFIG)/elements/nodepool-setup/root.d/50-apt-allow-unauthenticated
  93. sudo chmod a+x \
  94. $(dirname $NODEPOOL_CONFIG)/elements/nodepool-setup/root.d/50-apt-allow-unauthenticated
  95. sudo mkdir -p $NODEPOOL_DIB_BASE_PATH/images
  96. sudo mkdir -p $NODEPOOL_DIB_BASE_PATH/tmp
  97. sudo mkdir -p $NODEPOOL_DIB_BASE_PATH/cache
  98. sudo chown -R stack:stack $NODEPOOL_DIB_BASE_PATH
  99. }
  100. function nodepool_write_config {
  101. sudo mkdir -p $(dirname $NODEPOOL_CONFIG)
  102. sudo mkdir -p $(dirname $NODEPOOL_SECURE)
  103. cat > /tmp/logging.conf <<EOF
  104. [formatters]
  105. keys=simple
  106. [loggers]
  107. keys=root,nodepool,openstack,kazoo,keystoneauth,novaclient
  108. [handlers]
  109. keys=console
  110. [logger_root]
  111. level=WARNING
  112. handlers=console
  113. [logger_nodepool]
  114. level=DEBUG
  115. handlers=console
  116. qualname=nodepool
  117. propagate=0
  118. [logger_openstack]
  119. level=DEBUG
  120. handlers=console
  121. qualname=openstack
  122. propagate=0
  123. [logger_keystoneauth]
  124. level=DEBUG
  125. handlers=console
  126. qualname=keystoneauth
  127. propagate=0
  128. [logger_novaclient]
  129. level=DEBUG
  130. handlers=console
  131. qualname=novaclient
  132. propagate=0
  133. [logger_kazoo]
  134. level=INFO
  135. handlers=console
  136. qualname=kazoo
  137. propagate=0
  138. [handler_console]
  139. level=DEBUG
  140. class=StreamHandler
  141. formatter=simple
  142. args=(sys.stdout,)
  143. [formatter_simple]
  144. format=%(message)s
  145. datefmt=
  146. EOF
  147. sudo mv /tmp/logging.conf $NODEPOOL_LOGGING
  148. cat > /tmp/secure.conf << EOF
  149. # Empty
  150. EOF
  151. sudo mv /tmp/secure.conf $NODEPOOL_SECURE
  152. sudo mkdir /var/log/nodepool
  153. sudo chown -R stack:stack /var/log/nodepool
  154. if use_library_from_git "glean"; then
  155. git --git-dir=$DEST/glean/.git checkout -b devstack
  156. DIB_GLEAN_INSTALLTYPE="DIB_INSTALLTYPE_simple_init: 'repo'"
  157. DIB_GLEAN_REPOLOCATION="DIB_REPOLOCATION_glean: '$DEST/glean'"
  158. DIB_GLEAN_REPOREF="DIB_REPOREF_glean: 'devstack'"
  159. fi
  160. if [ -f $NODEPOOL_CACHE_GET_PIP ] ; then
  161. DIB_GET_PIP="DIB_REPOLOCATION_pip_and_virtualenv: file://$NODEPOOL_CACHE_GET_PIP"
  162. fi
  163. if [ -f /etc/ci/mirror_info.sh ] ; then
  164. source /etc/ci/mirror_info.sh
  165. DIB_DISTRIBUTION_MIRROR_CENTOS="DIB_DISTRIBUTION_MIRROR: $NODEPOOL_CENTOS_MIRROR"
  166. DIB_DISTRIBUTION_MIRROR_DEBIAN="DIB_DISTRIBUTION_MIRROR: $NODEPOOL_DEBIAN_MIRROR"
  167. DIB_DISTRIBUTION_MIRROR_UBUNTU="DIB_DISTRIBUTION_MIRROR: $NODEPOOL_UBUNTU_MIRROR"
  168. DIB_DEBOOTSTRAP_EXTRA_ARGS="DIB_DEBOOTSTRAP_EXTRA_ARGS: '--no-check-gpg'"
  169. fi
  170. NODEPOOL_CENTOS_7_MIN_READY=1
  171. NODEPOOL_DEBIAN_STRETCH_MIN_READY=1
  172. NODEPOOL_FEDORA_29_MIN_READY=1
  173. NODEPOOL_UBUNTU_BIONIC_MIN_READY=1
  174. NODEPOOL_UBUNTU_TRUSTY_MIN_READY=1
  175. NODEPOOL_UBUNTU_XENIAL_MIN_READY=1
  176. NODEPOOL_OPENSUSE_423_MIN_READY=1
  177. NODEPOOL_OPENSUSE_150_MIN_READY=1
  178. NODEPOOL_OPENSUSE_TUMBLEWEED_MIN_READY=1
  179. NODEPOOL_GENTOO_17_0_SYSTEMD_MIN_READY=1
  180. if $NODEPOOL_PAUSE_CENTOS_7_DIB ; then
  181. NODEPOOL_CENTOS_7_MIN_READY=0
  182. fi
  183. if $NODEPOOL_PAUSE_DEBIAN_STRETCH_DIB ; then
  184. NODEPOOL_DEBIAN_STRETCH_MIN_READY=0
  185. fi
  186. if $NODEPOOL_PAUSE_FEDORA_29_DIB ; then
  187. NODEPOOL_FEDORA_29_MIN_READY=0
  188. fi
  189. if $NODEPOOL_PAUSE_UBUNTU_BIONIC_DIB ; then
  190. NODEPOOL_UBUNTU_BIONIC_MIN_READY=0
  191. fi
  192. if $NODEPOOL_PAUSE_UBUNTU_TRUSTY_DIB ; then
  193. NODEPOOL_UBUNTU_TRUSTY_MIN_READY=0
  194. fi
  195. if $NODEPOOL_PAUSE_UBUNTU_XENIAL_DIB ; then
  196. NODEPOOL_UBUNTU_XENIAL_MIN_READY=0
  197. fi
  198. if $NODEPOOL_PAUSE_OPENSUSE_423_DIB ; then
  199. NODEPOOL_OPENSUSE_423_MIN_READY=0
  200. fi
  201. if $NODEPOOL_PAUSE_OPENSUSE_150_DIB ; then
  202. NODEPOOL_OPENSUSE_150_MIN_READY=0
  203. fi
  204. if $NODEPOOL_PAUSE_OPENSUSE_TUMBLEWEED_DIB ; then
  205. NODEPOOL_OPENSUSE_TUMBLEWEED_MIN_READY=0
  206. fi
  207. if $NODEPOOL_PAUSE_GENTOO_17_0_SYSTEMD_DIB; then
  208. NODEPOOL_GENTOO_17_0_SYSTEMD_MIN_READY=0
  209. fi
  210. cat > /tmp/nodepool.yaml <<EOF
  211. # You will need to make and populate this path as necessary,
  212. # cloning nodepool does not do this. Further in this doc we have an
  213. # example element.
  214. elements-dir: $(dirname $NODEPOOL_CONFIG)/elements
  215. images-dir: $NODEPOOL_DIB_BASE_PATH/images
  216. zookeeper-servers:
  217. - host: localhost
  218. port: 2181
  219. labels:
  220. - name: centos-7
  221. min-ready: $NODEPOOL_CENTOS_7_MIN_READY
  222. - name: debian-stretch
  223. min-ready: $NODEPOOL_DEBIAN_STRETCH_MIN_READY
  224. - name: fedora-29
  225. min-ready: $NODEPOOL_FEDORA_29_MIN_READY
  226. - name: ubuntu-bionic
  227. min-ready: $NODEPOOL_UBUNTU_BIONIC_MIN_READY
  228. - name: ubuntu-trusty
  229. min-ready: $NODEPOOL_UBUNTU_TRUSTY_MIN_READY
  230. - name: ubuntu-xenial
  231. min-ready: $NODEPOOL_UBUNTU_XENIAL_MIN_READY
  232. - name: opensuse-423
  233. min-ready: $NODEPOOL_OPENSUSE_423_MIN_READY
  234. - name: opensuse-150
  235. min-ready: $NODEPOOL_OPENSUSE_150_MIN_READY
  236. - name: opensuse-tumbleweed
  237. min-ready: $NODEPOOL_OPENSUSE_TUMBLEWEED_MIN_READY
  238. - name: gentoo-17-0-systemd
  239. min-ready: $NODEPOOL_GENTOO_17_0_SYSTEMD_MIN_READY
  240. providers:
  241. - name: devstack
  242. region-name: '$REGION_NAME'
  243. cloud: devstack
  244. # Long boot timeout to deal with potentially nested virt.
  245. boot-timeout: 600
  246. launch-timeout: 900
  247. rate: 0.25
  248. diskimages:
  249. - name: centos-7
  250. config-drive: true
  251. - name: debian-stretch
  252. config-drive: true
  253. - name: fedora-29
  254. config-drive: true
  255. - name: ubuntu-bionic
  256. config-drive: true
  257. - name: ubuntu-trusty
  258. config-drive: true
  259. - name: ubuntu-xenial
  260. config-drive: true
  261. - name: opensuse-423
  262. config-drive: true
  263. - name: opensuse-150
  264. config-drive: true
  265. - name: opensuse-tumbleweed
  266. config-drive: true
  267. - name: gentoo-17-0-systemd
  268. config-drive: true
  269. pools:
  270. - name: main
  271. max-servers: 5
  272. labels:
  273. - name: centos-7
  274. diskimage: centos-7
  275. min-ram: 1024
  276. flavor-name: 'nodepool'
  277. console-log: True
  278. key-name: $NODEPOOL_KEY_NAME
  279. instance-properties:
  280. nodepool_devstack: testing
  281. userdata: |
  282. #cloud-config
  283. write_files:
  284. - content: |
  285. testpassed
  286. path: /etc/testfile_nodepool_userdata
  287. - name: debian-stretch
  288. diskimage: debian-stretch
  289. min-ram: 512
  290. flavor-name: 'nodepool'
  291. console-log: True
  292. key-name: $NODEPOOL_KEY_NAME
  293. instance-properties:
  294. nodepool_devstack: testing
  295. userdata: |
  296. #cloud-config
  297. write_files:
  298. - content: |
  299. testpassed
  300. path: /etc/testfile_nodepool_userdata
  301. - name: fedora-29
  302. diskimage: fedora-29
  303. min-ram: 1024
  304. flavor-name: 'nodepool'
  305. console-log: True
  306. key-name: $NODEPOOL_KEY_NAME
  307. instance-properties:
  308. nodepool_devstack: testing
  309. userdata: |
  310. #cloud-config
  311. write_files:
  312. - content: |
  313. testpassed
  314. path: /etc/testfile_nodepool_userdata
  315. - name: ubuntu-bionic
  316. diskimage: ubuntu-bionic
  317. min-ram: 512
  318. flavor-name: 'nodepool'
  319. console-log: True
  320. key-name: $NODEPOOL_KEY_NAME
  321. instance-properties:
  322. nodepool_devstack: testing
  323. userdata: |
  324. #cloud-config
  325. write_files:
  326. - content: |
  327. testpassed
  328. path: /etc/testfile_nodepool_userdata
  329. - name: ubuntu-trusty
  330. diskimage: ubuntu-trusty
  331. min-ram: 512
  332. flavor-name: 'nodepool'
  333. console-log: True
  334. key-name: $NODEPOOL_KEY_NAME
  335. instance-properties:
  336. nodepool_devstack: testing
  337. userdata: |
  338. #cloud-config
  339. write_files:
  340. - content: |
  341. testpassed
  342. path: /etc/testfile_nodepool_userdata
  343. - name: ubuntu-xenial
  344. diskimage: ubuntu-xenial
  345. min-ram: 512
  346. flavor-name: 'nodepool'
  347. console-log: True
  348. key-name: $NODEPOOL_KEY_NAME
  349. instance-properties:
  350. nodepool_devstack: testing
  351. userdata: |
  352. #cloud-config
  353. write_files:
  354. - content: |
  355. testpassed
  356. path: /etc/testfile_nodepool_userdata
  357. - name: opensuse-423
  358. diskimage: opensuse-423
  359. min-ram: 512
  360. flavor-name: 'nodepool'
  361. console-log: True
  362. key-name: $NODEPOOL_KEY_NAME
  363. instance-properties:
  364. nodepool_devstack: testing
  365. userdata: |
  366. #cloud-config
  367. write_files:
  368. - content: |
  369. testpassed
  370. path: /etc/testfile_nodepool_userdata
  371. - name: opensuse-150
  372. diskimage: opensuse-150
  373. min-ram: 512
  374. flavor-name: 'nodepool'
  375. console-log: True
  376. key-name: $NODEPOOL_KEY_NAME
  377. instance-properties:
  378. nodepool_devstack: testing
  379. userdata: |
  380. #cloud-config
  381. write_files:
  382. - content: |
  383. testpassed
  384. path: /etc/testfile_nodepool_userdata
  385. - name: opensuse-tumbleweed
  386. diskimage: opensuse-tumbleweed
  387. min-ram: 512
  388. flavor-name: 'nodepool'
  389. console-log: True
  390. key-name: $NODEPOOL_KEY_NAME
  391. instance-properties:
  392. nodepool_devstack: testing
  393. userdata: |
  394. #cloud-config
  395. write_files:
  396. - content: |
  397. testpassed
  398. path: /etc/testfile_nodepool_userdata
  399. - name: gentoo-17-0-systemd
  400. diskimage: gentoo-17-0-systemd
  401. min-ram: 512
  402. flavor-name: 'nodepool'
  403. console-log: True
  404. key-name: $NODEPOOL_KEY_NAME
  405. instance-properties:
  406. nodepool_devstack: testing
  407. userdata: |
  408. #cloud-config
  409. write_files:
  410. - content: |
  411. testpassed
  412. path: /etc/testfile_nodepool_userdata
  413. diskimages:
  414. - name: centos-7
  415. pause: $NODEPOOL_PAUSE_CENTOS_7_DIB
  416. rebuild-age: 86400
  417. elements:
  418. - centos-minimal
  419. - vm
  420. - simple-init
  421. - growroot
  422. - devuser
  423. - openssh-server
  424. - nodepool-setup
  425. env-vars:
  426. TMPDIR: $NODEPOOL_DIB_BASE_PATH/tmp
  427. DIB_CHECKSUM: '1'
  428. DIB_SHOW_IMAGE_USAGE: '1'
  429. DIB_IMAGE_CACHE: $NODEPOOL_DIB_BASE_PATH/cache
  430. DIB_DEV_USER_AUTHORIZED_KEYS: $NODEPOOL_PUBKEY
  431. $DIB_DISTRIBUTION_MIRROR_CENTOS
  432. $DIB_GET_PIP
  433. $DIB_GLEAN_INSTALLTYPE
  434. $DIB_GLEAN_REPOLOCATION
  435. $DIB_GLEAN_REPOREF
  436. DIB_SIMPLE_INIT_NETWORKMANAGER: '1'
  437. - name: debian-stretch
  438. pause: $NODEPOOL_PAUSE_DEBIAN_STRETCH_DIB
  439. rebuild-age: 86400
  440. elements:
  441. - debian-minimal
  442. - vm
  443. - simple-init
  444. - growroot
  445. - devuser
  446. - openssh-server
  447. - nodepool-setup
  448. release: stretch
  449. env-vars:
  450. TMPDIR: $NODEPOOL_DIB_BASE_PATH/tmp
  451. DIB_CHECKSUM: '1'
  452. DIB_SHOW_IMAGE_USAGE: '1'
  453. DIB_IMAGE_CACHE: $NODEPOOL_DIB_BASE_PATH/cache
  454. DIB_APT_LOCAL_CACHE: '0'
  455. DIB_DISABLE_APT_CLEANUP: '1'
  456. DIB_DEV_USER_AUTHORIZED_KEYS: $NODEPOOL_PUBKEY
  457. DIB_DEBIAN_COMPONENTS: 'main'
  458. $DIB_DISTRIBUTION_MIRROR_DEBIAN
  459. $DIB_DEBOOTSTRAP_EXTRA_ARGS
  460. $DIB_GET_PIP
  461. $DIB_GLEAN_INSTALLTYPE
  462. $DIB_GLEAN_REPOLOCATION
  463. $DIB_GLEAN_REPOREF
  464. - name: fedora-29
  465. pause: $NODEPOOL_PAUSE_FEDORA_29_DIB
  466. rebuild-age: 86400
  467. elements:
  468. - fedora-minimal
  469. - vm
  470. - simple-init
  471. - growroot
  472. - devuser
  473. - openssh-server
  474. - nodepool-setup
  475. release: 29
  476. env-vars:
  477. TMPDIR: $NODEPOOL_DIB_BASE_PATH/tmp
  478. DIB_CHECKSUM: '1'
  479. DIB_SHOW_IMAGE_USAGE: '1'
  480. DIB_IMAGE_CACHE: $NODEPOOL_DIB_BASE_PATH/cache
  481. DIB_DEV_USER_AUTHORIZED_KEYS: $NODEPOOL_PUBKEY
  482. $DIB_GET_PIP
  483. $DIB_GLEAN_INSTALLTYPE
  484. $DIB_GLEAN_REPOLOCATION
  485. $DIB_GLEAN_REPOREF
  486. DIB_SIMPLE_INIT_NETWORKMANAGER: '1'
  487. - name: ubuntu-bionic
  488. pause: $NODEPOOL_PAUSE_UBUNTU_BIONIC_DIB
  489. rebuild-age: 86400
  490. elements:
  491. - ubuntu-minimal
  492. - vm
  493. - simple-init
  494. - growroot
  495. - devuser
  496. - openssh-server
  497. - nodepool-setup
  498. release: bionic
  499. env-vars:
  500. TMPDIR: $NODEPOOL_DIB_BASE_PATH/tmp
  501. DIB_CHECKSUM: '1'
  502. DIB_SHOW_IMAGE_USAGE: '1'
  503. DIB_IMAGE_CACHE: $NODEPOOL_DIB_BASE_PATH/cache
  504. DIB_APT_LOCAL_CACHE: '0'
  505. DIB_DISABLE_APT_CLEANUP: '1'
  506. DIB_DEV_USER_AUTHORIZED_KEYS: $NODEPOOL_PUBKEY
  507. DIB_DEBIAN_COMPONENTS: 'main,universe'
  508. $DIB_DISTRIBUTION_MIRROR_UBUNTU
  509. $DIB_DEBOOTSTRAP_EXTRA_ARGS
  510. $DIB_GET_PIP
  511. $DIB_GLEAN_INSTALLTYPE
  512. $DIB_GLEAN_REPOLOCATION
  513. $DIB_GLEAN_REPOREF
  514. - name: ubuntu-trusty
  515. pause: $NODEPOOL_PAUSE_UBUNTU_TRUSTY_DIB
  516. rebuild-age: 86400
  517. elements:
  518. - ubuntu-minimal
  519. - vm
  520. - simple-init
  521. - growroot
  522. - devuser
  523. - openssh-server
  524. - nodepool-setup
  525. release: trusty
  526. env-vars:
  527. TMPDIR: $NODEPOOL_DIB_BASE_PATH/tmp
  528. DIB_CHECKSUM: '1'
  529. DIB_SHOW_IMAGE_USAGE: '1'
  530. DIB_IMAGE_CACHE: $NODEPOOL_DIB_BASE_PATH/cache
  531. DIB_APT_LOCAL_CACHE: '0'
  532. DIB_DISABLE_APT_CLEANUP: '1'
  533. DIB_DEV_USER_AUTHORIZED_KEYS: $NODEPOOL_PUBKEY
  534. DIB_DEBIAN_COMPONENTS: 'main,universe'
  535. $DIB_DISTRIBUTION_MIRROR_UBUNTU
  536. $DIB_DEBOOTSTRAP_EXTRA_ARGS
  537. $DIB_GET_PIP
  538. $DIB_GLEAN_INSTALLTYPE
  539. $DIB_GLEAN_REPOLOCATION
  540. $DIB_GLEAN_REPOREF
  541. - name: ubuntu-xenial
  542. pause: $NODEPOOL_PAUSE_UBUNTU_XENIAL_DIB
  543. rebuild-age: 86400
  544. elements:
  545. - ubuntu-minimal
  546. - vm
  547. - simple-init
  548. - growroot
  549. - devuser
  550. - openssh-server
  551. - nodepool-setup
  552. release: xenial
  553. env-vars:
  554. TMPDIR: $NODEPOOL_DIB_BASE_PATH/tmp
  555. DIB_CHECKSUM: '1'
  556. DIB_SHOW_IMAGE_USAGE: '1'
  557. DIB_IMAGE_CACHE: $NODEPOOL_DIB_BASE_PATH/cache
  558. DIB_APT_LOCAL_CACHE: '0'
  559. DIB_DISABLE_APT_CLEANUP: '1'
  560. DIB_DEV_USER_AUTHORIZED_KEYS: $NODEPOOL_PUBKEY
  561. DIB_DEBIAN_COMPONENTS: 'main,universe'
  562. $DIB_DISTRIBUTION_MIRROR_UBUNTU
  563. $DIB_DEBOOTSTRAP_EXTRA_ARGS
  564. $DIB_GET_PIP
  565. $DIB_GLEAN_INSTALLTYPE
  566. $DIB_GLEAN_REPOLOCATION
  567. $DIB_GLEAN_REPOREF
  568. - name: opensuse-423
  569. pause: $NODEPOOL_PAUSE_OPENSUSE_423_DIB
  570. rebuild-age: 86400
  571. elements:
  572. - opensuse-minimal
  573. - vm
  574. - simple-init
  575. - growroot
  576. - devuser
  577. - openssh-server
  578. - nodepool-setup
  579. release: '42.3'
  580. env-vars:
  581. TMPDIR: $NODEPOOL_DIB_BASE_PATH/tmp
  582. DIB_CHECKSUM: '1'
  583. DIB_SHOW_IMAGE_USAGE: '1'
  584. DIB_IMAGE_CACHE: $NODEPOOL_DIB_BASE_PATH/cache
  585. DIB_DEV_USER_AUTHORIZED_KEYS: $NODEPOOL_PUBKEY
  586. $DIB_GET_PIP
  587. $DIB_GLEAN_INSTALLTYPE
  588. $DIB_GLEAN_REPOLOCATION
  589. $DIB_GLEAN_REPOREF
  590. - name: opensuse-150
  591. pause: $NODEPOOL_PAUSE_OPENSUSE_150_DIB
  592. rebuild-age: 86400
  593. elements:
  594. - opensuse-minimal
  595. - vm
  596. - simple-init
  597. - growroot
  598. - devuser
  599. - openssh-server
  600. - nodepool-setup
  601. release: '15.0'
  602. env-vars:
  603. TMPDIR: $NODEPOOL_DIB_BASE_PATH/tmp
  604. DIB_CHECKSUM: '1'
  605. DIB_SHOW_IMAGE_USAGE: '1'
  606. DIB_IMAGE_CACHE: $NODEPOOL_DIB_BASE_PATH/cache
  607. DIB_DEV_USER_AUTHORIZED_KEYS: $NODEPOOL_PUBKEY
  608. $DIB_GET_PIP
  609. $DIB_GLEAN_INSTALLTYPE
  610. $DIB_GLEAN_REPOLOCATION
  611. $DIB_GLEAN_REPOREF
  612. - name: opensuse-tumbleweed
  613. pause: $NODEPOOL_PAUSE_OPENSUSE_TUMBLEWEED_DIB
  614. rebuild-age: 86400
  615. elements:
  616. - opensuse-minimal
  617. - vm
  618. - simple-init
  619. - growroot
  620. - devuser
  621. - openssh-server
  622. - nodepool-setup
  623. release: 'tumbleweed'
  624. env-vars:
  625. TMPDIR: $NODEPOOL_DIB_BASE_PATH/tmp
  626. DIB_CHECKSUM: '1'
  627. DIB_SHOW_IMAGE_USAGE: '1'
  628. DIB_IMAGE_CACHE: $NODEPOOL_DIB_BASE_PATH/cache
  629. DIB_DEV_USER_AUTHORIZED_KEYS: $NODEPOOL_PUBKEY
  630. $DIB_GET_PIP
  631. $DIB_GLEAN_INSTALLTYPE
  632. $DIB_GLEAN_REPOLOCATION
  633. $DIB_GLEAN_REPOREF
  634. - name: gentoo-17-0-systemd
  635. pause: $NODEPOOL_PAUSE_GENTOO_17_0_SYSTEMD_DIB
  636. rebuild-age: 86400
  637. elements:
  638. - gentoo
  639. - vm
  640. - simple-init
  641. - growroot
  642. - devuser
  643. - openssh-server
  644. - nodepool-setup
  645. env-vars:
  646. TMPDIR: $NODEPOOL_DIB_BASE_PATH/tmp
  647. DIB_CHECKSUM: '1'
  648. DIB_SHOW_IMAGE_USAGE: '1'
  649. DIB_IMAGE_CACHE: $NODEPOOL_DIB_BASE_PATH/cache
  650. DIB_DEV_USER_AUTHORIZED_KEYS: $NODEPOOL_PUBKEY
  651. $DIB_GET_PIP
  652. $DIB_GLEAN_INSTALLTYPE
  653. $DIB_GLEAN_REPOLOCATION
  654. $DIB_GLEAN_REPOREF
  655. GENTOO_PROFILE: 'default/linux/amd64/17.0/systemd'
  656. EOF
  657. sudo mv /tmp/nodepool.yaml $NODEPOOL_CONFIG
  658. cp /etc/openstack/clouds.yaml /tmp
  659. cat >>/tmp/clouds.yaml <<EOF
  660. cache:
  661. max_age: 3600
  662. class: dogpile.cache.dbm
  663. arguments:
  664. filename: $HOME/.cache/openstack/shade.dbm
  665. expiration:
  666. floating-ip: 5
  667. server: 5
  668. port: 5
  669. # TODO(pabelanger): Remove once glean fully supports IPv6.
  670. client:
  671. force_ipv4: True
  672. EOF
  673. sudo mv /tmp/clouds.yaml /etc/openstack/clouds.yaml
  674. mkdir -p $HOME/.cache/openstack/
  675. }
  676. function nodepool_zk_on_tmpfs {
  677. local datadir
  678. datadir=$(sed -n -e 's/^dataDir=//p' /etc/zookeeper/conf/zoo.cfg)
  679. sudo service zookeeper stop
  680. sudo mount -t tmpfs -o nodev,nosuid,size=500M none $datadir
  681. sudo service zookeeper start
  682. }
  683. # Create configs
  684. # Setup custom flavor
  685. function configure_nodepool {
  686. # build a dedicated keypair for nodepool to use with guests
  687. nodepool_create_keypairs
  688. # write the nodepool config
  689. nodepool_write_config
  690. # write the elements
  691. nodepool_write_elements
  692. }
  693. function start_nodepool {
  694. # build a custom flavor that's more friendly to nodepool; give
  695. # disks a little room to grow
  696. local available_flavors=$(nova flavor-list)
  697. if [[ ! ( $available_flavors =~ 'nodepool-512' ) ]]; then
  698. nova flavor-create nodepool-512 64 512 5 1
  699. fi
  700. if [[ ! ( $available_flavors =~ 'nodepool-1024' ) ]]; then
  701. nova flavor-create nodepool-1024 128 1024 5 1
  702. fi
  703. # build sec group rules to reach the nodes, we need to do this
  704. # this late because nova hasn't started until this phase.
  705. if [[ -z $(openstack security group rule list --protocol tcp default | grep '65535') ]]; then
  706. openstack --os-project-name demo --os-username demo security group rule create --ingress --protocol tcp --dst-port 1:65535 --remote-ip 0.0.0.0/0 default
  707. openstack --os-project-name demo --os-username demo security group rule create --ingress --protocol udp --dst-port 1:65535 --remote-ip 0.0.0.0/0 default
  708. fi
  709. # start an unmanaged vm that should be ignored by nodepool
  710. local cirros_image=$(openstack --os-project-name demo --os-username demo image list | grep cirros | awk '{print $4}' | head -n1)
  711. openstack --os-project-name demo --os-username demo server create --flavor cirros256 --image $cirros_image unmanaged-vm
  712. # create root keypair to use with glean for devstack cloud.
  713. nova --os-project-name demo --os-username demo \
  714. keypair-add --pub-key $NODEPOOL_PUBKEY $NODEPOOL_KEY_NAME
  715. export PATH=$NODEPOOL_INSTALL/bin:$PATH
  716. # run a fake statsd so we test stats sending paths
  717. export STATSD_HOST=localhost
  718. export STATSD_PORT=8125
  719. run_process statsd "/usr/bin/socat -u udp-recv:$STATSD_PORT -"
  720. # Restart nodepool's zk on a tmpfs
  721. nodepool_zk_on_tmpfs
  722. # Ensure our configuration is valid.
  723. $NODEPOOL_INSTALL/bin/nodepool -c $NODEPOOL_CONFIG config-validate
  724. run_process nodepool-launcher "$NODEPOOL_INSTALL/bin/nodepool-launcher -c $NODEPOOL_CONFIG -s $NODEPOOL_SECURE -l $NODEPOOL_LOGGING -d"
  725. run_process nodepool-builder "$NODEPOOL_INSTALL/bin/nodepool-builder -c $NODEPOOL_CONFIG -l $NODEPOOL_LOGGING -d"
  726. :
  727. }
  728. function shutdown_nodepool {
  729. stop_process nodepool
  730. # Verify that the unmanaged vm still exists
  731. openstack --os-project-name demo --os-username demo server show unmanaged-vm
  732. :
  733. }
  734. function cleanup_nodepool {
  735. :
  736. }
  737. # check for service enabled
  738. if is_service_enabled nodepool-launcher; then
  739. if [[ "$1" == "stack" && "$2" == "install" ]]; then
  740. # Perform installation of service source
  741. echo_summary "Installing nodepool"
  742. install_nodepool
  743. elif [[ "$1" == "stack" && "$2" == "post-config" ]]; then
  744. # Configure after the other layer 1 and 2 services have been configured
  745. echo_summary "Configuring nodepool"
  746. configure_nodepool
  747. elif [[ "$1" == "stack" && "$2" == "test-config" ]]; then
  748. # Initialize and start the nodepool service
  749. echo_summary "Initializing nodepool"
  750. start_nodepool
  751. fi
  752. if [[ "$1" == "unstack" ]]; then
  753. # Shut down nodepool services
  754. # no-op
  755. shutdown_nodepool
  756. fi
  757. if [[ "$1" == "clean" ]]; then
  758. # Remove state and transient data
  759. # Remember clean.sh first calls unstack.sh
  760. # no-op
  761. cleanup_nodepool
  762. fi
  763. fi