Skip to content

Commit

Permalink
Modify network table to ease OS integration
Browse files Browse the repository at this point in the history
  • Loading branch information
tinova committed Dec 22, 2016
1 parent ac2a392 commit d06b586
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 7 deletions.
15 changes: 13 additions & 2 deletions models/fednet_pool.rb
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,21 @@ def update(id, username, is_admin, new_fednet)
# Build the network table
net_array = Array.new
fednet_hash[:netsegments].each{|ns|
net_array << ns[:cmp_blob]
net_array_element = Hash.new
net_array_element[:name] = ns[:name]
net_array_element[:vnid] = ns[:cmp_net_id]
net_array_element[:site] = FederatedSDN::SitePool.new().get(ns[:site_id]).name
net_array_element[:tenant_id] = FederatedSDN::TenantPool.new().get_tenant_id_in_site(owner, net_array_element[:site])
net_array_element[:cmp_blob] = ns[:cmp_blob]

net_array << net_array_element
}

result = link("opennebula", fednet_hash[:linktype], token, fa_array, net_array)
result = link("opennebula",
fednet_hash[:linktype],
token,
fa_array,
net_array)

if result.code == 0
new_resource["status"] = "linked"
Expand Down
8 changes: 4 additions & 4 deletions models/site_pool.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ def initialize()
end

def bootstrap
DB.run "CREATE TABLE #{TABLE_NAME} "\
"(id integer primary key autoincrement,"\
" name varchar(255) UNIQUE,"\
DB.run "CREATE TABLE #{TABLE_NAME} "\
"(id integer primary key autoincrement,"\
" name varchar(255) UNIQUE,"\
" type varchar(255),"\
" cmp_endpoint varchar(255))"
" cmp_endpoint varchar(255))"
end

# Needs at least name and cmp_endpoint
Expand Down
6 changes: 5 additions & 1 deletion models/tenant_pool.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def bootstrap

# Add root admin user
username = FederatedSDN::CONF[:root_username]
password = FederatedSDN::CONF[:root_password]
password = FederatedSDN::CONF[:root_password]
id = 1

tenant_hash = {
Expand Down Expand Up @@ -274,6 +274,10 @@ def is_admin(username)
@table.filter(:name => username).first[:type] == "admin"
end

def get_tenant_id_in_site(username, site)
tenant_id = @table.filter(:name => username).first[:id]
@table_to_site.filter(:tenant_id => tenant_id).filter(:site_id => site_id).first[:user_id_in_site]
end

def validate_user(site_type, cmp_endpoint, username, password)
cmd = ADAPTERS_LOCATION + "/" + site_type.downcase + "/"
Expand Down

0 comments on commit d06b586

Please sign in to comment.