opennebula-cli 5.6.2 → 5.7.80.pre

Sign up to get free protection for your applications and to get access to all the features.
@@ -96,33 +96,33 @@ class OneVNetHelper < OpenNebulaHelper::OneHelper
96
96
  # :description => "Number of addresses to reserve"
97
97
  # }
98
98
 
99
- GATEWAY = [
99
+ GATEWAY = {
100
100
  :name => "gateway",
101
101
  :large => "--gateway ip",
102
102
  :format => String,
103
103
  :description=> "IP of the gateway"
104
- ]
104
+ }
105
105
 
106
- NETMASK = [
106
+ NETMASK = {
107
107
  :name => "netmask",
108
108
  :large => "--netmask mask",
109
109
  :format => String,
110
110
  :description=> "Netmask in dot notation"
111
- ]
111
+ }
112
112
 
113
- VN_MAD = [
113
+ VN_MAD = {
114
114
  :name => "vn_mad",
115
115
  :large => "--vn_mad mad",
116
116
  :format => String,
117
117
  :description=> "Use this driver for the network"
118
- ]
118
+ }
119
119
 
120
- VLAN_ID = [
120
+ VLAN_ID = {
121
121
  :name => "vlanid",
122
122
  :large => "--vlanid id",
123
123
  :format => String,
124
124
  :description=> "VLAN ID assigned"
125
- ]
125
+ }
126
126
 
