mirror of
https://github.com/OpenNebula/one.git
synced 2025-01-21 18:03:38 +03:00
feature #2858: Add free_ar to free a previously reserved address range. Operation needs MANAGE permission on the reservation VNET (rm_ar is ADMIN)
This commit is contained in:
parent
f87d3bb3cf
commit
6136edf87c
@ -86,8 +86,11 @@ public:
|
||||
class VirtualNetworkRmAddressRange : public Request
|
||||
{
|
||||
public:
|
||||
VirtualNetworkRmAddressRange():Request("VirtualNetworkRmAddressRange",
|
||||
"A:sii", "Removes an address range from a virtual network")
|
||||
VirtualNetworkRmAddressRange(
|
||||
const string& name = "VirtualNetworkRmAddressRange",
|
||||
const string& sign = "A:sii",
|
||||
const string& help = "Removes an address range from a virtual network")
|
||||
: Request(name, sign, help)
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
pool = nd.get_vnpool();
|
||||
@ -96,7 +99,7 @@ public:
|
||||
auth_op = AuthRequest::ADMIN;
|
||||
};
|
||||
|
||||
~VirtualNetworkRmAddressRange(){};
|
||||
virtual ~VirtualNetworkRmAddressRange(){};
|
||||
|
||||
void request_execute(xmlrpc_c::paramList const& _paramList,
|
||||
RequestAttributes& att);
|
||||
@ -105,6 +108,33 @@ public:
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
class VirtualNetworkFreeAddressRange : public VirtualNetworkRmAddressRange
|
||||
{
|
||||
public:
|
||||
VirtualNetworkFreeAddressRange():VirtualNetworkRmAddressRange(
|
||||
"VirtualNetworkFreeAddressRange",
|
||||
"A:sii",
|
||||
"Frees a reserved address range from a virtual network")
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
pool = nd.get_vnpool();
|
||||
|
||||
auth_object = PoolObjectSQL::NET;
|
||||
auth_op = AuthRequest::MANAGE;
|
||||
};
|
||||
|
||||
~VirtualNetworkFreeAddressRange(){};
|
||||
|
||||
void request_execute(xmlrpc_c::paramList const& _paramList,
|
||||
RequestAttributes& att)
|
||||
{
|
||||
VirtualNetworkRmAddressRange::request_execute(_paramList, att);
|
||||
}
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
class VirtualNetworkUpdateAddressRange: public RequestManagerVirtualNetwork
|
||||
{
|
||||
public:
|
||||
|
@ -156,6 +156,16 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
||||
end
|
||||
end
|
||||
|
||||
free_desc = <<-EOT.unindent
|
||||
Frees a reserved address range from the Virtual Network
|
||||
EOT
|
||||
|
||||
command :free, free_desc, :vnetid, :ar_id do
|
||||
helper.perform_action(args[0],options,"address range freed") do |vn|
|
||||
vn.free(args[1])
|
||||
end
|
||||
end
|
||||
|
||||
hold_desc = <<-EOT.unindent
|
||||
Holds a Virtual Network lease, marking it as used
|
||||
EOT
|
||||
|
@ -36,7 +36,8 @@ module OpenNebula
|
||||
:hold => "vn.hold",
|
||||
:release => "vn.release",
|
||||
:rename => "vn.rename",
|
||||
:reserve => "vn.reserve"
|
||||
:reserve => "vn.reserve",
|
||||
:free_ar => "vn.free_ar"
|
||||
}
|
||||
|
||||
# Creates a VirtualNetwork description with just its identifier
|
||||
@ -219,6 +220,16 @@ module OpenNebula
|
||||
return rc
|
||||
end
|
||||
|
||||
# Removes an Address Range from the VirtualNetwork
|
||||
def free(ar_id)
|
||||
return Error.new('ID not defined') if !@pe_id
|
||||
|
||||
rc = @client.call(VN_METHODS[:free_ar], @pe_id, ar_id.to_i)
|
||||
rc = nil if !OpenNebula.is_error?(rc)
|
||||
|
||||
return rc
|
||||
end
|
||||
|
||||
# Changes the owner/group
|
||||
#
|
||||
# @param uid [Integer] the new owner id. Set to -1 to leave the current one
|
||||
|
@ -278,6 +278,7 @@ void RequestManager::register_xml_methods()
|
||||
// VirtualNetwork Methods
|
||||
xmlrpc_c::methodPtr vn_add_ar(new VirtualNetworkAddAddressRange());
|
||||
xmlrpc_c::methodPtr vn_rm_ar(new VirtualNetworkRmAddressRange());
|
||||
xmlrpc_c::methodPtr vn_free_ar(new VirtualNetworkFreeAddressRange());
|
||||
xmlrpc_c::methodPtr vn_update_ar(new VirtualNetworkUpdateAddressRange());
|
||||
xmlrpc_c::methodPtr vn_hold(new VirtualNetworkHold());
|
||||
xmlrpc_c::methodPtr vn_release(new VirtualNetworkRelease());
|
||||
@ -491,6 +492,7 @@ void RequestManager::register_xml_methods()
|
||||
RequestManagerRegistry.addMethod("one.vn.add_ar", vn_add_ar);
|
||||
RequestManagerRegistry.addMethod("one.vn.rm_ar", vn_rm_ar);
|
||||
RequestManagerRegistry.addMethod("one.vn.update_ar", vn_update_ar);
|
||||
RequestManagerRegistry.addMethod("one.vn.free_ar", vn_free_ar);
|
||||
RequestManagerRegistry.addMethod("one.vn.hold", vn_hold);
|
||||
RequestManagerRegistry.addMethod("one.vn.release", vn_release);
|
||||
RequestManagerRegistry.addMethod("one.vn.allocate", vn_allocate);
|
||||
|
Loading…
x
Reference in New Issue
Block a user