Skip to content
Browse files

Initial import.

  • Loading branch information...
0 parents commit f95325fc7ec27a2c8ed4a184eca95af8f428ac3d Dell Openstack Crowbar Team committed Jul 16, 2011
Showing with 9,782 additions and 0 deletions.
  1. +5 −0 crowbar/.loadpath
  2. +18 −0 crowbar/.project
  3. +4 −0 crowbar/CHANGE-LOG
  4. +142 −0 crowbar/README.build
  5. +453 −0 crowbar/build_crowbar.sh
  6. BIN crowbar/change-image/dell/PC6200v3.2.0.7.stk
  7. +1 −0 crowbar/change-image/dell/apt.conf
  8. +444 −0 crowbar/change-image/dell/barclamp_lib.rb
  9. +21 −0 crowbar/change-image/dell/barclamps/crowbar/Makefile
  10. +21 −0 crowbar/change-image/dell/barclamps/crowbar/app/controllers/crowbar_controller.rb
  11. +203 −0 crowbar/change-image/dell/barclamps/crowbar/app/models/crowbar_service.rb
  12. +52 −0 crowbar/change-image/dell/barclamps/crowbar/barclamp-crowbar.spec
  13. +17 −0 crowbar/change-image/dell/barclamps/crowbar/build_deb.sh
  14. +34 −0 crowbar/change-image/dell/barclamps/crowbar/build_rpm.sh
  15. +51 −0 crowbar/change-image/dell/barclamps/crowbar/chef/cookbooks/crowbar/README.rdoc
  16. +52 −0 crowbar/change-image/dell/barclamps/crowbar/chef/cookbooks/crowbar/files/default/crowbar
  17. +15 −0 crowbar/change-image/dell/barclamps/crowbar/chef/cookbooks/crowbar/files/default/crowbar.sh
  18. +2 −0 crowbar/change-image/dell/barclamps/crowbar/chef/cookbooks/crowbar/files/default/knife.rb
  19. +58 −0 crowbar/change-image/dell/barclamps/crowbar/chef/cookbooks/crowbar/metadata.json
  20. +19 −0 crowbar/change-image/dell/barclamps/crowbar/chef/cookbooks/crowbar/providers/user.rb
  21. +135 −0 crowbar/change-image/dell/barclamps/crowbar/chef/cookbooks/crowbar/recipes/default.rb
  22. +14 −0 crowbar/change-image/dell/barclamps/crowbar/chef/cookbooks/crowbar/recipes/local_apt_repo.rb
  23. +7 −0 crowbar/change-image/dell/barclamps/crowbar/chef/cookbooks/crowbar/resources/user.rb
  24. +40 −0 ...change-image/dell/barclamps/crowbar/chef/cookbooks/crowbar/templates/default/crowbar_app.conf.erb
  25. +68 −0 crowbar/change-image/dell/barclamps/crowbar/chef/data_bags/crowbar/bc-template-crowbar.json
  26. +88 −0 crowbar/change-image/dell/barclamps/crowbar/chef/data_bags/crowbar/bc-template-crowbar.schema
  27. +24 −0 crowbar/change-image/dell/barclamps/crowbar/chef/roles/crowbar.rb
  28. +23 −0 crowbar/change-image/dell/barclamps/crowbar/command_line/crowbar
  29. +6 −0 crowbar/change-image/dell/barclamps/crowbar/command_line/crowbar_crowbar
  30. +331 −0 crowbar/change-image/dell/barclamps/crowbar/command_line/crowbar_machines
  31. +184 −0 crowbar/change-image/dell/barclamps/crowbar/command_line/crowbar_node_state
  32. +22 −0 crowbar/change-image/dell/barclamps/crowbar/command_line/crowbar_node_status
  33. +4 −0 crowbar/change-image/dell/barclamps/crowbar/command_line/crowbar_watch_status
  34. +33 −0 crowbar/change-image/dell/barclamps/crowbar/command_line/transition.sh
  35. +5 −0 crowbar/change-image/dell/barclamps/crowbar/debian/changelog.tmpl
  36. +1 −0 crowbar/change-image/dell/barclamps/crowbar/debian/compat
  37. +13 −0 crowbar/change-image/dell/barclamps/crowbar/debian/control
  38. +26 −0 crowbar/change-image/dell/barclamps/crowbar/debian/copyright
  39. +53 −0 crowbar/change-image/dell/barclamps/crowbar/debian/postinst
  40. +8 −0 crowbar/change-image/dell/barclamps/crowbar/debian/rules
  41. +1 −0 crowbar/change-image/dell/barclamps/crowbar/debian/source/format
  42. +7 −0 crowbar/change-image/dell/barclamps/crowbar/version.sh
  43. +21 −0 crowbar/change-image/dell/barclamps/deployer/Makefile
  44. +21 −0 crowbar/change-image/dell/barclamps/deployer/app/controllers/deployer_controller.rb
  45. +276 −0 crowbar/change-image/dell/barclamps/deployer/app/models/deployer_service.rb
  46. +52 −0 crowbar/change-image/dell/barclamps/deployer/barclamp-deployer.spec
  47. +17 −0 crowbar/change-image/dell/barclamps/deployer/build_deb.sh
  48. +34 −0 crowbar/change-image/dell/barclamps/deployer/build_rpm.sh
  49. +100 −0 crowbar/change-image/dell/barclamps/deployer/chef/cookbooks/barclamp/libraries/barclamp_library.rb
  50. +36 −0 crowbar/change-image/dell/barclamps/deployer/chef/cookbooks/barclamp/metadata.json
  51. +5 −0 crowbar/change-image/dell/barclamps/deployer/chef/cookbooks/barclamp/recipes/default.rb
  52. +41 −0 crowbar/change-image/dell/barclamps/deployer/chef/cookbooks/ohai/README.md
  53. +21 −0 crowbar/change-image/dell/barclamps/deployer/chef/cookbooks/ohai/attributes/default.rb
  54. +1 −0 crowbar/change-image/dell/barclamps/deployer/chef/cookbooks/ohai/files/default/plugins/README
  55. +104 −0 crowbar/change-image/dell/barclamps/deployer/chef/cookbooks/ohai/files/default/plugins/crowbar.rb
  56. +30 −0 crowbar/change-image/dell/barclamps/deployer/chef/cookbooks/ohai/metadata.json
  57. +7 −0 crowbar/change-image/dell/barclamps/deployer/chef/cookbooks/ohai/metadata.rb
  58. +45 −0 crowbar/change-image/dell/barclamps/deployer/chef/cookbooks/ohai/recipes/default.rb
  59. +30 −0 crowbar/change-image/dell/barclamps/deployer/chef/data_bags/crowbar/bc-template-deployer.json
  60. +82 −0 crowbar/change-image/dell/barclamps/deployer/chef/data_bags/crowbar/bc-template-deployer.schema
  61. +10 −0 crowbar/change-image/dell/barclamps/deployer/chef/roles/deployer-client.rb
  62. +6 −0 crowbar/change-image/dell/barclamps/deployer/command_line/crowbar_deployer
  63. +5 −0 crowbar/change-image/dell/barclamps/deployer/debian/changelog.tmpl
  64. +1 −0 crowbar/change-image/dell/barclamps/deployer/debian/compat
  65. +13 −0 crowbar/change-image/dell/barclamps/deployer/debian/control
  66. +26 −0 crowbar/change-image/dell/barclamps/deployer/debian/copyright
  67. +53 −0 crowbar/change-image/dell/barclamps/deployer/debian/postinst
  68. +8 −0 crowbar/change-image/dell/barclamps/deployer/debian/rules
  69. +1 −0 crowbar/change-image/dell/barclamps/deployer/debian/source/format
  70. +7 −0 crowbar/change-image/dell/barclamps/deployer/version.sh
  71. +21 −0 crowbar/change-image/dell/barclamps/dns/Makefile
  72. +21 −0 crowbar/change-image/dell/barclamps/dns/app/controllers/dns_controller.rb
  73. +62 −0 crowbar/change-image/dell/barclamps/dns/app/models/dns_service.rb
  74. +52 −0 crowbar/change-image/dell/barclamps/dns/barclamp-dns.spec
  75. +17 −0 crowbar/change-image/dell/barclamps/dns/build_deb.sh
  76. +34 −0 crowbar/change-image/dell/barclamps/dns/build_rpm.sh
  77. +51 −0 crowbar/change-image/dell/barclamps/dns/chef/cookbooks/bind9/README.rdoc
  78. +5 −0 crowbar/change-image/dell/barclamps/dns/chef/cookbooks/bind9/attributes/default.rb
  79. +65 −0 crowbar/change-image/dell/barclamps/dns/chef/cookbooks/bind9/metadata.json
  80. +18 −0 crowbar/change-image/dell/barclamps/dns/chef/cookbooks/bind9/providers/host.rb
  81. +18 −0 crowbar/change-image/dell/barclamps/dns/chef/cookbooks/bind9/providers/net.rb
  82. +94 −0 crowbar/change-image/dell/barclamps/dns/chef/cookbooks/bind9/recipes/default.rb
  83. +6 −0 crowbar/change-image/dell/barclamps/dns/chef/cookbooks/bind9/resources/host.rb
  84. +6 −0 crowbar/change-image/dell/barclamps/dns/chef/cookbooks/bind9/resources/net.rb
  85. +24 −0 ...bar/change-image/dell/barclamps/dns/chef/cookbooks/bind9/templates/default/named.conf.options.erb
  86. +40 −0 crowbar/change-image/dell/barclamps/dns/chef/cookbooks/resolver/README.md
  87. +2 −0 crowbar/change-image/dell/barclamps/dns/chef/cookbooks/resolver/attributes/default.rb
  88. +97 −0 crowbar/change-image/dell/barclamps/dns/chef/cookbooks/resolver/metadata.json
  89. +29 −0 crowbar/change-image/dell/barclamps/dns/chef/cookbooks/resolver/metadata.rb
  90. +35 −0 crowbar/change-image/dell/barclamps/dns/chef/cookbooks/resolver/recipes/default.rb
  91. +6 −0 crowbar/change-image/dell/barclamps/dns/chef/cookbooks/resolver/templates/default/resolv.conf.erb
  92. +31 −0 crowbar/change-image/dell/barclamps/dns/chef/data_bags/crowbar/bc-template-dns.json
  93. +82 −0 crowbar/change-image/dell/barclamps/dns/chef/data_bags/crowbar/bc-template-dns.schema
  94. +9 −0 crowbar/change-image/dell/barclamps/dns/chef/roles/dns-client.rb
  95. +9 −0 crowbar/change-image/dell/barclamps/dns/chef/roles/dns-server.rb
  96. +6 −0 crowbar/change-image/dell/barclamps/dns/command_line/crowbar_dns
  97. +5 −0 crowbar/change-image/dell/barclamps/dns/debian/changelog.tmpl
  98. +1 −0 crowbar/change-image/dell/barclamps/dns/debian/compat
  99. +13 −0 crowbar/change-image/dell/barclamps/dns/debian/control
  100. +26 −0 crowbar/change-image/dell/barclamps/dns/debian/copyright
  101. +53 −0 crowbar/change-image/dell/barclamps/dns/debian/postinst
  102. +8 −0 crowbar/change-image/dell/barclamps/dns/debian/rules
  103. +1 −0 crowbar/change-image/dell/barclamps/dns/debian/source/format
  104. +7 −0 crowbar/change-image/dell/barclamps/dns/version.sh
  105. +21 −0 crowbar/change-image/dell/barclamps/ganglia/Makefile
  106. +21 −0 crowbar/change-image/dell/barclamps/ganglia/app/controllers/ganglia_controller.rb
  107. +89 −0 crowbar/change-image/dell/barclamps/ganglia/app/models/ganglia_service.rb
  108. +52 −0 crowbar/change-image/dell/barclamps/ganglia/barclamp-ganglia.spec
  109. +17 −0 crowbar/change-image/dell/barclamps/ganglia/build_deb.sh
  110. +34 −0 crowbar/change-image/dell/barclamps/ganglia/build_rpm.sh
  111. +5 −0 crowbar/change-image/dell/barclamps/ganglia/chef/cookbooks/ganglia/attributes/default.rb
  112. +43 −0 crowbar/change-image/dell/barclamps/ganglia/chef/cookbooks/ganglia/libraries/eval.rb
  113. +38 −0 crowbar/change-image/dell/barclamps/ganglia/chef/cookbooks/ganglia/metadata.json
  114. +26 −0 crowbar/change-image/dell/barclamps/ganglia/chef/cookbooks/ganglia/recipes/client.rb
  115. +1 −0 crowbar/change-image/dell/barclamps/ganglia/chef/cookbooks/ganglia/recipes/default.rb
  116. +31 −0 crowbar/change-image/dell/barclamps/ganglia/chef/cookbooks/ganglia/recipes/server.rb
  117. +125 −0 crowbar/change-image/dell/barclamps/ganglia/chef/cookbooks/ganglia/templates/default/gmetad.conf.erb
  118. +339 −0 crowbar/change-image/dell/barclamps/ganglia/chef/cookbooks/ganglia/templates/default/gmond.conf.erb
  119. +27 −0 crowbar/change-image/dell/barclamps/ganglia/chef/data_bags/crowbar/bc-template-ganglia.json
  120. +69 −0 crowbar/change-image/dell/barclamps/ganglia/chef/data_bags/crowbar/bc-template-ganglia.schema
  121. +8 −0 crowbar/change-image/dell/barclamps/ganglia/chef/roles/ganglia-client.rb
  122. +9 −0 crowbar/change-image/dell/barclamps/ganglia/chef/roles/ganglia-server.rb
  123. +6 −0 crowbar/change-image/dell/barclamps/ganglia/command_line/crowbar_ganglia
  124. +5 −0 crowbar/change-image/dell/barclamps/ganglia/debian/changelog.tmpl
  125. +1 −0 crowbar/change-image/dell/barclamps/ganglia/debian/compat
  126. +13 −0 crowbar/change-image/dell/barclamps/ganglia/debian/control
  127. +26 −0 crowbar/change-image/dell/barclamps/ganglia/debian/copyright
  128. +53 −0 crowbar/change-image/dell/barclamps/ganglia/debian/postinst
  129. +8 −0 crowbar/change-image/dell/barclamps/ganglia/debian/rules
  130. +1 −0 crowbar/change-image/dell/barclamps/ganglia/debian/source/format
  131. +7 −0 crowbar/change-image/dell/barclamps/ganglia/version.sh
  132. +20 −0 crowbar/change-image/dell/barclamps/ipmi/app/controllers/ipmi_controller.rb
  133. +51 −0 crowbar/change-image/dell/barclamps/ipmi/app/models/ipmi_service.rb
  134. +28 −0 crowbar/change-image/dell/barclamps/ipmi/chef/cookbooks/ipmi/attributes/default.rb
  135. +41 −0 crowbar/change-image/dell/barclamps/ipmi/chef/cookbooks/ipmi/metadata.json
  136. +24 −0 crowbar/change-image/dell/barclamps/ipmi/chef/cookbooks/ipmi/metadata.rb
  137. +117 −0 crowbar/change-image/dell/barclamps/ipmi/chef/cookbooks/ipmi/recipes/ipmi-configure.rb
  138. +30 −0 crowbar/change-image/dell/barclamps/ipmi/chef/data_bags/crowbar/bc-template-ipmi.json
  139. +45 −0 crowbar/change-image/dell/barclamps/ipmi/chef/data_bags/crowbar/bc-template-ipmi.schema
  140. +24 −0 crowbar/change-image/dell/barclamps/ipmi/chef/roles/ipmi-configure.rb
  141. +21 −0 crowbar/change-image/dell/barclamps/logging/Makefile
  142. +21 −0 crowbar/change-image/dell/barclamps/logging/app/controllers/logging_controller.rb
  143. +64 −0 crowbar/change-image/dell/barclamps/logging/app/models/logging_service.rb
  144. +52 −0 crowbar/change-image/dell/barclamps/logging/barclamp-logging.spec
  145. +17 −0 crowbar/change-image/dell/barclamps/logging/build_deb.sh
  146. +34 −0 crowbar/change-image/dell/barclamps/logging/build_rpm.sh
  147. +37 −0 crowbar/change-image/dell/barclamps/logging/chef/cookbooks/logging/metadata.json
  148. +28 −0 crowbar/change-image/dell/barclamps/logging/chef/cookbooks/logging/recipes/client.rb
  149. 0 crowbar/change-image/dell/barclamps/logging/chef/cookbooks/logging/recipes/default.rb
  150. +19 −0 crowbar/change-image/dell/barclamps/logging/chef/cookbooks/logging/recipes/server.rb
  151. +5 −0 ...r/change-image/dell/barclamps/logging/chef/cookbooks/logging/templates/default/rsyslog.client.erb
  152. +8 −0 ...r/change-image/dell/barclamps/logging/chef/cookbooks/logging/templates/default/rsyslog.server.erb
  153. +27 −0 crowbar/change-image/dell/barclamps/logging/chef/data_bags/crowbar/bc-template-logging.json
  154. +73 −0 crowbar/change-image/dell/barclamps/logging/chef/data_bags/crowbar/bc-template-logging.schema
  155. +9 −0 crowbar/change-image/dell/barclamps/logging/chef/roles/logging-client.rb
  156. +9 −0 crowbar/change-image/dell/barclamps/logging/chef/roles/logging-server.rb
  157. +6 −0 crowbar/change-image/dell/barclamps/logging/command_line/crowbar_logging
  158. +5 −0 crowbar/change-image/dell/barclamps/logging/debian/changelog.tmpl
  159. +1 −0 crowbar/change-image/dell/barclamps/logging/debian/compat
  160. +13 −0 crowbar/change-image/dell/barclamps/logging/debian/control
  161. +26 −0 crowbar/change-image/dell/barclamps/logging/debian/copyright
  162. +53 −0 crowbar/change-image/dell/barclamps/logging/debian/postinst
  163. +8 −0 crowbar/change-image/dell/barclamps/logging/debian/rules
  164. +1 −0 crowbar/change-image/dell/barclamps/logging/debian/source/format
  165. +7 −0 crowbar/change-image/dell/barclamps/logging/version.sh
  166. +30 −0 crowbar/change-image/dell/barclamps/mk_pkg.sh
  167. +21 −0 crowbar/change-image/dell/barclamps/nagios/Makefile
  168. +7 −0 crowbar/change-image/dell/barclamps/nagios/app/controllers/nagios_controller.rb
  169. +78 −0 crowbar/change-image/dell/barclamps/nagios/app/models/nagios_service.rb
  170. +52 −0 crowbar/change-image/dell/barclamps/nagios/barclamp-nagios.spec
  171. +17 −0 crowbar/change-image/dell/barclamps/nagios/build_deb.sh
  172. +34 −0 crowbar/change-image/dell/barclamps/nagios/build_rpm.sh
  173. +195 −0 crowbar/change-image/dell/barclamps/nagios/chef/cookbooks/nagios/README.rdoc
  174. +39 −0 crowbar/change-image/dell/barclamps/nagios/chef/cookbooks/nagios/attributes/client.rb
  175. +56 −0 crowbar/change-image/dell/barclamps/nagios/chef/cookbooks/nagios/attributes/server.rb
  176. +40 −0 crowbar/change-image/dell/barclamps/nagios/chef/cookbooks/nagios/definitions/nagios_conf.rb
  177. BIN crowbar/change-image/dell/barclamps/nagios/chef/cookbooks/nagios/files/default/icons/centos.gd2
  178. BIN crowbar/change-image/dell/barclamps/nagios/chef/cookbooks/nagios/files/default/icons/centos.gif
  179. BIN crowbar/change-image/dell/barclamps/nagios/chef/cookbooks/nagios/files/default/icons/centos.jpg
  180. BIN crowbar/change-image/dell/barclamps/nagios/chef/cookbooks/nagios/files/default/icons/centos.png
  181. BIN crowbar/change-image/dell/barclamps/nagios/chef/cookbooks/nagios/files/default/icons/munin-head.gif
  182. BIN crowbar/change-image/dell/barclamps/nagios/chef/cookbooks/nagios/files/default/icons/ubuntu.gd2
  183. BIN crowbar/change-image/dell/barclamps/nagios/chef/cookbooks/nagios/files/default/icons/ubuntu.gif
  184. BIN crowbar/change-image/dell/barclamps/nagios/chef/cookbooks/nagios/files/default/icons/ubuntu.jpg
  185. BIN crowbar/change-image/dell/barclamps/nagios/chef/cookbooks/nagios/files/default/icons/ubuntu.png
  186. +204 −0 crowbar/change-image/dell/barclamps/nagios/chef/cookbooks/nagios/files/default/plugins/LICENSE.txt
  187. +158 −0 ...ange-image/dell/barclamps/nagios/chef/cookbooks/nagios/files/default/plugins/check-mysql-slave.pl
  188. +98 −0 crowbar/change-image/dell/barclamps/nagios/chef/cookbooks/nagios/files/default/plugins/check_mem.sh
  189. +159 −0 ...ange-image/dell/barclamps/nagios/chef/cookbooks/nagios/files/default/plugins/check_mysqlhealth.pl
  190. +94 −0 .../change-image/dell/barclamps/nagios/chef/cookbooks/nagios/files/default/plugins/check_nova_manage
  191. +222 −0 ...-image/dell/barclamps/nagios/chef/cookbooks/nagios/files/default/plugins/check_rabbitmq_aliveness
  192. +230 −0 ...ge-image/dell/barclamps/nagios/chef/cookbooks/nagios/files/default/plugins/check_rabbitmq_objects
  193. +271 −0 ...e-image/dell/barclamps/nagios/chef/cookbooks/nagios/files/default/plugins/check_rabbitmq_overview
  194. +288 −0 ...nge-image/dell/barclamps/nagios/chef/cookbooks/nagios/files/default/plugins/check_rabbitmq_server
  195. +117 −0 crowbar/change-image/dell/barclamps/nagios/chef/cookbooks/nagios/files/default/plugins/check_solr.rb
  196. +96 −0 crowbar/change-image/dell/barclamps/nagios/chef/cookbooks/nagios/files/default/plugins/db_queues.rb
  197. +84 −0 ...bar/change-image/dell/barclamps/nagios/chef/cookbooks/nagios/files/default/plugins/file_queues.rb
  198. +26 −0 ...r/change-image/dell/barclamps/nagios/chef/cookbooks/nagios/files/default/plugins/nagios_helper.rb
  199. +60 −0 crowbar/change-image/dell/barclamps/nagios/chef/cookbooks/nagios/libraries/default.rb
  200. +48 −0 crowbar/change-image/dell/barclamps/nagios/chef/cookbooks/nagios/metadata.json
  201. +16 −0 crowbar/change-image/dell/barclamps/nagios/chef/cookbooks/nagios/metadata.rb
  202. +107 −0 crowbar/change-image/dell/barclamps/nagios/chef/cookbooks/nagios/recipes/client.rb
  203. +23 −0 crowbar/change-image/dell/barclamps/nagios/chef/cookbooks/nagios/recipes/default.rb
  204. +201 −0 crowbar/change-image/dell/barclamps/nagios/chef/cookbooks/nagios/recipes/server.rb
