1
0
mirror of https://github.com/OpenNebula/one.git synced 2024-12-23 17:33:56 +03:00

feature #661: Add VirtualNetwork type helper

This commit is contained in:
Daniel Molina 2011-06-09 16:35:15 +02:00
parent 08af7304af
commit 5a958f7032

View File

@ -30,6 +30,13 @@ module OpenNebula
:rmleases => "vn.rmleases"
}
NETWORK_TYPES=%w{RANGED FIXED}
SHORT_NETWORK_TYPES={
"RANGED" => "R",
"FIXED" => "F"
}
# Creates a VirtualNetwork description with just its identifier
# this method should be used to create plain VirtualNetwork objects.
# +id+ the id of the network
@ -111,6 +118,25 @@ module OpenNebula
return rc
end
#######################################################################
# Helpers to get Virtual Network information
#######################################################################
# Returns the type of the Virtual Network (numeric value)
def type
self['TYPE'].to_i
end
# Returns the type of the Virtual Network (string value)
def type_str
NETWORK_TYPES[type]
end
# Returns the state of the Virtual Network (string value)
def short_type_str
SHORT_NETWORK_TYPES[type_str]
end
private
def set_publish(published)
return Error.new('ID not defined') if !@pe_id