mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-28 14:50:08 +03:00
Merge branch 'feature-4215' into feature-4217
This commit is contained in:
commit
019966cd79
@ -1262,10 +1262,12 @@ public:
|
||||
*
|
||||
* @param nic NIC to be released
|
||||
* @param vmid Virtual Machine oid
|
||||
* @param vrid Virtual Router id if the VM is a VR, or -1
|
||||
*
|
||||
* @return 0 on success, -1 otherwise
|
||||
*/
|
||||
static int release_network_leases(VectorAttribute const * nic, int vmid);
|
||||
static int release_network_leases(
|
||||
VectorAttribute const * nic, int vmid, int vrid);
|
||||
|
||||
/**
|
||||
* Releases all disk images taken by this Virtual Machine
|
||||
@ -1317,6 +1319,16 @@ public:
|
||||
*/
|
||||
const VectorAttribute* get_disk(int disk_id) const;
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Virtual Router related functions
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Returns the Virtual Router ID if this VM is a VR, or -1
|
||||
* @return VR ID or -1
|
||||
*/
|
||||
int get_vrouter_id();
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Context related functions
|
||||
// ------------------------------------------------------------------------
|
||||
@ -1532,6 +1544,7 @@ public:
|
||||
*
|
||||
* @param vm_id Id of the VM where this nic will be attached
|
||||
* @param vm_sgs the securty group ids already present in the VM
|
||||
* @param vm_vrid Virtual Router id if the VM is a VR, or -1
|
||||
* @param new_nic New NIC vector attribute, obtained from get_attach_nic_info
|
||||
* @param rules Security Group rules will be added at the end of this
|
||||
* vector. If not used, the VectorAttributes must be freed by the calling
|
||||
@ -1544,6 +1557,7 @@ public:
|
||||
static int set_up_attach_nic(
|
||||
int vm_id,
|
||||
set<int>& vm_sgs,
|
||||
int vm_vrid,
|
||||
VectorAttribute * new_nic,
|
||||
vector<VectorAttribute*> &rules,
|
||||
int max_nic_id,
|
||||
@ -1954,6 +1968,13 @@ private:
|
||||
*/
|
||||
int parse_defaults(string& error_str);
|
||||
|
||||
/**
|
||||
* Parse virtual router related attributes
|
||||
* @param error_str Returns the error reason, if any
|
||||
* @return 0 on success
|
||||
*/
|
||||
int parse_vrouter(string& error_str);
|
||||
|
||||
/**
|
||||
* Known attributes for network contextualization rendered as:
|
||||
* ETH_<nicid>_<context[0]> = $NETWORK[context[1], vnet_name]
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include "VirtualNetworkTemplate.h"
|
||||
#include "Clusterable.h"
|
||||
#include "AddressRangePool.h"
|
||||
#include "ObjectCollection.h"
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
@ -199,21 +200,33 @@ public:
|
||||
* Release previously given address lease
|
||||
* @param arid of the address range where the address was leased from
|
||||
* @param vid the ID of the VM
|
||||
* @param vrid Virtual Router id if the VM is a VR, or -1
|
||||
* @param mac MAC address identifying the lease
|
||||
*/
|
||||
void free_addr(unsigned int arid, int vid, const string& mac)
|
||||
void free_addr(unsigned int arid, int vid, int vrid, const string& mac)
|
||||
{
|
||||
ar_pool.free_addr(arid, PoolObjectSQL::VM, vid, mac);
|
||||
|
||||
if (vrid != -1)
|
||||
{
|
||||
vrouters.del_collection_id(vrid);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Release previously given address lease
|
||||
* @param vid the ID of the VM
|
||||
* @param vrid Virtual Router id if the VM is a VR, or -1
|
||||
* @param mac MAC address identifying the lease
|
||||
*/
|
||||
void free_addr(int vid, const string& mac)
|
||||
void free_addr(int vid, int vrid, const string& mac)
|
||||
{
|
||||
ar_pool.free_addr(PoolObjectSQL::VM, vid, mac);
|
||||
|
||||
if (vrid != -1)
|
||||
{
|
||||
vrouters.del_collection_id(vrid);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -246,6 +259,7 @@ public:
|
||||
* * BRIDGE: for this virtual network
|
||||
* @param nic attribute for the VM template
|
||||
* @param vid of the VM getting the lease
|
||||
* @param vrid Virtual Router id if the VM is a VR, or -1
|
||||
* @param inherit_attrs Attributes to be inherited from the vnet template
|
||||
* into the nic
|
||||
* @return 0 on success
|
||||
@ -253,6 +267,7 @@ public:
|
||||
int nic_attribute(
|
||||
VectorAttribute * nic,
|
||||
int vid,
|
||||
int vrid,
|
||||
const vector<string>& inherit_attrs);
|
||||
|
||||
/**
|
||||
@ -458,6 +473,11 @@ private:
|
||||
*/
|
||||
AddressRangePool ar_pool;
|
||||
|
||||
/**
|
||||
* Set of Virtual Router IDs
|
||||
*/
|
||||
ObjectCollection vrouters;
|
||||
|
||||
// *************************************************************************
|
||||
// DataBase implementation (Private)
|
||||
// *************************************************************************
|
||||
|
@ -107,6 +107,7 @@ public:
|
||||
* @param nic_id the id for this NIC
|
||||
* @param uid of the VM owner
|
||||
* @param vid of the VM requesting the lease
|
||||
* @param vrid Virtual Router id if the VM is a VR, or -1
|
||||
* @param error_str string describing the error
|
||||
* @return 0 on success,
|
||||
* -1 error,
|
||||
@ -117,6 +118,7 @@ public:
|
||||
int nic_id,
|
||||
int uid,
|
||||
int vid,
|
||||
int vrid,
|
||||
string& error_str);
|
||||
|
||||
/**
|
||||
|
@ -37,6 +37,16 @@ public:
|
||||
*/
|
||||
string& to_xml(string& xml) const;
|
||||
|
||||
int get_vmid()
|
||||
{
|
||||
return vmid;
|
||||
}
|
||||
|
||||
void set_vmid(int vmid)
|
||||
{
|
||||
this->vmid = vmid;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Template Contents
|
||||
// ------------------------------------------------------------------------
|
||||
@ -66,6 +76,13 @@ private:
|
||||
|
||||
friend class VirtualRouterPool;
|
||||
|
||||
|
||||
// *************************************************************************
|
||||
// Attributes
|
||||
// *************************************************************************
|
||||
|
||||
int vmid;
|
||||
|
||||
// *************************************************************************
|
||||
// DataBase implementation (Private)
|
||||
// *************************************************************************
|
||||
|
@ -28,7 +28,7 @@ const long long AclRule::CLUSTER_ID = 0x0000000800000000LL;
|
||||
|
||||
const long long AclRule::NONE_ID = 0x1000000000000000LL;
|
||||
|
||||
const int AclRule::num_pool_objects = 13;
|
||||
const int AclRule::num_pool_objects = 14;
|
||||
const PoolObjectSQL::ObjectType AclRule::pool_objects[] = {
|
||||
PoolObjectSQL::VM,
|
||||
PoolObjectSQL::HOST,
|
||||
@ -42,7 +42,8 @@ const PoolObjectSQL::ObjectType AclRule::pool_objects[] = {
|
||||
PoolObjectSQL::DOCUMENT,
|
||||
PoolObjectSQL::ZONE,
|
||||
PoolObjectSQL::SECGROUP,
|
||||
PoolObjectSQL::VDC
|
||||
PoolObjectSQL::VDC,
|
||||
PoolObjectSQL::VROUTER
|
||||
};
|
||||
|
||||
const int AclRule::num_auth_operations = 4;
|
||||
@ -57,7 +58,7 @@ const long long AclRule::INVALID_CLUSTER_OBJECTS =
|
||||
PoolObjectSQL::VM | PoolObjectSQL::IMAGE | PoolObjectSQL::USER |
|
||||
PoolObjectSQL::TEMPLATE | PoolObjectSQL::GROUP | PoolObjectSQL::ACL |
|
||||
PoolObjectSQL::CLUSTER | PoolObjectSQL::DOCUMENT | PoolObjectSQL::ZONE |
|
||||
PoolObjectSQL::SECGROUP | PoolObjectSQL::VDC;
|
||||
PoolObjectSQL::SECGROUP | PoolObjectSQL::VDC | PoolObjectSQL::VROUTER;
|
||||
|
||||
const long long AclRule::INVALID_GROUP_OBJECTS =
|
||||
PoolObjectSQL::HOST | PoolObjectSQL::GROUP | PoolObjectSQL::CLUSTER |
|
||||
@ -233,7 +234,7 @@ bool AclRule::malformed(string& error_str) const
|
||||
oss << "[resource] type is missing";
|
||||
}
|
||||
|
||||
if ( (resource & 0xFFFC000000000000LL) != 0 )
|
||||
if ( (resource & 0xFFF8000000000000LL) != 0 )
|
||||
{
|
||||
if ( error )
|
||||
{
|
||||
|
@ -9,9 +9,9 @@
|
||||
:size: 8
|
||||
:right: true
|
||||
|
||||
:RES_VHNIUTGDCOZSv:
|
||||
:RES_VHNIUTGDCOZSvR:
|
||||
:desc: Which resource the rule applies to
|
||||
:size: 17
|
||||
:size: 18
|
||||
|
||||
:RID:
|
||||
:desc: Resource ID
|
||||
@ -31,7 +31,7 @@
|
||||
:default:
|
||||
- :ID
|
||||
- :USER
|
||||
- :RES_VHNIUTGDCOZSv
|
||||
- :RES_VHNIUTGDCOZSvR
|
||||
- :RID
|
||||
- :OPE_UMAC
|
||||
- :ZONE
|
||||
|
@ -3,6 +3,10 @@
|
||||
:desc: ONE identifier for the Virtual Router
|
||||
:size: 4
|
||||
|
||||
:VMID:
|
||||
:desc: VM associated with the Virtual Router
|
||||
:size: 4
|
||||
|
||||
:NAME:
|
||||
:desc: Name of the Virtual Router
|
||||
:size: 27
|
||||
@ -20,6 +24,7 @@
|
||||
|
||||
:default:
|
||||
- :ID
|
||||
- :VMID
|
||||
- :USER
|
||||
- :GROUP
|
||||
- :NAME
|
||||
|
@ -44,7 +44,7 @@ private
|
||||
def self.resource_mask(str)
|
||||
resource_type=str.split("/")[0]
|
||||
|
||||
mask = "-------------"
|
||||
mask = "--------------"
|
||||
|
||||
resource_type.split("+").each{|type|
|
||||
case type
|
||||
@ -74,6 +74,8 @@ private
|
||||
mask[11] = "S"
|
||||
when "VDC"
|
||||
mask[12] = "v"
|
||||
when "VROUTER"
|
||||
mask[13] = "R"
|
||||
end
|
||||
}
|
||||
mask
|
||||
@ -113,8 +115,8 @@ private
|
||||
d['STRING'].split(" ")[0]
|
||||
end
|
||||
|
||||
column :RES_VHNIUTGDCOZSv, "Resource to which the rule applies",
|
||||
:size => 17 do |d|
|
||||
column :RES_VHNIUTGDCOZSvR, "Resource to which the rule applies",
|
||||
:size => 18 do |d|
|
||||
OneAclHelper::resource_mask d['STRING'].split(" ")[1]
|
||||
end
|
||||
|
||||
@ -131,7 +133,7 @@ private
|
||||
OneAclHelper::right_mask d['STRING'].split(" ")[2]
|
||||
end
|
||||
|
||||
default :ID, :USER, :RES_VHNIUTGDCOZSv, :RID, :OPE_UMAC, :ZONE
|
||||
default :ID, :USER, :RES_VHNIUTGDCOZSvR, :RID, :OPE_UMAC, :ZONE
|
||||
end
|
||||
|
||||
table
|
||||
|
@ -324,6 +324,13 @@ class OneVNetHelper < OpenNebulaHelper::OneHelper
|
||||
end
|
||||
end.show(leases, {})
|
||||
|
||||
puts
|
||||
|
||||
CLIHelper.print_header("%-15s" % "VIRTUAL ROUTERS")
|
||||
vn.vrouter_ids.each do |id|
|
||||
puts "%-15s" % [id]
|
||||
end
|
||||
|
||||
if options[:show_ar]
|
||||
ar_list.each do |ar_id|
|
||||
puts
|
||||
|
@ -52,6 +52,10 @@ class OneVirtualRouterHelper < OpenNebulaHelper::OneHelper
|
||||
d["ID"]
|
||||
end
|
||||
|
||||
column :VMID, "VM associated with the Virtual Router", :size=>4 do |d|
|
||||
d["VMID"]
|
||||
end
|
||||
|
||||
column :NAME, "Name of the Virtual Router", :left, :size=>27 do |d|
|
||||
d["NAME"]
|
||||
end
|
||||
@ -65,7 +69,7 @@ class OneVirtualRouterHelper < OpenNebulaHelper::OneHelper
|
||||
helper.group_name(d, options)
|
||||
end
|
||||
|
||||
default :ID, :USER, :GROUP, :NAME
|
||||
default :ID, :VMID, :USER, :GROUP, :NAME
|
||||
end
|
||||
|
||||
table
|
||||
@ -94,6 +98,7 @@ class OneVirtualRouterHelper < OpenNebulaHelper::OneHelper
|
||||
str_h1 % "VIRTUAL ROUTER #{obj['ID']} INFORMATION")
|
||||
puts str % ["ID", obj.id.to_s]
|
||||
puts str % ["NAME", obj.name]
|
||||
puts str % ["VIRTUAL MACHINE", obj['VMID']]
|
||||
puts str % ["USER", obj['UNAME']]
|
||||
puts str % ["GROUP", obj['GNAME']]
|
||||
puts
|
||||
|
@ -1442,6 +1442,7 @@ int DispatchManager::attach_nic(
|
||||
int max_nic_id;
|
||||
int uid;
|
||||
int oid;
|
||||
int vrid;
|
||||
int rc;
|
||||
|
||||
set<int> vm_sgs;
|
||||
@ -1496,8 +1497,9 @@ int DispatchManager::attach_nic(
|
||||
|
||||
vm->set_resched(false);
|
||||
|
||||
uid = vm->get_uid();
|
||||
oid = vm->get_oid();
|
||||
uid = vm->get_uid();
|
||||
oid = vm->get_oid();
|
||||
vrid = vm->get_vrouter_id();
|
||||
|
||||
vmpool->update(vm);
|
||||
|
||||
@ -1505,6 +1507,7 @@ int DispatchManager::attach_nic(
|
||||
|
||||
rc = VirtualMachine::set_up_attach_nic(oid,
|
||||
vm_sgs,
|
||||
vrid,
|
||||
nic,
|
||||
sg_rules,
|
||||
max_nic_id,
|
||||
@ -1518,7 +1521,7 @@ int DispatchManager::attach_nic(
|
||||
|
||||
if ( rc == 0 )
|
||||
{
|
||||
VirtualMachine::release_network_leases(nic, vid);
|
||||
VirtualMachine::release_network_leases(nic, vid, vrid);
|
||||
|
||||
vector<VectorAttribute*>::iterator it;
|
||||
for(it = sg_rules.begin(); it != sg_rules.end(); it++)
|
||||
|
@ -380,7 +380,7 @@ void Group::add_admin_rules(int user_id)
|
||||
NebulaLog::log("GROUP",Log::ERROR,error_msg);
|
||||
}
|
||||
|
||||
// #<uid> VM+NET+IMAGE+TEMPLATE+DOCUMENT+SECGROUP/@<gid> USE+MANAGE *
|
||||
// #<uid> VM+NET+IMAGE+TEMPLATE+DOCUMENT+SECGROUP+VROUTER/@<gid> USE+MANAGE *
|
||||
rc = aclm->add_rule(
|
||||
AclRule::INDIVIDUAL_ID |
|
||||
user_id,
|
||||
@ -391,6 +391,7 @@ void Group::add_admin_rules(int user_id)
|
||||
PoolObjectSQL::TEMPLATE |
|
||||
PoolObjectSQL::DOCUMENT |
|
||||
PoolObjectSQL::SECGROUP |
|
||||
PoolObjectSQL::VROUTER |
|
||||
AclRule::GROUP_ID |
|
||||
oid,
|
||||
|
||||
@ -463,7 +464,7 @@ void Group::del_admin_rules(int user_id)
|
||||
NebulaLog::log("GROUP",Log::ERROR,error_msg);
|
||||
}
|
||||
|
||||
// #<uid> VM+NET+IMAGE+TEMPLATE+DOCUMENT+SECGROUP/@<gid> USE+MANAGE *
|
||||
// #<uid> VM+NET+IMAGE+TEMPLATE+DOCUMENT+SECGROUP+VROUTER/@<gid> USE+MANAGE *
|
||||
rc = aclm->del_rule(
|
||||
AclRule::INDIVIDUAL_ID |
|
||||
user_id,
|
||||
@ -474,6 +475,7 @@ void Group::del_admin_rules(int user_id)
|
||||
PoolObjectSQL::TEMPLATE |
|
||||
PoolObjectSQL::DOCUMENT |
|
||||
PoolObjectSQL::SECGROUP |
|
||||
PoolObjectSQL::VROUTER |
|
||||
AclRule::GROUP_ID |
|
||||
oid,
|
||||
|
||||
|
@ -71,6 +71,7 @@ public class Acl extends PoolElement{
|
||||
tmpResources.put("ZONE" , 0x0000800000000000L);
|
||||
tmpResources.put("SECGROUP" , 0x0001000000000000L);
|
||||
tmpResources.put("VDC" , 0x0002000000000000L);
|
||||
tmpResources.put("VROUTER" , 0x0004000000000000L);
|
||||
|
||||
RESOURCES = Collections.unmodifiableMap(tmpResources);
|
||||
|
||||
|
@ -61,7 +61,8 @@ module OpenNebula
|
||||
"DOCUMENT" => 0x400000000000,
|
||||
"ZONE" => 0x800000000000,
|
||||
"SECGROUP" => 0x1000000000000,
|
||||
"VDC" => 0x2000000000000
|
||||
"VDC" => 0x2000000000000,
|
||||
"VROUTER" => 0x4000000000000
|
||||
}
|
||||
|
||||
RIGHTS =
|
||||
|
@ -324,6 +324,17 @@ module OpenNebula
|
||||
end
|
||||
end
|
||||
|
||||
# Returns an array with the numeric virtual router ids
|
||||
def vrouter_ids
|
||||
array = Array.new
|
||||
|
||||
self.each("VROUTERS/ID") do |id|
|
||||
array << id.text.to_i
|
||||
end
|
||||
|
||||
return array
|
||||
end
|
||||
|
||||
private
|
||||
def set_publish(published)
|
||||
group_u = published ? 1 : 0
|
||||
|
@ -381,6 +381,7 @@ tabs:
|
||||
vnet_ar_list_tab: true
|
||||
vnet_leases_tab: true
|
||||
vnet_sg_list_tab: true
|
||||
vnet_vr_list_tab: true
|
||||
table_columns:
|
||||
- 0 # Checkbox
|
||||
- 1 # ID
|
||||
@ -433,9 +434,10 @@ tabs:
|
||||
table_columns:
|
||||
- 0 # Checkbox
|
||||
- 1 # ID
|
||||
- 2 # Owner
|
||||
- 3 # Group
|
||||
- 4 # Name
|
||||
- 2 # VMID
|
||||
- 3 # Owner
|
||||
- 4 # Group
|
||||
- 5 # Name
|
||||
actions:
|
||||
VirtualRouter.refresh: true
|
||||
VirtualRouter.create_dialog: true
|
||||
|
@ -381,6 +381,7 @@ tabs:
|
||||
vnet_ar_list_tab: true
|
||||
vnet_leases_tab: true
|
||||
vnet_sg_list_tab: true
|
||||
vnet_vr_list_tab: true
|
||||
table_columns:
|
||||
- 0 # Checkbox
|
||||
- 1 # ID
|
||||
@ -433,9 +434,10 @@ tabs:
|
||||
table_columns:
|
||||
- 0 # Checkbox
|
||||
- 1 # ID
|
||||
- 2 # Owner
|
||||
- 3 # Group
|
||||
- 4 # Name
|
||||
- 2 # VMID
|
||||
- 3 # Owner
|
||||
- 4 # Group
|
||||
- 5 # Name
|
||||
actions:
|
||||
VirtualRouter.refresh: true
|
||||
VirtualRouter.create_dialog: true
|
||||
|
@ -382,6 +382,7 @@ tabs:
|
||||
vnet_ar_list_tab: true
|
||||
vnet_leases_tab: true
|
||||
vnet_sg_list_tab: true
|
||||
vnet_vr_list_tab: true
|
||||
table_columns:
|
||||
- 0 # Checkbox
|
||||
- 1 # ID
|
||||
@ -434,9 +435,10 @@ tabs:
|
||||
table_columns:
|
||||
- 0 # Checkbox
|
||||
- 1 # ID
|
||||
- 2 # Owner
|
||||
- 3 # Group
|
||||
- 4 # Name
|
||||
- 2 # VMID
|
||||
- 3 # Owner
|
||||
- 4 # Group
|
||||
- 5 # Name
|
||||
actions:
|
||||
VirtualRouter.refresh: true
|
||||
VirtualRouter.create_dialog: true
|
||||
|
@ -119,7 +119,7 @@ class SunstoneServer < CloudServer
|
||||
when "vnet" then VirtualNetworkJSON.new(VirtualNetwork.build_xml, @client)
|
||||
when "user" then UserJSON.new(User.build_xml, @client)
|
||||
when "acl" then AclJSON.new(Acl.build_xml, @client)
|
||||
when "datastore" then DatastoreJSON.new(Acl.build_xml, @client)
|
||||
when "datastore" then DatastoreJSON.new(Datastore.build_xml, @client)
|
||||
when "zone" then ZoneJSON.new(Zone.build_xml, @client)
|
||||
when "security_group" then SecurityGroupJSON.new(SecurityGroup.build_xml, @client)
|
||||
when "vdc" then VdcJSON.new(Vdc.build_xml, @client)
|
||||
|
@ -171,6 +171,9 @@ define(function(require) {
|
||||
case "VDC":
|
||||
resources_str+=Locale.tr("VDCs")+", ";
|
||||
break;
|
||||
case "VROUTER":
|
||||
resources_str+=Locale.tr("Virtual Routers")+", ";
|
||||
break;
|
||||
}
|
||||
}
|
||||
//remove ", " from end
|
||||
|
@ -116,6 +116,10 @@
|
||||
<input type="checkbox" id="res_vdc" name="res_vdc" class="resource_cb" value="VDC">
|
||||
<label for="res_vdc">{{tr "VDCs"}}</label>
|
||||
</div>
|
||||
<div class="large-3 medium-6 columns end">
|
||||
<input type="checkbox" id="res_vrouter" name="res_vrouter" class="resource_cb" value="VROUTER">
|
||||
<label for="res_vrouter">{{tr "Virtual Routers"}}</label>
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
|
@ -33,7 +33,8 @@ define(function(require) {
|
||||
require('./vnets-tab/panels/info'),
|
||||
require('./vnets-tab/panels/ar'),
|
||||
require('./vnets-tab/panels/leases'),
|
||||
require('./vnets-tab/panels/secgroups')
|
||||
require('./vnets-tab/panels/secgroups'),
|
||||
require('./vnets-tab/panels/vrouters')
|
||||
];
|
||||
|
||||
var _panelsHooks = [
|
||||
|
88
src/sunstone/public/app/tabs/vnets-tab/panels/vrouters.js
Normal file
88
src/sunstone/public/app/tabs/vnets-tab/panels/vrouters.js
Normal file
@ -0,0 +1,88 @@
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* Copyright 2002-2015, OpenNebula Project, OpenNebula Systems */
|
||||
/* */
|
||||
/* 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. */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
define(function(require) {
|
||||
/*
|
||||
DEPENDENCIES
|
||||
*/
|
||||
|
||||
var Locale = require('utils/locale');
|
||||
var VirtualRoutersTable = require('tabs/vrouters-tab/datatable');
|
||||
|
||||
/*
|
||||
CONSTANTS
|
||||
*/
|
||||
|
||||
var PANEL_ID = require('./vrouters/panelId');
|
||||
var VR_TABLE_ID = PANEL_ID + "VirtualRoutersTable";
|
||||
var RESOURCE = "Network";
|
||||
var XML_ROOT = "VNET";
|
||||
|
||||
/*
|
||||
CONSTRUCTOR
|
||||
*/
|
||||
|
||||
function Panel(info) {
|
||||
this.title = Locale.tr("V. Routers");
|
||||
this.icon = "fa-random";
|
||||
|
||||
this.element = info[XML_ROOT];
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
Panel.PANEL_ID = PANEL_ID;
|
||||
Panel.prototype.html = _html;
|
||||
Panel.prototype.setup = _setup;
|
||||
|
||||
return Panel;
|
||||
|
||||
/*
|
||||
FUNCTION DEFINITIONS
|
||||
*/
|
||||
|
||||
function _html() {
|
||||
var vrs = [];
|
||||
|
||||
if (this.element.VROUTERS.ID != undefined){
|
||||
vrs = this.element.VROUTERS.ID;
|
||||
|
||||
if (!$.isArray(vrs)){
|
||||
vrs = [vrs];
|
||||
}
|
||||
}
|
||||
|
||||
var opts = {
|
||||
info: true,
|
||||
select: true,
|
||||
selectOptions: {
|
||||
read_only: true,
|
||||
fixed_ids: vrs
|
||||
}
|
||||
};
|
||||
|
||||
this.vroutersTable = new VirtualRoutersTable(VR_TABLE_ID, opts);
|
||||
|
||||
return this.vroutersTable.dataTableHTML;
|
||||
}
|
||||
|
||||
function _setup(context) {
|
||||
this.vroutersTable.initialize();
|
||||
this.vroutersTable.refreshResourceTableSelect();
|
||||
|
||||
return false;
|
||||
}
|
||||
});
|
@ -0,0 +1,19 @@
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* Copyright 2002-2015, OpenNebula Project, OpenNebula Systems */
|
||||
/* */
|
||||
/* 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. */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
define(function(require){
|
||||
return 'vnet_vr_list_tab';
|
||||
})
|
@ -56,6 +56,7 @@ define(function(require) {
|
||||
|
||||
this.columns = [
|
||||
Locale.tr("ID"),
|
||||
Locale.tr("VMID"),
|
||||
Locale.tr("Owner"),
|
||||
Locale.tr("Group"),
|
||||
Locale.tr("Name")
|
||||
@ -63,7 +64,7 @@ define(function(require) {
|
||||
|
||||
this.selectOptions = {
|
||||
"id_index": 1,
|
||||
"name_index": 4,
|
||||
"name_index": 5,
|
||||
"select_resource": Locale.tr("Please select a virtual router from the list"),
|
||||
"you_selected": Locale.tr("You selected the following virtual router:"),
|
||||
"select_resource_multiple": Locale.tr("Please select one or more virtual routers from the list"),
|
||||
@ -91,6 +92,7 @@ define(function(require) {
|
||||
element.ID + '" name="selected_items" value="' +
|
||||
element.ID + '"/>',
|
||||
element.ID,
|
||||
element.VMID,
|
||||
element.UNAME,
|
||||
element.GNAME,
|
||||
element.NAME
|
||||
|
@ -24,6 +24,8 @@ define(function(require) {
|
||||
var PermissionsTable = require('utils/panel/permissions-table');
|
||||
var RenameTr = require('utils/panel/rename-tr');
|
||||
var OpenNebulaVirtualRouter = require('opennebula/virtualrouter');
|
||||
var Sunstone = require('sunstone');
|
||||
var Config = require('sunstone-config');
|
||||
|
||||
/*
|
||||
TEMPLATES
|
||||
@ -65,6 +67,13 @@ define(function(require) {
|
||||
|
||||
function _html() {
|
||||
var renameTrHTML = RenameTr.html(TAB_ID, RESOURCE, this.element.NAME);
|
||||
|
||||
var vmid = this.element.VMID;
|
||||
|
||||
if (vmid == "-1"){
|
||||
vmid = undefined; // Change made to use {{#if vmid}} in handlebars
|
||||
}
|
||||
|
||||
var permissionsTableHTML = PermissionsTable.html(TAB_ID, RESOURCE, this.element);
|
||||
|
||||
// TODO: simplify interface?
|
||||
@ -78,12 +87,22 @@ define(function(require) {
|
||||
return TemplateInfo({
|
||||
'element': this.element,
|
||||
'renameTrHTML': renameTrHTML,
|
||||
'vmid': vmid,
|
||||
'permissionsTableHTML': permissionsTableHTML,
|
||||
'templateTableHTML': templateTableHTML
|
||||
});
|
||||
}
|
||||
|
||||
function _setup(context) {
|
||||
$("a.vmid", context).on("click", function(){
|
||||
// TODO: this should be checked internally in showElement,
|
||||
// but it won't work because of bug #4198
|
||||
|
||||
if (Config.isTabEnabled("vms-tab")){
|
||||
Sunstone.showElement("vms-tab", "VM.show", $(this).text());
|
||||
}
|
||||
});
|
||||
|
||||
RenameTr.setup(TAB_ID, RESOURCE, this.element.ID, context);
|
||||
PermissionsTable.setup(TAB_ID, RESOURCE, this.element, context);
|
||||
|
||||
|
@ -18,7 +18,7 @@
|
||||
<div class="large-6 columns">
|
||||
<table id="info_virtual_router_table" class="dataTable">
|
||||
<thead>
|
||||
<tr>
|
||||
<tr>
|
||||
<th colspan="3">{{tr "Information"}}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
@ -28,6 +28,16 @@
|
||||
<td class="value_td" colspan="2">{{element.ID}}</td>
|
||||
</tr>
|
||||
{{{renameTrHTML}}}
|
||||
<tr>
|
||||
<td class="key_td">{{tr "VM ID"}}</td>
|
||||
<td class="value_td" colspan="2">
|
||||
{{#if vmid}}
|
||||
<a class="vmid">{{vmid}}</a>
|
||||
{{else}}
|
||||
--
|
||||
{{/if}}
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
@ -428,6 +428,17 @@ int VirtualMachine::insert(SqlDB * db, string& error_str)
|
||||
goto error_defaults;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Parse the virtual router attributes
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
rc = parse_vrouter(error_str);
|
||||
|
||||
if ( rc != 0 )
|
||||
{
|
||||
goto error_vrouter;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Get network leases
|
||||
// ------------------------------------------------------------------------
|
||||
@ -584,6 +595,7 @@ error_one_vms:
|
||||
|
||||
error_os:
|
||||
error_defaults:
|
||||
error_vrouter:
|
||||
error_public:
|
||||
error_name:
|
||||
error_common:
|
||||
@ -823,6 +835,32 @@ error_cleanup:
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
int VirtualMachine::parse_vrouter(string& error_str)
|
||||
{
|
||||
string st;
|
||||
|
||||
user_obj_template->get("VROUTER", st);
|
||||
|
||||
if (!st.empty())
|
||||
{
|
||||
obj_template->replace("VROUTER", st);
|
||||
}
|
||||
|
||||
user_obj_template->get("VROUTER_ID", st);
|
||||
|
||||
if (!st.empty())
|
||||
{
|
||||
obj_template->replace("VROUTER_ID", st);
|
||||
}
|
||||
|
||||
user_obj_template->erase("VROUTER");
|
||||
user_obj_template->erase("VROUTER_ID");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
@ -2551,6 +2589,7 @@ VectorAttribute * VirtualMachine::get_attach_nic_info(
|
||||
int VirtualMachine::set_up_attach_nic(
|
||||
int vm_id,
|
||||
set<int>& vm_sgs,
|
||||
int vm_vrid,
|
||||
VectorAttribute * new_nic,
|
||||
vector<VectorAttribute*> &rules,
|
||||
int max_nic_id,
|
||||
@ -2562,7 +2601,8 @@ int VirtualMachine::set_up_attach_nic(
|
||||
|
||||
set<int> nic_sgs;
|
||||
|
||||
int rc = vnpool->nic_attribute(new_nic, max_nic_id+1, uid, vm_id, error_str);
|
||||
int rc = vnpool->nic_attribute(new_nic, max_nic_id+1, uid, vm_id,
|
||||
vm_vrid, error_str);
|
||||
|
||||
if ( rc == -1 ) //-2 is not using a pre-defined network
|
||||
{
|
||||
@ -2962,7 +3002,7 @@ int VirtualMachine::get_network_leases(string& estr)
|
||||
|
||||
merge_nic_defaults(nic);
|
||||
|
||||
rc = vnpool->nic_attribute(nic, i, uid, oid, estr);
|
||||
rc = vnpool->nic_attribute(nic, i, uid, oid, get_vrouter_id(), estr);
|
||||
|
||||
if (rc == -1)
|
||||
{
|
||||
@ -3028,14 +3068,15 @@ void VirtualMachine::release_network_leases()
|
||||
VectorAttribute const * nic =
|
||||
dynamic_cast<VectorAttribute const * >(nics[i]);
|
||||
|
||||
release_network_leases(nic, oid);
|
||||
release_network_leases(nic, oid, get_vrouter_id());
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
int VirtualMachine::release_network_leases(VectorAttribute const * nic, int vmid)
|
||||
int VirtualMachine::release_network_leases(
|
||||
VectorAttribute const * nic, int vmid, int vrid)
|
||||
{
|
||||
VirtualNetworkPool* vnpool = Nebula::instance().get_vnpool();
|
||||
VirtualNetwork* vn;
|
||||
@ -3073,11 +3114,11 @@ int VirtualMachine::release_network_leases(VectorAttribute const * nic, int vmid
|
||||
|
||||
if (nic->vector_value("AR_ID", ar_id) == 0)
|
||||
{
|
||||
vn->free_addr(ar_id, vmid, mac);
|
||||
vn->free_addr(ar_id, vmid, vrid, mac);
|
||||
}
|
||||
else
|
||||
{
|
||||
vn->free_addr(vmid, mac);
|
||||
vn->free_addr(vmid, vrid, mac);
|
||||
}
|
||||
|
||||
vnpool->update(vn);
|
||||
@ -3207,6 +3248,21 @@ void VirtualMachine::release_security_groups(int id, const VectorAttribute *nic)
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
int VirtualMachine::get_vrouter_id()
|
||||
{
|
||||
int vrid;
|
||||
|
||||
if (!obj_template->get("VROUTER_ID", vrid))
|
||||
{
|
||||
vrid = -1;
|
||||
}
|
||||
|
||||
return vrid;
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
int VirtualMachine::generate_context(string &files, int &disk_id,
|
||||
string& token_password)
|
||||
{
|
||||
|
@ -1119,6 +1119,7 @@ void VirtualMachinePool::delete_attach_nic(int vid)
|
||||
int uid;
|
||||
int gid;
|
||||
int oid;
|
||||
int vrid;
|
||||
|
||||
vm = get(vid,true);
|
||||
|
||||
@ -1127,10 +1128,11 @@ void VirtualMachinePool::delete_attach_nic(int vid)
|
||||
return;
|
||||
}
|
||||
|
||||
nic = vm->delete_attach_nic();
|
||||
uid = vm->get_uid();
|
||||
gid = vm->get_gid();
|
||||
oid = vm->get_oid();
|
||||
nic = vm->delete_attach_nic();
|
||||
uid = vm->get_uid();
|
||||
gid = vm->get_gid();
|
||||
oid = vm->get_oid();
|
||||
vrid = vm->get_vrouter_id();
|
||||
|
||||
update(vm);
|
||||
|
||||
@ -1144,6 +1146,6 @@ void VirtualMachinePool::delete_attach_nic(int vid)
|
||||
|
||||
Quotas::quota_del(Quotas::NETWORK, uid, gid, &tmpl);
|
||||
|
||||
VirtualMachine::release_network_leases(nic, oid);
|
||||
VirtualMachine::release_network_leases(nic, oid, vrid);
|
||||
}
|
||||
}
|
||||
|
@ -46,7 +46,8 @@ VirtualNetwork::VirtualNetwork(int _uid,
|
||||
PoolObjectSQL(-1,NET,"",_uid,_gid,_uname,_gname,table),
|
||||
Clusterable(_cluster_id, _cluster_name),
|
||||
bridge(""),
|
||||
parent_vid(_pvid)
|
||||
parent_vid(_pvid),
|
||||
vrouters("VROUTERS")
|
||||
{
|
||||
if (_vn_template != 0)
|
||||
{
|
||||
@ -418,6 +419,7 @@ string& VirtualNetwork::to_xml_extended(string& xml, bool extended,
|
||||
{
|
||||
ostringstream os;
|
||||
|
||||
string vrouters_xml;
|
||||
string template_xml;
|
||||
string leases_xml;
|
||||
string perm_str;
|
||||
@ -464,6 +466,8 @@ string& VirtualNetwork::to_xml_extended(string& xml, bool extended,
|
||||
}
|
||||
os << "<USED_LEASES>"<< ar_pool.get_used_addr() << "</USED_LEASES>";
|
||||
|
||||
os << vrouters.to_xml(vrouters_xml);
|
||||
|
||||
os << obj_template->to_xml(template_xml);
|
||||
|
||||
os << ar_pool.to_xml(leases_xml, extended, vms, vnets);
|
||||
@ -506,6 +510,18 @@ int VirtualNetwork::from_xml(const string &xml_str)
|
||||
xpath(vlan_id,"/VNET/VLAN_ID","");
|
||||
xpath(parent_vid,"/VNET/PARENT_NETWORK_ID",-1);
|
||||
|
||||
ObjectXML::get_nodes("/VNET/VROUTERS", content);
|
||||
|
||||
if (content.empty())
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
rc += vrouters.from_xml_node(content[0]);
|
||||
|
||||
ObjectXML::free_nodes(content);
|
||||
content.clear();
|
||||
|
||||
// Virtual Network template
|
||||
ObjectXML::get_nodes("/VNET/TEMPLATE", content);
|
||||
|
||||
@ -553,6 +569,7 @@ int VirtualNetwork::from_xml(const string &xml_str)
|
||||
int VirtualNetwork::nic_attribute(
|
||||
VectorAttribute * nic,
|
||||
int vid,
|
||||
int vrid,
|
||||
const vector<string>& inherit_attrs)
|
||||
{
|
||||
string inherit_val;
|
||||
@ -642,6 +659,11 @@ int VirtualNetwork::nic_attribute(
|
||||
nic->replace("SECURITY_GROUPS",
|
||||
one_util::join(nic_sgs.begin(), nic_sgs.end(), ','));
|
||||
|
||||
if (rc == 0 && vrid != -1)
|
||||
{
|
||||
vrouters.add_collection_id(vrid);
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
@ -243,6 +243,7 @@ int VirtualNetworkPool::nic_attribute(VectorAttribute * nic,
|
||||
int nic_id,
|
||||
int uid,
|
||||
int vid,
|
||||
int vrid,
|
||||
string& error)
|
||||
{
|
||||
string network;
|
||||
@ -268,7 +269,7 @@ int VirtualNetworkPool::nic_attribute(VectorAttribute * nic,
|
||||
return -1;
|
||||
}
|
||||
|
||||
int rc = vnet->nic_attribute(nic, vid, inherit_attrs);
|
||||
int rc = vnet->nic_attribute(nic, vid, vrid, inherit_attrs);
|
||||
|
||||
if ( rc == 0 )
|
||||
{
|
||||
|
@ -27,7 +27,8 @@ VirtualRouter::VirtualRouter( int id,
|
||||
const string& _gname,
|
||||
int _umask,
|
||||
Template * _template_contents):
|
||||
PoolObjectSQL(id,VROUTER,"",_uid,_gid,_uname,_gname,table)
|
||||
PoolObjectSQL(id,VROUTER,"",_uid,_gid,_uname,_gname,table),
|
||||
vmid(-1)
|
||||
{
|
||||
if (_template_contents != 0)
|
||||
{
|
||||
@ -197,6 +198,7 @@ string& VirtualRouter::to_xml(string& xml) const
|
||||
<< "<UNAME>" << uname << "</UNAME>"
|
||||
<< "<GNAME>" << gname << "</GNAME>"
|
||||
<< "<NAME>" << name << "</NAME>"
|
||||
<< "<VMID>" << vmid << "</VMID>"
|
||||
<< perms_to_xml(perm_str)
|
||||
<< obj_template->to_xml(template_xml)
|
||||
<< "</VROUTER>";
|
||||
@ -224,6 +226,7 @@ int VirtualRouter::from_xml(const string& xml)
|
||||
rc += xpath(uname, "/VROUTER/UNAME", "not_found");
|
||||
rc += xpath(gname, "/VROUTER/GNAME", "not_found");
|
||||
rc += xpath(name, "/VROUTER/NAME", "not_found");
|
||||
rc += xpath(vmid, "/VROUTER/VMID", -1);
|
||||
|
||||
// Permissions
|
||||
rc += perms_from_xml();
|
||||
|
Loading…
x
Reference in New Issue
Block a user