Sorry, we could not display the entire diff because too many files (1,385) changed.
5 crowbar/.loadpath
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<loadpath>
+ <pathentry path="" type="src"/>
+ <pathentry path="org.rubypeople.rdt.launching.RUBY_CONTAINER" type="con"/>
+</loadpath>
18 crowbar/.project
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>crowbar</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.rubypeople.rdt.core.rubybuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.rubypeople.rdt.core.rubynature</nature>
+ <nature>org.radrails.rails.core.railsnature</nature>
+ </natures>
+</projectDescription>
4 crowbar/CHANGE-LOG
@@ -0,0 +1,4 @@
+
+
+--- Initial Version ----
+
142 crowbar/README.build
@@ -0,0 +1,142 @@
+This file documents how to build the Crowbar installation DVD image.
+
+Prerequisites:
+ * An unfiltered Internet connection and a decent amount of bandwidth.
+ The first time you try to build Crowbar it will need to download
+ about 1.5 gigs worth of data from the official Ubuntu apt repositories,
+ the Opscode chef repository, the official Openstack 2011.2 PPA, and
+ an official Ubuntu CD image mirror.
+ * bash version 4 or higher
+ build_crowbar.sh uses associative arrays, which bash got in version 4.
+ * mkisofs
+ The end product of the build script is an ISO image that will be used
+ to bootstrap the Crowbar admin node.
+ * debootstrap
+ The build process needs to download all the .debs and gems that
+ Crowbar requires, and we don't want to inadvertently mess up the build
+ machine when we do that. All extra packages are downloaded into a
+ chrooted minimal Ubuntu intall, and we use debootstrap to enable that.
+ * Sudo to root privileges for the following commands:
+ * /bin/mount, /bin/umount
+ We have to be able to mount and umount the Ubuntu .iso image, as well as
+ a tmpfs for debootstrap, and we have to be able to bind mount
+ /dev, /dev/pts, /proc, and /sys into the debootstrap chroot environment.
+ * /usr/sbin/debootstrap
+ debootstrap requires root privileges to run.
+ * /bin/cp
+ We need to copy things into and out of the debootstrap environment to
+ ensure it downloads and caches the right packages.
+ * /usr/sbin/chroot
+ All our package caching is done in a chroot environment, and chroot
+ requires root permissions to run.
+
+ If you want to allow build_crowbar to run the above commands as root
+ without having to enter a password each time, the build_crowbar.sh
+ includes a sample line you can fix up and add to /etc/sudoers.
+ * A working Sledgehammer tftpboot image.
+ Sledgehammer is a minimal CentOS 5.6 pxe bootable image that we use
+ to perform hardware discovery and configuration for devices that do not
+ have low-level management tools for Ubuntu. You can find information on
+ how to build Sledgehamemr by reading its HOWTO.Non.Redhat file. We do
+ not do fully automated builds of Sledgehammer due to a lack of a CentOS
+ equivalent of debootstrap.
+
+Usage:
+ * Run build_crowbar.sh.
+ The first time it is run, it will download and cache all the files it
+ needs from the official Ubuntu, Chef, and Openstack repositories. It will
+ then build the Crowbar installation image, save it to the current
+ working directory, and print out a message saying where it saved the image.
+ On subsequent runs it will run with the files it cached from the first
+ run, unless update-cache is passed as a parameter to the script.
+
+Customization:
+
+ build_crowbar.sh has several different parameters you can tune, either from
+ $HOME/.build-crowbar.conf (for developer use), or from build-crowbar.conf
+ in the current directory (for automated builds).
+
+ Here are the parameters you can change through the above configuration files:
+ * DEBUG
+ If DEBUG is set to anything, build_crowbar will run in debug mode, and will
+ print a transcript of everything it is doing to standard error.
+ * CACHE_DIR
+ This is the default location where build_crowbar.sh will keep the files
+ it caches, along with the temporary directories used to mount the
+ ISO image, the debootstrap chroot, and the directory we perform the build
+ in. It defaults to $HOME/.crowbar-build-cache.
+ * ISO_LIBRARY
+ This is the default location where the Ubuntu .iso is stored. It defaults
+ to $CACHE_DIR/iso
+ * ISO_DEST
+ This is the location that we will save the Crowbar install iamge to.
+ It defaults to the current directory.
+ * IMAGE_DIR
+ This is the location that we will mount isos in.
+ It defaults to $CACHE_DIR/image
+ * BUILD_DIR
+ This is the directory we will stage the Crowbar build into.
+ It defaults to $CACHE_DIR/build
+ * UBUNTU_VERSION
+ This is the numeric version of Ubuntu we are building Crowbar with.
+ Right now we base the build on 10.10
+ * UBUNTU_CODENAME
+ This is the one-word codename of $UBUNTU_VERSION. Weird things will
+ happen if it is not kept in sync with $UBUNTU_VERSION
+ * PPAS
+ This is an array of PPA archives to look in to gather packages from.
+ This defaults to ("openstack-release/2011.2"), which is the official
+ PPA for the Cactus release of Openstack.
+ * UBUNTU_ISO_MIRROR
+ This is the base URL for the mirror we will try to download the
+ Ubuntu server ISO from. It defaults to "http://mirror.anl.gov/pub".
+ * SLEDGEHAMMER_PXE_DIR
+ This points to the location we expect to find the unpacked Sledgehammer
+ PXE boot archive. It defaults to $CACHE_DIR/tftpboot
+ * VERSION
+ The default version of Crowbar. Defaults to dev.
+ * OPENSTACK_ISO
+ The name of the ISO that build_crowbar.sh generates.
+ Defaults to openstack-$VERSION.iso
+ * CROWBAR_DIR
+ The directory that the Crowbar source is cheched out to.
+ Defaults to the directory that build_crowbar.sh is in.
+ * SLEDGEHAMMER_DIR
+ The directory that the Sledgehammer source is checked out to.
+ Defaults to $CROWBAR_DIR/../sledgehammer
+ * VCS_CLEAN_CMD
+ This is the command that build_crowbar.sh will run to clean the tree before
+ staging the Crowbar build.
+ Defaults to 'git clean -f -x -d'
+ * DEBS
+ This is an array of additional packages that build_crowbar.sh will try
+ to populate the .deb cache with. It is empty by default.
+ * GEMS
+ This is an array of additional Ruby gems that build_crowbar will try to
+ populate its .gem cache with. It is empty by default.
+ * AMIS
+ This is an array of urls for AMI images that you want to prepopulate
+ Crowbar with. By default it contains the URL for the official release
+ AMI of Ubuntu 11.04 x86_64 server.
+ * UBUNTU_CHROOT
+ This is the directory that we will mount a tmpfs on when we debootstrap
+ a minimal Ubuntu install to prepopulate the deb and gem caches.
+ It defaults to $CACHE_DIR/$UBUNTU_CODENAME.chroot
+ * DEB_CACHE
+ This is the directory that will hold our .deb cache.
+ It defaults to $CACHE_DIR/$UBUNTU_CODENAME/debs
+ * GEM_CACHE
+ This is the directory that will hold our gem cache.
+ It defaults to $CACHE_DIR/gems
+ * AMI_CACHE
+ This is the directory that will hold our AMI cache.
+ It defaults to $CACHE_DIR/amis
+ * UBUNTU_ISO
+ This is the full name of the Ubuntu ISO we will use as the base of the
+ Crowbar installation image.
+ Defaults to "ubuntu-$UBUNTU_VERSION-server-amd64.iso", which will
+ base us on the amd64 server spin of Ubuntu.
+ * UBUNTU_DIR
+ This is the directory we will mount $UBUNTU_ISO on when we extract files
+ from it.
+ Defaults to $IMAGE_DIR/$UBUNTU_ISO minus the .iso at the end.
453 crowbar/build_crowbar.sh
@@ -0,0 +1,453 @@
+#!/bin/bash
+# Copyright 2011, Dell
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# Author: VictorLowther
+#
+
+# This script expects to be able to run certian commands as root.
+# Either run it as a user who can sudo to root, or give the user
+# you are running it as the following sudo rights:
+# crowbar-tester ALL = NOPASSWD: /bin/mount, /bin/umount, /usr/sbin/debootstrap, /bin/cp, /usr/sbin/chroot
+
+# When running this script for the first time, it will automatically create a
+# cache directory and try to populate it with all the build dependencies.
+# After that, if you need to pull in new dependencies, you will need to
+# call the script with the update-cache parameter.
+
+[[ $DEBUG ]] && {
+ set -x
+ export PS4='(${nodename:-none})${BASH_SOURCE}@${LINENO}(${FUNCNAME[0]}): '
+}
+
+export PATH="$PATH:/sbin:/usr/sbin:/usr/local/sbin"
+
+# Location for caches that should not be erased between runs
+CACHE_DIR="$HOME/.crowbar-build-cache"
+
+# Location to store .iso images
+ISO_LIBRARY="$CACHE_DIR/iso"
+ISO_DEST="$PWD"
+
+# Location that holds temporary mount images of our.isos
+# if we need to extract them onto our target image.
+IMAGE_DIR="$CACHE_DIR/image"
+
+# Location we will stage the new openstack iso at.
+BUILD_DIR="$CACHE_DIR/build"
+
+# Version of Ubuntu we are building openstack on to.
+UBUNTU_VERSION=10.10
+UBUNTU_CODENAME=maverick
+PPAS=("openstack-release/2011.2")
+
+# Server to download the mirror from if we need to.
+UBUNTU_ISO_MIRROR="http://mirror.anl.gov/pub"
+
+# Directory that holds our Sledgehammer PXE tree.
+SLEDGEHAMMER_PXE_DIR="$CACHE_DIR/tftpboot"
+
+# Version for ISO
+VERSION="dev"
+
+# Name of the openstack iso we will build
+OPENSTACK_ISO="openstack-${VERSION}.iso"
+
+# Location of the Crowbar checkout we are building from.
+CROWBAR_DIR="${0%/*}"
+SLEDGEHAMMER_DIR="${CROWBAR_DIR}/../sledgehammer"
+VCS_CLEAN_CMD='git clean -f -x -d'
+
+# Arrays holding the additional debs, gems, and AMI images we will populate
+# Crowbar with.
+DEBS=()
+GEMS=()
+AMIS=("http://uec-images.ubuntu.com/releases/11.04/release/ubuntu-11.04-server-uec-amd64.tar.gz")
+
+
+die() { shift; echo "$(date '+%F %T %z'): $*" >&2; exit 1; }
+debug() { echo "$(date '+%F %T %z'): $*" >&2; }
+clean_dirs() {
+ local d=''
+ for d in "$@"; do
+ ( mkdir -p "$d"
+ cd "$d"
+ chmod -R u+w .
+ rm -rf * )
+ done
+}
+
+update_caches() {
+ # Hold a list of directories we will need to umount
+ TO_UMOUNT=()
+
+ # Make sure our cache directories exist.
+ mkdir -p "$DEB_CACHE"
+ mkdir -p "$GEM_CACHE"
+
+ # A little helper function for doing bind mounts.
+ bind_mount() {
+ TO_UMOUNT=("${TO_UMOUNT[@]}" "$2")
+ [[ -d $2 ]] || mkdir -p "$2"
+ grep -q "$2" /proc/self/mounts || sudo mount --bind "$1" "$2"
+ }
+
+ # A little helper for running commands in the chroot.
+ in_chroot() { sudo -H chroot "$UBUNTU_CHROOT" "$@"; }
+
+ # second, debootstrap a minimal install of our target version of
+ # Ubuntu to ensure that we don't interfere with the host's package cache.
+ debug "Making package-fetching chroot"
+ mkdir -p "$UBUNTU_CHROOT"
+ sudo mount -t tmpfs -o size=1G none "$UBUNTU_CHROOT"
+ sudo debootstrap "$UBUNTU_CODENAME" "$UBUNTU_CHROOT" \
+ "file://$BUILD_DIR" || \
+ die 1 "Could not bootstrap our scratch target!"
+ # mount some important directories for the chroot
+ for d in proc sys dev dev/pts; do
+ bind_mount "/$d" "$UBUNTU_CHROOT/$d"
+ done
+ # make sure the chroot can resolve hostnames
+ sudo cp /etc/resolv.conf "$UBUNTU_CHROOT/etc/resolv.conf"
+
+ # Make sure we are using a correctly prepopulated sources.list.
+ sudo cp "$BUILD_DIR/extra/sources.list" \
+ "$UBUNTU_CHROOT/etc/apt/sources.list"
+
+ # if we have deb caches, copy them back in to save time on the downloads.
+ sudo cp -a "$DEB_CACHE/." "$UBUNTU_CHROOT/var/cache/apt/archives/."
+
+ debug "Fetching needed packages"
+ # update, add infrastructure for adding PPAs,
+ # add additional PPAs, and update again.
+ in_chroot /usr/bin/apt-get -y --force-yes --allow-unauthenticated update
+ in_chroot /usr/bin/apt-get -y --force-yes --allow-unauthenticated install \
+ python-software-properties
+ for ppa in "${PPAS[@]}"; do
+ in_chroot apt-add-repository "ppa:$ppa"
+ done
+ # Get the key for the Opscode repo we are grabbing Chef bits from.
+ wget -qO - http://apt.opscode.com/packages@opscode.com.gpg.key | \
+ in_chroot /usr/bin/apt-key add -
+ in_chroot /usr/bin/apt-get -y --force-yes --allow-unauthenticated update
+
+ # Download all the packages apt thinks we will need.
+ in_chroot /usr/bin/apt-get -y --force-yes \
+ --allow-unauthenticated --download-only install "${DEBS[@]}"
+ # actually install ruby1.8-dev and gem and their deps.
+ in_chroot /usr/bin/apt-get -y --force-yes \
+ --allow-unauthenticated install ruby1.8-dev rubygems1.8 build-essential
+ # install the gems we will need and all their dependencies
+ # We will get some build failures, but at this point we don't care because
+ # we are just caching the gems for the real install.
+ debug "Fetching Gems"
+ echo "There may be build failures here, we can safely ignore them."
+ gem_re='([^0-9].*)-([0-9].*)'
+ for gem in "${GEMS[@]}"; do
+ if [[ $gem =~ $gem_re ]]; then
+ echo "${BASH_REMATCH[*]}"
+ gemname="${BASH_REMATCH[1]}"
+ gemver="${BASH_REMATCH[2]}"
+ else
+ gemname="$gem"
+ gemver=''
+ fi
+ gemopts=(install --no-ri --no-rdoc)
+ [[ $gemver ]] && gemopts+=(--version "= ${gemver}")
+ in_chroot /usr/bin/gem "${gemopts[@]}" "$gemname"
+ done
+ debug "Saving downloaded packages"
+ # Save our updated gems and debs in the cache for later.
+ cp -a "$UBUNTU_CHROOT/var/cache/apt/archives/." "$DEB_CACHE/."
+ cp -a "$UBUNTU_CHROOT/var/lib/gems/1.8/cache/." "$GEM_CACHE/."
+ sync
+
+ debug "Cleaning up mounts"
+ # umount all the stuff we have mounted for the chroot.
+ while grep -q "$UBUNTU_CHROOT" /proc/self/mounts; do
+ for m in "${TO_UMOUNT[@]}"; do sudo umount "$m"; sleep 1; done
+ sudo umount "$UBUNTU_CHROOT"
+ done
+}
+
+copy_debs() {
+ # $1 = pool directory to build initial list of excludes against
+ # $2 = directory to copy from
+ # $3 = directory to copy to.
+
+ # First, a couple of hashes to hold deb => revision values
+ declare -A deb_pool
+ declare -A dest_pool
+
+ local debname=''
+ local debarr=()
+ local debs_to_copy=()
+
+
+ # Scan through our pool to find debs we can easily omit.
+ while read debname; do
+ [[ -f $debname && $debname = *.deb ]] || continue
+ debname="${debname##*/}"
+ debarr=(${debname//_/ }) # split into (name version arch)
+ deb_pool["${debarr[0]}"]="${debarr[1]}"
+ done < <(find "$1" -name '*.deb')
+
+ (
+ cd "$2"
+ for deb in *; do
+ [[ -f $deb && $deb = *.deb ]] || continue
+ debname="${deb##*/}" # don't care about the source path
+ debname="${debname%_*.deb}" # don't care about the arch
+ debver="${debname#*_}"
+ debname="${debname%_*}"
+ # First, have we already copied another version of this
+ # deb? If so, decide whether to copy it or not.
+ if [[ ${dest_pool["$debname"]} ]]; then
+ # We have seen it. If the version we already copied
+ # is older than this one, queue this for copying instead.
+ # This relies on * expansion returning names in order.
+ if [[ ${dest_pool["$debname"]} < $debver ]]; then
+ debug "Omitting ${debname}_${dest_pool[$debname]} in favor of ${debname}_${debver}"
+ debs_to_copy[$((${#debs_to_copy[@]} - 1))]="$deb"
+ dest_pool["$debname"]="$debver"
+ fi
+ # Second check and see if it is already inthe install pool.
+ # If it is and it is the same or lesser version, don't copy it
+ elif [[ ${deb_pool["$debname"]} ]]; then
+ if [[ ${deb_pool["$debname"]} < $debver ]]; then
+ debs_to_copy+=("$deb")
+ else
+ debug "${debname}_${debver} in CD pool, omitting"
+ fi
+ else
+ # It is not already in deb_pool or dest_pool, copy it.
+ debs_to_copy+=("$deb")
+ debug "Will copy ${debname}_${debver}"
+ fi
+ done
+ # Now, we have a list of debs to copy, so do it.
+ mkdir -p "$3"
+ cp -t "$3" "${debs_to_copy[@]}"
+ )
+}
+
+maybe_update_cache() {
+ local pkgfile deb gem pkg_type rest need_update _pwd
+ debug "Processing package lists"
+ # Zero out our sources.list
+ > "$BUILD_DIR/extra/sources.list"
+ # Download and stash any extra files we may need
+ # First, build our list of repos, ppas, debs, and gems
+ for pkgfile in "$BUILD_DIR/extra/packages/"*.list; do
+ [[ -f $pkgfile ]] || continue
+ while read pkg_type rest; do
+ case $pkg_type in
+ repository)
+ echo "${rest%%#*}" >> "$BUILD_DIR/extra/sources.list";;
+ ppas) PPAS+=(${rest%%#*});;
+ debs) DEBS+=(${rest%%#*});;
+ gems) GEMS+=(${rest%%#*});;
+ esac
+ done <"$pkgfile"
+ done
+
+ _pwd=$PWD
+ cd "$DEB_CACHE"
+ # second, verify that the debs we need are in the cache.
+ for deb in "${DEBS[@]}"; do
+ [[ $(echo "$deb"*.deb) != "$deb*.deb" ]] || {
+ need_update=true
+ break
+ }
+ done
+
+ cd "$GEM_CACHE"
+ # third, verify that the gems we need are in the cache
+ for gem in "${GEMS[@]}"; do
+ [[ $(echo "$gem"*.gem) != "$gem*.gem" ]] || {
+ need_update=true
+ break
+ }
+ done
+ cd "$_pwd"
+
+ if [[ $need_update = true || \
+ ( ! -d $DEB_CACHE ) || $* =~ update-cache ]]; then
+ update_caches
+ else
+ return 0
+ fi
+}
+
+for cmd in sudo chroot debootstrap mkisofs; do
+ which "$cmd" &>/dev/null || \
+ die 1 "Please install $cmd before trying to build Crowbar."
+done
+
+{
+ # Make sure only one instance of the ISO build runs at a time.
+ # Otherwise you can easily end up with a corrupted image.
+ flock 65
+
+ # Source our config file if we have one
+ [[ -f $HOME/.build-crowbar.conf ]] && \
+ . "$HOME/.build-crowbar.conf"
+
+ # Look for a local one.
+ [[ -f build-crowbar.conf ]] && \
+ . "build-crowbar.conf"
+
+ # Finalize where we expect to find our caches and out chroot.
+ # If they were set in one of the conf files, don't touch them.
+
+ # The directory we perform a minimal install of Ubuntu into if we need
+ # to refresh our gem or deb caches
+ [[ $UBUNTU_CHROOT ]] || UBUNTU_CHROOT="$CACHE_DIR/$UBUNTU_CODENAME.chroot"
+
+ # Directories where we cache our debs, gems, and ami files
+ [[ $DEB_CACHE ]] || DEB_CACHE="$CACHE_DIR/$UBUNTU_CODENAME/debs"
+ [[ $GEM_CACHE ]] || GEM_CACHE="$CACHE_DIR/gems"
+ [[ $AMI_CACHE ]] || AMI_CACHE="$CACHE_DIR/amis"
+
+ # The name of the Ubuntu iso we are using as a base.
+ [[ $UBUNTU_ISO ]] || UBUNTU_ISO="ubuntu-$UBUNTU_VERSION-server-amd64.iso"
+
+ # directory we will mount the Ubuntu .iso on to extract packages.
+ [[ $UBUNTU_DIR ]] || UBUNTU_DIR="$IMAGE_DIR/${UBUNTU_ISO%.iso}"
+
+
+ # Make any directories we don't already have
+ for d in "$ISO_LIBRARY" "$ISO_DEST" "$IMAGE_DIR" "$BUILD_DIR" "$AMI_CACHE" \
+ "$SLEDGEHAMMER_PXE_DIR" "$UBUNTU_CHROOT"; do
+ mkdir -p "$d"
+ done
+
+ # Make sure Sledgehammer has already been built and pre-staged.
+ if ! [[ -f $SLEDGEHAMMER_DIR/bin/sledgehammer-tftpboot.tar.gz || \
+ -f $SLEDGEHAMMER_PXE_DIR/initrd0.img ]]; then
+ echo "Slegehammer TFTP image missing!"
+ echo "Please build Sledgehammer from $SLEDGEHAMMER_DIR before buildin gCrowbar."
+ exit 1
+ fi
+
+ # make sure we have the AMIs we want
+ for ami in "${AMIS[@]}"; do
+ [[ -f $AMI_CACHE/${ami##*/} ]] && continue
+ echo "$(date '+%F %T %z'): Downloading and caching $ami"
+ curl -o "$AMI_CACHE/${ami##*/}" "$ami" || \
+ die 1 "Could not download $ami"
+ done
+
+ # Try and download our ISO if we don't already have it
+ [[ -f $ISO_LIBRARY/$UBUNTU_ISO ]] || {
+ echo "$(date '+%F %T %z'): Downloading and caching $UBUNTU_ISO"
+ curl -o "$ISO_LIBRARY/$UBUNTU_ISO" \
+ "$UBUNTU_ISO_MIRROR/ubuntu-iso/CDs/$UBUNTU_VERSION/$UBUNTU_ISO" || \
+ die 1 "Missing our Ubuntu source image"
+ }
+
+ # Start with a clean slate.
+ clean_dirs "$UBUNTU_DIR" "$BUILD_DIR"
+
+ (cd "$CROWBAR_DIR"; $VCS_CLEAN_CMD)
+ # Copy everything off the Ubuntu ISO to our build directory
+ debug "Copying Ubuntu off $UBUNTU_ISO"
+ sudo mount -t iso9660 -o loop "$ISO_LIBRARY/$UBUNTU_ISO" "$UBUNTU_DIR" || \
+ die "Could not mount $UBUNTU_ISO"
+ cp -rT "$UBUNTU_DIR" "$BUILD_DIR"
+ sudo umount -d "$UBUNTU_DIR"
+
+ # Make everything writable again.
+ chmod -R u+w "$BUILD_DIR"
+
+ # Make additional directories we will need.
+ for d in discovery extra ami updates ; do
+ mkdir -p "$BUILD_DIR/$d"
+ done
+
+ # Copy over the Crowbar bits and their prerequisites
+ debug "Staging extra Crowbar bits"
+ cp -r "$CROWBAR_DIR/ubuntu-$UBUNTU_VERSION-extra"/* "$BUILD_DIR/extra"
+ cp -r "$CROWBAR_DIR/change-image"/* "$BUILD_DIR"
+
+ # If we were asked to update our cache, do it.
+ maybe_update_cache "$@"
+
+ # Copy our extra debs, gems, and amis over
+ debug "Copying debs, gems, and amis"
+ copy_debs "$BUILD_DIR/pool" "$DEB_CACHE" "$BUILD_DIR/extra/debs"
+ cp -r "$GEM_CACHE" "$BUILD_DIR/extra"
+ cp -r "$AMI_CACHE/." "$BUILD_DIR/ami/."
+
+ # Make our new packages repository.
+ ( cd "$BUILD_DIR/extra"
+ debug "Recreating Packages.gz"
+ dpkg-scanpackages debs /dev/null 2>/dev/null |gzip -9 >Packages.gz)
+ # Store off the version
+ echo "$VERSION" >> "$BUILD_DIR/dell/Version"
+
+ # Fix up the initrd
+ ( cd "$CROWBAR_DIR/initrd"
+ debug "Fixing up initrd"
+ [[ -d scratch ]] && rm -rf scratch
+ mkdir scratch
+ # Grab _all_ the nic drivers. We probably don't need them,
+ # but a little paranoia never hurt anyone.
+ ( cd scratch;
+ debug "Adding all nic drivers"
+ for udeb in "$BUILD_DIR/pool/main/l/linux/"nic-*-generic-*.udeb; do
+ ar x "$udeb"
+ tar xzf data.tar.gz
+ rm -rf debian-binary *.tar.gz
+ done
+ # Make sure installing off a USB connected DVD will work
+ debug "Adding USB connected DVD support"
+ mkdir -p var/lib/dpkg/info
+ cp ../cdrom-detect.postinst var/lib/dpkg/info
+ # Append our new gzipped CPIO archive onto the old one.
+ find . |cpio --create --format=newc --owner root:root 2>/dev/null | \
+ gzip -9 >> "$BUILD_DIR/install/initrd.gz" )
+ rm -rf scratch )
+
+ # Copy over the Sledgehammer bits
+ debug "Copying over Sledgehammer bits"
+ for d in "$CROWBAR_DIR/"updates*; do
+ [[ -d $d ]] || continue
+ cp -r "$d"/* "$BUILD_DIR/updates"
+ done
+ # If we need to copy over a new Sledgehammer image, do so.
+ if [[ $SLEDGEHAMMER_DIR/bin/sledgehammer-tftpboot.tar.gz -nt \
+ $SLEDGEHAMMER_PXE_DIR/initrd0.img ]]; then
+ ( cd $SLEDGEHAMMER_PXE_DIR
+ debug "Extracting new Sledgehammer TFTP boot image"
+ rm -rf .
+ cd ..
+ tar xzf "$SLEDGEHAMMER_DIR/bin/sledgehammer-tftpboot.tar.gz"
+ rm -f "$SLEDGEHAMMER_DIR/bin/sledgehammer-tftpboot.tar.gz"
+ )
+ fi
+ cp -a "$SLEDGEHAMMER_PXE_DIR"/* "$BUILD_DIR/discovery"
+
+ # Make our image
+ debug "Creating new ISO"
+ ( cd "$BUILD_DIR"
+ find -name '.svn' -type d -exec rm -rf '{}' ';' 2>/dev/null >/dev/null
+ mkdir -p $ISO_DEST
+ mkisofs -r -V "Crowbar $VERSION DVD" -cache-inodes -J -l -quiet \
+ -b isolinux/isolinux.bin -c isolinux/boot.cat \
+ -no-emul-boot --boot-load-size 4 -boot-info-table \
+ -o "$ISO_DEST/$OPENSTACK_ISO" "$BUILD_DIR" ) || \
+ die 1 "There was a problem building our ISO."
+ echo "$(date '+%F %T %z'): Finshed. Image at $ISO_DEST/$OPENSTACK_ISO"
+} 65> /tmp/.build_crowbar.lock
BIN crowbar/change-image/dell/PC6200v3.2.0.7.stk
Binary file not shown.
1 crowbar/change-image/dell/apt.conf
@@ -0,0 +1 @@
+APT::Get::AllowUnauthenticated 1 ;
444 crowbar/change-image/dell/barclamp_lib.rb
@@ -0,0 +1,444 @@
+
+require 'rubygems'
+require 'net/http'
+require 'net/http/digest_auth'
+require 'uri'
+require 'json'
+require 'getoptlong'
+
+@debug = false
+@hostname = ENV["CROWBAR_IP"]
+# DO NOT CHANGE THE NEXT 2 LINES
+# gather_cli replies on the exact format they are in.
+@hostname = "127.0.0.1" unless @hostname
+@port = 3000
+@headers = {
+ "Accept" => "application/json",
+ "Content-Type" => "application/json"
+}
+@data = ""
+@allow_zero_args = false
+@timeout = 500
+@key = ENV["CROWBAR_KEY"]
+if @key
+ @username=@key.split(':',2)[0]
+ @password=@key.split(':',2)[1]
+end
+
+#
+# Parsing options can be added by adding to this list before calling opt_parse
+#
+@options = [
+ [ [ '--help', '-h', GetoptLong::NO_ARGUMENT ], "--help or -h - help" ],
+ [ [ '--username', '-U', GetoptLong::REQUIRED_ARGUMENT ], "--username <username> or -U <username> - specifies the username" ],
+ [ [ '--password', '-P', GetoptLong::REQUIRED_ARGUMENT ], "--password <password> or -P <password> - specifies the password" ],
+ [ [ '--hostname', '-n', GetoptLong::REQUIRED_ARGUMENT ], "--hostname <name or ip> or -n <name or ip> - specifies the destination server" ],
+ [ [ '--port', '-p', GetoptLong::REQUIRED_ARGUMENT ], "--port <port> or -p <port> - specifies the destination server port" ],
+ [ [ '--debug', '-d', GetoptLong::NO_ARGUMENT ], "--debug or -d - turns on debugging information" ],
+ [ [ '--data', GetoptLong::REQUIRED_ARGUMENT ], "--data <data> - used by create or edit as data (must be in json format)" ],
+ [ [ '--file', GetoptLong::REQUIRED_ARGUMENT ], "--file <file> - used by create or edit as data when read from a file (must be in json format)" ],
+ [ [ '--timeout', GetoptLong::REQUIRED_ARGUMENT ], "--timeout <seconds> - timeout in seconds for read http reads" ]
+]
+
+#
+# New commands can be added by adding to this list before calling run_command
+#
+# Proposal is an example of running sub-commands
+#
+@proposal_commands = {
+ "list" => [ "proposal_list", "list - show a list of current proposals" ],
+ "create" => [ "proposal_create ARGV.shift", "create <name> - create a proposal" ],
+ "show" => [ "proposal_show ARGV.shift", "show <name> - show a specific proposal" ],
+ "edit" => [ "proposal_edit ARGV.shift", "edit <name> - edit a new proposal" ],
+ "delete" => [ "proposal_delete ARGV.shift", "delete <name> - delete a proposal" ],
+ "commit" => [ "proposal_commit ARGV.shift", "commit <name> - Commit a proposal to active" ],
+ "dequeue" => [ "proposal_dequeue ARGV.shift", "dequeue <name> - Dequeue a proposal to active" ]
+}
+
+@commands = {
+ "help" => [ "help", "help - this page" ],
+ "api_help" => [ "api_help", "crowbar API help - help for this barclamp." ],
+ "list" => [ "list", "list - show a list of current configs" ],
+ "show" => [ "show ARGV.shift", "show <name> - show a specific config" ],
+ "delete" => [ "delete ARGV.shift", "delete <name> - delete a config" ],
+ "proposal" => [ "run_sub_command(@proposal_commands, ARGV.shift)", "proposal - Proposal sub-commands", @proposal_commands ],
+ "elements" => [ "elements", "elements - List elements of a #{@barclamp} deploy" ],
+ "element_node" => [ "element_node ARGV.shift", "element_node <name> - List nodes that could be that element" ],
+ "transition" => [ "transition(ARGV.shift,ARGV.shift)", "transition <name> <state> - Transition machine named name to state" ]
+}
+
+
+def print_commands(cmds, spacer = " ")
+ cmds.each do |key, command|
+ puts "#{spacer}#{command[1]}"
+ print_commands(command[2], " #{spacer}") if command[0] =~ /run_sub_command\(/
+ end
+end
+
+def usage (rc)
+ puts "Usage: crowbar #{@barclamp} [options] <subcommands>"
+ @options.each do |options|
+ puts " #{options[1]}"
+ end
+ print_commands(@commands)
+ exit rc
+end
+
+def help
+ usage 0
+end
+
+def authenticate(req,uri,data=nil)
+ uri.user=@username
+ uri.password=@password
+ res=nil
+ Net::HTTP.start(uri.host, uri.port) {|http|
+ http.read_timeout = @timeout
+ r = req.new(uri.request_uri,@headers)
+ r.body = data if data
+ res = http.request r
+ puts "DEBUG: (a) return code: #{res.code}" if @debug
+ puts "DEBUG: (a) return body: #{res.body}" if @debug
+ puts "DEBUG: (a) return headers: #{res.headers}" if @debug
+ if res['www-authenticate']
+ digest_auth=Net::HTTP::DigestAuth.new
+ auth=Net::HTTP::DigestAuth.new.auth_header(uri,
+ res['www-authenticate'],
+ req::METHOD)
+ r.add_field 'Authorization', auth
+ res = http.request r
+ end
+ }
+ res
+end
+
+def get_json(path)
+ uri = URI.parse("http://#{@hostname}:#{@port}/crowbar/#{@barclamp}/1.0#{path}")
+ res = authenticate(Net::HTTP::Get,uri)
+
+ puts "DEBUG: (g) hostname: #{uri.host}:#{uri.port}" if @debug
+ puts "DEBUG: (g) request: #{uri.path}" if @debug
+ puts "DEBUG: (g) return code: #{res.code}" if @debug
+ puts "DEBUG: (g) return body: #{res.body}" if @debug
+
+ return [res.body, res.code.to_i ] if res.code.to_i != 200
+
+ struct = JSON.parse(res.body)
+
+ puts "DEBUG: (g) JSON parse structure = #{struct.inspect}" if @debug
+
+ return [struct, 200]
+end
+
+def post_json(path, data)
+ uri = URI.parse("http://#{@hostname}:#{@port}/crowbar/#{@barclamp}/1.0#{path}")
+ res = authenticate(Net::HTTP::Post,uri,data)
+
+ puts "DEBUG: (post) hostname: #{uri.host}:#{uri.port}" if @debug
+ puts "DEBUG: (post) request: #{uri.path}" if @debug
+ puts "DEBUG: (post) data: #{@data}" if @debug
+ puts "DEBUG: (post) return code: #{res.code}" if @debug
+ puts "DEBUG: (post) return body: #{res.body}" if @debug
+
+ [res.body, res.code.to_i ]
+end
+
+def put_json(path, data)
+ uri = URI.parse("http://#{@hostname}:#{@port}/crowbar/#{@barclamp}/1.0#{path}")
+ res = authenticate(Net::HTTP::Put,uri,data)
+
+ puts "DEBUG: (put) hostname: #{uri.host}:#{uri.port}" if @debug
+ puts "DEBUG: (put) request: #{uri.path}" if @debug
+ puts "DEBUG: (put) data: #{@data}" if @debug
+ puts "DEBUG: (put) return code: #{res.code}" if @debug
+ puts "DEBUG: (put) return body: #{res.body}" if @debug
+
+ [res.body, res.code.to_i ]
+end
+
+def delete_json(path)
+ uri = URI.parse("http://#{@hostname}:#{@port}/crowbar/#{@barclamp}/1.0#{path}")
+ res = authenticate(Net::HTTP::Delete,uri)
+
+ puts "DEBUG: (d) hostname: #{uri.host}:#{uri.port}" if @debug
+ puts "DEBUG: (d) request: #{uri.path}" if @debug
+ puts "DEBUG: (d) return code: #{res.code}" if @debug
+ puts "DEBUG: (d) return body: #{res.body}" if @debug
+
+ [res.body, res.code.to_i ]
+end
+
+
+def list
+ struct = get_json("/")
+
+ if struct[1] != 200
+ [ "Failed to talk to service list: #{struct[1]}: #{struct[0]}", 1 ]
+ elsif struct[0].nil? or struct[0].empty?
+ [ "No current configurations", 0 ]
+ else
+ out = ""
+ struct[0].each do |name|
+ out = out + "\n" if out != ""
+ out = out + "#{name}"
+ end
+ [ out, 0 ]
+ end
+end
+
+def api_help
+ struct=get_json("/help")
+ if struct[1] != 200
+ [ "Failed to talk to service list: #{struct[1]}: #{struct[0]}", 1 ]
+ elsif struct[0].nil? or struct[0].empty?
+ [ "No help", 0 ]
+ else
+ [ jj(struct[0]), 0 ]
+ end
+end
+
+def show(name)
+ usage -1 if name.nil? or name == ""
+
+ struct = get_json("/#{name}")
+
+ if struct[1] == 200
+ [ "#{JSON.pretty_generate(struct[0])}", 0 ]
+ elsif struct[1] == 404
+ [ "No current configuration for #{name}", 1 ]
+ else
+ [ "Failed to talk to service show: #{struct[1]}: #{struct[0]}", 1 ]
+ end
+end
+
+def delete(name)
+ usage -1 if name.nil? or name == ""
+
+ struct = delete_json("/#{name}")
+
+ if struct[1] == 200
+ [ "Deleted #{name}", 0 ]
+ elsif struct[1] == 404
+ [ "Delete failed for #{name}: Not Found", 1 ]
+ else
+ [ "Failed to talk to service delete: #{struct[1]}: #{struct[0]}", 1 ]
+ end
+end
+
+def proposal_list
+ struct = get_json("/proposals/")
+
+ if struct[1] != 200
+ [ "Failed to talk to service proposal list: #{struct[1]}: #{struct[0]}", 1 ]
+ elsif struct[0].nil? or struct[0].empty?
+ [ "No current proposals", 0 ]
+ else
+ out = ""
+ struct[0].each do |name|
+ out = out + "\n" if out != ""
+ out = out + "#{name}"
+ end
+ [ out, 0 ]
+ end
+end
+
+def proposal_show(name)
+ usage -1 if name.nil? or name == ""
+
+ struct = get_json("/proposals/#{name}")
+
+ if struct[1] == 200
+ [ "#{JSON.pretty_generate(struct[0])}", 0 ]
+ elsif struct[1] == 404
+ [ "No current proposal for #{name}", 1 ]
+ else
+ [ "Failed to talk to service proposal show: #{struct[1]}: #{struct[0]}", 1 ]
+ end
+end
+
+def proposal_create(name)
+ usage -1 if name.nil? or name == ""
+
+ @data = "{\"id\":\"#{name}\"}" if @data.nil? or @data == ""
+
+ struct = put_json("/proposals", @data)
+
+ if struct[1] == 200
+ [ "Created #{name}", 0 ]
+ else
+ [ "Failed to talk to service proposal create: #{struct[1]}: #{struct[0]}", 1]
+ end
+end
+
+def proposal_edit(name)
+ usage -1 if name.nil? or name == ""
+
+ struct = post_json("/proposals/#{name}", @data)
+
+ if struct[1] == 200
+ [ "Edited #{name}", 0 ]
+ elsif struct[1] == 404
+ [ "Failed to edit: #{name} : Not Found", 1 ]
+ elsif struct[1] == 400
+ [ "Failed to edit: #{name} : Errors in data\n#{struct[0]}", 1 ]
+ else
+ [ "Failed to talk to service proposal edit: #{struct[1]}: #{struct[0]}", 1 ]
+ end
+end
+
+def proposal_delete(name)
+ usage -1 if name.nil? or name == ""
+
+ struct = delete_json("/proposals/#{name}")
+
+ if struct[1] == 200
+ [ "Deleted #{name}", 0 ]
+ elsif struct[1] == 404
+ [ "Delete failed for #{name}: Not Found", 1 ]
+ else
+ [ "Failed to talk to service delete: #{struct[1]}: #{struct[0]}", 1 ]
+ end
+end
+
+def proposal_commit(name)
+ usage -1 if name.nil? or name == ""
+
+ struct = post_json("/proposals/commit/#{name}", @data)
+
+ if struct[1] == 200
+ [ "Committed #{name}", 0 ]
+ elsif struct[1] == 202
+ [ "Queued #{name} because #{struct[0]}", 0 ]
+ else
+ [ "Failed to talk to service proposal commit: #{struct[1]}: #{struct[0]}", 1 ]
+ end
+end
+
+def proposal_dequeue(name)
+ usage -1 if name.nil? or name == ""
+
+ struct = post_json("/proposals/dequeue/#{name}", @data)
+
+ if struct[1] == 200
+ [ "Dequeued #{name}", 0 ]
+ else
+ [ "Failed to talk to service proposal dequeue: #{struct[1]}: #{struct[0]}", 1 ]
+ end
+end
+
+def elements
+ struct = get_json("/elements")
+
+ if struct[1] != 200
+ [ "Failed to talk to service elements: #{struct[1]}: #{struct[0]}", 1 ]
+ elsif struct[0].nil? or struct[0].empty?
+ [ "No current elements", 1 ]
+ else
+ out = ""
+ struct[0].each do |name|
+ out = out + "\n" if out != ""
+ out = out + "#{name}"
+ end
+ [ out, 0 ]
+ end
+end
+
+def element_node(element)
+ usage -1 if element.nil? or element == ""
+
+ struct = get_json("/elements/#{element}")
+
+ if struct[1] != 200
+ [ "Failed to talk to service element_node: #{struct[1]}: #{struct[0]}", 1 ]
+ elsif struct[0].nil? or struct[0].empty?
+ [ "No nodes for #{element}", 1 ]
+ else
+ out = ""
+ struct[0].each do |name|
+ out = out + "\n" if out != ""
+ out = out + "#{name}"
+ end
+ [ out, 0 ]
+ end
+end
+
+def transition(name, state)
+ usage -1 if name.nil? or name == ""
+
+ data = {
+ "name" => name,
+ "state" => state
+ }
+ struct = post_json("/transition/default", data.to_json)
+
+ if struct[1] == 200
+ [ "Transitioned #{name}", 0 ]
+ else
+ [ "Failed to talk to service transition: #{struct[1]}: #{struct[0]}", 1 ]
+ end
+end
+
+
+
+### Start MAIN ###
+
+def opt_parse()
+ sub_options = @options.map { |x| x[0] }
+ lsub_options = @options.map { |x| [ x[0][0], x[2] ] }
+ opts = GetoptLong.new(*sub_options)
+
+ opts.each do |opt, arg|
+ case opt
+ when '--help'
+ usage 0
+ when '--debug'
+ @debug = true
+ when '--hostname'
+ @hostname = arg
+ when '--username'
+ @username = arg
+ when '--password'
+ @password = arg
+ when '--port'
+ @port = arg.to_i
+ when '--data'
+ @data = arg
+ when '--timeout'
+ @timeout = arg
+ when '--file'
+ @data = File.read(arg)
+ else
+ found = false
+ lsub_options.each do |x|
+ next if x[0] != opt
+ eval x[1]
+ found = true
+ end
+ usage -1 unless found
+ end
+ end
+
+ if ARGV.length == 0 and !@allow_zero_args
+ usage -1
+ end
+
+ STDERR.puts "CROWBAR_KEY not set, will not be able to authenticate!" if @username.nil? or @password.nil?
+ STDERR.puts "Please set CROWBAR_KEY or use -U and -P" if @username.nil? or @password.nil?
+end
+
+def run_sub_command(cmds, subcmd)
+ cmd = cmds[subcmd]
+ usage -2 if cmd.nil?
+ eval cmd[0]
+end
+
+def run_command()
+ run_sub_command(@commands, ARGV.shift)
+end
+
+def main()
+ opt_parse
+ res = run_command
+ puts res[0]
+ exit res[1]
+end
21 crowbar/change-image/dell/barclamps/crowbar/Makefile
@@ -0,0 +1,21 @@
+
+clean:
+ @echo "Cleaning barclamp-crowbar"
+
+distclean:
+ @echo "Dist-Cleaning barclamp-crowbar"
+
+all: clean build install
+
+build:
+ @echo "Building barclamp-crowbar"
+
+install:
+ @echo "Installing barclamp-crowbar"
+ mkdir -p ${DESTDIR}/opt/crowbar/openstack_manager
+ cp -r app ${DESTDIR}/opt/crowbar/openstack_manager
+ mkdir -p ${DESTDIR}/usr/share/barclamp-crowbar
+ cp -r chef ${DESTDIR}/usr/share/barclamp-crowbar
+ mkdir -p ${DESTDIR}/usr/bin
+ cp -r command_line/* ${DESTDIR}/usr/bin
+
21 crowbar/change-image/dell/barclamps/crowbar/app/controllers/crowbar_controller.rb
@@ -0,0 +1,21 @@
+# Copyright 2011, Dell
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+class CrowbarController < BarclampController
+ def initialize
+ @service_object = CrowbarService.new(logger)
+ end
+end
+
203 crowbar/change-image/dell/barclamps/crowbar/app/models/crowbar_service.rb
@@ -0,0 +1,203 @@
+# Copyright 2011, Dell
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+class CrowbarService < ServiceObject
+
+ def initialize(thelogger)
+ @bc_name = "crowbar"
+ @logger = thelogger
+ end
+
+ #
+ # Below are the parts to handle transition requests.
+ #
+ # This routine handles name-based state transitions. The system will then inform barclamps.
+ # It will create a node and assign it an admin address.
+ #
+ def transition(inst, name, state)
+ save_it = false
+
+ @logger.info("Crowbar transition enter: #{name} to #{state}")
+
+ node = NodeObject.find_node_by_name name
+ if node.nil? and (state == "discovering" or state == "testing")
+ @logger.debug("Crowbar transition: creating new node for #{name} to #{state}")
+ node = Chef::Node.new
+ node["crowbar"] = {}
+
+ node[:fqdn] = name
+ node.name name
+
+ node = NodeObject.new node
+ node.save
+ end
+ if node.nil?
+ @logger.error("Crowbar transition leaving: node not found nor created - #{name} to #{state}")
+ return [200, {}]
+ end
+
+ node["crowbar"] = {} if node["crowbar"].nil?
+ node["crowbar"]["network"] = {} if node["crowbar"]["network"].nil?
+ node["crowbar"]["decoration"] = { :name=> name }
+
+ pop_it = false
+ if node[:state] != state
+ @logger.debug("Crowbar transition: state has changed so we need to do stuff for #{name} to #{state}")
+
+ node["crowbar"]["state_debug"] = {} if node["crowbar"]["state_debug"].nil?
+ if node["crowbar"]["state_debug"][state].nil?
+ node["crowbar"]["state_debug"][state] = 1
+ else
+ node["crowbar"]["state_debug"][state] = node["crowbar"]["state_debug"][state] + 1
+ end
+
+ node[:state] = state
+ save_it = true
+ pop_it = true
+ end
+
+ node.save if save_it
+
+ if pop_it
+ crole = RoleObject.find_role_by_name("crowbar-config-#{inst}")
+ ro = crole.default_attributes["crowbar"]["run_order"]
+
+ #
+ # If we are discovering the node and it is an admin, make sure that we add the crowbar config
+ #
+ if state == "discovering" and node.admin?
+ db = ProposalObject.find_proposal("crowbar", inst)
+ add_role_to_instance_and_node("crowbar", inst, name, db, crole, "crowbar")
+ end
+
+ roles = RoleObject.find_roles_by_search "transitions:true AND (transition_list:all OR transition_list:#{ChefObject.chef_escape(state)})"
+ # Make sure the deployer objects run first.
+ roles.sort! do |x,y|
+ xname = x.name.gsub(/-config-.*$/, "")
+ yname = y.name.gsub(/-config-.*$/, "")
+
+ xs = 1000
+ xs = ro[xname] unless ro[xname].nil?
+ ys = 1000
+ ys = ro[yname] unless ro[yname].nil?
+ xs <=> ys
+ end
+
+ roles.each do |role|
+ role.override_attributes.each do |bc, data|
+ jsondata = {
+ "name" => name,
+ "state" => state
+ }
+ rname = role.name.gsub("#{bc}-config-","")
+ begin
+ @logger.info("Crowbar transition: calling #{bc}:#{rname} for #{name} for #{state}")
+ service = eval("#{bc.capitalize}Service.new @logger")
+ answer = service.transition(rname, name, state)
+ if answer[0] != 200
+ @logger.error("Crowbar transition: finished #{bc}:#{rname} for #{name} for #{state}: FAILED #{answer[1]}")
+ else
+ @logger.debug("Crowbar transition: finished #{bc}:#{rname} for #{name} for #{state}")
+ unless answer[1]["name"].nil?
+ name = answer[1]["name"]
+ end
+ end
+ rescue Exception => e
+ @logger.fatal("json/transition for #{bc}:#{rname} failed: #{e.message}")
+ @logger.fatal("#{e.backtrace}")
+ end
+ end
+ end
+
+ # We have a node that has become ready, test to see if there are queued proposals to commit
+ process_queue if state == "ready"
+ end
+
+ @logger.debug("Crowbar transition leaving: #{name} to #{state}")
+ [200, NodeObject.find_node_by_name(name).to_hash ]
+ end
+
+ def create_proposal
+ @logger.debug("Crowbar create_proposal enter")
+ base = super
+ @logger.debug("Crowbar create_proposal exit")
+ base
+ end
+
+ def apply_role (role, inst)
+ @logger.debug("Crowbar apply_role: enter")
+ answer = super
+ @logger.debug("Crowbar apply_role: super apply_role finished")
+
+ node = role.default_attributes
+ @logger.debug("Crowbar apply_role: create initial instances")
+ unless node["crowbar"].nil? or node["crowbar"]["instances"].nil?
+ node["crowbar"]["instances"].each do |k,plist|
+ plist.each do |v|
+ id = "default"
+ data = "{\"id\":\"#{id}\"}"
+ if v != "default"
+ file = File.open(v, "r")
+ data = file.readlines.to_s
+ file.close
+
+ struct = JSON.parse(data)
+ id = struct["id"].gsub("bc-#{k}-", "")
+ end
+
+ @logger.debug("Crowbar apply_role: creating #{k}.#{id}")
+
+ # Create a service to talk to.
+ service = eval("#{k.capitalize}Service.new @logger")
+
+ @logger.debug("Crowbar apply_role: Calling get to see if it already exists: #{k}.#{id}")
+ answer = service.proposals
+ if answer[0] != 200
+ @logger.error("Failed to list #{k}: #{answer[0]} : #{answer[1]}")
+ else
+ unless answer[1].include?(id)
+ @logger.debug("Crowbar apply_role: didn't already exist, creating proposal for #{k}.#{id}")
+ answer = service.proposal_create JSON.parse(data)
+ if answer[0] != 200
+ @logger.error("Failed to create #{k}.#{id}: #{answer[0]} : #{answer[1]}")
+ end
+ end
+
+ @logger.debug("Crowbar apply_role: check to see if it is already active: #{k}.#{id}")
+ answer = service.list_active
+ if answer[0] != 200
+ @logger.error("Failed to list active #{k}: #{answer[0]} : #{answer[1]}")
+ else
+ unless answer[1].include?(id)
+ @logger.debug("Crowbar apply_role: #{k}.#{id} wasn't active: Activating")
+ answer = service.proposal_commit id
+ if answer[0] != 200
+ @logger.error("Failed to commit #{k}.#{id}: #{answer[0]} : #{answer[1]}")
+ end
+ end
+ end
+ end
+
+ @logger.fatal("Crowbar apply_role: Done with creating: #{k}.#{id}")
+ end
+ end
+ end
+
+ @logger.debug("Crowbar apply_role: leaving: #{answer}")
+ answer
+ end
+
+end
+
52 crowbar/change-image/dell/barclamps/crowbar/barclamp-crowbar.spec
@@ -0,0 +1,52 @@
+
+%define _topdir BUILD_DIR
+%define name barclamp-crowbar
+%define release RPM_CONTEXT_NUMBER
+%define version MAJOR_VERSION.MINOR_VERSION
+%define buildroot %{_topdir}/%{name}-%{version}-root
+
+BuildRoot: %{buildroot}
+Summary: Core functionaly within Crowbar
+License: Apache 2.0
+Name: %{name}
+BuildArch: noarch
+Version: %{version}
+Release: %{release}
+Source: %{name}-%{version}.tar.gz
+Prefix: /
+Group: Development/Tools
+
+%description
+A Crowbar Barclamp that manages crowbar deployments within a Crowbar environment.
+
+%prep
+%setup -q
+
+%build
+
+%install
+make install DESTDIR=${RPM_BUILD_ROOT}
+
+%post
+cd /usr/share/barclamp-crowbar/chef/cookbooks
+knife cookbook upload -o . -a -u chef-webui -k /etc/chef/webui.pem
+
+cd /usr/share/barclamp-crowbar/chef/data_bags/crowbar
+for i in *.json; do
+ knife data bag from file crowbar $i
+done
+
+cd /usr/share/barclamp-crowbar/chef/roles
+for i in *.rb; do
+ knife role from file $i
+done
+
+service httpd graceful
+
+
+%files
+%defattr(-,root,root)
+/usr/bin
+/usr/share
+/opt
+
17 crowbar/change-image/dell/barclamps/crowbar/build_deb.sh
@@ -0,0 +1,17 @@
+#
+# Must have tools:
+# apt-get install dpkg-dev debhelper devscripts fakeroot linda dh-make
+#
+
+. ./version.sh
+
+sed -e "s/CHANGE_LOG_LINE/barclamp-${BARCLAMP_NAME} (${MAJOR_VERSION}.${MINOR_VERSION}-${DEB_CONTEXT_NUMBER}) unstable; urgency=low/" debian/changelog.tmpl > debian/changelog
+
+
+yes | debuild -us -uc
+
+mkdir -p bin
+mv ../barclamp-${BARCLAMP_NAME}_*.deb bin
+mv ../barclamp-${BARCLAMP_NAME}_*gz bin
+rm ../barclamp-${BARCLAMP_NAME}_*
+
34 crowbar/change-image/dell/barclamps/crowbar/build_rpm.sh
@@ -0,0 +1,34 @@
+#!/bin/bash
+
+#
+# Needs sudo apt-get install rpm
+#
+
+. ./version.sh
+
+BUILD_DIR="/tmp/build.$$"
+rm -rf ${BUILD_DIR}
+mkdir -p ${BUILD_DIR}/BUILD
+mkdir -p ${BUILD_DIR}/RPMS
+mkdir -p ${BUILD_DIR}/SOURCES
+mkdir -p ${BUILD_DIR}/SPECS
+mkdir -p ${BUILD_DIR}/SRPMS
+
+FULL_NAME="barclamp-${BARCLAMP_NAME}-${MAJOR_VERSION}.${MINOR_VERSION}"
+
+mkdir $FULL_NAME
+cp -r Makefile app chef command_line $FULL_NAME
+tar -zcf ${BUILD_DIR}/SOURCES/${FULL_NAME}.tar.gz ${FULL_NAME}
+rm -rf ${FULL_NAME}
+
+sed -e "s%BUILD_DIR%$BUILD_DIR%" barclamp-${BARCLAMP_NAME}.spec > ${BUILD_DIR}/SPECS/barclamp-${BARCLAMP_NAME}.spec
+sed -ie "s%MAJOR_VERSION%${MAJOR_VERSION}%" ${BUILD_DIR}/SPECS/barclamp-${BARCLAMP_NAME}.spec
+sed -ie "s%MINOR_VERSION%${MINOR_VERSION}%" ${BUILD_DIR}/SPECS/barclamp-${BARCLAMP_NAME}.spec
+sed -ie "s%RPM_CONTEXT_NUMBER%${RPM_CONTEXT_NUMBER}%" ${BUILD_DIR}/SPECS/barclamp-${BARCLAMP_NAME}.spec
+
+rpmbuild -v -ba --clean ${BUILD_DIR}/SPECS/barclamp-${BARCLAMP_NAME}.spec
+
+mkdir -p bin
+cp ${BUILD_DIR}/RPMS/noarch/* bin
+cp ${BUILD_DIR}/SRPMS/* bin
+#rm -rf ${BUILD_DIR}
51 crowbar/change-image/dell/barclamps/crowbar/chef/cookbooks/crowbar/README.rdoc
@@ -0,0 +1,51 @@
+= DESCRIPTION:
+
+
+= REQUIREMENTS:
+
+== Platform:
+
+
+== Cookbooks:
+
+
+* ruby
+* apache2
+* passenger
+
+= ATTRIBUTES:
+
+* rails[:version] - Install the specified version. Default false (installs latest).
+* rails[:environment] - Set Rails environment. Default production.
+
+= USAGE:
+
+The recommended Rails application deployment method is Passenger and use the Apache2 cookbook's web_app define.
+
+ include_recipe "apache2"
+ include_recipe "passenger"
+ include_recipe "rails"
+
+ web_app "some_rails_app" do
+ docroot "/srv/some_rails_app/public"
+ template "some_rails_app.conf.erb"
+ end
+
+We provide an example rails application vhost config file in this cookbook. Remember, for Passenger, DocumentRoot (docroot) needs 'public'. Per the web_app define, other parameters can be passed arbitrarily and used in the template.
+
+= LICENSE and AUTHOR:
+
+Author:: Joshua Timberman (<joshua@opscode.com>)
+Copyright:: 2009, Opscode, Inc
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
52 crowbar/change-image/dell/barclamps/crowbar/chef/cookbooks/crowbar/files/default/crowbar
@@ -0,0 +1,52 @@
+#!/bin/bash
+#
+# Mark the admin node as ready on reboot.
+#
+
+IP="127.0.0.1"
+
+exec 2>>/var/log/crowbar-join.errlog
+
+export PS4='${BASH_SOURCE}@${LINENO}(${FUNCNAME[0]}): '
+set -x
+
+if [[ -f /etc/crowbar.install.key ]]; then
+ export CROWBAR_KEY="$(cat /etc/crowbar.install.key)"
+fi
+
+# Run a command and log its output.
+log_to() {
+ # $1 = install log to log to
+ # $@ = rest of args
+ local __log="/var/log/install-$1"
+ local __timestamp="$(date '+%F %T %z')"
+ shift
+ printf "\n%s\n" "$__timestamp: Running $*" | \
+ tee -a "$__log.err" >> "$__log.log"
+ local _ret=0
+ if "$@" 2>> "$__log.err" >>"$__log.log"; then
+ _ret=0
+ else
+ _ret="$?"
+ echo "$__timestamp: $* failed."
+ echo "See $__log.log and $__log.err for more information."
+ fi
+ printf "\n$s\n--------\n" "$(date '+%F %T %z'): Done $*" | \
+ tee -a "$__log.err" >> "$__log.log"
+ return $_ret
+}
+
+post_state() {
+ local curlargs=(-o "/var/log/$1-$2.json" --connect-timeout 60 -s \
+ -L -X POST --data-binary "{ \"name\": \"$1\", \"state\": \"$2\" }" \
+ -H "Accept: application/json" -H "Content-Type: application/json" \
+ --max-time 240)
+ [[ $CROWBAR_KEY ]] && curlargs+=(-u "$CROWBAR_KEY" --digest)
+ curl "${curlargs[@]}" "http://$IP:3000/crowbar/crowbar/1.0/transition/default"
+}
+
+# Mark us as readying, and get our cert.
+post_state $HOSTNAME "readying"
+post_state $HOSTNAME "ready"
+
+echo "Done"
15 crowbar/change-image/dell/barclamps/crowbar/chef/cookbooks/crowbar/files/default/crowbar.sh
@@ -0,0 +1,15 @@
+#
+# Default path variables.
+#
+
+# Make sure /opt/dell/bin is in the root path
+if ! echo ${PATH} | /bin/grep -q /opt/dell/bin ; then
+ if [ `/usr/bin/id -u` = 0 ] ; then
+ PATH=${PATH}:/opt/dell/bin
+ fi
+fi
+
+if [ -f /etc/crowbar.install.key ] ; then
+ export CROWBAR_KEY=`cat /etc/crowbar.install.key`
+fi
+
2 crowbar/change-image/dell/barclamps/crowbar/chef/cookbooks/crowbar/files/default/knife.rb
@@ -0,0 +1,2 @@
+node_name "chef-webui"
+client_key "/etc/chef/webui.pem"
58 crowbar/change-image/dell/barclamps/crowbar/chef/cookbooks/crowbar/metadata.json
@@ -0,0 +1,58 @@
+{
+ "providing": {
+ },
+ "attributes": {
+ },
+ "replacing": {
+ },
+ "dependencies": {
+ "apache2": [
+
+ ],
+ "ruby": [
+
+ ],
+ "passenger_apache2": [
+
+ ],
+ "rails": [
+
+ ]
+ },
+ "groupings": {
+ },
+ "recommendations": {
+ },
+ "platforms": {
+ "debian": [
+
+ ],
+ "fedora": [
+
+ ],
+ "centos": [
+
+ ],
+ "ubuntu": [
+
+ ],
+ "redhat": [
+
+ ]
+ },
+ "license": "Apache 2.0",
+ "version": "0.9.5",
+ "maintainer": "Dell, Inc.",
+ "suggestions": {
+ },
+ "recipes": {
+ "crowbar": "Installs crowbar",
+ "crowbar::local_apt_repo": "Makes the local node a repos to itself"
+ },
+ "maintainer_email": "crowbar@dell.com",
+ "name": "crowbar",
+ "conflicting": {
+ },
+ "description": "Installs crowbar",
+ "long_description": ""
+ }
19 crowbar/change-image/dell/barclamps/crowbar/chef/cookbooks/crowbar/providers/user.rb
@@ -0,0 +1,19 @@
+
+action :add do
+ filename = "/opt/dell/openstack_manager/htdigest"
+ digest = Digest::MD5.hexdigest("#{new_resource.name}:#{new_resource.description}:#{new_resource.password}")
+ utils_line "#{new_resource.name}:#{new_resource.description}:#{digest}" do
+ action :add
+ file filename
+ end
+end
+
+action :remove do
+ filename = "/opt/dell/openstack_manager/htdigest"
+ digest = Digest::MD5.hexdigest("#{new_resource.name}:#{new_resource.description}:#{new_resource.password}")
+ utils_line "#{new_resource.name}:#{new_resource.description}:#{digest}" do
+ action :remove
+ file filename
+ end
+end
+
135 crowbar/change-image/dell/barclamps/crowbar/chef/cookbooks/crowbar/recipes/default.rb
@@ -0,0 +1,135 @@
+#
+# Cookbook Name:: crowbar
+# Recipe:: default
+#
+# Copyright 2011, Opscode, Inc. and Dell, Inc
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+include_recipe "apache2"
+include_recipe "apache2::mod_auth_digest"
+include_recipe "passenger_apache2"
+include_recipe "rails"
+
+package "ipmitool"
+
+group "crowbar"
+
+user "crowbar" do
+ comment "Crowbar"
+ gid "crowbar"
+ home "/home/random"
+ shell "/bin/false"
+end
+
+directory "/root/.chef" do
+ owner "root"
+ group "root"
+ mode "0700"
+ action :create
+end
+
+cookbook_file "/etc/profile.d/crowbar.sh" do
+ owner "root"
+ group "root"
+ mode "0755"
+ action :create
+ source "crowbar.sh"
+end
+
+cookbook_file "/root/.chef/knife.rb" do
+ owner "root"
+ group "root"
+ mode "0600"
+ action :create
+ source "knife.rb"
+end
+
+directory "/home/openstack/.chef" do
+ owner "openstack"
+ group "openstack"
+ mode "0700"
+ action :create
+end
+
+cookbook_file "/home/openstack/.chef/knife.rb" do
+ owner "openstack"
+ group "openstack"
+ mode "0600"
+ action :create
+ source "knife.rb"
+end
+
+bash "Add crowbar chef client" do
+ environment ({'EDITOR' => '/bin/true'})
+ code "knife client create crowbar -a --file /opt/dell/openstack_manager/config/client.pem -u chef-validator -k /etc/chef/validation.pem"
+ not_if "knife client list -u crowbar -k /opt/dell/openstack_manager/config/client.pem"
+end
+
+file "/opt/dell/openstack_manager/log/production.log" do
+ owner "crowbar"
+ group "crowbar"
+ mode "0666"
+ action :create
+end
+
+file "/opt/dell/openstack_manager/tmp/queue.lock" do
+ owner "crowbar"
+ group "crowbar"
+ mode "0644"
+ action :create
+end
+file "/opt/dell/openstack_manager/tmp/ip.lock" do
+ owner "crowbar"
+ group "crowbar"
+ mode "0644"
+ action :create
+end
+
+# Add crowbar users - system added machine-install in install-chef.sh
+node["crowbar"]["users"].each do |user,hash|
+ crowbar_user user do
+ action :add
+ description hash["description"]
+ password hash["password"]
+ end
+end unless node["crowbar"].nil? or node["crowbar"]["users"].nil?
+
+bash "set permissions" do
+ code "chown -R crowbar:crowbar /opt/dell/openstack_manager"
+ not_if "ls -al /opt/dell/openstack_manager/README | grep -q crowbar"
+end
+
+web_app "crowbar_app" do
+ server_name node[:fqdn]
+ docroot "/opt/dell/openstack_manager/public"
+ template "crowbar_app.conf.erb"
+end
+
+cookbook_file "/etc/init.d/crowbar" do
+ owner "root"
+ group "root"
+ mode "0755"
+ action :create
+ source "crowbar"
+end
+
+["3", "5", "2"].each do |i|
+ link "/etc/rc#{i}.d/S99xcrowbar" do
+ action :create
+ to "/etc/init.d/crowbar"
+ not_if "test -L /etc/rc#{i}.d/S99xcrowbar"
+ end
+end
+
14 crowbar/change-image/dell/barclamps/crowbar/chef/cookbooks/crowbar/recipes/local_apt_repo.rb
@@ -0,0 +1,14 @@
+
+apt_repository "local maverick main" do
+ uri "file:///tftpboot/ubuntu_dvd"
+ distribution "maverick"
+ components [ "main", "restricted" ]
+ action :add
+end
+
+apt_repository "local extra repos" do
+ uri "file:///tftpboot/ubuntu_dvd/extra/"
+ distribution "/"
+ action :add
+end
+
7 crowbar/change-image/dell/barclamps/crowbar/chef/cookbooks/crowbar/resources/user.rb
@@ -0,0 +1,7 @@
+
+actions :add, :remove
+
+attribute :name, :kind_of => String, :name_attribute => true
+attribute :description, :kind_of => String
+attribute :password, :kind_of => String
+
40 ...mage/dell/barclamps/crowbar/chef/cookbooks/crowbar/templates/default/crowbar_app.conf.erb
@@ -0,0 +1,40 @@
+Listen 3000
+<VirtualHost *:3000>
+ ServerName <%= @params[:server_name] %>
+ DocumentRoot <%= @params[:docroot] %>
+
+ <Location />
+ AuthType Digest
+ AuthName "Crowbar"
+ AuthDigestDomain http://192.168.124.10:3000/
+ AuthDigestProvider file
+ AuthUserFile /opt/dell/openstack_manager/htdigest
+ Require valid-user
+ </Location>
+
+ RailsBaseURI /
+ RailsMaxPoolSize <%= node[:rails][:max_pool_size] %>
+ RailsPoolIdleTime 3600
+ RailsEnv '<%= node[:rails][:environment] %>'
+
+ LogLevel info
+ ErrorLog <%= node[:apache][:log_dir] %>/<%= @params[:name] %>_error.log
+ CustomLog <%= node[:apache][:log_dir] %>/<%= @params[:name] %>_access.log combined
+
+ ErrorDocument 404 /404.html
+ ErrorDocument 500 /500.html
+
+ RewriteEngine On
+
+ # Handle maintenance mode
+ RewriteCond %{DOCUMENT_ROOT}/system/maintenance.html -f
+ RewriteCond