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 25KB

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