mirror of
https://github.com/OpenNebula/one.git
synced 2026-11-19 11:22:55 +09:00
Feature #3456: DS enable/disable in ruby oca and cli
This commit is contained in:
1 parent
ab5483df14
commit
e90f0693c1
4 files changed
+87
-20
No files matched your search
@@ -33,12 +33,17 @@
|
||||
|
||||
:DS:
|
||||
:desc: Datastore driver
|
||||
:size: 8
|
||||
:size: 6
|
||||
:left: true
|
||||
|
||||
:TM:
|
||||
:desc: Transfer driver
|
||||
:size: 8
|
||||
:size: 7
|
||||
:left: true
|
||||
|
||||
:STAT:
|
||||
:desc: State of the Datastore
|
||||
:size: 4
|
||||
:left: true
|
||||
|
||||
:default:
|
||||
@@ -51,4 +56,5 @@
|
||||
- :TYPE
|
||||
- :DS
|
||||
- :TM
|
||||
- :STAT
|
||||
|
||||
@@ -82,15 +82,21 @@ class OneDatastoreHelper < OpenNebulaHelper::OneHelper
|
||||
Datastore::SHORT_DATASTORE_TYPES[type]
|
||||
end
|
||||
|
||||
column :DS, "Datastore driver", :left, :size=>8 do |d|
|
||||
column :DS, "Datastore driver", :left, :size=>6 do |d|
|
||||
d["DS_MAD"]
|
||||
end
|
||||
|
||||
column :TM, "Transfer driver", :left, :size=>8 do |d|
|
||||
column :TM, "Transfer driver", :left, :size=>7 do |d|
|
||||
d["TM_MAD"]
|
||||
end
|
||||
|
||||
default :ID, :NAME, :SIZE, :AVAIL, :CLUSTER, :IMAGES, :TYPE, :DS, :TM
|
||||
column :STAT, "State of the Datastore", :left, :size=>4 do |d|
|
||||
state = Datastore::DATASTORE_STATES[d["STATE"].to_i]
|
||||
Datastore::SHORT_DATASTORE_STATES[state]
|
||||
end
|
||||
|
||||
default :ID, :NAME, :SIZE, :AVAIL, :CLUSTER, :IMAGES,
|
||||
:TYPE, :DS, :TM, :STAT
|
||||
end
|
||||
|
||||
table
|
||||
@@ -128,6 +134,7 @@ class OneDatastoreHelper < OpenNebulaHelper::OneHelper
|
||||
puts str % ["TM_MAD", datastore['TM_MAD']]
|
||||
puts str % ["BASE PATH",datastore['BASE_PATH']]
|
||||
puts str % ["DISK_TYPE",Image::DISK_TYPES[datastore['DISK_TYPE'].to_i]]
|
||||
puts str % ["STATE", datastore.state_str]
|
||||
puts
|
||||
|
||||
CLIHelper.print_header(str_h1 % "DATASTORE CAPACITY", false)
|
||||
|
||||
@@ -184,4 +184,24 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
||||
o.rename(args[1])
|
||||
end
|
||||
end
|
||||
|
||||
enable_desc = <<-EOT.unindent
|
||||
Enables the given Datastore. Only available for System Datastores
|
||||
EOT
|
||||
|
||||
command :enable, enable_desc, [:range,:datastoreid_list] do
|
||||
helper.perform_actions(args[0],options,"enabled") do |obj|
|
||||
obj.enable
|
||||
end
|
||||
end
|
||||
|
||||
disable_desc = <<-EOT.unindent
|
||||
Disables the given Datastore. Only available for System Datastores
|
||||
EOT
|
||||
|
||||
command :disable, disable_desc, [:range,:datastoreid_list] do
|
||||
helper.perform_actions(args[0],options,"disabled") do |obj|
|
||||
obj.disable
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -30,7 +30,8 @@ module OpenNebula
|
||||
:update => "datastore.update",
|
||||
:chown => "datastore.chown",
|
||||
:chmod => "datastore.chmod",
|
||||
:rename => "datastore.rename"
|
||||
:rename => "datastore.rename",
|
||||
:enable => "datastore.enable"
|
||||
}
|
||||
|
||||
DATASTORE_TYPES=%w{IMAGE SYSTEM FILE}
|
||||
@@ -41,6 +42,13 @@ module OpenNebula
|
||||
"FILE" => "fil"
|
||||
}
|
||||
|
||||
DATASTORE_STATES=%w{READY DISABLED}
|
||||
|
||||
SHORT_DATASTORE_STATES={
|
||||
"READY" => "rdy",
|
||||
"DISABLED" => "disa"
|
||||
}
|
||||
|
||||
# Creates a Datastore description with just its identifier
|
||||
# this method should be used to create plain Datastore objects.
|
||||
# +id+ the id of the user
|
||||
@@ -66,20 +74,6 @@ module OpenNebula
|
||||
#######################################################################
|
||||
# XML-RPC Methods for the Datastore Object
|
||||
#######################################################################
|
||||
# Returns the datastore type
|
||||
def type
|
||||
self['TYPE'].to_i
|
||||
end
|
||||
|
||||
# Returns the datastore type (string value)
|
||||
def type_str
|
||||
DATASTORE_TYPES[type]
|
||||
end
|
||||
|
||||
# Returns the datastore type (string value)
|
||||
def short_type_str
|
||||
SHORT_DATASTORE_TYPES[type_str]
|
||||
end
|
||||
|
||||
# Retrieves the information of the given Datastore.
|
||||
def info()
|
||||
@@ -157,10 +151,50 @@ module OpenNebula
|
||||
return call(DATASTORE_METHODS[:rename], @pe_id, name)
|
||||
end
|
||||
|
||||
# Enables a Datastore
|
||||
def enable
|
||||
return call(DATASTORE_METHODS[:enable], @pe_id, true)
|
||||
end
|
||||
|
||||
# Disables a Datastore
|
||||
def disable
|
||||
return call(DATASTORE_METHODS[:enable], @pe_id, false)
|
||||
end
|
||||
|
||||
# ---------------------------------------------------------------------
|
||||
# Helpers to get information
|
||||
# ---------------------------------------------------------------------
|
||||
|
||||
# Returns the datastore type
|
||||
def type
|
||||
self['TYPE'].to_i
|
||||
end
|
||||
|
||||
# Returns the datastore type (string value)
|
||||
def type_str
|
||||
DATASTORE_TYPES[type]
|
||||
end
|
||||
|
||||
# Returns the datastore type (string value)
|
||||
def short_type_str
|
||||
SHORT_DATASTORE_TYPES[type_str]
|
||||
end
|
||||
|
||||
# Returns the state of the datastore (numeric value)
|
||||
def state
|
||||
self['STATE'].to_i
|
||||
end
|
||||
|
||||
# Returns the state of the datastore (string value)
|
||||
def state_str
|
||||
DATASTORE_STATES[state]
|
||||
end
|
||||
|
||||
# Returns the state of the datastore (string value)
|
||||
def short_state_str
|
||||
SHORT_DATASTORE_STATES[state_str]
|
||||
end
|
||||
|
||||
# Returns whether or not the image with id 'id' is part of this datastore
|
||||
def contains(id)
|
||||
#This doesn't work in ruby 1.8.5
|
||||
|
||||
Reference in new issue
Block a user