Class: OneTemplateHelper
Constant Summary
collapse
- VM_NAME =
{
:name => "name",
:large => "--name name",
:format => String,
:description => "Name of the new VM or TEMPLATE. When instantiating\n multiple VMs you can use the \\\"%i\\\" wildcard to produce\n different names such as vm-0, vm-1...\n".strip
}
- MULTIPLE =
{
:name => "multiple",
:short => "-m x",
:large => "--multiple x",
:format => Integer,
:description => "Instance multiple VMs"
}
- USERDATA =
{
:name => "userdata",
:large => "--userdata userdata",
:format => String,
:description => "Integrate userdata into the EC2 section"
}
- EXTENDED =
{
:name => "extended",
:large => "--extended",
:description => "Process the template and included extended "+
"information, such as the SIZE for each DISK"
}
- RECURSIVE =
{
:name => "recursive",
:large => "--recursive",
:description => "Applies the action to the template plus any "+
"image defined in DISK"
}
- PERSISTENT =
{
:name => "persistent",
:large => "--persistent",
:description => "Creates a private persistent copy of the template "+
"plus any image defined in DISK, and instantiates that copy"
}
- INT_EXP =
/^-?\d+$/
- FLOAT_EXP =
/^-?\d+(\.\d+)?$/
Instance Attribute Summary
#client
Class Method Summary
collapse
Instance Method Summary
collapse
#check_orphan, client, #create_resource, #filterflag_to_i, filterflag_to_i_desc, get_client, get_password, #group_name, #initialize, #list_pool, #list_pool_format, #list_pool_table, #list_pool_top, #list_pool_xml, #list_to_id, list_to_id_desc, name_to_id, #perform_action, #perform_actions, #print_page, #retrieve_resource, #set_client, set_endpoint, set_password, set_user, #start_pager, #stop_pager, table_conf, #to_id, to_id_desc, #user_name
Class Method Details
.conf_file ⇒ Object
72
73
74
|
# File 'lib/one_helper/onetemplate_helper.rb', line 72
def self.conf_file
"onetemplate.yaml"
end
|
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
|
# File 'lib/one_helper/onetemplate_helper.rb', line 142
def self.get_user_inputs(template, keys = [])
user_inputs = template['VMTEMPLATE']['TEMPLATE']['USER_INPUTS']
return '' unless user_inputs
answers = OpenNebulaHelper.parse_user_inputs(user_inputs, keys)
answers_s = ''
answers.each do |key, val|
next unless val
if key != template['VMTEMPLATE']['TEMPLATE'][key]
answers_s << "#{key} = \""
answers_s << val.gsub('"', "\\\"") << "\"\n"
end
end
answers_s
end
|
.rname ⇒ Object
68
69
70
|
# File 'lib/one_helper/onetemplate_helper.rb', line 68
def self.rname
"VMTEMPLATE"
end
|
Instance Method Details
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
|
# File 'lib/one_helper/onetemplate_helper.rb', line 107
def format_pool(options)
config_file = self.class.table_conf
table = CLIHelper::ShowTable.new(config_file, self) do
column :ID, "ONE identifier for the Template", :size=>4 do |d|
d["ID"]
end
column :NAME, "Name of the Template", :left, :size=>27 do |d|
d["NAME"]
end
column :USER, "Username of the Template owner", :left,
:size=>15 do |d|
helper.user_name(d, options)
end
column :GROUP, "Group of the Template", :left, :size=>15 do |d|
helper.group_name(d, options)
end
column :REGTIME, "Registration time of the Template",
:size=>15 do |d|
OpenNebulaHelper.time_to_str(d["REGTIME"])
end
default :ID, :USER, :GROUP, :NAME, :REGTIME
end
table
end
|
#show_resource(id, options) ⇒ Object
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
# File 'lib/one_helper/onetemplate_helper.rb', line 77
def show_resource(id, options)
resource = retrieve_resource(id)
if !options[:extended].nil?
rc = resource.info(options[:extended])
else
rc = resource.info
end
return -1, rc.message if OpenNebula.is_error?(rc)
if options[:xml]
return 0, resource.to_xml(true)
elsif options[:json]
if options[:body]
return 0, check_resource_xsd(resource)
else
return 0, ::JSON.pretty_generate(
check_resource_xsd(resource)
)
end
elsif options[:yaml]
return 0, check_resource_xsd(resource).to_yaml(:indent => 4)
else
format_resource(resource, options)
return 0
end
end
|