Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added Bridge class.

Made parent/child relationship between interfaces generic.
Updated scaffolds for Bridges
Updated code to reflect new routing scheme
  • Loading branch information...
commit 8995898d52199cc7f89f91a2ee5c513403964ab0 1 parent 5d4b991
@cdearborn cdearborn authored
Showing with 249 additions and 198 deletions.
  1. +47 −41 bin/crowbar_network
  2. +1 −1  crowbar_engine/barclamp_network/app/controllers/barclamp_network/conduits_controller.rb
  3. +65 −44 crowbar_engine/barclamp_network/app/controllers/barclamp_network/networks_controller.rb
  4. +20 −0 crowbar_engine/barclamp_network/app/controllers/barclamp_network/scaffolds/bridge_controller.rb
  5. +15 −31 crowbar_engine/barclamp_network/app/models/barclamp_network/barclamp.rb
  6. +5 −7 crowbar_engine/barclamp_network/app/models/barclamp_network/bond.rb
  7. +16 −0 crowbar_engine/barclamp_network/app/models/barclamp_network/bridge.rb
  8. +5 −4 crowbar_engine/barclamp_network/app/models/barclamp_network/interface.rb
  9. +0 −1  crowbar_engine/barclamp_network/app/models/barclamp_network/physical_interface.rb
  10. +0 −1  crowbar_engine/barclamp_network/app/models/barclamp_network/vlan_interface.rb
  11. +1 −0  crowbar_engine/barclamp_network/config/locales/en.yml
  12. +12 −17 crowbar_engine/barclamp_network/config/routes.rb
  13. +2 −3 crowbar_engine/barclamp_network/db/migrate/20120730175238_create_interfaces.rb
  14. +26 −24 crowbar_engine/barclamp_network/db/migrate/20130124211800_scaffold_navs.rb
  15. +14 −14 crowbar_engine/barclamp_network/test/unit/bond_model_test.rb
  16. +20 −10 crowbar_engine/barclamp_network/test/unit/network_barclamp_test.rb