127
127
  ADDAR_OPTIONS = [
128
128
  SIZE, MAC, IP, IP6, IP6_GLOBAL, IP6_ULA, GATEWAY, NETMASK, VN_MAD,
@@ -361,4 +361,16 @@ class OneVNetHelper < OpenNebulaHelper::OneHelper
361
361
  end
362
362
  end
363
363
  end
364
+
365
+ def self.add_ar_options_used?(options)
366
+ # Get the template options names as symbols. options hash
367
+ # uses symbols
368
+ add_ar_options=OneVNetHelper::ADDAR_OPTIONS.map do |o|
369
+ o[:name].to_sym
370
+ end
371
+
372
+ # Check if one at least one of the template options is
373
+ # in options hash
374
+ (add_ar_options-options.keys)!=add_ar_options
375
+ end
364
376
  end
@@ -0,0 +1,104 @@
1
+ # -------------------------------------------------------------------------- #
2
+ # Copyright 2002-2018, OpenNebula Project, OpenNebula Systems #
3
+ # #
4
+ # Licensed under the Apache License, Version 2.0 (the "License"); you may #
5
+ # not use this file except in compliance with the License. You may obtain #
6
+ # a copy of the License at #
7
+ # #
8
+ # http://www.apache.org/licenses/LICENSE-2.0 #
9
+ # #
10
+ # Unless required by applicable law or agreed to in writing, software #
11
+ # distributed under the License is distributed on an "AS IS" BASIS, #
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
13
+ # See the License for the specific language governing permissions and #
14
+ # limitations under the License. #
15
+ #--------------------------------------------------------------------------- #
16
+
17
+ require 'one_helper'
18
+ require 'one_helper/onetemplate_helper'
19
+ require 'base64'
20
+
21
+ class OneVNTemplateHelper < OneTemplateHelper
22
+ VN_NAME={
23
+ :name => "name",
24
+ :large => "--name name",
25
+ :format => String,
26
+ :description => <<-EOT.strip
27
+ Name of the new VN TEMPLATE. When instantiating
28
+ multiple VNs you can use the \"%i\" wildcard to produce
29
+ different names such as vm-0, vm-1...
30
+ EOT
31
+ }
32
+
33
+ MULTIPLE={
34
+ :name => "multiple",
35
+ :short => "-m x",
36
+ :large => "--multiple x",
37
+ :format => Integer,
38
+ :description => "Instance multiple VNs"
39
+ }
40
+
41
+ EXTENDED={
42
+ :name => "extended",
43
+ :large => "--extended",
44
+ :description => "Process the template and included extended "+
45
+ "information"
46
+ }
47
+
48
+ def self.rname
49
+ "VNTEMPLATE"
50
+ end
51
+
52
+ def self.conf_file
53
+ "onevntemplate.yaml"
54
+ end
55
+
56
+ INT_EXP = /^-?\d+$/
57
+ FLOAT_EXP = /^-?\d+(\.\d+)?$/
58
+
59
+ private
60
+
61
+ def factory(id=nil)
62
+ if id
63
+ OpenNebula::VNTemplate.new_with_id(id, @client)
64
+ else
65
+ xml=OpenNebula::VNTemplate.build_xml
66
+ OpenNebula::VNTemplate.new(xml, @client)
67
+ end
68
+ end
69
+
70
+ def factory_pool(user_flag=-2)
71
+ OpenNebula::VNTemplatePool.new(@client, user_flag)
72
+ end
73
+
74
+ def format_resource(template, options = {})
75
+ str="%-15s: %-20s"
76
+ str_h1="%-80s"
77
+
78
+ CLIHelper.print_header(
79
+ str_h1 % "TEMPLATE #{template['ID']} INFORMATION")
80
+ puts str % ["ID", template.id.to_s]
81
+ puts str % ["NAME", template.name]
82
+ puts str % ["USER", template['UNAME']]
83
+ puts str % ["GROUP", template['GNAME']]
84
+ puts str % ["LOCK", OpenNebulaHelper.level_lock_to_str(template['LOCK/LOCKED'])]
85
+ puts str % ["REGISTER TIME",
86
+ OpenNebulaHelper.time_to_str(template['REGTIME'])]
87
+ puts
88
+
89
+ CLIHelper.print_header(str_h1 % "PERMISSIONS",false)
90
+
91
+ ["OWNER", "GROUP", "OTHER"].each { |e|
92
+ mask = "---"
93
+ mask[0] = "u" if template["PERMISSIONS/#{e}_U"] == "1"
94
+ mask[1] = "m" if template["PERMISSIONS/#{e}_M"] == "1"
95
+ mask[2] = "a" if template["PERMISSIONS/#{e}_A"] == "1"
96
+
97
+ puts str % [e, mask]
98
+ }
99
+ puts
100
+
101
+ CLIHelper.print_header(str_h1 % "TEMPLATE CONTENTS",false)
102
+ puts template.template_str
103
+ end
104
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opennebula-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.6.2
4
+ version: 5.7.80.pre
5
5
  platform: ruby
6
6
  authors:
7
7
  - OpenNebula
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-10-10 00:00:00.000000000 Z
11
+ date: 2019-01-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: opennebula
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 5.6.2
19
+ version: 5.7.80.pre
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 5.6.2
26
+ version: 5.7.80.pre
27
27
  description: Commands used to talk to OpenNebula
28
28
  email: contact@opennebula.org
29
29
  executables:
@@ -47,6 +47,7 @@ executables:
47
47
  - onevm
48
48
  - onevmgroup
49
49
  - onevnet
50
+ - onevntemplate
50
51
  - onevrouter
51
52
  - onezone
52
53
  extensions: []
@@ -72,6 +73,7 @@ files:
72
73
  - bin/onevm
73
74
  - bin/onevmgroup
74
75
  - bin/onevnet
76
+ - bin/onevntemplate
75
77
  - bin/onevrouter
76
78
  - bin/onezone
77
79
  - lib/cli_helper.rb
@@ -95,6 +97,7 @@ files:
95
97
  - lib/one_helper/onevm_helper.rb
96
98
  - lib/one_helper/onevmgroup_helper.rb
97
99
  - lib/one_helper/onevnet_helper.rb
100
+ - lib/one_helper/onevntemplate_helper.rb
98
101
  - lib/one_helper/onevrouter_helper.rb
99
102
  - lib/one_helper/onezone_helper.rb
100
103
  - NOTICE
@@ -114,9 +117,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
114
117
  version: '0'
115
118
  required_rubygems_version: !ruby/object:Gem::Requirement
116
119
  requirements:
117
- - - '>='
120
+ - - '>'
118
121
  - !ruby/object:Gem::Version
119
- version: '0'
122
+ version: 1.3.1
120
123
  requirements: []
121
124
  rubyforge_project:
122
125
  rubygems_version: 2.0.14.1