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

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