Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

This commit is the output of running the script to convert a barclamp…

… to a rails engine.

In addition, some copyright dates were manually updated from 2011 to 2013
  • Loading branch information...
commit c06e597d4b0f70669891d28441382fc7267a5461 1 parent 2d4f15e
@cdearborn cdearborn authored
Showing with 8,933 additions and 4 deletions.
  1. +1 −1  bin/crowbar_network
  2. +1 −1  chef/cookbooks/network/recipes/default.rb
  3. +7 −0 crowbar_engine/barclamp_network/.gitignore
  4. +17 −0 crowbar_engine/barclamp_network/Gemfile
  5. +98 −0 crowbar_engine/barclamp_network/Gemfile.lock
  6. +40 −0 crowbar_engine/barclamp_network/Rakefile
  7. 0  crowbar_engine/barclamp_network/app/assets/images/barclamp_network/.gitkeep
  8. +15 −0 crowbar_engine/barclamp_network/app/assets/javascripts/barclamp_network/application.js
  9. +52 −0 crowbar_engine/barclamp_network/app/assets/stylesheets/barclamp_network/_network.sass
  10. +13 −0 crowbar_engine/barclamp_network/app/assets/stylesheets/barclamp_network/application.css
  11. +4 −0 crowbar_engine/barclamp_network/app/controllers/barclamp_network/application_controller.rb
  12. +286 −0 crowbar_engine/barclamp_network/app/controllers/barclamp_network/conduits_controller.rb
  13. +380 −0 crowbar_engine/barclamp_network/app/controllers/barclamp_network/networks_controller.rb
  14. +19 −0 ...bar_engine/barclamp_network/app/controllers/barclamp_network/scaffolds/allocated_ip_addresses_controller.rb
  15. +19 −0 crowbar_engine/barclamp_network/app/controllers/barclamp_network/scaffolds/bmc_interfaces_controller.rb
  16. +19 −0 crowbar_engine/barclamp_network/app/controllers/barclamp_network/scaffolds/bonds_controller.rb
  17. +19 −0 crowbar_engine/barclamp_network/app/controllers/barclamp_network/scaffolds/bus_maps_controller.rb
  18. +19 −0 crowbar_engine/barclamp_network/app/controllers/barclamp_network/scaffolds/buses_controller.rb
  19. +19 −0 crowbar_engine/barclamp_network/app/controllers/barclamp_network/scaffolds/conduit_actions_controller.rb
  20. +19 −0 crowbar_engine/barclamp_network/app/controllers/barclamp_network/scaffolds/conduit_filters_controller.rb
  21. +19 −0 crowbar_engine/barclamp_network/app/controllers/barclamp_network/scaffolds/conduit_rules_controller.rb
  22. +19 −0 crowbar_engine/barclamp_network/app/controllers/barclamp_network/scaffolds/conduits_controller.rb
  23. +19 −0 crowbar_engine/barclamp_network/app/controllers/barclamp_network/scaffolds/create_bonds_controller.rb
  24. +19 −0 crowbar_engine/barclamp_network/app/controllers/barclamp_network/scaffolds/create_vlans_controller.rb
  25. +19 −0 crowbar_engine/barclamp_network/app/controllers/barclamp_network/scaffolds/interface_maps_controller.rb
  26. +19 −0 crowbar_engine/barclamp_network/app/controllers/barclamp_network/scaffolds/interface_selectors_controller.rb
  27. +19 −0 crowbar_engine/barclamp_network/app/controllers/barclamp_network/scaffolds/interfaces_controller.rb
  28. +19 −0 crowbar_engine/barclamp_network/app/controllers/barclamp_network/scaffolds/ip_addresses_controller.rb
  29. +19 −0 crowbar_engine/barclamp_network/app/controllers/barclamp_network/scaffolds/ip_ranges_controller.rb
  30. +19 −0 crowbar_engine/barclamp_network/app/controllers/barclamp_network/scaffolds/network_mode_filters_controller.rb
  31. +19 −0 crowbar_engine/barclamp_network/app/controllers/barclamp_network/scaffolds/networks_controller.rb
  32. +19 −0 ...bar_engine/barclamp_network/app/controllers/barclamp_network/scaffolds/node_attribute_filters_controller.rb
  33. +19 −0 crowbar_engine/barclamp_network/app/controllers/barclamp_network/scaffolds/physical_interfaces_controller.rb
  34. +19 −0 crowbar_engine/barclamp_network/app/controllers/barclamp_network/scaffolds/routers_controller.rb
  35. +19 −0 crowbar_engine/barclamp_network/app/controllers/barclamp_network/scaffolds/select_by_indices_controller.rb
  36. +19 −0 crowbar_engine/barclamp_network/app/controllers/barclamp_network/scaffolds/select_by_speeds_controller.rb
  37. +19 −0 crowbar_engine/barclamp_network/app/controllers/barclamp_network/scaffolds/vlan_interfaces_controller.rb
  38. +19 −0 crowbar_engine/barclamp_network/app/controllers/barclamp_network/scaffolds/vlans_controller.rb
  39. +4 −0 crowbar_engine/barclamp_network/app/helpers/barclamp_network/application_helper.rb
  40. +24 −0 crowbar_engine/barclamp_network/app/models/barclamp_network/allocated_ip_address.rb
  41. +45 −0 crowbar_engine/barclamp_network/app/models/barclamp_network/attrib_instance_bus_order.rb
  42. +51 −0 crowbar_engine/barclamp_network/app/models/barclamp_network/attrib_instance_ip_address.rb
  43. +761 −0 crowbar_engine/barclamp_network/app/models/barclamp_network/barclamp.rb
  44. +16 −0 crowbar_engine/barclamp_network/app/models/barclamp_network/bmc_interface.rb
  45. +29 −0 crowbar_engine/barclamp_network/app/models/barclamp_network/bond.rb
  46. +22 −0 crowbar_engine/barclamp_network/app/models/barclamp_network/bus.rb
  47. +23 −0 crowbar_engine/barclamp_network/app/models/barclamp_network/bus_map.rb
  48. +70 −0 crowbar_engine/barclamp_network/app/models/barclamp_network/conduit.rb
  49. +17 −0 crowbar_engine/barclamp_network/app/models/barclamp_network/conduit_action.rb
  50. +24 −0 crowbar_engine/barclamp_network/app/models/barclamp_network/conduit_filter.rb
  51. +123 −0 crowbar_engine/barclamp_network/app/models/barclamp_network/conduit_rule.rb
  52. +19 −0 crowbar_engine/barclamp_network/app/models/barclamp_network/create_bond.rb
  53. +16 −0 crowbar_engine/barclamp_network/app/models/barclamp_network/create_vlan.rb
  54. +26 −0 crowbar_engine/barclamp_network/app/models/barclamp_network/interface.rb
  55. +36 −0 crowbar_engine/barclamp_network/app/models/barclamp_network/interface_map.rb
  56. +37 −0 crowbar_engine/barclamp_network/app/models/barclamp_network/interface_selector.rb
  57. +43 −0 crowbar_engine/barclamp_network/app/models/barclamp_network/ip_address.rb
  58. +28 −0 crowbar_engine/barclamp_network/app/models/barclamp_network/ip_range.rb
  59. +212 −0 crowbar_engine/barclamp_network/app/models/barclamp_network/network.rb
  60. +32 −0 crowbar_engine/barclamp_network/app/models/barclamp_network/network_mode_filter.rb
  61. +761 −0 crowbar_engine/barclamp_network/app/models/barclamp_network/network_service.rb
  62. +59 −0 crowbar_engine/barclamp_network/app/models/barclamp_network/network_utils.rb
  63. +24 −0 crowbar_engine/barclamp_network/app/models/barclamp_network/node_attribute_filter.rb
  64. +17 −0 crowbar_engine/barclamp_network/app/models/barclamp_network/physical_interface.rb
  65. +33 −0 crowbar_engine/barclamp_network/app/models/barclamp_network/role_filter.rb
  66. +24 −0 crowbar_engine/barclamp_network/app/models/barclamp_network/router.rb
  67. +27 −0 crowbar_engine/barclamp_network/app/models/barclamp_network/select_by_index.rb
  68. +61 −0 crowbar_engine/barclamp_network/app/models/barclamp_network/select_by_speed.rb
  69. +28 −0 crowbar_engine/barclamp_network/app/models/barclamp_network/selector.rb
  70. +22 −0 crowbar_engine/barclamp_network/app/models/barclamp_network/vlan.rb
  71. +18 −0 crowbar_engine/barclamp_network/app/models/barclamp_network/vlan_interface.rb
  72. +10 −0 crowbar_engine/barclamp_network/app/views/barclamp_network/_edit_deployment.html.haml
  73. +14 −0 crowbar_engine/barclamp_network/app/views/layouts/barclamp_network/application.html.erb
  74. +23 −0 crowbar_engine/barclamp_network/barclamp_network.gemspec
  75. +17 −0 crowbar_engine/barclamp_network/config/initializers/api.rb
  76. +180 −0 crowbar_engine/barclamp_network/config/locales/en.yml
  77. +2 −0  crowbar_engine/barclamp_network/config/routes.rb
  78. +27 −0 crowbar_engine/barclamp_network/db/migrate/20120730175122_create_networks.rb
  79. +29 −0 crowbar_engine/barclamp_network/db/migrate/20120730175238_create_interfaces.rb
  80. +27 −0 crowbar_engine/barclamp_network/db/migrate/20120730175255_create_ip_addresses.rb
  81. +24 −0 crowbar_engine/barclamp_network/db/migrate/20120801015043_barclamp_import_network.rb
  82. +24 −0 crowbar_engine/barclamp_network/db/migrate/20120821194639_create_conduits.rb
  83. +24 −0 crowbar_engine/barclamp_network/db/migrate/20120822201408_create_routers.rb
  84. +24 −0 crowbar_engine/barclamp_network/db/migrate/20120827150258_create_ip_ranges.rb
  85. +25 −0 crowbar_engine/barclamp_network/db/migrate/20120914175602_create_buses.rb
  86. +24 −0 crowbar_engine/barclamp_network/db/migrate/20120914175721_create_bus_maps.rb
  87. +23 −0 crowbar_engine/barclamp_network/db/migrate/20120914175733_create_interface_maps.rb
  88. +23 −0 crowbar_engine/barclamp_network/db/migrate/20120918205152_create_interface_selectors.rb
  89. +29 −0 crowbar_engine/barclamp_network/db/migrate/20120918205303_create_conduit_filters.rb
  90. +26 −0 crowbar_engine/barclamp_network/db/migrate/20120919110841_create_conduit_actions.rb
  91. +23 −0 crowbar_engine/barclamp_network/db/migrate/20120919190544_create_conduit_rules.rb
  92. +24 −0 crowbar_engine/barclamp_network/db/migrate/20121214183538_create_vlans.rb
  93. +25 −0 crowbar_engine/barclamp_network/db/migrate/20130112145100_create_selectors.rb
  94. +32 −0 crowbar_engine/barclamp_network/db/migrate/20130115160000_network_navs.rb
  95. +27 −0 crowbar_engine/barclamp_network/db/migrate/20130115220245_create_allocated_ip_addresses.rb
  96. +23 −0 crowbar_engine/barclamp_network/db/migrate/20130123083500_create_interfaces_networks.rb
  97. +74 −0 crowbar_engine/barclamp_network/db/migrate/20130124211800_scaffold_navs.rb
  98. +4 −0 crowbar_engine/barclamp_network/lib/barclamp_network.rb
  99. +5 −0 crowbar_engine/barclamp_network/lib/barclamp_network/engine.rb
  100. +3 −0  crowbar_engine/barclamp_network/lib/barclamp_network/version.rb
  101. +4 −0 crowbar_engine/barclamp_network/lib/tasks/barclamp_network_tasks.rake
  102. +8 −0 crowbar_engine/barclamp_network/script/rails
  103. +7 −0 crowbar_engine/barclamp_network/test/barclamp_network_test.rb
  104. +261 −0 crowbar_engine/barclamp_network/test/dummy/README.rdoc
  105. +7 −0 crowbar_engine/barclamp_network/test/dummy/Rakefile
  106. +15 −0 crowbar_engine/barclamp_network/test/dummy/app/assets/javascripts/application.js
  107. +13 −0 crowbar_engine/barclamp_network/test/dummy/app/assets/stylesheets/application.css
  108. +3 −0  crowbar_engine/barclamp_network/test/dummy/app/controllers/application_controller.rb
  109. +2 −0  crowbar_engine/barclamp_network/test/dummy/app/helpers/application_helper.rb
  110. 0  crowbar_engine/barclamp_network/test/dummy/app/mailers/.gitkeep
  111. 0  crowbar_engine/barclamp_network/test/dummy/app/models/.gitkeep
  112. +14 −0 crowbar_engine/barclamp_network/test/dummy/app/views/layouts/application.html.erb
  113. +4 −0 crowbar_engine/barclamp_network/test/dummy/config.ru
  114. +59 −0 crowbar_engine/barclamp_network/test/dummy/config/application.rb
  115. +10 −0 crowbar_engine/barclamp_network/test/dummy/config/boot.rb
  116. +25 −0 crowbar_engine/barclamp_network/test/dummy/config/database.yml
  117. +5 −0 crowbar_engine/barclamp_network/test/dummy/config/environment.rb
  118. +37 −0 crowbar_engine/barclamp_network/test/dummy/config/environments/development.rb
  119. +67 −0 crowbar_engine/barclamp_network/test/dummy/config/environments/production.rb
  120. +37 −0 crowbar_engine/barclamp_network/test/dummy/config/environments/test.rb
  121. +7 −0 crowbar_engine/barclamp_network/test/dummy/config/initializers/backtrace_silencers.rb
  122. +15 −0 crowbar_engine/barclamp_network/test/dummy/config/initializers/inflections.rb
  123. +5 −0 crowbar_engine/barclamp_network/test/dummy/config/initializers/mime_types.rb
  124. +7 −0 crowbar_engine/barclamp_network/test/dummy/config/initializers/secret_token.rb
  125. +8 −0 crowbar_engine/barclamp_network/test/dummy/config/initializers/session_store.rb
  126. +14 −0 crowbar_engine/barclamp_network/test/dummy/config/initializers/wrap_parameters.rb
  127. +5 −0 crowbar_engine/barclamp_network/test/dummy/config/locales/en.yml
  128. +4 −0 crowbar_engine/barclamp_network/test/dummy/config/routes.rb
  129. 0  crowbar_engine/barclamp_network/test/dummy/lib/assets/.gitkeep
  130. 0  crowbar_engine/barclamp_network/test/dummy/log/.gitkeep
  131. +26 −0 crowbar_engine/barclamp_network/test/dummy/public/404.html
  132. +26 −0 crowbar_engine/barclamp_network/test/dummy/public/422.html
  133. +25 −0 crowbar_engine/barclamp_network/test/dummy/public/500.html
  134. 0  crowbar_engine/barclamp_network/test/dummy/public/favicon.ico
  135. +6 −0 crowbar_engine/barclamp_network/test/dummy/script/rails
  136. +10 −0 crowbar_engine/barclamp_network/test/integration/navigation_test.rb
  137. +177 −0 crowbar_engine/barclamp_network/test/network_test_helper.rb
  138. +15 −0 crowbar_engine/barclamp_network/test/test_helper.rb
  139. +142 −0 crowbar_engine/barclamp_network/test/unit/allocated_ip_address_model.rb
  140. +35 −0 crowbar_engine/barclamp_network/test/unit/attrib_instance_bus_order_test.rb
  141. +55 −0 crowbar_engine/barclamp_network/test/unit/attrib_instance_ip_address_test.rb
  142. +83 −0 crowbar_engine/barclamp_network/test/unit/bond_model_test.rb
  143. +56 −0 crowbar_engine/barclamp_network/test/unit/bus_map_model_test.rb
  144. +47 −0 crowbar_engine/barclamp_network/test/unit/bus_model_test.rb
  145. +23 −0 crowbar_engine/barclamp_network/test/unit/conduit_action_test.rb
  146. +25 −0 crowbar_engine/barclamp_network/test/unit/conduit_filter_test.rb
  147. +290 −0 crowbar_engine/barclamp_network/test/unit/conduit_rule_test.rb
  148. +426 −0 crowbar_engine/barclamp_network/test/unit/conduit_test.rb
  149. +47 −0 crowbar_engine/barclamp_network/test/unit/create_bond_test.rb
  150. +78 −0 crowbar_engine/barclamp_network/test/unit/interface_map_model_test.rb
  151. +53 −0 crowbar_engine/barclamp_network/test/unit/interface_model_test.rb
  152. +103 −0 crowbar_engine/barclamp_network/test/unit/interface_selector_test.rb
  153. +93 −0 crowbar_engine/barclamp_network/test/unit/ip_address_model_test.rb
  154. +83 −0 crowbar_engine/barclamp_network/test/unit/ip_range_model_test.rb
  155. +42 −0 crowbar_engine/barclamp_network/test/unit/network_mode_filter_test.rb
  156. +354 −0 crowbar_engine/barclamp_network/test/unit/network_model_test.rb
  157. +500 −0 crowbar_engine/barclamp_network/test/unit/network_service_test.rb
  158. +95 −0 crowbar_engine/barclamp_network/test/unit/network_utils_test.rb
  159. +44 −0 crowbar_engine/barclamp_network/test/unit/node_attribute_filter_test.rb
  160. +44 −0 crowbar_engine/barclamp_network/test/unit/role_filter_test.rb
  161. +68 −0 crowbar_engine/barclamp_network/test/unit/router_model_test.rb
  162. +62 −0 crowbar_engine/barclamp_network/test/unit/select_by_index_test.rb
  163. +145 −0 crowbar_engine/barclamp_network/test/unit/select_by_speed_test.rb
  164. +27 −0 crowbar_engine/barclamp_network/test/unit/selector_test.rb
  165. +47 −0 crowbar_engine/barclamp_network/test/unit/vlan_model_test.rb
  166. +1 −1  crowbar_framework/app/controllers/conduits_controller.rb
  167. +1 −1  crowbar_framework/app/controllers/networks_controller.rb
