class OneVNTemplateHelper

Constants

EXTENDED
FLOAT_EXP
INT_EXP
MULTIPLE
VN_NAME

Public Class Methods

conf_file() click to toggle source
# File lib/one_helper/onevntemplate_helper.rb, line 52
def self.conf_file
    "onevntemplate.yaml"
end
rname() click to toggle source
# File lib/one_helper/onevntemplate_helper.rb, line 48
def self.rname
    "VNTEMPLATE"
end

Private Instance Methods

factory(id=nil) click to toggle source
# File lib/one_helper/onevntemplate_helper.rb, line 61
def factory(id=nil)
    if id
        OpenNebula::VNTemplate.new_with_id(id, @client)
    else
        xml=OpenNebula::VNTemplate.build_xml
        OpenNebula::VNTemplate.new(xml, @client)
    end
end
factory_pool(user_flag=-2) click to toggle source
# File lib/one_helper/onevntemplate_helper.rb, line 70
def factory_pool(user_flag=-2)
    OpenNebula::VNTemplatePool.new(@client, user_flag)
end
format_resource(template, options = {}) click to toggle source
# File lib/one_helper/onevntemplate_helper.rb, line 74
def format_resource(template, options = {})
    str="%-15s: %-20s"
    str_h1="%-80s"

    CLIHelper.print_header(
        str_h1 % "TEMPLATE #{template['ID']} INFORMATION")
    puts str % ["ID", template.id.to_s]
    puts str % ["NAME", template.name]
    puts str % ["USER", template['UNAME']]
    puts str % ["GROUP", template['GNAME']]
    puts str % ["LOCK", OpenNebulaHelper.level_lock_to_str(template['LOCK/LOCKED'])]
    puts str % ["REGISTER TIME",
        OpenNebulaHelper.time_to_str(template['REGTIME'])]
    puts

    CLIHelper.print_header(str_h1 % "PERMISSIONS",false)

    ["OWNER", "GROUP", "OTHER"].each { |e|
        mask = "---"
        mask[0] = "u" if template["PERMISSIONS/#{e}_U"] == "1"
        mask[1] = "m" if template["PERMISSIONS/#{e}_M"] == "1"
        mask[2] = "a" if template["PERMISSIONS/#{e}_A"] == "1"

        puts str % [e,  mask]
    }
    puts

    CLIHelper.print_header(str_h1 % "TEMPLATE CONTENTS",false)
    puts template.template_str
end