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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765
  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. - name: debian-stretch
  282. diskimage: debian-stretch
  283. min-ram: 512
  284. flavor-name: 'nodepool'
  285. console-log: True
  286. key-name: $NODEPOOL_KEY_NAME
  287. instance-properties:
  288. nodepool_devstack: testing
  289. - name: fedora-29
  290. diskimage: fedora-29
  291. min-ram: 1024
  292. flavor-name: 'nodepool'
  293. console-log: True
  294. key-name: $NODEPOOL_KEY_NAME
  295. instance-properties:
  296. nodepool_devstack: testing
  297. - name: ubuntu-bionic
  298. diskimage: ubuntu-bionic
  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. - name: ubuntu-trusty
  306. diskimage: ubuntu-trusty
  307. min-ram: 512
  308. flavor-name: 'nodepool'
  309. console-log: True
  310. key-name: $NODEPOOL_KEY_NAME
  311. instance-properties:
  312. nodepool_devstack: testing
  313. - name: ubuntu-xenial
  314. diskimage: ubuntu-xenial
  315. min-ram: 512
  316. flavor-name: 'nodepool'
  317. console-log: True
  318. key-name: $NODEPOOL_KEY_NAME
  319. instance-properties:
  320. nodepool_devstack: testing
  321. - name: opensuse-423
  322. diskimage: opensuse-423
  323. min-ram: 512
  324. flavor-name: 'nodepool'
  325. console-log: True
  326. key-name: $NODEPOOL_KEY_NAME
  327. instance-properties:
  328. nodepool_devstack: testing
  329. - name: opensuse-150
  330. diskimage: opensuse-150
  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. - name: opensuse-tumbleweed
  338. diskimage: opensuse-tumbleweed
  339. min-ram: 512
  340. flavor-name: 'nodepool'
  341. console-log: True
  342. key-name: $NODEPOOL_KEY_NAME
  343. instance-properties:
  344. nodepool_devstack: testing
  345. - name: gentoo-17-0-systemd
  346. diskimage: gentoo-17-0-systemd
  347. min-ram: 512
  348. flavor-name: 'nodepool'
  349. console-log: True
  350. key-name: $NODEPOOL_KEY_NAME
  351. instance-properties:
  352. nodepool_devstack: testing
  353. diskimages:
  354. - name: centos-7
  355. pause: $NODEPOOL_PAUSE_CENTOS_7_DIB
  356. rebuild-age: 86400
  357. elements:
  358. - centos-minimal
  359. - vm
  360. - simple-init
  361. - growroot
  362. - devuser
  363. - openssh-server
  364. - nodepool-setup
  365. env-vars:
  366. TMPDIR: $NODEPOOL_DIB_BASE_PATH/tmp
  367. DIB_CHECKSUM: '1'
  368. DIB_SHOW_IMAGE_USAGE: '1'
  369. DIB_IMAGE_CACHE: $NODEPOOL_DIB_BASE_PATH/cache
  370. DIB_DEV_USER_AUTHORIZED_KEYS: $NODEPOOL_PUBKEY
  371. $DIB_DISTRIBUTION_MIRROR_CENTOS
  372. $DIB_GET_PIP
  373. $DIB_GLEAN_INSTALLTYPE
  374. $DIB_GLEAN_REPOLOCATION
  375. $DIB_GLEAN_REPOREF
  376. DIB_SIMPLE_INIT_NETWORKMANAGER: '1'
  377. - name: debian-stretch
  378. pause: $NODEPOOL_PAUSE_DEBIAN_STRETCH_DIB
  379. rebuild-age: 86400
  380. elements:
  381. - debian-minimal
  382. - vm
  383. - simple-init
  384. - growroot
  385. - devuser
  386. - openssh-server
  387. - nodepool-setup
  388. release: stretch
  389. env-vars:
  390. TMPDIR: $NODEPOOL_DIB_BASE_PATH/tmp
  391. DIB_CHECKSUM: '1'
  392. DIB_SHOW_IMAGE_USAGE: '1'
  393. DIB_IMAGE_CACHE: $NODEPOOL_DIB_BASE_PATH/cache
  394. DIB_APT_LOCAL_CACHE: '0'
  395. DIB_DISABLE_APT_CLEANUP: '1'
  396. DIB_DEV_USER_AUTHORIZED_KEYS: $NODEPOOL_PUBKEY
  397. DIB_DEBIAN_COMPONENTS: 'main'
  398. $DIB_DISTRIBUTION_MIRROR_DEBIAN
  399. $DIB_DEBOOTSTRAP_EXTRA_ARGS
  400. $DIB_GET_PIP
  401. $DIB_GLEAN_INSTALLTYPE
  402. $DIB_GLEAN_REPOLOCATION
  403. $DIB_GLEAN_REPOREF
  404. - name: fedora-29
  405. pause: $NODEPOOL_PAUSE_FEDORA_29_DIB
  406. rebuild-age: 86400
  407. elements:
  408. - fedora-minimal
  409. - vm
  410. - simple-init
  411. - growroot
  412. - devuser
  413. - openssh-server
  414. - nodepool-setup
  415. release: 29
  416. env-vars:
  417. TMPDIR: $NODEPOOL_DIB_BASE_PATH/tmp
  418. DIB_CHECKSUM: '1'
  419. DIB_SHOW_IMAGE_USAGE: '1'
  420. DIB_IMAGE_CACHE: $NODEPOOL_DIB_BASE_PATH/cache
  421. DIB_DEV_USER_AUTHORIZED_KEYS: $NODEPOOL_PUBKEY
  422. $DIB_GET_PIP
  423. $DIB_GLEAN_INSTALLTYPE
  424. $DIB_GLEAN_REPOLOCATION
  425. $DIB_GLEAN_REPOREF
  426. DIB_SIMPLE_INIT_NETWORKMANAGER: '1'
  427. - name: ubuntu-bionic
  428. pause: $NODEPOOL_PAUSE_UBUNTU_BIONIC_DIB
  429. rebuild-age: 86400
  430. elements:
  431. - ubuntu-minimal
  432. - vm
  433. - simple-init
  434. - growroot
  435. - devuser
  436. - openssh-server
  437. - nodepool-setup
  438. release: bionic
  439. env-vars:
  440. TMPDIR: $NODEPOOL_DIB_BASE_PATH/tmp
  441. DIB_CHECKSUM: '1'
  442. DIB_SHOW_IMAGE_USAGE: '1'
  443. DIB_IMAGE_CACHE: $NODEPOOL_DIB_BASE_PATH/cache
  444. DIB_APT_LOCAL_CACHE: '0'
  445. DIB_DISABLE_APT_CLEANUP: '1'
  446. DIB_DEV_USER_AUTHORIZED_KEYS: $NODEPOOL_PUBKEY
  447. DIB_DEBIAN_COMPONENTS: 'main,universe'
  448. $DIB_DISTRIBUTION_MIRROR_UBUNTU
  449. $DIB_DEBOOTSTRAP_EXTRA_ARGS
  450. $DIB_GET_PIP
  451. $DIB_GLEAN_INSTALLTYPE
  452. $DIB_GLEAN_REPOLOCATION
  453. $DIB_GLEAN_REPOREF
  454. - name: ubuntu-trusty
  455. pause: $NODEPOOL_PAUSE_UBUNTU_TRUSTY_DIB
  456. rebuild-age: 86400
  457. elements:
  458. - ubuntu-minimal
  459. - vm
  460. - simple-init
  461. - growroot
  462. - devuser
  463. - openssh-server
  464. - nodepool-setup
  465. release: trusty
  466. env-vars:
  467. TMPDIR: $NODEPOOL_DIB_BASE_PATH/tmp
  468. DIB_CHECKSUM: '1'
  469. DIB_SHOW_IMAGE_USAGE: '1'
  470. DIB_IMAGE_CACHE: $NODEPOOL_DIB_BASE_PATH/cache
  471. DIB_APT_LOCAL_CACHE: '0'
  472. DIB_DISABLE_APT_CLEANUP: '1'
  473. DIB_DEV_USER_AUTHORIZED_KEYS: $NODEPOOL_PUBKEY
  474. DIB_DEBIAN_COMPONENTS: 'main,universe'
  475. $DIB_DISTRIBUTION_MIRROR_UBUNTU
  476. $DIB_DEBOOTSTRAP_EXTRA_ARGS
  477. $DIB_GET_PIP
  478. $DIB_GLEAN_INSTALLTYPE
  479. $DIB_GLEAN_REPOLOCATION
  480. $DIB_GLEAN_REPOREF
  481. - name: ubuntu-xenial
  482. pause: $NODEPOOL_PAUSE_UBUNTU_XENIAL_DIB
  483. rebuild-age: 86400
  484. elements:
  485. - ubuntu-minimal
  486. - vm
  487. - simple-init
  488. - growroot
  489. - devuser
  490. - openssh-server
  491. - nodepool-setup
  492. release: xenial
  493. env-vars:
  494. TMPDIR: $NODEPOOL_DIB_BASE_PATH/tmp
  495. DIB_CHECKSUM: '1'
  496. DIB_SHOW_IMAGE_USAGE: '1'
  497. DIB_IMAGE_CACHE: $NODEPOOL_DIB_BASE_PATH/cache
  498. DIB_APT_LOCAL_CACHE: '0'
  499. DIB_DISABLE_APT_CLEANUP: '1'
  500. DIB_DEV_USER_AUTHORIZED_KEYS: $NODEPOOL_PUBKEY
  501. DIB_DEBIAN_COMPONENTS: 'main,universe'
  502. $DIB_DISTRIBUTION_MIRROR_UBUNTU
  503. $DIB_DEBOOTSTRAP_EXTRA_ARGS
  504. $DIB_GET_PIP
  505. $DIB_GLEAN_INSTALLTYPE
  506. $DIB_GLEAN_REPOLOCATION
  507. $DIB_GLEAN_REPOREF
  508. - name: opensuse-423
  509. pause: $NODEPOOL_PAUSE_OPENSUSE_423_DIB
  510. rebuild-age: 86400
  511. elements:
  512. - opensuse-minimal
  513. - vm
  514. - simple-init
  515. - growroot
  516. - devuser
  517. - openssh-server
  518. - nodepool-setup
  519. release: '42.3'
  520. env-vars:
  521. TMPDIR: $NODEPOOL_DIB_BASE_PATH/tmp
  522. DIB_CHECKSUM: '1'
  523. DIB_SHOW_IMAGE_USAGE: '1'
  524. DIB_IMAGE_CACHE: $NODEPOOL_DIB_BASE_PATH/cache
  525. DIB_DEV_USER_AUTHORIZED_KEYS: $NODEPOOL_PUBKEY
  526. $DIB_GET_PIP
  527. $DIB_GLEAN_INSTALLTYPE
  528. $DIB_GLEAN_REPOLOCATION
  529. $DIB_GLEAN_REPOREF
  530. - name: opensuse-150
  531. pause: $NODEPOOL_PAUSE_OPENSUSE_150_DIB
  532. rebuild-age: 86400
  533. elements:
  534. - opensuse-minimal
  535. - vm
  536. - simple-init
  537. - growroot
  538. - devuser
  539. - openssh-server
  540. - nodepool-setup
  541. release: '15.0'
  542. env-vars:
  543. TMPDIR: $NODEPOOL_DIB_BASE_PATH/tmp
  544. DIB_CHECKSUM: '1'
  545. DIB_SHOW_IMAGE_USAGE: '1'
  546. DIB_IMAGE_CACHE: $NODEPOOL_DIB_BASE_PATH/cache
  547. DIB_DEV_USER_AUTHORIZED_KEYS: $NODEPOOL_PUBKEY
  548. $DIB_GET_PIP
  549. $DIB_GLEAN_INSTALLTYPE
  550. $DIB_GLEAN_REPOLOCATION
  551. $DIB_GLEAN_REPOREF
  552. - name: opensuse-tumbleweed
  553. pause: $NODEPOOL_PAUSE_OPENSUSE_TUMBLEWEED_DIB
  554. rebuild-age: 86400
  555. elements:
  556. - opensuse-minimal
  557. - vm
  558. - simple-init
  559. - growroot
  560. - devuser
  561. - openssh-server
  562. - nodepool-setup
  563. release: 'tumbleweed'
  564. env-vars:
  565. TMPDIR: $NODEPOOL_DIB_BASE_PATH/tmp
  566. DIB_CHECKSUM: '1'
  567. DIB_SHOW_IMAGE_USAGE: '1'
  568. DIB_IMAGE_CACHE: $NODEPOOL_DIB_BASE_PATH/cache
  569. DIB_DEV_USER_AUTHORIZED_KEYS: $NODEPOOL_PUBKEY
  570. $DIB_GET_PIP
  571. $DIB_GLEAN_INSTALLTYPE
  572. $DIB_GLEAN_REPOLOCATION
  573. $DIB_GLEAN_REPOREF
  574. - name: gentoo-17-0-systemd
  575. pause: $NODEPOOL_PAUSE_GENTOO_17_0_SYSTEMD_DIB
  576. rebuild-age: 86400
  577. elements:
  578. - gentoo
  579. - vm
  580. - simple-init
  581. - growroot
  582. - devuser
  583. - openssh-server
  584. - nodepool-setup
  585. env-vars:
  586. TMPDIR: $NODEPOOL_DIB_BASE_PATH/tmp
  587. DIB_CHECKSUM: '1'
  588. DIB_SHOW_IMAGE_USAGE: '1'
  589. DIB_IMAGE_CACHE: $NODEPOOL_DIB_BASE_PATH/cache
  590. DIB_DEV_USER_AUTHORIZED_KEYS: $NODEPOOL_PUBKEY
  591. $DIB_GET_PIP
  592. $DIB_GLEAN_INSTALLTYPE
  593. $DIB_GLEAN_REPOLOCATION
  594. $DIB_GLEAN_REPOREF
  595. GENTOO_PROFILE: 'default/linux/amd64/17.0/systemd'
  596. EOF
  597. sudo mv /tmp/nodepool.yaml $NODEPOOL_CONFIG
  598. cp /etc/openstack/clouds.yaml /tmp
  599. cat >>/tmp/clouds.yaml <<EOF
  600. cache:
  601. max_age: 3600
  602. class: dogpile.cache.dbm
  603. arguments:
  604. filename: $HOME/.cache/openstack/shade.dbm
  605. expiration:
  606. floating-ip: 5
  607. server: 5
  608. port: 5
  609. # TODO(pabelanger): Remove once glean fully supports IPv6.
  610. client:
  611. force_ipv4: True
  612. EOF
  613. sudo mv /tmp/clouds.yaml /etc/openstack/clouds.yaml
  614. mkdir -p $HOME/.cache/openstack/
  615. }
  616. function nodepool_zk_on_tmpfs {
  617. local datadir
  618. datadir=$(sed -n -e 's/^dataDir=//p' /etc/zookeeper/conf/zoo.cfg)
  619. sudo service zookeeper stop
  620. sudo mount -t tmpfs -o nodev,nosuid,size=500M none $datadir
  621. sudo service zookeeper start
  622. }
  623. # Create configs
  624. # Setup custom flavor
  625. function configure_nodepool {
  626. # build a dedicated keypair for nodepool to use with guests
  627. nodepool_create_keypairs
  628. # write the nodepool config
  629. nodepool_write_config
  630. # write the elements
  631. nodepool_write_elements
  632. }
  633. function start_nodepool {
  634. # build a custom flavor that's more friendly to nodepool; give
  635. # disks a little room to grow
  636. local available_flavors=$(nova flavor-list)
  637. if [[ ! ( $available_flavors =~ 'nodepool-512' ) ]]; then
  638. nova flavor-create nodepool-512 64 512 5 1
  639. fi
  640. if [[ ! ( $available_flavors =~ 'nodepool-1024' ) ]]; then
  641. nova flavor-create nodepool-1024 128 1024 5 1
  642. fi
  643. # build sec group rules to reach the nodes, we need to do this
  644. # this late because nova hasn't started until this phase.
  645. if [[ -z $(openstack security group rule list --protocol tcp default | grep '65535') ]]; then
  646. 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
  647. 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
  648. fi
  649. # start an unmanaged vm that should be ignored by nodepool
  650. local cirros_image=$(openstack --os-project-name demo --os-username demo image list | grep cirros | awk '{print $4}' | head -n1)
  651. openstack --os-project-name demo --os-username demo server create --flavor cirros256 --image $cirros_image unmanaged-vm
  652. # create root keypair to use with glean for devstack cloud.
  653. nova --os-project-name demo --os-username demo \
  654. keypair-add --pub-key $NODEPOOL_PUBKEY $NODEPOOL_KEY_NAME
  655. export PATH=$NODEPOOL_INSTALL/bin:$PATH
  656. # run a fake statsd so we test stats sending paths
  657. export STATSD_HOST=localhost
  658. export STATSD_PORT=8125
  659. run_process statsd "/usr/bin/socat -u udp-recv:$STATSD_PORT -"
  660. # Restart nodepool's zk on a tmpfs
  661. nodepool_zk_on_tmpfs
  662. # Ensure our configuration is valid.
  663. $NODEPOOL_INSTALL/bin/nodepool -c $NODEPOOL_CONFIG config-validate
  664. run_process nodepool-launcher "$NODEPOOL_INSTALL/bin/nodepool-launcher -c $NODEPOOL_CONFIG -s $NODEPOOL_SECURE -l $NODEPOOL_LOGGING -d"
  665. run_process nodepool-builder "$NODEPOOL_INSTALL/bin/nodepool-builder -c $NODEPOOL_CONFIG -l $NODEPOOL_LOGGING -d"
  666. :
  667. }
  668. function shutdown_nodepool {
  669. stop_process nodepool
  670. # Verify that the unmanaged vm still exists
  671. openstack --os-project-name demo --os-username demo server show unmanaged-vm
  672. :
  673. }
  674. function cleanup_nodepool {
  675. :
  676. }
  677. # check for service enabled
  678. if is_service_enabled nodepool-launcher; then
  679. if [[ "$1" == "stack" && "$2" == "install" ]]; then
  680. # Perform installation of service source
  681. echo_summary "Installing nodepool"
  682. install_nodepool
  683. elif [[ "$1" == "stack" && "$2" == "post-config" ]]; then
  684. # Configure after the other layer 1 and 2 services have been configured
  685. echo_summary "Configuring nodepool"
  686. configure_nodepool
  687. elif [[ "$1" == "stack" && "$2" == "test-config" ]]; then
  688. # Initialize and start the nodepool service
  689. echo_summary "Initializing nodepool"
  690. start_nodepool
  691. fi
  692. if [[ "$1" == "unstack" ]]; then
  693. # Shut down nodepool services
  694. # no-op
  695. shutdown_nodepool
  696. fi
  697. if [[ "$1" == "clean" ]]; then
  698. # Remove state and transient data
  699. # Remember clean.sh first calls unstack.sh
  700. # no-op
  701. cleanup_nodepool
  702. fi
  703. fi