View
2  bin/crowbar_network
@@ -1,5 +1,5 @@
#!/usr/bin/env ruby
-# Copyright 2011, Dell
+# Copyright 2013, Dell
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
View
2  chef/cookbooks/network/recipes/default.rb
@@ -1,4 +1,4 @@
-# Copyright 2011, Dell
+# Copyright 2013, Dell
# Copyright 2012, SUSE Linux Products GmbH
#
# Licensed under the Apache License, Version 2.0 (the "License");
View
7 crowbar_engine/barclamp_network/.gitignore
@@ -0,0 +1,7 @@
+.bundle/
+log/*.log
+pkg/
+test/dummy/db/*.sqlite3
+test/dummy/log/*.log
+test/dummy/tmp/
+test/dummy/.sass-cache
View
17 crowbar_engine/barclamp_network/Gemfile
@@ -0,0 +1,17 @@
+source "http://rubygems.org"
+
+# Declare your gem's dependencies in barclamp_network.gemspec.
+# Bundler will treat runtime dependencies like base dependencies, and
+# development dependencies will be added by default to the :development group.
+gemspec
+
+# jquery-rails is used by the dummy application
+gem "jquery-rails"
+
+# Declare any dependencies that are still in development here instead of in
+# your gemspec. These might include edge Rails or gems from your path or
+# Git. Remember to move these dependencies to your gemspec before releasing
+# your gem to rubygems.org.
+
+# To use debugger
+# gem 'ruby-debug'
View
98 crowbar_engine/barclamp_network/Gemfile.lock
@@ -0,0 +1,98 @@
+PATH
+ remote: .
+ specs:
+ barclamp_network (0.0.1)
+ rails (~> 3.2.9)
+
+GEM
+ remote: http://rubygems.org/
+ specs:
+ actionmailer (3.2.12)
+ actionpack (= 3.2.12)
+ mail (~> 2.4.4)
+ actionpack (3.2.12)
+ activemodel (= 3.2.12)
+ activesupport (= 3.2.12)
+ builder (~> 3.0.0)
+ erubis (~> 2.7.0)
+ journey (~> 1.0.4)
+ rack (~> 1.4.5)
+ rack-cache (~> 1.2)
+ rack-test (~> 0.6.1)
+ sprockets (~> 2.2.1)
+ activemodel (3.2.12)
+ activesupport (= 3.2.12)
+ builder (~> 3.0.0)
+ activerecord (3.2.12)
+ activemodel (= 3.2.12)
+ activesupport (= 3.2.12)
+ arel (~> 3.0.2)
+ tzinfo (~> 0.3.29)
+ activeresource (3.2.12)
+ activemodel (= 3.2.12)
+ activesupport (= 3.2.12)
+ activesupport (3.2.12)
+ i18n (~> 0.6)
+ multi_json (~> 1.0)
+ arel (3.0.2)
+ builder (3.0.4)
+ erubis (2.7.0)
+ hike (1.2.1)
+ i18n (0.6.1)
+ journey (1.0.4)
+ jquery-rails (2.2.1)
+ railties (>= 3.0, < 5.0)
+ thor (>= 0.14, < 2.0)
+ json (1.7.7)
+ mail (2.4.4)
+ i18n (>= 0.4.0)
+ mime-types (~> 1.16)
+ treetop (~> 1.4.8)
+ mime-types (1.21)
+ multi_json (1.6.1)
+ polyglot (0.3.3)
+ rack (1.4.5)
+ rack-cache (1.2)
+ rack (>= 0.4)
+ rack-ssl (1.3.3)
+ rack
+ rack-test (0.6.2)
+ rack (>= 1.0)
+ rails (3.2.12)
+ actionmailer (= 3.2.12)
+ actionpack (= 3.2.12)
+ activerecord (= 3.2.12)
+ activeresource (= 3.2.12)
+ activesupport (= 3.2.12)
+ bundler (~> 1.0)
+ railties (= 3.2.12)
+ railties (3.2.12)
+ actionpack (= 3.2.12)
+ activesupport (= 3.2.12)
+ rack-ssl (~> 1.3.2)
+ rake (>= 0.8.7)
+ rdoc (~> 3.4)
+ thor (>= 0.14.6, < 2.0)
+ rake (10.0.3)
+ rdoc (3.12.1)
+ json (~> 1.4)
+ sprockets (2.2.2)
+ hike (~> 1.2)
+ multi_json (~> 1.0)
+ rack (~> 1.0)
+ tilt (~> 1.1, != 1.3.0)
+ sqlite3 (1.3.7)
+ thor (0.17.0)
+ tilt (1.3.3)
+ treetop (1.4.12)
+ polyglot
+ polyglot (>= 0.3.1)
+ tzinfo (0.3.35)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ barclamp_network!
+ jquery-rails
+ sqlite3
View
40 crowbar_engine/barclamp_network/Rakefile
@@ -0,0 +1,40 @@
+#!/usr/bin/env rake
+begin
+ require 'bundler/setup'
+rescue LoadError
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
+end
+begin
+ require 'rdoc/task'
+rescue LoadError
+ require 'rdoc/rdoc'
+ require 'rake/rdoctask'
+ RDoc::Task = Rake::RDocTask
+end
+
+RDoc::Task.new(:rdoc) do |rdoc|
+ rdoc.rdoc_dir = 'rdoc'
+ rdoc.title = 'BarclampNetwork'
+ rdoc.options << '--line-numbers'
+ rdoc.rdoc_files.include('README.rdoc')
+ rdoc.rdoc_files.include('lib/**/*.rb')
+end
+
+APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
+load 'rails/tasks/engine.rake'
+
+
+
+Bundler::GemHelper.install_tasks
+
+require 'rake/testtask'
+
+Rake::TestTask.new(:test) do |t|
+ t.libs << 'lib'
+ t.libs << 'test'
+ t.pattern = 'test/**/*_test.rb'
+ t.verbose = false
+end
+
+
+task :default => :test
View
0  crowbar_engine/barclamp_network/app/assets/images/barclamp_network/.gitkeep
No changes.
View
15 crowbar_engine/barclamp_network/app/assets/javascripts/barclamp_network/application.js
@@ -0,0 +1,15 @@
+// This is a manifest file that'll be compiled into application.js, which will include all the files
+// listed below.
+//
+// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
+// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
+//
+// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
+// the compiled file.
+//
+// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
+// GO AFTER THE REQUIRES BELOW.
+//
+//= require jquery
+//= require jquery_ujs
+//= require_tree .
View
52 crowbar_engine/barclamp_network/app/assets/stylesheets/barclamp_network/_network.sass
@@ -0,0 +1,52 @@
+table.vlan
+ tbody
+ tr
+ &:hover, &:active
+ background: $secondary_bg
+ th
+ text-align: center
+ td
+ text-align: center
+ a
+ text-decoration: none
+ color: $text_color
+
+table.switch
+ thead th
+ text-align: center
+ a
+ color: $text_color
+ text-decoration: none
+ font-weight: bold
+ td
+ &.tight
+ padding: 0px
+ div.port
+ background: $secondary_bg
+ border: 1px solid $border_color
+ &.tight
+ background: none
+ border: 1px solid $page_bg
+ &.edge
+ background: $secondary_bg + #322
+ border: 1px solid $notice_border_color
+ div.port_number
+ font-size: -2
+ font-weight: bold
+ float: left
+ div.node
+ text-align: center
+ a
+ color: $text_color
+ text-decoration: none
+ font-weight: bold
+ div.port_nc
+ background: $secondary_bg - #222
+ &.tight
+ border: 1px solid $page_bg
+ background: none
+ div.port_number
+ font-size: -2
+ float: left
+ div.node
+ text-align: center
View
13 crowbar_engine/barclamp_network/app/assets/stylesheets/barclamp_network/application.css
@@ -0,0 +1,13 @@
+/*
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
+ * listed below.
+ *
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
+ * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
+ *
+ * You're free to add application-wide styles to this file and they'll appear at the top of the
+ * compiled file, but it's generally better to create a new file per style scope.
+ *
+ *= require_self
+ *= require_tree .
+ */
View
4 crowbar_engine/barclamp_network/app/controllers/barclamp_network/application_controller.rb
@@ -0,0 +1,4 @@
+module BarclampNetwork
+ class ApplicationController < ActionController::Base
+ end
+end
View
286 crowbar_engine/barclamp_network/app/controllers/barclamp_network/conduits_controller.rb
@@ -0,0 +1,286 @@
+# Copyright 2013, 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 ConduitsController < BarclampController
+ # Make a copy of the barclamp controller help
+ self.help_contents = Array.new(superclass.help_contents)
+
+
+
+ def show
+ Rails.logger.debug("Show sxxxxxxxxxxxxxxxxxxxxxxxxx id: #{params[:id]}");
+ @conduit = Conduit.find(params[:id]) unless params[:id].nil?
+ respond_to do |format|
+ format.json { render :json => network_refs }
+ format.xml { render :xml => network_refs }
+ format.html {
+ Rails.logger.debug("Format HTML show::::::::::: #{@conduit.inspect}");
+ }
+ end
+ end
+
+
+ def edit
+ Rails.logger.debug("Edit Conduit");
+ @conduit = Conduit.find(params[:id]) unless params[:id].nil?
+ @conduits = Conduit.all
+ respond_to do |format|
+ format.html {
+ Rails.logger.debug("Format HTML edit network:::::::::: #{@conduit.inspect}");
+ Rails.logger.debug("Format HTML allocated_ips:::::::::: #{@conduit.allocated_ips}");
+ }
+ end
+ end
+
+ def update
+ # network_update
+
+ @conduit = Conduit.find(params[:id])
+ if @conduit.update_attributes(params[:network])
+ Rails.logger.debug("updateupdateupdateupdateupdate update:::::::::: #{@conduit.allocated_ips}");
+ redirect_to :action => :networks
+ else
+ render 'edit'
+ end
+
+ end
+
+ add_help(:conduit_list,[],[:get])
+ def index
+ Rails.logger.debug("Listing conduits");
+
+ conduit_refs = []
+
+ @conduits = Conduit.all
+ @conduits.each { |conduit|
+ conduit_refs << conduit.id
+ }
+
+ respond_to do |format|
+ format.json { render :json => conduit_refs }
+ format.xml { render :xml => conduit_refs }
+ format.html {
+ Rails.logger.debug("Format HTML conduits#{@conduits.inspect}");
+ }
+ end
+ end
+
+ add_help(:network_show,[:id],[:get])
+ def network_show
+ id = params[:id]
+
+ Rails.logger.debug("Showing network #{id}");
+
+ ret = operations.network_get(id)
+
+ return render :text => ret[1], :status => ret[0] if ret[0] != 200
+
+ respond_to do |format|
+ format.json { render :json => ret[1].to_json( :include => {:subnet => {:only => :cidr}, :router => {:only => :pref, :include => {:ip => {:only => :cidr}}}, :ip_ranges => {:only => :name, :include => {:start_address => {:only => :cidr}, :end_address => {:only => :cidr}}}})}
+ end
+ end
+
+ add_help(:network_create,[:name, :conduit_id, :subnet, :dhcp_enabled, :ip_ranges, :router_pref, :router_ip],[:post])
+ def network_create
+ name = params[:name]
+ conduit_id = params[:conduit_id]
+ subnet = params[:subnet]
+ dhcp_enabled = params[:dhcp_enabled]
+ ip_ranges_json = params[:ip_ranges]
+ if !ip_ranges_json.nil?
+ ip_ranges = JSON.parse(ip_ranges_json)
+ end
+ router_pref = params[:router_pref]
+ router_ip = params[:router_ip]
+
+ Rails.logger.debug("Creating network #{name}");
+
+ ret = operations.network_create(name, conduit_id, subnet, dhcp_enabled, ip_ranges, router_pref, router_ip)
+
+ return render :text => ret[1], :status => ret[0] if ret[0] != 200
+
+ respond_to do |format|
+ format.json { render :json => ret[1] }
+ end
+ end
+
+ add_help(:network_update,[:id, :conduit_id, :subnet, :dhcp_enabled, :ip_ranges, :router_pref, :router_ip],[:put])
+ def network_update
+ id = params[:id]
+ conduit_id = params[:conduit_id]
+ subnet = params[:subnet]
+ dhcp_enabled = params[:dhcp_enabled]
+ ip_ranges_json = params[:ip_ranges]
+ if !ip_ranges_json.nil?
+ ip_ranges = JSON.parse(ip_ranges_json)
+ end
+ router_pref = params[:router_pref]
+ router_ip = params[:router_ip]
+
+ Rails.logger.debug("Updating network #{id}");
+
+ ret = operations.network_update(id, conduit_id, subnet, dhcp_enabled, ip_ranges, router_pref, router_ip)
+
+ return render :text => ret[1], :status => ret[0] if ret[0] != 200
+
+ respond_to do |format|
+ format.json { render :json => ret[1] }
+ end
+ end
+
+ add_help(:network_delete,[:id],[:delete])
+ def network_delete
+ Rails.logger.debug("Deleting network #{params[:id]}");
+
+ ret = operations.network_delete(params[:id])
+ return render :text => ret[1], :status => ret[0] if ret[0] != 200
+ render :json => ret[1]
+ end
+
+ add_help(:allocate_ip,[:id,:network,:range,:name],[:post])
+ def allocate_ip
+ id = params[:id] # Conduit id
+ network = params[:network]
+ range = params[:range]
+ name = params[:name]
+ suggestion = params[:suggestion]
+
+ ret = operations.allocate_ip(id, network, range, name, suggestion)
+ return render :text => ret[1], :status => ret[0] if ret[0] != 200
+ render :json => ret[1]
+ end
+
+ add_help(:deallocate_ip,[:id,:network,:name],[:post])
+ def deallocate_ip
+ id = params[:id] # Conduit id
+ network = params[:network]
+ name = params[:name]
+
+ ret = operations.deallocate_ip(id, network, name)
+ return render :text => ret[1], :status => ret[0] if ret[0] != 200
+ render :json => ret[1]
+ end
+
+ add_help(:enable_interface,[:id,:network,:name],[:post])
+ def enable_interface
+ id = params[:id] # Conduit id
+ network = params[:network]
+ name = params[:name]
+
+ ret = operations.enable_interface(id, network, name)
+ return render :text => ret[1], :status => ret[0] if ret[0] != 200
+ render :json => ret[1]
+ end
+
+ add_help(:disable_interface,[:id,:network,:name],[:post])
+ def disable_interface
+ id = params[:id] # Conduit id
+ network = params[:network]
+ name = params[:name]
+
+ ret = operations.disable_interface(id, network, name)
+ return render :text => ret[1], :status => ret[0] if ret[0] != 200
+ render :json => ret[1]
+ end
+
+ def switch
+ @vports = {}
+ @sum = 0
+ @groups = {}
+ @switches = {}
+ @nodes = {}
+ @port_start = 1
+ nodes = (params[:node] ? NodeObject.find_nodes_by_name(params[:node]) : NodeObject.all)
+ nodes.each do |node|
+ @sum = @sum + node.name.hash
+ @nodes[node.name] = { :alias=>node.alias, :description=>node.description(false, true), :status=>node.status }
+ #build groups
+ group = node.group
+ @groups[group] = { :automatic=>!node.display_set?('group'), :status=>{"ready"=>0, "failed"=>0, "unknown"=>0, "unready"=>0, "pending"=>0}, :nodes=>{} } unless @groups.key? group
+ @groups[group][:nodes][node.group_order] = node.name
+ @groups[group][:status][node.status] = (@groups[group][:status][node.status] || 0).to_i + 1
+ #build switches
+ node_nics(node).each do |switch|
+ key = switch[:switch]
+ if key
+ @switches[key] = { :status=>{"ready"=>0, "failed"=>0, "unknown"=>0, "unready"=>0, "pending"=>0}, :nodes=>{}, :max_port=>(23+@port_start)} unless @switches.key? key
+ port = if switch['switch_port'] == -1 or switch['switch_port'] == "-1"
+ @vports[key] = 1 + (@vports[key] || 0)
+ else
+ switch[:port]
+ end
+ @port_start = 0 if port == 0
+ @switches[key][:max_port] = port if port>@switches[key][:max_port]
+ @switches[key][:nodes][port] = { :handle=>node.name, :intf=>switch[:intf] }
+ @switches[key][:status][node.status] = (@switches[key][:status][node.status] || 0).to_i + 1
+ end
+ end
+ end
+ #make sure port max is even
+ flash[:notice] = "<b>#{I18n.t :warning, :scope => :error}:</b> #{I18n.t :no_nodes_found, :scope => :error}".html_safe if @nodes.empty?
+ end
+
+ def vlan
+ net_bc = RoleObject.find_role_by_name 'network-config-default'
+ if net_bc.barclamp == 'network'
+ @vlans = net_bc.default_attributes['network']['networks']
+ end
+ @nodes = {}
+ NodeObject.all.each do |node|
+ @nodes[node.name] = { :alias=>node.alias, :description=>node.description(false, true), :vlans=>{} }
+ @nodes[node.name][:vlans] = node_vlans(node)
+ end
+
+ end
+
+ private
+
+ def node_vlans(node)
+ nv = {}
+ vlans = node["crowbar"]["network"].each do |vlan, vdetails|
+ nv[vlan] = { :address => vdetails["address"], :active=>vdetails["use_vlan"] }
+ end
+ nv
+ end
+
+ def node_nics(node)
+ switches = []
+ begin
+ # list the interfaces
+ if_list = node.crowbar_ohai["detected"]["network"].keys
+ # this is a virtual switch if ALL the interfaces are virtual
+ physical = if_list.map{ |intf| node.crowbar_ohai["switch_config"][intf]['switch_name'] != '-1' }.include? false
+ if_list.each do | intf |
+ connected = !physical #if virtual, then all ports are connected
+ raw = node.crowbar_ohai["switch_config"][intf]
+ s_name = raw['switch_name'] || -1
+ s_unit = raw['switch_unit'] || -1
+ if s_name == -1 or s_name == "-1"
+ s_name = I18n.t('network.controller.virtual') + ":" + intf.split('.')[0]
+ s_unit = nil
+ else
+ connected = true
+ end
+ if connected
+ s_name= "#{s_name}:#{s_unit}" unless s_unit.nil?
+ switches << { :switch=>s_name, :intf=>intf, :port=>raw['switch_port'].to_i }
+ end
+ end
+ rescue Exception=>e
+ Rails.logger.debug("could not build interface/switch list for #{node.name} due to #{e.message}")
+ end
+ switches
+ end
+end
View
380 crowbar_engine/barclamp_network/app/controllers/barclamp_network/networks_controller.rb
@@ -0,0 +1,380 @@
+# Copyright 2013, 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 NetworksController < BarclampController
+ # Make a copy of the barclamp controller help
+ self.help_contents = Array.new(superclass.help_contents)
+
+ add_help(:network_list,[],[:get])
+ def networks
+ Rails.logger.debug("Listing networks");
+
+ network_refs = []
+
+ Network.all.each { |network|
+ network_refs << network.id
+ }
+
+ respond_to do |format|
+ format.json { render :json => network_refs }
+ format.xml { render :xml => network_refs }
+ end
+ end
+
+ add_help(:network_show,[:id],[:get])
+ def network_show
+ id = params[:id]
+
+ Rails.logger.debug("Showing network #{id}")
+
+ ret = operations.network_get(id)
+
+ return render :text => ret[1], :status => ret[0] if ret[0] != 200
+
+ respond_to do |format|
+ format.json { render :json => ret[1].to_json( :include => {:subnet => {:only => :cidr}, :router => {:only => :pref, :include => {:ip => {:only => :cidr}}}, :ip_ranges => {:only => :name, :include => {:start_address => {:only => :cidr}, :end_address => {:only => :cidr}}}})}
+ end
+ end
+
+ add_help(:network_create,[:name, :proposal_id, :conduit_id, :subnet, :dhcp_enabled, :use_vlan, :ip_ranges, :router_pref, :router_ip],[:post])
+ def network_create
+ name = params[:name]
+ proposal_id = params[:proposal_id]
+ conduit_id = params[:conduit_id]
+ subnet = params[:subnet]
+ dhcp_enabled = to_bool( params[:dhcp_enabled] )
+ use_vlan = to_bool( params[:use_vlan] )
+ ip_ranges = params[:ip_ranges]
+ router_pref = params[:router_pref]
+ router_ip = params[:router_ip]
+
+ Rails.logger.debug("Creating network #{name}");
+
+ ret = operations.network_create(name, proposal_id, conduit_id, subnet, dhcp_enabled, use_vlan, ip_ranges, router_pref, router_ip)
+
+ return render :text => ret[1], :status => ret[0] if ret[0] != 200
+
+ respond_to do |format|
+ format.json { render :json => ret[1].to_json( :include => {:subnet => {:only => :cidr}, :router => {:only => :pref, :include => {:ip => {:only => :cidr}}}, :ip_ranges => {:only => :name, :include => {:start_address => {:only => :cidr}, :end_address => {:only => :cidr}}}})}
+ end
+ end
+
+ add_help(:network_update,[:id, :conduit_id, :subnet, :dhcp_enabled, :use_vlan, :ip_ranges, :router_pref, :router_ip],[:put])
+ def network_update
+ id = params[:id]
+ conduit_id = params[:conduit_id]
+ subnet = params[:subnet]
+ dhcp_enabled = to_bool( params[:dhcp_enabled] )
+ use_vlan = to_bool( params[:use_vlan] )
+ ip_ranges = params[:ip_ranges]
+ router_pref = params[:router_pref]
+ router_ip = params[:router_ip]
+
+ Rails.logger.debug("Updating network #{id}");
+
+ ret = operations.network_update(id, conduit_id, subnet, dhcp_enabled, use_vlan, ip_ranges, router_pref, router_ip)
+
+ return render :text => ret[1], :status => ret[0] if ret[0] != 200
+
+ respond_to do |format|
+ format.json { render :json => ret[1].to_json( :include => {:subnet => {:only => :cidr}, :router => {:only => :pref, :include => {:ip => {:only => :cidr}}}, :ip_ranges => {:only => :name, :include => {:start_address => {:only => :cidr}, :end_address => {:only => :cidr}}}})}
+ end
+ end
+
+ add_help(:network_delete,[:id],[:delete])
+ def network_delete
+ Rails.logger.debug("Deleting network #{params[:id]}");
+
+ ret = operations.network_delete(params[:id])
+ return render :text => ret[1], :status => ret[0] if ret[0] != 200
+ render :json => ret[1]
+ end
+
+ add_help(:allocate_ip,[:id,:network,:range,:name],[:post])
+ def allocate_ip
+ id = params[:id] # Network id
+ network = params[:network]
+ range = params[:range]
+ name = params[:name]
+ suggestion = params[:suggestion]
+
+ ret = operations.allocate_ip(id, network, range, name, suggestion)
+ return render :text => ret[1], :status => ret[0] if ret[0] != 200
+ render :json => ret[1]
+ end
+
+ add_help(:network_allocate_ip,[:id,:network_id,:node_id,:range],[:post])
+ def network_allocate_ip
+ proposal_id = params[:id]
+ proposal_id = nil if proposal_id == "-1"
+ network_id = params[:network_id]
+ node_id = params[:node_id]
+ range = params[:range]
+ suggestion = params[:suggestion]
+
+ ret = operations.network_allocate_ip(proposal_id, network_id, range, node_id, suggestion)
+ return render :text => ret[1], :status => ret[0] if ret[0] != 200
+ render :json => ret[1]
+ end
+
+ add_help(:deallocate_ip,[:id,:network,:name],[:post])
+ def deallocate_ip
+ id = params[:id] # Network id
+ network = params[:network]
+ name = params[:name]
+
+ ret = operations.deallocate_ip(id, network, name)
+ return render :text => ret[1], :status => ret[0] if ret[0] != 200
+ render :json => ret[1]
+ end
+
+ add_help(:network_deallocate_ip,[:id,:network_id,:node_id],[:delete])
+ def network_deallocate_ip
+ proposal_id = params[:id]
+ proposal_id = nil if proposal_id == "-1"
+ network_id = params[:network_id]
+ node_id = params[:node_id]
+
+ ret = operations.network_deallocate_ip(proposal_id, network_id, node_id)
+ return render :text => ret[1], :status => ret[0] if ret[0] != 200
+ render :json => ret[1]
+ end
+
+ add_help(:enable_interface,[:id,:network,:name],[:post])
+ def enable_interface
+ id = params[:id] # Network id
+ network = params[:network]
+ name = params[:name]
+
+ ret = operations.enable_interface(id, network, name)
+ return render :text => ret[1], :status => ret[0] if ret[0] != 200
+ render :json => ret[1]
+ end
+
+ add_help(:network_enable_interface,[:id,:network_id,:node_id],[:post])
+ def network_enable_interface
+ proposal_id = params[:id]
+ proposal_id = nil if proposal_id == "-1"
+ network_id = params[:network_id]
+ node_id = params[:node_id]
+
+ ret = operations.network_enable_interface(proposal_id, network_id, node_id)
+ return render :text => ret[1], :status => ret[0] if ret[0] != 200
+ render :json => ret[1]
+ end
+
+ add_help(:disable_interface,[:id,:network,:name],[:post])
+ def disable_interface
+ id = params[:id] # Network id
+ network = params[:network]
+ name = params[:name]
+
+ ret = operations.disable_interface(id, network, name)
+ return render :text => ret[1], :status => ret[0] if ret[0] != 200
+ render :json => ret[1]
+ end
+
+ def switch
+ @vports = {}
+ @sum = 0
+ @groups = {}
+ @switches = {}
+ @nodes = {}
+ @port_start = 1
+ nodes = (params[:node] ? NodeObject.find_nodes_by_name(params[:node]) : NodeObject.all)
+ nodes.each do |node|
+ @sum = @sum + node.name.hash
+ @nodes[node.name] = { :alias=>node.alias, :description=>node.description(false, true), :status=>node.status }
+ #build groups
+ group = node.group
+ @groups[group] = { :automatic=>!node.display_set?('group'), :status=>{"ready"=>0, "failed"=>0, "unknown"=>0, "unready"=>0, "pending"=>0}, :nodes=>{} } unless @groups.key? group
+ @groups[group][:nodes][node.group_order] = node.name
+ @groups[group][:status][node.status] = (@groups[group][:status][node.status] || 0).to_i + 1
+ #build switches
+ node_nics(node).each do |switch|
+ key = switch[:switch]
+ if key
+ @switches[key] = { :status=>{"ready"=>0, "failed"=>0, "unknown"=>0, "unready"=>0, "pending"=>0}, :nodes=>{}, :max_port=>(23+@port_start)} unless @switches.key? key
+ port = if switch['switch_port'] == -1 or switch['switch_port'] == "-1"
+ @vports[key] = 1 + (@vports[key] || 0)
+ else
+ switch[:port]
+ end
+ @port_start = 0 if port == 0
+ @switches[key][:max_port] = port if port>@switches[key][:max_port]
+ @switches[key][:nodes][port] = { :handle=>node.name, :intf=>switch[:intf] }
+ @switches[key][:status][node.status] = (@switches[key][:status][node.status] || 0).to_i + 1
+ end
+ end
+ end
+ #make sure port max is even
+ flash[:notice] = "<b>#{I18n.t :warning, :scope => :error}:</b> #{I18n.t :no_nodes_found, :scope => :error}".html_safe if @nodes.empty?
+ end
+
+ def vlan
+ net_bc = RoleObject.find_role_by_name 'network-config-default'
+ if net_bc.barclamp == 'network'
+ @vlans = net_bc.default_attributes['network']['networks']
+ end
+ @nodes = {}
+ NodeObject.all.each do |node|
+ @nodes[node.name] = { :alias=>node.alias, :description=>node.description(false, true), :vlans=>{} }
+ @nodes[node.name][:vlans] = node_vlans(node)
+ end
+
+ end
+
+ def nodes
+
+ net_bc = RoleObject.find_role_by_name 'network-config-default'
+ @modes = []
+ @active_mode = @mode = net_bc.default_attributes['network']['mode']
+ # first, we need a mode list
+ net_bc.default_attributes['network']['conduit_map'].each do |conduit|
+ mode = conduit['pattern'].split('/')[0]
+ @modes << mode unless @modes.include? mode
+ @mode = params[:mode] if @modes.include? params[:mode]
+ end
+ # now we need to complete conduit list for the mode (we have to inspect all conduits!)
+ @conduits = []
+ net_bc.default_attributes['network']['conduit_map'].each do |conduit|
+ mode = conduit['pattern'].split('/')[0]
+ conduit['conduit_list'].each { |c, details| @conduits << c unless @conduits.include? c } if mode == @mode
+ end
+
+ @nodes = {}
+ NodeObject.all.each do |node|
+ @nodes[node.name] = {:alias=>node.alias, :description=>node.description, :model=>node.hardware, :bus=>node.get_bus_order, :conduits=>node.build_node_map }
+ end
+ @conduits = @conduits.sort
+
+ end
+
+ #UI Methods
+ def show
+ Rails.logger.debug("NetworksController.show");
+ begin
+ @network = Network.find(params[:id]) unless params[:id].nil?
+ rescue
+ @network = Network.find_by_name(params[:id])
+ end
+ Rails.logger.debug("NetworksController.show inpect found network: #{@network.inspect}");
+ respond_to do |format|
+ format.json {
+ Rails.logger.debug("NetworksController.show format JSON: #{@network.inspect}");
+ render :json => @network
+ }
+ format.html {
+ Rails.logger.debug("NetworksController.show format HTML: #{@network.inspect}");
+ }
+ end
+ end
+
+ def index
+ Rails.logger.debug("NetworksController.index");
+ @networks = Network.all
+ respond_to do |format|
+ format.json { render :json => network_refs }
+ format.html {
+ Rails.logger.debug("NetworksController.index Format HTML: #{@networks.inspect}");
+ }
+ end
+ end
+
+ def edit
+ Rails.logger.debug("NetworksController.edit");
+ @network = Network.find(params[:id]) unless params[:id].nil?
+ @conduits = Conduit.all
+ respond_to do |format|
+ format.html {
+ Rails.logger.debug("NetworksController.edit Format HTML: #{@network.inspect}");
+ }
+ end
+ end
+
+ def update
+ Rails.logger.debug("NetworksController.update!");
+ @network = Network.find(params[:id])
+ if @network.update_attributes(params[:network])
+ redirect_to :action => :index
+ else
+ render 'edit'
+ end
+ end
+
+ add_help(:conduit_list,[],[:get])
+ def conduit
+ Rails.logger.debug("Listing conduits");
+
+ conduit_refs = []
+
+ @conduits = Conduit.all
+ @conduits.each { |conduit|
+ conduit_refs << conduit.id
+ }
+
+ respond_to do |format|
+ format.json { render :json => conduit_refs }
+ format.xml { render :xml => conduit_refs }
+ format.html {
+ Rails.logger.debug("Format HTML conduits#{@conduits.inspect}");
+ }
+ end
+ end
+
+ private
+ def to_bool(value)
+ return true if value == true || value =~ /^true|t$/i
+ return false if value == false || value =~ /^false|f$/i
+ raise ArgumentError.new("Invalid boolean value")
+ end
+
+ def node_vlans(node)
+ nv = {}
+ vlans = node["crowbar"]["network"].each do |vlan, vdetails|
+ nv[vlan] = { :address => vdetails["address"], :active=>vdetails["use_vlan"] }
+ end
+ nv
+ end
+
+ def node_nics(node)
+ switches = []
+ begin
+ # list the interfaces
+ if_list = node.crowbar_ohai["detected"]["network"].keys
+ # this is a virtual switch if ALL the interfaces are virtual
+ physical = if_list.map{ |intf| node.crowbar_ohai["switch_config"][intf]['switch_name'] != '-1' }.include? false
+ if_list.each do | intf |
+ connected = !physical #if virtual, then all ports are connected
+ raw = node.crowbar_ohai["switch_config"][intf]
+ s_name = raw['switch_name'] || -1
+ s_unit = raw['switch_unit'] || -1
+ if s_name == -1 or s_name == "-1"
+ s_name = I18n.t('network.controller.virtual') + ":" + intf.split('.')[0]
+ s_unit = nil
+ else
+ connected = true
+ end
+ if connected
+ s_name= "#{s_name}:#{s_unit}" unless s_unit.nil?
+ switches << { :switch=>s_name, :intf=>intf, :port=>raw['switch_port'].to_i }
+ end
+ end
+ rescue Exception=>e
+ Rails.logger.debug("could not build interface/switch list for #{node.name} due to #{e.message}")
+ end
+ switches
+ end
+end
View
19 ...p_network/app/controllers/barclamp_network/scaffolds/allocated_ip_addresses_controller.rb
@@ -0,0 +1,19 @@
+# Copyright 2013, 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 Scaffolds::AllocatedIpAddressesController < ApplicationController
+ active_scaffold :allocated_ip_address do |conf|
+ end
+end
View
19 .../barclamp_network/app/controllers/barclamp_network/scaffolds/bmc_interfaces_controller.rb
@@ -0,0 +1,19 @@
+# Copyright 2013, 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 Scaffolds::BmcInterfacesController < ApplicationController
+ active_scaffold :bmc_interface do |conf|
+ end
+end
View
19 ...ar_engine/barclamp_network/app/controllers/barclamp_network/scaffolds/bonds_controller.rb
@@ -0,0 +1,19 @@
+# Copyright 2013, 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 Scaffolds::BondsController < ApplicationController
+ active_scaffold :bond do |conf|
+ end
+end
View
19 ...engine/barclamp_network/app/controllers/barclamp_network/scaffolds/bus_maps_controller.rb
@@ -0,0 +1,19 @@
+# Copyright 2013, 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 Scaffolds::BusMapsController < ApplicationController
+ active_scaffold :bus_map do |conf|
+ end
+end
View
19 ...ar_engine/barclamp_network/app/controllers/barclamp_network/scaffolds/buses_controller.rb
@@ -0,0 +1,19 @@
+# Copyright 2013, 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 Scaffolds::BusesController < ApplicationController
+ active_scaffold :bus do |conf|
+ end
+end
View
19 ...barclamp_network/app/controllers/barclamp_network/scaffolds/conduit_actions_controller.rb
@@ -0,0 +1,19 @@
+# Copyright 2013, 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 Scaffolds::ConduitActionsController < ApplicationController
+ active_scaffold :conduit_action do |conf|
+ end
+end
View
19 ...barclamp_network/app/controllers/barclamp_network/scaffolds/conduit_filters_controller.rb
@@ -0,0 +1,19 @@
+# Copyright 2013, 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 Scaffolds::ConduitFiltersController < ApplicationController
+ active_scaffold :conduit_filter do |conf|
+ end
+end
View
19 ...e/barclamp_network/app/controllers/barclamp_network/scaffolds/conduit_rules_controller.rb
@@ -0,0 +1,19 @@
+# Copyright 2013, 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 Scaffolds::ConduitRulesController < ApplicationController
+ active_scaffold :conduit_rule do |conf|
+ end
+end
View
19 ...engine/barclamp_network/app/controllers/barclamp_network/scaffolds/conduits_controller.rb
@@ -0,0 +1,19 @@
+# Copyright 2013, 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 Scaffolds::ConduitsController < ApplicationController
+ active_scaffold :conduit do |conf|
+ end
+end
View
19 ...ne/barclamp_network/app/controllers/barclamp_network/scaffolds/create_bonds_controller.rb
@@ -0,0 +1,19 @@
+# Copyright 2013, 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 Scaffolds::CreateBondsController < ApplicationController
+ active_scaffold :create_bond do |conf|
+ end
+end
View
19 ...ne/barclamp_network/app/controllers/barclamp_network/scaffolds/create_vlans_controller.rb
@@ -0,0 +1,19 @@
+# Copyright 2013, 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 Scaffolds::CreateVlansController < ApplicationController
+ active_scaffold :create_vlan do |conf|
+ end
+end
View
19 .../barclamp_network/app/controllers/barclamp_network/scaffolds/interface_maps_controller.rb
@@ -0,0 +1,19 @@
+# Copyright 2013, 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 Scaffolds::InterfaceMapsController < ApplicationController
+ active_scaffold :interface_map do |conf|
+ end
+end
View
19 ...lamp_network/app/controllers/barclamp_network/scaffolds/interface_selectors_controller.rb
@@ -0,0 +1,19 @@
+# Copyright 2013, 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 Scaffolds::InterfaceSelectorsController < ApplicationController
+ active_scaffold :interface_selector do |conf|
+ end
+end
View
19 ...gine/barclamp_network/app/controllers/barclamp_network/scaffolds/interfaces_controller.rb
@@ -0,0 +1,19 @@
+# Copyright 2013, 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 Scaffolds::InterfacesController < ApplicationController
+ active_scaffold :interface do |conf|
+ end
+end
View
19 ...ne/barclamp_network/app/controllers/barclamp_network/scaffolds/ip_addresses_controller.rb
@@ -0,0 +1,19 @@
+# Copyright 2013, 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 Scaffolds::IpAddressesController < ApplicationController
+ active_scaffold :ip_address do |conf|
+ end
+end
View
19 ...ngine/barclamp_network/app/controllers/barclamp_network/scaffolds/ip_ranges_controller.rb
@@ -0,0 +1,19 @@
+# Copyright 2013, 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 Scaffolds::IpRangesController < ApplicationController
+ active_scaffold :ip_range do |conf|
+ end
+end
View
19 ...amp_network/app/controllers/barclamp_network/scaffolds/network_mode_filters_controller.rb
@@ -0,0 +1,19 @@
+# Copyright 2013, 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 Scaffolds::NetworkModeFiltersController < ApplicationController
+ active_scaffold :network_mode_filter do |conf|
+ end
+end
View
19 ...engine/barclamp_network/app/controllers/barclamp_network/scaffolds/networks_controller.rb
@@ -0,0 +1,19 @@
+# Copyright 2013, 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 Scaffolds::NetworksController < ApplicationController
+ active_scaffold :network do |conf|
+ end
+end
View
19 ...p_network/app/controllers/barclamp_network/scaffolds/node_attribute_filters_controller.rb
@@ -0,0 +1,19 @@
+# Copyright 2013, 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 Scaffolds::NodeAttributeFiltersController < ApplicationController
+ active_scaffold :node_attribute_filter do |conf|
+ end
+end
View
19 ...lamp_network/app/controllers/barclamp_network/scaffolds/physical_interfaces_controller.rb
@@ -0,0 +1,19 @@
+# Copyright 2013, 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 Scaffolds::PhysicalInterfacesController < ApplicationController
+ active_scaffold :physical_interface do |conf|
+ end
+end
View
19 ..._engine/barclamp_network/app/controllers/barclamp_network/scaffolds/routers_controller.rb
@@ -0,0 +1,19 @@
+# Copyright 2013, 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 Scaffolds::RoutersController < ApplicationController
+ active_scaffold :router do |conf|
+ end
+end
View
19 ...rclamp_network/app/controllers/barclamp_network/scaffolds/select_by_indices_controller.rb
@@ -0,0 +1,19 @@
+# Copyright 2013, 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 Scaffolds::SelectByIndicesController < ApplicationController
+ active_scaffold :select_by_index do |conf|
+ end
+end
View
19 ...arclamp_network/app/controllers/barclamp_network/scaffolds/select_by_speeds_controller.rb
@@ -0,0 +1,19 @@
+# Copyright 2013, 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 Scaffolds::SelectBySpeedsController < ApplicationController
+ active_scaffold :select_by_speed do |conf|
+ end
+end
View
19 ...barclamp_network/app/controllers/barclamp_network/scaffolds/vlan_interfaces_controller.rb
@@ -0,0 +1,19 @@
+# Copyright 2013, 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 Scaffolds::VlanInterfacesController < ApplicationController
+ active_scaffold :vlan_interface do |conf|
+ end
+end
View
19 ...ar_engine/barclamp_network/app/controllers/barclamp_network/scaffolds/vlans_controller.rb
@@ -0,0 +1,19 @@
+# Copyright 2013, 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 Scaffolds::VlansController < ApplicationController
+ active_scaffold :vlan do |conf|
+ end
+end
View
4 crowbar_engine/barclamp_network/app/helpers/barclamp_network/application_helper.rb
@@ -0,0 +1,4 @@
+module BarclampNetwork
+ module ApplicationHelper
+ end
+end
View
24 crowbar_engine/barclamp_network/app/models/barclamp_network/allocated_ip_address.rb
@@ -0,0 +1,24 @@
+# Copyright 2013, 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 BarclampNetwork::AllocatedIpAddress < ActiveRecord::Base
+ belongs_to :interface, :inverse_of => :allocated_ip_addresses
+ belongs_to :network, :inverse_of => :allocated_ips
+ attr_accessible :ip
+
+ validates :ip,
+ :presence => true,
+ :format => { :with => /^([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])$/, :message => "not a valid IP" }
+ validates :network, :presence => true
+end
View
45 crowbar_engine/barclamp_network/app/models/barclamp_network/attrib_instance_bus_order.rb
@@ -0,0 +1,45 @@
+# Copyright 2013, 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 BarclampNetwork::AttribInstanceBusOrder < AttribInstance
+ def state
+ AttribInstance.calc_state(value_actual , value_request, jig_run_id)
+ end
+
+
+ def request=(value)
+ # Discard since this attribute is a facade over AR objects
+ raise "Not implemented"
+ end
+
+
+ def request
+ raise "Not implemented"
+ end
+
+
+ def actual=(value)
+ # Discard since this attribute is a facade over AR objects
+ end
+
+
+ def actual
+ buses = InterfaceMap.get_bus_order(node)
+ bus_order=[]
+ buses.each {|bus|
+ bus_order << bus.path
+ }
+ bus_order.to_json
+ end
+end
View
51 crowbar_engine/barclamp_network/app/models/barclamp_network/attrib_instance_ip_address.rb
@@ -0,0 +1,51 @@
+# Copyright 2013, 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 BarclampNetwork::AttribInstanceIpAddress < AttribInstance
+ def state
+ AttribInstance.calc_state(value_actual , value_request, jig_run_id)
+ end
+
+
+ def request=(value)
+ # Discard since this attribute is a facade over AR objects
+ raise "Not implemented"
+ end
+
+
+ def request
+ raise "Not implemented"
+ end
+
+
+ def actual=(value)
+ # Discard since this attribute is a facade over AR objects
+ end
+
+
+ def actual(proposal="default", network="admin")
+ error_code, *rest = NetworkUtils.find_proposal_and_network(proposal, network)
+ raise "#{error_code}: #{rest[0]}" if error_code != 200
+
+ proposal = rest[0]
+ network = rest[1]
+
+ results = AllocatedIpAddress.joins(:interface).where(:interfaces => {:node_id => node.id}).where(:network_id => network.id)
+ if results.length == 0
+ raise "Node #{NetworkUtils.log_name(node)} does not have an address allocated on network #{log_name(self)}"
+ end
+
+ results.first.ip
+ end
+end
View
761 crowbar_engine/barclamp_network/app/models/barclamp_network/barclamp.rb
@@ -0,0 +1,761 @@
+# Copyright 2013, 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 BarclampNetwork::Barclamp < Barclamp
+
+ def apply_role_pre_chef_call(old_config, new_config, all_nodes)
+ proposal = new_config.proposal
+
+ # TODO Remove the below HACK and add code the retrieves the new network
+ # json from the barclamp template
+
+ # Start HACK
+ new_json = read_new_network_json()
+ attrs_config = new_json["attributes"]
+ # End HACK
+
+ populate_network_defaults( attrs_config["network"], proposal )
+ end
+
+
+ def self.read_new_network_json()
+ fp = File.join(Rails.root,"..","barclamps","network","chef","data_bags","crowbar","bc-template-network-new.json")
+ JSON.load File.open(fp, "r")
+ end
+
+
+ def populate_network_defaults( network_attrs_config, proposal )
+ create_interface_map( network_attrs_config, proposal )
+ create_conduits( network_attrs_config, proposal )
+ create_networks( network_attrs_config, proposal )
+ end
+
+
+ def create_interface_map( network_attrs_config, proposal )
+ interface_map = InterfaceMap.new()
+ interface_map.proposal = proposal
+ interface_map_config = network_attrs_config["interface_map"]
+ interface_map_config.each { |bus_map_config|
+ bus_map = BusMap.new()
+ bus_map.pattern = bus_map_config["pattern"]
+ interface_map.bus_maps << bus_map
+
+ bus_index = 0
+ bus_order_config = bus_map_config["bus_order"]
+ bus_order_config.each { |bus_config|
+ bus = Bus.new()
+ bus.path = bus_config
+ bus.order = bus_index
+ bus_index += 1
+ bus_map.buses << bus
+ }
+ }
+
+ interface_map.save!
+ interface_map
+ end
+
+
+ def create_conduits( network_attrs_config, proposal )
+ conduits_config = network_attrs_config["conduit_map"]
+ conduits_config.each { |conduit_config|
+ conduit = Conduit.new()
+ conduit.proposal = proposal
+ conduit.name = conduit_config["conduit_name"]
+
+ conduit_rules_config = conduit_config["conduit_rules"]
+ conduit_rules_config.each { |conduit_rule_config|
+ conduit_rule = ConduitRule.new()
+ conduit.conduit_rules << conduit_rule
+
+ conduit_filters_config = conduit_rule_config["conduit_filters"]
+ conduit_filters_config.each { |conduit_filter_name, conduit_filter_parms|
+ conduit_filter = Object.const_get(conduit_filter_name).new()
+ conduit_rule.conduit_filters << conduit_filter
+ conduit_filter_parms.each { |param_name, param_value|
+ conduit_filter.send( "#{param_name}=", param_value )
+ }
+ conduit_filter.save!
+ }
+
+ interface_selectors_config = conduit_rule_config["interface_selectors"]
+ interface_selectors_config.each { |interface_selector_config|
+ interface_selector = InterfaceSelector.new()
+ conduit_rule.interface_selectors << interface_selector
+
+ interface_selector_config.each { |selector_name, selector_parms|
+ selector = Object.const_get(selector_name).new()
+ interface_selector.selectors << selector
+ selector_parms.each { |param_name, param_value|
+ selector.send( "#{param_name}=", param_value )
+ }
+ selector.save!
+ }
+ interface_selector.save!
+ }
+
+ conduit_actions_config = conduit_rule_config["conduit_actions"]
+ conduit_actions_config.each { |conduit_action_config|
+ conduit_action_config.each { |conduit_action_name, conduit_action_parms|
+ conduit_action = Object.const_get(conduit_action_name).new()
+ conduit_rule.conduit_actions << conduit_action
+ conduit_action_parms.each { |param_name, param_value|
+ conduit_action.send( "#{param_name}=", param_value )
+ }
+ conduit_action.save!
+ }
+ }
+ conduit_rule.save!
+ }
+
+ conduit.save!
+ }
+ end
+
+
+ def create_networks( network_attrs_config, proposal )
+ networks_config = network_attrs_config["networks"]
+ networks_config.each { |network_name, network_config|
+ network = Network.new()
+ network.proposal = proposal
+ network.name = network_name
+ network_config.each { |param_name, param_value|
+ case param_name
+ when "conduit"
+ network.conduit = Conduit.find_key(param_value)
+ when "use_vlan"
+ network.use_vlan = param_value
+ when "vlan"
+ network.vlan = Vlan.new(:tag => param_value)
+ when "subnet"
+ network.subnet = IpAddress.new(:cidr => param_value)
+ when "dhcp_enabled"
+ network.dhcp_enabled = param_value
+ when "router"
+ network.router = Router.new() if network.router.nil?
+ network.router.ip = IpAddress.new(:cidr => param_value)
+ when "router_pref"
+ network.router = Router.new() if network.router.nil?
+ network.router.pref = param_value.to_i
+ when "ranges"
+ param_value.each { |range_name, range|
+ ip_range = IpRange.new(:name => range_name)
+ start_address = range["start"]
+ ip_range.start_address = IpAddress.new(:cidr => start_address)
+ end_address = range["end"]
+ ip_range.end_address = IpAddress.new(:cidr => end_address)
+ network.ip_ranges << ip_range
+ }
+ end
+ }
+
+ network.save!
+ }
+ end
+
+
+ def allocate_ip(bc_instance, network, range, name, suggestion = nil)
+ @logger.debug("Network allocate_ip: entering #{name} #{network} #{range}")
+
+ return [404, "No network specified"] if network.nil?
+ return [404, "No range specified"] if range.nil?
+ return [404, "No name specified"] if name.nil?
+
+ # Find the node
+ node = NodeObject.find_node_by_name name
+ @logger.error("Network allocate_ip: return node not found: #{name} #{network} #{range}") if node.nil?
+ return [404, "No node found"] if node.nil?
+
+ # Find an interface based upon config
+ role = RoleObject.find_role_by_name "network-config-#{bc_instance}"
+ @logger.error("Network allocate_ip: No network data found: #{name} #{network} #{range}") if role.nil?
+ return [404, "No network data found"] if role.nil?
+
+ # If we already have on allocated, return success
+ unless node.address(network)
+ @logger.error("Network allocate_ip: node already has address: #{name} #{network} #{range}")
+ return [200, node[:crowbar][:network][network]]
+ end
+
+ net_info={}
+ found = false
+ CrowbarUtils.with_lock("ip") do
+ begin # Rescue block
+ db = ProposalObject.find_data_bag_item "crowbar/#{network}_network"
+ net_info = build_net_info(network, name, db)
+
+ rangeH = db["network"]["ranges"][range]
+ rangeH = db["network"]["ranges"]["host"] if rangeH.nil?
+
+ index = IPAddr.new(rangeH["start"]) & ~IPAddr.new(net_info["netmask"])
+ index = index.to_i
+ stop_address = IPAddr.new(rangeH["end"]) & ~IPAddr.new(net_info["netmask"])
+ stop_address = IPAddr.new(net_info["subnet"]) | (stop_address.to_i + 1)
+ address = IPAddr.new(net_info["subnet"]) | index
+
+ if suggestion
+ @logger.error("Allocating with suggestion: #{suggestion}")
+ subsug = IPAddr.new(suggestion) & IPAddr.new(net_info["netmask"])
+ subnet = IPAddr.new(net_info["subnet"]) & IPAddr.new(net_info["netmask"])
+ if subnet == subsug
+ if db["allocated"][suggestion].nil?
+ @logger.error("Using suggestion: #{name} #{network} #{suggestion}")
+ address = suggestion
+ found = true
+ end
+ end
+ end
+
+ unless found
+ # Did we already allocate this, but the node lose it?
+ unless db["allocated_by_name"][node.name].nil?
+ found = true
+ address = db["allocated_by_name"][node.name]["address"]
+ end
+ end
+
+ # Let's search for an empty one.
+ while !found do
+ if db["allocated"][address.to_s].nil?
+ found = true
+ break
+ end
+ index = index + 1
+ address = IPAddr.new(net_info["subnet"]) | index
+ break if address == stop_address
+ end
+
+ if found
+ net_info["address"] = address.to_s
+ db["allocated_by_name"][node.name] = { "machine" => node.name, "interface" => net_info["conduit"], "address" => address.to_s }
+ db["allocated"][address.to_s] = { "machine" => node.name, "interface" => net_info["conduit"], "address" => address.to_s }
+ db.save
+ end
+ rescue Exception => e
+ @logger.error("Error finding address: #{e.message}")
+ end
+ end
+
+ @logger.info("Network allocate_ip: no address available: #{name} #{network} #{range}") if !found
+ return [404, "No Address Available"] if !found
+
+ # Save the information.
+ node.crowbar["crowbar"]["network"][network] = net_info
+ node.save
+
+ @logger.info("Network allocate_ip: Assigned: #{name} #{network} #{range} #{net_info["address"]}")
+ [200, net_info]
+ end
+
+
+ def network_allocate_ip(proposal_id, network_id, range, node_id, suggestion = nil)
+ @logger.debug("Entering network_allocate_ip(proposal_id: #{proposal_id}, network_id: #{network_id}, range: #{range}, node_id: #{node_id}, suggestion: #{suggestion})")
+
+ proposal_id = proposal_id.to_s
+ proposal_id = nil if proposal_id.empty?
+
+ # Validate inputs
+ return [400, "No network_id specified"] if network_id.nil?
+ return [400, "No node_id specified"] if node_id.nil?
+
+ # Find the node
+ node = Node.find_key(node_id)
+ return [404, "Node #{node_id} does not exist"] if node.nil?
+
+ # Find the proposal and network
+ error_code, *rest = NetworkUtils.find_proposal_and_network(proposal_id, network_id)
+ return [error_code, rest[0]] if error_code != 200
+ proposal = rest[0]
+ network = rest[1]
+
+ network.allocate_ip(range, node, suggestion)
+ end
+
+
+ def deallocate_ip(bc_instance, network, name)
+ @logger.debug("Network deallocate_ip: entering #{name} #{network}")
+
+ return [404, "No network specified"] if network.nil?
+ return [404, "No name specified"] if name.nil?
+
+ # Find the node
+ node = NodeObject.find_node_by_name name
+ @logger.error("Network deallocate_ip: return node not found: #{name} #{network}") if node.nil?
+ return [404, "No node found"] if node.nil?
+
+ # Find an interface based upon config
+ role = RoleObject.find_role_by_name "network-config-#{bc_instance}"
+ @logger.error("Network allocate_ip: No network data found: #{name} #{network}") if role.nil?
+ return [404, "No network data found"] if role.nil?
+
+ # If we already have on allocated, return success
+ net_info = node.get_network_by_type(network)
+ if net_info.nil? or net_info["address"].nil?
+ @logger.error("Network deallocate_ip: node does not have address: #{name} #{network}")
+ return [200, nil]
+ end
+
+ save = false
+ CrowbarUtils.with_lock("ip") do
+ begin # Rescue block
+ db = ProposalObject.find_data_bag_item "crowbar/#{network}_network"
+
+ address = net_info["address"]
+
+ # Did we already allocate this, but the node lose it?
+ unless db["allocated_by_name"][node.name].nil?
+ save = true
+
+ newhash = {}
+ db["allocated_by_name"].each do |k,v|
+ newhash[k] = v unless k == node.name
+ end
+ db["allocated_by_name"] = newhash
+ end
+
+ unless db["allocated"][address.to_s].nil?
+ save = true
+ newhash = {}
+ db["allocated"].each do |k,v|
+ newhash[k] = v unless k == address.to_s
+ end
+ db["allocated"] = newhash
+ end
+
+ if save
+ db.save
+ end
+ rescue