View
88 bin/crowbar_network
@@ -18,23 +18,23 @@
require File.join(File.expand_path(File.dirname(__FILE__)), "barclamp_lib")
@barclamp = "network"
-@commands["network_deallocate_ip"] = [ "network_deallocate_ip(ARGV.shift,ARGV.shift,ARGV.shift)", "network_deallocate_ip <deployment_id> <node_id> <network_id> - Deallocate an ip from a node on a network" ]
-@commands["network_allocate_ip"] = [ "network_allocate_ip(ARGV.shift,ARGV.shift,ARGV.shift,ARGV.shift,ARGV.shift)", "network_allocate_ip <deployment_id> <node_id> <network_id> <range> [suggestion] - Allocate an ip for a node on a network from a range" ]
-@commands["network_enable_interface"] = [ "network_enable_interface(ARGV.shift,ARGV.shift,ARGV.shift)", "network_enable_interface <deployment_id> <node_id> <network_id> - Ensure that an interface is present for the specified network" ]
-@commands["network_list"] = [ "network_list()", "network_list - Show a list of current networks" ]
-@commands["network_show"] = [ "network_show(ARGV.shift)", "network_show <name_or_id> - Show a specific network" ]
-@commands["network_create"] = [ "network_create(ARGV.shift,ARGV.shift,ARGV.shift,ARGV.shift,ARGV.shift,ARGV.shift,ARGV.shift,ARGV.shift)", "network_create <deployment_id> <name> <conduit_id> <subnet> <dhcp_enabled> <ip_ranges> <router_pref> <router_ip> - Create a network" ]
-@commands["network_edit"] = [ "network_edit(ARGV.shift,ARGV.shift,ARGV.shift,ARGV.shift,ARGV.shift,ARGV.shift,ARGV.shift)", "network_edit <name_or_id> <conduit_id> <subnet> <dhcp_enabled> <ip_ranges> <router_pref> <router_ip> - Edit a network" ]
-@commands["network_delete"] = [ "network_delete(ARGV.shift)", "network_delete <name_or_id> - Delete a network" ]
+@commands["deallocate_ip"] = [ "deallocate_ip(ARGV.shift,ARGV.shift,ARGV.shift)", "deallocate_ip <deployment_id> <network_id> <node_id> - Deallocate an ip from a node on a network" ]
+@commands["allocate_ip"] = [ "allocate_ip(ARGV.shift,ARGV.shift,ARGV.shift,ARGV.shift,ARGV.shift)", "allocate_ip <deployment_id> <network_id> <node_id> <range> [suggestion] - Allocate an ip for a node on a network from a range" ]
+@commands["enable_interface"] = [ "enable_interface(ARGV.shift,ARGV.shift,ARGV.shift)", "enable_interface <deployment_id> <network_id> <node_id> - Ensure that an interface is present for the specified network" ]
+@commands["list"] = [ "list(ARGV.shift)", "list <deployment_id>- Show a list of current networks" ]
+@commands["show"] = [ "show(ARGV.shift,ARGV.shift)", "show <deployment_id> <network_id> - Show a specific network" ]
+@commands["create"] = [ "create(ARGV.shift,ARGV.shift,ARGV.shift,ARGV.shift,ARGV.shift,ARGV.shift,ARGV.shift,ARGV.shift)", "create <deployment_id> <name> <conduit_id> <subnet> <dhcp_enabled> <ip_ranges> <router_pref> <router_ip> - Create a network" ]
+@commands["edit"] = [ "edit(ARGV.shift,ARGV.shift,ARGV.shift,ARGV.shift,ARGV.shift,ARGV.shift,ARGV.shift,ARGV.shift)", "edit <deployment_id> <network_id> <conduit_id> <subnet> <dhcp_enabled> <ip_ranges> <router_pref> <router_ip> - Edit a network" ]
+@commands["delete"] = [ "delete(ARGV.shift,ARGV.shift)", "delete <deployment_id> <network_id> - Delete a network" ]
-def network_enable_interface(deployment_id, node_id, network_id)
+def enable_interface(deployment_id, network_id, node_id)
usage -1 if deployment_id.nil? or deployment_id == ""
- usage -1 if node_id.nil? or node_id == ""
usage -1 if network_id.nil? or network_id == ""
+ usage -1 if node_id.nil? or node_id == ""
- @data = { "node_id" => node_id, "network_id" => network_id }.to_json
- struct = post_json2("2.0/crowbar/2.0/network/networks/#{deployment_id}/enable_interface", @data)
+ @data = { "node_id" => node_id }.to_json
+ struct = put_json2("#{@barclamp}/v2/deployments/#{deployment_id}/networks/#{network_id}/enable_interface", @data)
case struct[1]
when 200
@@ -44,22 +44,22 @@ def network_enable_interface(deployment_id, node_id, network_id)
when 400
[ "Failed to enable interface for deployment #{deployment_id}, network #{network_id}, node #{node_id}: Errors in data\n#{struct[0]}", 1 ]
else
- [ "Failed to talk to service network_enable_interface for deployment #{deployment_id}, network #{network_id}, node #{node_id}: #{struct[1]}: #{struct[0]}", 1 ]
+ [ "Failed to talk to service enable_interface for deployment #{deployment_id}, network #{network_id}, node #{node_id}: #{struct[1]}: #{struct[0]}", 1 ]
end
end
-def network_allocate_ip(deployment_id, node_id, network_id, range, suggestion)
+def allocate_ip(deployment_id, network_id, node_id, range, suggestion)
usage -1 if deployment_id.nil? or deployment_id == ""
- usage -1 if node_id.nil? or node_id == ""
usage -1 if network_id.nil? or network_id == ""
+ usage -1 if node_id.nil? or node_id == ""
usage -1 if range.nil? or range == ""
- @data = { "network_id" => network_id, "node_id" => node_id, "range" => range }
+ @data = { "node_id" => node_id, "range" => range }
@data["suggestion"] = suggestion if suggestion
@data = @data.to_json
- struct = post_json2("2.0/crowbar/2.0/network/networks/#{deployment_id}/allocate_ip", @data)
+ struct = put_json2("#{@barclamp}/v2/deployments/#{deployment_id}/networks/#{network_id}/allocate_ip", @data)
case struct[1]
when 200
@@ -69,17 +69,18 @@ def network_allocate_ip(deployment_id, node_id, network_id, range, suggestion)
when 400
[ "Failed to allocate IP for deployment #{deployment_id}, network #{network_id}, node #{node_id}: Errors in data\n#{struct[0]}", 1 ]
else
- [ "Failed to talk to service network_allocate_ip for deployment #{deployment_id}, network #{network_id}, node #{node_id}: #{struct[1]}: #{struct[0]}", 1 ]
+ [ "Failed to talk to service allocate_ip for deployment #{deployment_id}, network #{network_id}, node #{node_id}: #{struct[1]}: #{struct[0]}", 1 ]
end
end
-def network_deallocate_ip(deployment_id, node_id, network_id)
+def deallocate_ip(deployment_id, network_id, node_id)
usage -1 if deployment_id.nil? or deployment_id == ""
- usage -1 if node_id.nil? or node_id == ""
usage -1 if network_id.nil? or network_id == ""
+ usage -1 if node_id.nil? or node_id == ""
- struct = delete_json2("2.0/crowbar/2.0/network/networks/#{deployment_id}/deallocate_ip/#{network_id}/#{node_id}")
+ @data = { "node_id" => node_id }.to_json
+ struct = put_json2("#{@barclamp}/v2/deployments/#{deployment_id}/networks/#{network_id}/deallocate_ip", @data)
case struct[1]
when 200
@@ -89,13 +90,15 @@ def network_deallocate_ip(deployment_id, node_id, network_id)
when 400
[ "Failed to deallocate IP address for deployment #{deployment_id}, network #{network_id}, node #{node_id}: Errors in data\n#{struct[0]}", 1 ]
else
- [ "Failed to talk to service network_deallocate_ip for deployment #{deployment_id}, network #{network_id}, node #{node_id}: #{struct[1]}: #{struct[0]}", 1 ]
+ [ "Failed to talk to service deallocate_ip for deployment #{deployment_id}, network #{network_id}, node #{node_id}: #{struct[1]}: #{struct[0]}", 1 ]
end
end
-def network_list()
- struct = get_json2("2.0/crowbar/2.0/network/networks")
+def list(deployment_id)
+ usage -1 if deployment_id.nil? or deployment_id == ""
+
+ struct = get_json2("#{@barclamp}/v2/deployments/#{deployment_id}/networks")
if struct[1] != 200
[ "Failed to talk to service network list: #{struct[1]}: #{struct[0]}", 1 ]
@@ -107,10 +110,11 @@ def network_list()
end
-def network_show(id)
- usage -1 if id.nil? or id == ""
+def show(deployment_id, network_id)
+ usage -1 if deployment_id.nil? or deployment_id == ""
+ usage -1 if network_id.nil? or network_id == ""
- struct = get_json2("2.0/crowbar/2.0/network/networks/#{id}")
+ struct = get_json2("#{@barclamp}/v2/deployments/#{deployment_id}/networks/#{network_id}")
if struct[1] == 200
[ "#{JSON.pretty_generate(struct[0])}", 0 ]
@@ -122,7 +126,7 @@ def network_show(id)
end
-def network_create(deployment_id, name, conduit_id, subnet, dhcp_enabled, ip_ranges, router_pref, router_ip)
+def create(deployment_id, name, conduit_id, subnet, dhcp_enabled, ip_ranges, router_pref, router_ip)
usage -1 if deployment_id.nil? or deployment_id == ""
usage -1 if name.nil? or name == ""
usage -1 if conduit_id.nil? or conduit_id == ""
@@ -141,7 +145,7 @@ def network_create(deployment_id, name, conduit_id, subnet, dhcp_enabled, ip_ran
"router_pref" => router_pref,
"router_ip" => router_ip
}.to_json
- struct = post_json2("2.0/crowbar/2.0/network/networks", @data)
+ struct = post_json2("#{@barclamp}/v2/deployments/#{deployment_id}/networks", @data)
if struct[1] == 200
[ "Created network #{name}", 0 ]
@@ -153,8 +157,9 @@ def network_create(deployment_id, name, conduit_id, subnet, dhcp_enabled, ip_ran
end
-def network_edit(name_or_id, conduit_id, subnet, dhcp_enabled, ip_ranges, router_pref, router_ip)
- usage -1 if name_or_id.nil? or name_or_id == ""
+def edit(deployment_id, network_id, conduit_id, subnet, dhcp_enabled, ip_ranges, router_pref, router_ip)
+ usage -1 if deployment_id.nil? or deployment_id == ""
+ usage -1 if network_id.nil? or network_id == ""
usage -1 if conduit_id.nil? or conduit_id == ""
usage -1 if dhcp_enabled.nil? or dhcp_enabled == ""
usage -1 if ip_ranges.nil? or ip_ranges == ""
@@ -162,7 +167,7 @@ def network_edit(name_or_id, conduit_id, subnet, dhcp_enabled, ip_ranges, router
# router_ip is not required
@data = {
- "name" => name_or_id,
+ "name" => network_id,
"conduit_id" => conduit_id,
"subnet" => subnet,
"dhcp_enabled" => dhcp_enabled,
@@ -171,31 +176,32 @@ def network_edit(name_or_id, conduit_id, subnet, dhcp_enabled, ip_ranges, router
"router_ip" => router_ip
}.to_json
- struct = put_json2("2.0/crowbar/2.0/network/networks/#{name_or_id}", @data)
+ struct = put_json2("#{@barclamp}/v2/deployments/#{deployment_id}/networks/#{network_id}", @data)
if struct[1] == 200
- [ "Edited #{name_or_id}", 0 ]
+ [ "Edited #{network_id}", 0 ]
elsif struct[1] == 404
- [ "Failed to edit network: #{name_or_id} : Not Found", 1 ]
+ [ "Failed to edit network: #{network_id} : Not Found", 1 ]
elsif struct[1] == 400
- [ "Failed to edit network: #{name_or_id} : Errors in data\n#{struct[0]}", 1 ]
+ [ "Failed to edit network: #{network_id} : Errors in data\n#{struct[0]}", 1 ]
else
[ "An error occured while editing the network: #{struct[1]}: #{struct[0]}", 1 ]
end
end
-def network_delete(name_or_id)
- usage -1 if name_or_id.nil? or name_or_id == ""
+def delete(deployment_id, network_id)
+ usage -1 if deployment_id.nil? or deployment_id == ""
+ usage -1 if network_id.nil? or network_id == ""
- struct = delete_json2("2.0/crowbar/2.0/network/networks/#{name_or_id}")
+ struct = delete_json2("#{@barclamp}/v2/deployments/#{deployment_id}/networks/#{network_id}")
if struct[1] == 200
- [ "Deleted network #{name_or_id}", 0 ]
+ [ "Deleted network #{network_id}", 0 ]
elsif struct[1] == 404
[ struct[0], 1 ]
else
- [ "Failed to talk to service network_delete: #{struct[1]}: #{struct[0]}", 1 ]
+ [ "Failed to talk to service delete: #{struct[1]}: #{struct[0]}", 1 ]
end
end
View
2  crowbar_engine/barclamp_network/app/controllers/barclamp_network/conduits_controller.rb
@@ -13,7 +13,7 @@
# limitations under the License.
#
-class ConduitsController < BarclampController
+class BarclampNetwork::ConduitsController < BarclampController
# Make a copy of the barclamp controller help
self.help_contents = Array.new(superclass.help_contents)
View
109 crowbar_engine/barclamp_network/app/controllers/barclamp_network/networks_controller.rb
@@ -13,18 +13,27 @@
# limitations under the License.
#
-class NetworksController < BarclampController
+class BarclampNetwork::NetworksController < BarclampsController
+ respond_to :html, :json
+
+
# Make a copy of the barclamp controller help
self.help_contents = Array.new(superclass.help_contents)
- add_help(:network_list,[],[:get])
+ def initialize
+ @barclamp = Barclamp.find_key("network")
+ end
+
+
+ add_help(:list,[:deployment_id],[:get])
def networks
- Rails.logger.debug("Listing networks");
+ deployment_id = params[:deployment_id]
+ deployment_id = nil if deployment_id == "-1"
network_refs = []
- Network.all.each { |network|
+ BarclampNetwork::Network.all.each { |network|
network_refs << network.id
}
@@ -35,13 +44,13 @@ def networks
end
- add_help(:network_show,[:id],[:get])
+ add_help(:network_show,[:deployment_id, :network_id],[:get])
def network_show
- id = params[:id]
-
- Rails.logger.debug("Showing network #{id}")
+ deployment_id = params[:deployment_id]
+ deployment_id = nil if deployment_id == "-1"
+ network_id = params[:id]
- ret = operations.network_get(id)
+ ret = @barclamp.network_get(deployment_id, network_id)
return render :text => ret[1], :status => ret[0] if ret[0] != 200
@@ -51,9 +60,10 @@ def network_show
end
- add_help(:network_create,[:deployment_id, :name, :conduit_id, :subnet, :dhcp_enabled, :ip_ranges, :router_pref, :router_ip],[:post])
+ add_help(:create,[:deployment_id, :name, :conduit_id, :subnet, :dhcp_enabled, :ip_ranges, :router_pref, :router_ip],[:post])
def network_create
deployment_id = params[:deployment_id]
+ deployment_id = nil if deployment_id == "-1"
name = params[:name]
conduit_id = params[:conduit_id]
subnet = params[:subnet]
@@ -64,7 +74,7 @@ def network_create
Rails.logger.debug("Creating network #{name}");
- ret = operations.network_create(deployment_id, name, conduit_id, subnet, dhcp_enabled, ip_ranges, router_pref, router_ip)
+ ret = @barclamp.network_create(deployment_id, name, conduit_id, subnet, dhcp_enabled, ip_ranges, router_pref, router_ip)
return render :text => ret[1], :status => ret[0] if ret[0] != 200
@@ -74,9 +84,11 @@ def network_create
end
- add_help(:network_update,[:id, :conduit_id, :subnet, :dhcp_enabled, :ip_ranges, :router_pref, :router_ip],[:put])
+ add_help(:update,[:deployment_id, :network_id, :conduit_id, :subnet, :dhcp_enabled, :ip_ranges, :router_pref, :router_ip],[:put])
def network_update
- id = params[:id]
+ deployment_id = params[:deployment_id]
+ deployment_id = nil if deployment_id == "-1"
+ network_id = params[:id]
conduit_id = params[:conduit_id]
subnet = params[:subnet]
dhcp_enabled = to_bool( params[:dhcp_enabled] )
@@ -86,7 +98,7 @@ def network_update
Rails.logger.debug("Updating network #{id}");
- ret = operations.network_update(id, conduit_id, subnet, dhcp_enabled, ip_ranges, router_pref, router_ip)
+ ret = @barclamp.network_update(deployment_id, network_id, conduit_id, subnet, dhcp_enabled, ip_ranges, router_pref, router_ip)
return render :text => ret[1], :status => ret[0] if ret[0] != 200
@@ -96,52 +108,54 @@ def network_update
end
- add_help(:network_delete,[:id],[:delete])
- def network_delete
- Rails.logger.debug("Deleting network #{params[:id]}");
+ add_help(:destroy,[:deployment_id,:network_id],[:delete])
+ def destroy
+ deployment_id = params[:deployment_id]
+ deployment_id = nil if deployment_id == "-1"
+ network_id = params[:id]
- ret = operations.network_delete(params[:id])
+ ret = @barclamp.network_destroy(deployment_id, network_id)
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
- deployment_id = params[:id]
+ add_help(:allocate_ip,[:deployment_id,:network_id,:node_id,:range],[:put])
+ def allocate_ip
+ deployment_id = params[:deployment_id]
deployment_id = nil if deployment_id == "-1"
- network_id = params[:network_id]
+ network_id = params[:id]
node_id = params[:node_id]
range = params[:range]
suggestion = params[:suggestion]
- ret = operations.network_allocate_ip(deployment_id, network_id, range, node_id, suggestion)
+ ret = @barclamp.network_allocate_ip(deployment_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(:network_deallocate_ip,[:id,:network_id,:node_id],[:delete])
- def network_deallocate_ip
- deployment_id = params[:id]
+ add_help(:deallocate_ip,[:deployment_id,:network_id,:node_id],[:put])
+ def deallocate_ip
+ deployment_id = params[:deployment_id]
deployment_id = nil if deployment_id == "-1"
- network_id = params[:network_id]
+ network_id = params[:id]
node_id = params[:node_id]
- ret = operations.network_deallocate_ip(deployment_id, network_id, node_id)
+ ret = @barclamp.network_deallocate_ip(deployment_id, network_id, node_id)
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
- deployment_id = params[:id]
+ add_help(:enable_interface,[:deployment_id,:network_id,:node_id],[:put])
+ def enable_interface
+ deployment_id = params[:deployment_id]
deployment_id = nil if deployment_id == "-1"
- network_id = params[:network_id]
+ network_id = params[:id]
node_id = params[:node_id]
- ret = operations.network_enable_interface(deployment_id, network_id, node_id)
+ ret = @barclamp.network_enable_interface(deployment_id, network_id, node_id)
return render :text => ret[1], :status => ret[0] if ret[0] != 200
render :json => ret[1]
end
@@ -227,9 +241,9 @@ def nodes
def show
Rails.logger.debug("NetworksController.show");
begin
- @network = Network.find(params[:id]) unless params[:id].nil?
+ @network = BarclampNetwork::Network.find(params[:id]) unless params[:id].nil?
rescue
- @network = Network.find_by_name(params[:id])
+ @network = BarclampNetwork::Network.find_by_name(params[:id])
end
Rails.logger.debug("NetworksController.show inpect found network: #{@network.inspect}");
respond_to do |format|
@@ -245,19 +259,26 @@ def show
def index
Rails.logger.debug("NetworksController.index");
- @networks = Network.all
- respond_to do |format|
- format.json { render :json => network_refs }
- format.html {
+
+ respond_with(networks = BarclampNetwork::Network.all) do |format|
+ format.html do
Rails.logger.debug("NetworksController.index Format HTML: #{@networks.inspect}");
- }
+ render
+ end
+ format.json do
+ network_refs = {}
+ networks.each { |network|
+ network_refs[network.id] = network.name
+ }
+ render :json => network_refs.to_json
+ end
end
end
def edit
Rails.logger.debug("NetworksController.edit");
- @network = Network.find(params[:id]) unless params[:id].nil?
- @conduits = Conduit.all
+ @network = BarclampNetwork::Network.find(params[:id]) unless params[:id].nil?
+ @conduits = BarclampNetwork::Conduit.all
respond_to do |format|
format.html {
Rails.logger.debug("NetworksController.edit Format HTML: #{@network.inspect}");
@@ -267,7 +288,7 @@ def edit
def update
Rails.logger.debug("NetworksController.update!");
- @network = Network.find(params[:id])
+ @network = BarclampNetwork::Network.find(params[:id])
if @network.update_attributes(params[:network])
redirect_to :action => :index
else
@@ -281,7 +302,7 @@ def conduit
conduit_refs = []
- @conduits = Conduit.all
+ @conduits = BarclampNetwork::Conduit.all
@conduits.each { |conduit|
conduit_refs << conduit.id
}
View
20 crowbar_engine/barclamp_network/app/controllers/barclamp_network/scaffolds/bridge_controller.rb
@@ -0,0 +1,20 @@
+# 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::BridgeController < ApplicationController
+ active_scaffold :'barclamp_network/bridge' do |conf|
+ end
+end
View
46 crowbar_engine/barclamp_network/app/models/barclamp_network/barclamp.rb
@@ -37,7 +37,7 @@ def self.read_network_json()
def network_allocate_ip(deployment_id, network_id, range, node_id, suggestion = nil)
- Rails.logger.debug("Entering network_allocate_ip(deployment_id: #{deployment_id}, network_id: #{network_id}, range: #{range}, node_id: #{node_id}, suggestion: #{suggestion})")
+ Rails.logger.debug("Entering allocate_ip(deployment_id: #{deployment_id}, network_id: #{network_id}, range: #{range}, node_id: #{node_id}, suggestion: #{suggestion})")
deployment_id = deployment_id.to_s
deployment_id = nil if deployment_id.empty?
@@ -60,7 +60,7 @@ def network_allocate_ip(deployment_id, network_id, range, node_id, suggestion =
def network_deallocate_ip(deployment_id, network_id, node_id)
- Rails.logger.debug("Entering network_deallocate_ip(deployment_id: #{deployment_id}, network_id: #{network_id}, node_id: #{node_id}")
+ Rails.logger.debug("Entering deallocate_ip(deployment_id: #{deployment_id}, network_id: #{network_id}, node_id: #{node_id}")
deployment_id = deployment_id.to_s
deployment_id = nil if deployment_id.empty?
@@ -117,7 +117,7 @@ def transition(inst, name, state)
def network_enable_interface(deployment_id, network_id, node_id)
- Rails.logger.debug("Entering network_enable_interface(deployment_id: #{deployment_id}, network_id: #{network_id}, node_id: #{node_id})")
+ Rails.logger.debug("Entering enable_interface(deployment_id: #{deployment_id}, network_id: #{network_id}, node_id: #{node_id})")
deployment_id = deployment_id.to_s
deployment_id = nil if deployment_id.empty?
@@ -138,18 +138,8 @@ def network_enable_interface(deployment_id, network_id, node_id)
end
- def network_get(id)
- begin
- network = BarclampNetwork::Network.find_key(id)
- if network.nil?
- return [404, "Network #{id} does not exist."]
- else
- return [200, BarclampNetwork::Network.find_key(id)]
- end
- rescue RuntimeError => ex
- Rails.logger.error(ex.message)
- [500, ex.message]
- end
+ def network_get(deployment_id, network_id)
+ BarclampNetwork::NetworkUtils.find_network(network_id, deployment_id)
end
@@ -205,16 +195,15 @@ def network_create(deployment_id, name, conduit_id, subnet, dhcp_enabled, ip_ran
end
- def network_update(id, conduit_id, subnet, dhcp_enabled, ip_ranges, router_pref, router_ip)
- Rails.logger.debug("Entering network_update #{id}")
+ def network_update(deployment_id, network_id, conduit_id, subnet, dhcp_enabled, ip_ranges, router_pref, router_ip)
+ Rails.logger.debug("Entering update_network #{id}")
network = nil
begin
BarclampNetwork::Network.transaction do
- network = BarclampNetwork::Network.find_key(id)
- if network.nil?
- return [400, "Network #{id} cannot be updated because it does not exist"]
- end
+ error_code, result = BarclampNetwork::NetworkUtils.find_network(network_id, deployment_id)
+ return [error_code, result] if error_code != 200
+ network = result
conduit = BarclampNetwork::Conduit.find_key(conduit_id)
if conduit.nil?
@@ -319,18 +308,13 @@ def network_update(id, conduit_id, subnet, dhcp_enabled, ip_ranges, router_pref,
end
- def network_delete(id)
- Rails.logger.debug("Entering network_delete #{id}")
-
+ def network_destroy(deployment_id, network_id)
begin
- network = BarclampNetwork::Network.find_key(id)
- if network.nil?
- err_msg = "Network #{id} cannot be deleted because it does not exist."
- Rails.logger.warn(err_msg)
- return [404, err_msg]
- end
+ error_code, result = BarclampNetwork::NetworkUtils.find_network(network_id, deployment_id)
+ return [error_code, result] if error_code != 200
+ network = result
- Rails.logger.debug("Deleting network #{network.id}/\"#{network.name}\"")
+ Rails.logger.debug("Destroying network #{network.id}/\"#{network.name}\"")
network.destroy
[200, ""]
rescue RuntimeError => ex
View
12 crowbar_engine/barclamp_network/app/models/barclamp_network/bond.rb
@@ -13,17 +13,15 @@
# limitations under the License.
class BarclampNetwork::Bond < BarclampNetwork::Interface
- attr_accessible :team_mode, :name
-
- has_many :physical_interfaces, :dependent => :nullify, :class_name => "BarclampNetwork::PhysicalInterface"
+ attr_accessible :team_mode
validates :team_mode, :presence => true, :numericality => { :only_integer => true, :greater_than_or_equal_to => 0, :less_than_or_equal_to => 6 }
- validate :has_two_or_more_physical_interfaces
+ validate :has_two_or_more_interfaces
- def has_two_or_more_physical_interfaces
- if physical_interfaces.size < 2
- errors.add(:two_or_more_physical_interfaces, "A Bond must have at least two physical interfaces")
+ def has_two_or_more_interfaces
+ if interfaces.size < 2
+ errors.add(:two_or_more_interfaces, "A Bond must have at least two interfaces")
end
end
end
View
16 crowbar_engine/barclamp_network/app/models/barclamp_network/bridge.rb
@@ -0,0 +1,16 @@
+# 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::Bridge < BarclampNetwork::Interface
+end
View
9 crowbar_engine/barclamp_network/app/models/barclamp_network/interface.rb
@@ -13,14 +13,15 @@
# limitations under the License.
class BarclampNetwork::Interface < ActiveRecord::Base
- attr_protected :id
+ attr_accessible :id
+ attr_accessible :name
has_many :allocated_ip_addresses, :inverse_of => :interface, :dependent => :destroy, :class_name => "BarclampNetwork::AllocatedIpAddress"
- belongs_to :vlan_interface, :inverse_of => :interfaces, :class_name => "BarclampNetwork::VlanInterface"
belongs_to :node
has_and_belongs_to_many :networks, :join_table => "#{BarclampNetwork::TABLE_PREFIX}interfaces_networks", :class_name => "BarclampNetwork::Network"
-
- # attr_accessible :name
+
+ has_many :interfaces, :inverse_of => :interface, :dependent => :nullify, :class_name => "BarclampNetwork::Interface"
+ belongs_to :interface, :inverse_of => :interfaces, :class_name => "BarclampNetwork::Interface"
validates :name, :presence => true
end
View
1  crowbar_engine/barclamp_network/app/models/barclamp_network/physical_interface.rb
@@ -13,5 +13,4 @@
# limitations under the License.
class BarclampNetwork::PhysicalInterface < BarclampNetwork::Interface
- belongs_to :bond, :inverse_of => :physical_interfaces, :class_name => "BarclampNetwork::Bond"
end
View
1  crowbar_engine/barclamp_network/app/models/barclamp_network/vlan_interface.rb
@@ -13,6 +13,5 @@
# limitations under the License.
class BarclampNetwork::VlanInterface < BarclampNetwork::Interface
- has_many :interfaces, :inverse_of => :vlan_interface, :dependent => :nullify, :class_name => "BarclampNetwork::Interface"
belongs_to :vlan, :inverse_of => :vlan_interfaces, :class_name => "BarclampNetwork::Vlan"
end
View
1  crowbar_engine/barclamp_network/config/locales/en.yml
@@ -33,6 +33,7 @@ en:
allocated_ip_addresses: Allocated IP Addresses
bmc_interfaces: BMC Interfaces
bonds: Bonds
+ bridges: Bridges
bus_maps: Bus Maps
buses: Buses
config_actions: Config Actions
View
29 crowbar_engine/barclamp_network/config/routes.rb
@@ -4,6 +4,7 @@
resources :allocated_ip_addresses do as_routes end
resources :bmc_interfaces do as_routes end
resources :bonds do as_routes end
+ resources :bridges do as_routes end
resources :bus_maps do as_routes end
resources :buses do as_routes end
resources :config_actions do as_routes end
@@ -29,7 +30,6 @@
resources :vlans do as_routes end
end
- # CB1 - should move to network barclamp!
scope 'network' do
version = "2.0"
resources :networks, :conduits
@@ -38,26 +38,21 @@
get 'vlan(/:id)', :controller => 'networks', :action=>'vlan', :constraints => { :id => /.*/ }, :as => :vlan
end
- # API routes (must be json and must prefix 2.0)()
scope :defaults => {:format=> 'json'} do
- # 2.0 API Pattern
- # depricated 2.0 API Pattern
- scope '2.0' do
- constraints(:id => /([a-zA-Z0-9\-\.\_]*)/, :version => /[0-9].[0-9]/ ) do
- scope 'crowbar' do # MOVE TO GENERIC!
- scope '2.0' do # MOVE TO GENERIC!
- get "network/networks", :controller => 'networks', :action=>'networks' # MOVE TO GENERIC!
- get "network/networks/:id", :controller => 'networks', :action=>'network_show' # MOVE TO GENERIC!
- post "network/networks", :controller => 'networks', :action=>'network_create' # MOVE TO GENERIC!
- put "network/networks/:id", :controller => 'networks', :action=>'network_update' # MOVE TO GENERIC!
- delete "network/networks/:id", :controller => 'networks', :action=>'network_delete' # MOVE TO GENERIC!
- post "network/networks/:id/allocate_ip", :controller => 'networks', :action=>'network_allocate_ip'
- delete "network/networks/:id/deallocate_ip/:network_id/:node_id", :controller => 'networks', :action=>'network_deallocate_ip'
- post "network/networks/:id/enable_interface", :controller => 'networks', :action=>'network_enable_interface'
+ constraints( :version => /v[1-9]/ ) do
+ scope ':version' do
+ resources :deployments do
+ scope :module => "barclamp_network" do
+ resources :networks do
+ member do
+ put 'allocate_ip'
+ put 'deallocate_ip'
+ put 'enable_interface'
+ end
+ end
end
end
end
end
end
-
end
View
5 crowbar_engine/barclamp_network/db/migrate/20120730175238_create_interfaces.rb
@@ -17,11 +17,10 @@ def change
create_table "#{BarclampNetwork::TABLE_PREFIX}interfaces" do |t|
t.string :type
t.string :name
+ t.references :node
+ t.references :interface
t.integer :team_mode
- t.references :vlan_interface
- t.references :bond
t.references :vlan
- t.references :node
t.timestamps
end
View
50 crowbar_engine/barclamp_network/db/migrate/20130124211800_scaffold_navs.rb
@@ -18,30 +18,31 @@ def self.up
Nav.find_or_create_by_item :item=>'scaffold_network', :parent_item=>'scaffold', :name=>'nav.scaffold.network.top', :description=>'nav.scaffold.network.top_description', :path=>'scaffolds_networks_path', :order=>600, :development=>true
Nav.find_or_create_by_item :item=>'scaffold_network_allocated_ip_addresses', :parent_item=>'scaffold_network_networks', :name=>'nav.scaffold.network.allocated_ip_addresses', :description=>'nav.scaffold.network.allocated_ip_addresses_description', :path=>'scaffolds_allocated_ip_addresses_path', :order=>601, :development=>true
Nav.find_or_create_by_item :item=>'scaffold_network_bmc_interfaces', :parent_item=>'scaffold_network_interfaces', :name=>'nav.scaffold.network.bmc_interfaces', :description=>'nav.scaffold.network.bmc_interfaces_description', :path=>'scaffolds_bmc_interfaces_path', :order=>602, :development=>true
- Nav.find_or_create_by_item :item=>'scaffold_network_bonds_interfaces', :parent_item=>'scaffold_network_interfaces', :name=>'nav.scaffold.network.bonds', :description=>'nav.scaffold.network.bonds_description', :path=>'scaffolds_bonds_path', :order=>603, :development=>true
- Nav.find_or_create_by_item :item=>'scaffold_network_bus_maps', :parent_item=>'scaffold_network_interface_maps', :name=>'nav.scaffold.network.bus_maps', :description=>'nav.scaffold.network.bus_maps_description', :path=>'scaffolds_bus_maps_path', :order=>604, :development=>true
- Nav.find_or_create_by_item :item=>'scaffold_network_buses', :parent_item=>'scaffold_network_bus_maps', :name=>'nav.scaffold.network.buses', :description=>'nav.scaffold.network.buses_description', :path=>'scaffolds_buses_path', :order=>605, :development=>true
- Nav.find_or_create_by_item :item=>'scaffold_network_config_actions', :parent_item=>'scaffold_network_conduit_rules', :name=>'nav.scaffold.network.config_actions', :description=>'nav.scaffold.network.config_actions_description', :path=>'scaffolds_config_actions_path', :order=>606, :development=>true
- Nav.find_or_create_by_item :item=>'scaffold_network_conduit_filters', :parent_item=>'scaffold_network_conduit_rules', :name=>'nav.scaffold.network.conduit_filters', :description=>'nav.scaffold.network.conduit_filters_description', :path=>'scaffolds_conduit_filters_path', :order=>607, :development=>true
- Nav.find_or_create_by_item :item=>'scaffold_network_conduit_rules', :parent_item=>'scaffold_network_conduits', :name=>'nav.scaffold.network.conduit_rules', :description=>'nav.scaffold.network.conduit_rules_description', :path=>'scaffolds_conduit_rules_path', :order=>608, :development=>true
- Nav.find_or_create_by_item :item=>'scaffold_network_conduits', :parent_item=>'scaffold_network', :name=>'nav.scaffold.network.conduits', :description=>'nav.scaffold.network.conduits_description', :path=>'scaffolds_conduits_path', :order=>609, :development=>true
- Nav.find_or_create_by_item :item=>'scaffold_network_create_bonds', :parent_item=>'scaffold_network_config_actions', :name=>'nav.scaffold.network.create_bonds', :description=>'nav.scaffold.network.create_bonds_description', :path=>'scaffolds_create_bonds_path', :order=>610, :development=>true
- Nav.find_or_create_by_item :item=>'scaffold_network_create_vlans', :parent_item=>'scaffold_network_config_actions', :name=>'nav.scaffold.network.create_vlans', :description=>'nav.scaffold.network.create_vlans_description', :path=>'scaffolds_create_vlans_path', :order=>611, :development=>true
- Nav.find_or_create_by_item :item=>'scaffold_network_create_bridges', :parent_item=>'scaffold_network_config_actions', :name=>'nav.scaffold.network.create_bridges', :description=>'nav.scaffold.network.create_bridges_description', :path=>'scaffolds_create_bridges_path', :order=>611, :development=>true
- Nav.find_or_create_by_item :item=>'scaffold_network_interface_maps', :parent_item=>'scaffold_network', :name=>'nav.scaffold.network.interface_maps', :description=>'nav.scaffold.network.interface_maps_description', :path=>'scaffolds_interface_maps_path', :order=>612, :development=>true
- Nav.find_or_create_by_item :item=>'scaffold_network_interface_selectors', :parent_item=>'scaffold_network_conduit_rules', :name=>'nav.scaffold.network.interface_selectors', :description=>'nav.scaffold.network.interface_selectors_description', :path=>'scaffolds_interface_selectors_path', :order=>613, :development=>true
- Nav.find_or_create_by_item :item=>'scaffold_network_interfaces', :parent_item=>'scaffold_network_networks', :name=>'nav.scaffold.network.interfaces', :description=>'nav.scaffold.network.interfaces_description', :path=>'scaffolds_interfaces_path', :order=>614, :development=>true
- Nav.find_or_create_by_item :item=>'scaffold_network_ip_addresses', :parent_item=>'scaffold_network_networks', :name=>'nav.scaffold.network.ip_addresses', :description=>'nav.scaffold.network.ip_addresses_description', :path=>'scaffolds_ip_addresses_path', :order=>615, :development=>true
- Nav.find_or_create_by_item :item=>'scaffold_network_ip_ranges', :parent_item=>'scaffold_network_networks', :name=>'nav.scaffold.network.ip_ranges', :description=>'nav.scaffold.network.ip_ranges_description', :path=>'scaffolds_ip_ranges_path', :order=>616, :development=>true
- Nav.find_or_create_by_item :item=>'scaffold_network_network_mode_filters', :parent_item=>'scaffold_network_conduit_filters', :name=>'nav.scaffold.network.network_mode_filters', :description=>'nav.scaffold.network.network_mode_filters_description', :path=>'scaffolds_network_mode_filters_path', :order=>617, :development=>true
- Nav.find_or_create_by_item :item=>'scaffold_network_networks', :parent_item=>'scaffold_network', :name=>'nav.scaffold.network.networks', :description=>'nav.scaffold.network.networks_description', :path=>'scaffolds_networks_path', :order=>618, :development=>true
- Nav.find_or_create_by_item :item=>'scaffold_network_node_attribute_filters', :parent_item=>'scaffold_network_conduit_filters', :name=>'nav.scaffold.network.node_attribute_filters', :description=>'nav.scaffold.network.node_attribute_filters_description', :path=>'scaffolds_node_attribute_filters_path', :order=>619, :development=>true
- Nav.find_or_create_by_item :item=>'scaffold_network_physical_interfaces', :parent_item=>'scaffold_physical_interfaces', :name=>'nav.scaffold.network.physical_interfaces', :description=>'nav.scaffold.network.physical_interfaces_description', :path=>'scaffolds_physical_interfaces_path', :order=>620, :development=>true
- Nav.find_or_create_by_item :item=>'scaffold_network_routers', :parent_item=>'scaffold_network_networks', :name=>'nav.scaffold.network.routers', :description=>'nav.scaffold.network.routers_description', :path=>'scaffolds_routers_path', :order=>621, :development=>true
- Nav.find_or_create_by_item :item=>'scaffold_network_select_by_indices', :parent_item=>'scaffold_network_interface_selectors', :name=>'nav.scaffold.network.select_by_indices', :description=>'nav.scaffold.network.select_by_indices_description', :path=>'scaffolds_select_by_indices_path', :order=>622, :development=>true
- Nav.find_or_create_by_item :item=>'scaffold_network_select_by_speeds', :parent_item=>'scaffold_network_interface_selectors', :name=>'nav.scaffold.network.select_by_speeds', :description=>'nav.scaffold.network.select_by_speeds_description', :path=>'scaffolds_select_by_speeds_path', :order=>623, :development=>true
- Nav.find_or_create_by_item :item=>'scaffold_network_vlan_interfaces', :parent_item=>'scaffold_interfaces', :name=>'nav.scaffold.network.vlan_interfaces', :description=>'nav.scaffold.network.vlan_interfaces_description', :path=>'scaffolds_vlan_interfaces_path', :order=>624, :development=>true
- Nav.find_or_create_by_item :item=>'scaffold_network_vlans', :parent_item=>'scaffold_network_networks', :name=>'nav.scaffold.network.vlans', :description=>'nav.scaffold.network.vlans_description', :path=>'scaffolds_vlans_path', :order=>625, :development=>true
+ Nav.find_or_create_by_item :item=>'scaffold_network_bonds', :parent_item=>'scaffold_network_interfaces', :name=>'nav.scaffold.network.bonds', :description=>'nav.scaffold.network.bonds_description', :path=>'scaffolds_bonds_path', :order=>603, :development=>true
+ Nav.find_or_create_by_item :item=>'scaffold_network_bridges', :parent_item=>'scaffold_network_interfaces', :name=>'nav.scaffold.network.bridges', :description=>'nav.scaffold.network.bridges_description', :path=>'scaffolds_bridges_path', :order=>604, :development=>true
+ Nav.find_or_create_by_item :item=>'scaffold_network_bus_maps', :parent_item=>'scaffold_network_interface_maps', :name=>'nav.scaffold.network.bus_maps', :description=>'nav.scaffold.network.bus_maps_description', :path=>'scaffolds_bus_maps_path', :order=>605, :development=>true
+ Nav.find_or_create_by_item :item=>'scaffold_network_buses', :parent_item=>'scaffold_network_bus_maps', :name=>'nav.scaffold.network.buses', :description=>'nav.scaffold.network.buses_description', :path=>'scaffolds_buses_path', :order=>606, :development=>true
+ Nav.find_or_create_by_item :item=>'scaffold_network_config_actions', :parent_item=>'scaffold_network_conduit_rules', :name=>'nav.scaffold.network.config_actions', :description=>'nav.scaffold.network.config_actions_description', :path=>'scaffolds_config_actions_path', :order=>607, :development=>true
+ Nav.find_or_create_by_item :item=>'scaffold_network_conduit_filters', :parent_item=>'scaffold_network_conduit_rules', :name=>'nav.scaffold.network.conduit_filters', :description=>'nav.scaffold.network.conduit_filters_description', :path=>'scaffolds_conduit_filters_path', :order=>608, :development=>true
+ Nav.find_or_create_by_item :item=>'scaffold_network_conduit_rules', :parent_item=>'scaffold_network_conduits', :name=>'nav.scaffold.network.conduit_rules', :description=>'nav.scaffold.network.conduit_rules_description', :path=>'scaffolds_conduit_rules_path', :order=>609, :development=>true
+ Nav.find_or_create_by_item :item=>'scaffold_network_conduits', :parent_item=>'scaffold_network', :name=>'nav.scaffold.network.conduits', :description=>'nav.scaffold.network.conduits_description', :path=>'scaffolds_conduits_path', :order=>610, :development=>true
+ Nav.find_or_create_by_item :item=>'scaffold_network_create_bonds', :parent_item=>'scaffold_network_config_actions', :name=>'nav.scaffold.network.create_bonds', :description=>'nav.scaffold.network.create_bonds_description', :path=>'scaffolds_create_bonds_path', :order=>611, :development=>true
+ Nav.find_or_create_by_item :item=>'scaffold_network_create_vlans', :parent_item=>'scaffold_network_config_actions', :name=>'nav.scaffold.network.create_vlans', :description=>'nav.scaffold.network.create_vlans_description', :path=>'scaffolds_create_vlans_path', :order=>612, :development=>true
+ Nav.find_or_create_by_item :item=>'scaffold_network_create_bridges', :parent_item=>'scaffold_network_config_actions', :name=>'nav.scaffold.network.create_bridges', :description=>'nav.scaffold.network.create_bridges_description', :path=>'scaffolds_create_bridges_path', :order=>613, :development=>true
+ Nav.find_or_create_by_item :item=>'scaffold_network_interface_maps', :parent_item=>'scaffold_network', :name=>'nav.scaffold.network.interface_maps', :description=>'nav.scaffold.network.interface_maps_description', :path=>'scaffolds_interface_maps_path', :order=>614, :development=>true
+ Nav.find_or_create_by_item :item=>'scaffold_network_interface_selectors', :parent_item=>'scaffold_network_conduit_rules', :name=>'nav.scaffold.network.interface_selectors', :description=>'nav.scaffold.network.interface_selectors_description', :path=>'scaffolds_interface_selectors_path', :order=>615, :development=>true
+ Nav.find_or_create_by_item :item=>'scaffold_network_interfaces', :parent_item=>'scaffold_network_networks', :name=>'nav.scaffold.network.interfaces', :description=>'nav.scaffold.network.interfaces_description', :path=>'scaffolds_interfaces_path', :order=>616, :development=>true
+ Nav.find_or_create_by_item :item=>'scaffold_network_ip_addresses', :parent_item=>'scaffold_network_networks', :name=>'nav.scaffold.network.ip_addresses', :description=>'nav.scaffold.network.ip_addresses_description', :path=>'scaffolds_ip_addresses_path', :order=>617, :development=>true
+ Nav.find_or_create_by_item :item=>'scaffold_network_ip_ranges', :parent_item=>'scaffold_network_networks', :name=>'nav.scaffold.network.ip_ranges', :description=>'nav.scaffold.network.ip_ranges_description', :path=>'scaffolds_ip_ranges_path', :order=>618, :development=>true
+ Nav.find_or_create_by_item :item=>'scaffold_network_network_mode_filters', :parent_item=>'scaffold_network_conduit_filters', :name=>'nav.scaffold.network.network_mode_filters', :description=>'nav.scaffold.network.network_mode_filters_description', :path=>'scaffolds_network_mode_filters_path', :order=>619, :development=>true
+ Nav.find_or_create_by_item :item=>'scaffold_network_networks', :parent_item=>'scaffold_network', :name=>'nav.scaffold.network.networks', :description=>'nav.scaffold.network.networks_description', :path=>'scaffolds_networks_path', :order=>620, :development=>true
+ Nav.find_or_create_by_item :item=>'scaffold_network_node_attribute_filters', :parent_item=>'scaffold_network_conduit_filters', :name=>'nav.scaffold.network.node_attribute_filters', :description=>'nav.scaffold.network.node_attribute_filters_description', :path=>'scaffolds_node_attribute_filters_path', :order=>621, :development=>true
+ Nav.find_or_create_by_item :item=>'scaffold_network_physical_interfaces', :parent_item=>'scaffold_physical_interfaces', :name=>'nav.scaffold.network.physical_interfaces', :description=>'nav.scaffold.network.physical_interfaces_description', :path=>'scaffolds_physical_interfaces_path', :order=>622, :development=>true
+ Nav.find_or_create_by_item :item=>'scaffold_network_routers', :parent_item=>'scaffold_network_networks', :name=>'nav.scaffold.network.routers', :description=>'nav.scaffold.network.routers_description', :path=>'scaffolds_routers_path', :order=>623, :development=>true
+ Nav.find_or_create_by_item :item=>'scaffold_network_select_by_indices', :parent_item=>'scaffold_network_interface_selectors', :name=>'nav.scaffold.network.select_by_indices', :description=>'nav.scaffold.network.select_by_indices_description', :path=>'scaffolds_select_by_indices_path', :order=>624, :development=>true
+ Nav.find_or_create_by_item :item=>'scaffold_network_select_by_speeds', :parent_item=>'scaffold_network_interface_selectors', :name=>'nav.scaffold.network.select_by_speeds', :description=>'nav.scaffold.network.select_by_speeds_description', :path=>'scaffolds_select_by_speeds_path', :order=>625, :development=>true
+ Nav.find_or_create_by_item :item=>'scaffold_network_vlan_interfaces', :parent_item=>'scaffold_interfaces', :name=>'nav.scaffold.network.vlan_interfaces', :description=>'nav.scaffold.network.vlan_interfaces_description', :path=>'scaffolds_vlan_interfaces_path', :order=>626, :development=>true
+ Nav.find_or_create_by_item :item=>'scaffold_network_vlans', :parent_item=>'scaffold_network_networks', :name=>'nav.scaffold.network.vlans', :description=>'nav.scaffold.network.vlans_description', :path=>'scaffolds_vlans_path', :order=>627, :development=>true
end
def self.down
@@ -49,6 +50,7 @@ def self.down
Nav.delete_by_item 'scaffold_network_allocated_ip_addresses'
Nav.delete_by_item 'scaffold_network_bmc_interfaces'
Nav.delete_by_item 'scaffold_network_bonds'
+ Nav.delete_by_item 'scaffold_network_bridges'
Nav.delete_by_item 'scaffold_network_bus_maps'
Nav.delete_by_item 'scaffold_network_buses'
Nav.delete_by_item 'scaffold_network_config_actions'
View
28 crowbar_engine/barclamp_network/test/unit/bond_model_test.rb
@@ -19,22 +19,22 @@ class BondModelTest < ActiveSupport::TestCase
# Test successful creation
test "Bond creation: success" do
bond = BarclampNetwork::Bond.new( :name => "fred", :team_mode => 6 )
- bond.physical_interfaces << BarclampNetwork::PhysicalInterface.new(:name => "wilma")
- bond.physical_interfaces << BarclampNetwork::PhysicalInterface.new(:name => "betty")
+ bond.interfaces << BarclampNetwork::PhysicalInterface.new(:name => "wilma")
+ bond.interfaces << BarclampNetwork::PhysicalInterface.new(:name => "betty")
assert bond.save!
assert_equal "fred", bond.name
assert_equal 6, bond.team_mode
- assert_equal 2, bond.physical_interfaces.count
- assert bond.physical_interfaces.first.name.in? %w(wilma betty)
- assert bond.physical_interfaces.second.name.in? %w(wilma betty)
+ assert_equal 2, bond.interfaces.count
+ assert bond.interfaces.first.name.in? %w(wilma betty)
+ assert bond.interfaces.second.name.in? %w(wilma betty)
end
# Test creation failure due to missing team_mode
test "Bond creation: failure due to missing team_mode" do
bond = BarclampNetwork::Bond.new( :name => "fred" )
- bond.physical_interfaces << BarclampNetwork::PhysicalInterface.new(:name => "wilma")
- bond.physical_interfaces << BarclampNetwork::PhysicalInterface.new(:name => "betty")
+ bond.interfaces << BarclampNetwork::PhysicalInterface.new(:name => "wilma")
+ bond.interfaces << BarclampNetwork::PhysicalInterface.new(:name => "betty")
assert_raise ActiveRecord::RecordInvalid do
bond.save!
end
@@ -44,8 +44,8 @@ class BondModelTest < ActiveSupport::TestCase
# Test creation failure due to low team_mode
test "Bond creation: failure due to low team_mode" do
bond = BarclampNetwork::Bond.new( :name => "fred", :team_mode => -1 )
- bond.physical_interfaces << BarclampNetwork::PhysicalInterface.new(:name => "wilma")
- bond.physical_interfaces << BarclampNetwork::PhysicalInterface.new(:name => "betty")
+ bond.interfaces << BarclampNetwork::PhysicalInterface.new(:name => "wilma")
+ bond.interfaces << BarclampNetwork::PhysicalInterface.new(:name => "betty")
assert_raise ActiveRecord::RecordInvalid do
bond.save!
end
@@ -55,8 +55,8 @@ class BondModelTest < ActiveSupport::TestCase
# Test creation failure due to high team_mode
test "Bond creation: failure due to high team_mode" do
bond = BarclampNetwork::Bond.new( :name => "fred", :team_mode => 7 )
- bond.physical_interfaces << BarclampNetwork::PhysicalInterface.new(:name => "wilma")
- bond.physical_interfaces << BarclampNetwork::PhysicalInterface.new(:name => "betty")
+ bond.interfaces << BarclampNetwork::PhysicalInterface.new(:name => "wilma")
+ bond.interfaces << BarclampNetwork::PhysicalInterface.new(:name => "betty")
assert_raise ActiveRecord::RecordInvalid do
bond.save!
end
@@ -65,7 +65,7 @@ class BondModelTest < ActiveSupport::TestCase
# Test creation failure due to no physical interfaces
test "Bond creation: failure due to no physical interfaces" do
- bond = BarclampNetwork::Bond.new( :name => "fred", :team_mode => 7 )
+ bond = BarclampNetwork::Bond.new( :name => "fred", :team_mode => 6 )
assert_raise ActiveRecord::RecordInvalid do
bond.save!
end
@@ -74,8 +74,8 @@ class BondModelTest < ActiveSupport::TestCase
# Test creation failure due to 1 physical interface
test "Bond creation: failure due to 1 physical interface" do
- bond = BarclampNetwork::Bond.new( :name => "fred", :team_mode => 7 )
- bond.physical_interfaces << BarclampNetwork::PhysicalInterface.new(:name => "wilma")
+ bond = BarclampNetwork::Bond.new( :name => "fred", :team_mode => 6 )
+ bond.interfaces << BarclampNetwork::PhysicalInterface.new(:name => "wilma")
assert_raise ActiveRecord::RecordInvalid do
bond.save!
end
View
30 crowbar_engine/barclamp_network/test/unit/network_barclamp_test.rb
@@ -92,7 +92,7 @@ class NetworkBarclampTest < ActiveSupport::TestCase
create_a_network(barclamp, deployment, net_name)
# Get by name
- network = get_a_network(barclamp, net_name)
+ network = get_a_network(barclamp, deployment.id, net_name)
assert_equal net_name, network.name, "Expected to get network with name #{net_name}, got network with name #{network.name}"
end
@@ -107,7 +107,7 @@ class NetworkBarclampTest < ActiveSupport::TestCase
# Get by id
id=network.id
- network = get_a_network(barclamp, id)
+ network = get_a_network(barclamp, deployment.id, id)
assert_equal id, network.id, "Expected to get network with id #{id}, got network with id #{network.id}"
end
@@ -115,9 +115,10 @@ class NetworkBarclampTest < ActiveSupport::TestCase
# Test retrieval of non-existant object
test "network_get: non-existant network" do
barclamp = NetworkTestHelper.create_a_barclamp()
+ deployment = barclamp.create_proposal()
# Get by name
- http_error, network = barclamp.network_get("zippityDoDa")
+ http_error, network = barclamp.network_get(deployment.id, "zippityDoDa")
assert_not_nil network, "Expected to get error message, but got nil"
assert_equal 404, http_error, "Expected to get HTTP error code 404, got HTTP error code: #{http_error}, #{network}"
end
@@ -132,6 +133,7 @@ class NetworkBarclampTest < ActiveSupport::TestCase
create_a_network(barclamp, deployment, net_name)
http_error, network = barclamp.network_update(
+ deployment.id,
net_name,
"intf0",
"192.168.122.0/24",
@@ -155,6 +157,7 @@ class NetworkBarclampTest < ActiveSupport::TestCase
create_a_network(barclamp, deployment, net_name)
http_error, network = barclamp.network_update(
+ deployment.id,
net_name,
"intf0",
"192.168.122.0/24",
@@ -178,6 +181,7 @@ class NetworkBarclampTest < ActiveSupport::TestCase
create_a_network(barclamp, deployment, net_name)
http_error, network = barclamp.network_update(
+ deployment.id,
net_name,
"intf0",
"192.168.122.0/24",
@@ -199,6 +203,7 @@ class NetworkBarclampTest < ActiveSupport::TestCase
create_a_network(barclamp, deployment, net_name)
http_error, network = barclamp.network_update(
+ deployment.id,
net_name,
"intf0",
"192.168.122.0/24",
@@ -220,6 +225,7 @@ class NetworkBarclampTest < ActiveSupport::TestCase
create_a_network(barclamp, deployment, net_name)
http_error, network = barclamp.network_update(
+ deployment.id,
net_name,
"intf0",
"192.168.122.0/24",
@@ -241,6 +247,7 @@ class NetworkBarclampTest < ActiveSupport::TestCase
create_a_network(barclamp, deployment, net_name)
http_error, network = barclamp.network_update(
+ deployment.id,
net_name,
"intf0",
"192.168.122.0/24",
@@ -262,6 +269,7 @@ class NetworkBarclampTest < ActiveSupport::TestCase
create_a_network(barclamp, deployment, net_name)
http_error, network = barclamp.network_update(
+ deployment.id,
net_name,
"intf0",
"192.168.122.0/24",
@@ -277,7 +285,9 @@ class NetworkBarclampTest < ActiveSupport::TestCase
# Test deletion of non-existant network
test "network_delete: non-existant network" do
barclamp = NetworkTestHelper.create_a_barclamp()
- delete_nonexistant_network( barclamp, "zippityDoDa")
+ deployment = barclamp.create_proposal()
+
+ delete_nonexistant_network( barclamp, deployment.id, "zippityDoDa")
end
@@ -290,11 +300,11 @@ class NetworkBarclampTest < ActiveSupport::TestCase
create_a_network(barclamp, deployment, net_name)
# Delete by name
- http_error, msg = barclamp.network_delete(net_name)
+ http_error, msg = barclamp.network_destroy(deployment.id, net_name)
assert_equal 200, http_error, "HTTP error code returned: #{http_error}, #{msg}"
# Verify deletion
- delete_nonexistant_network(barclamp, net_name)
+ delete_nonexistant_network(barclamp, deployment.id, net_name)
end
@@ -494,8 +504,8 @@ def create_a_network(barclamp, deployment, name)
private
# Retrieve a Network
- def get_a_network(barclamp, id)
- http_error, network = barclamp.network_get(id)
+ def get_a_network(barclamp, deployment_id, network_id)
+ http_error, network = barclamp.network_get(deployment_id, network_id)
assert_not_nil network
assert_equal 200, http_error, "HTTP error code returned: #{http_error}, #{network}"
network
@@ -503,8 +513,8 @@ def get_a_network(barclamp, id)
# Try to delete a Network that does not exist
- def delete_nonexistant_network( barclamp, id )
- http_error, msg = barclamp.network_delete(id)
+ def delete_nonexistant_network( barclamp, deployment_id, network_id )
+ http_error, msg = barclamp.network_destroy(deployment_id, network_id)
assert_not_nil msg, "Expected to get error message, but got nil"
assert_equal 404, http_error, "HTTP error code returned: #{http_error}, #{msg}"
end
Please sign in to comment.
Something went wrong with that request. Please try again.