occi 2.5.19 → 3.0.0.beta.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/.travis.yml +3 -1
- data/AUTHORS +4 -3
- data/Gemfile +9 -0
- data/Gemfile.lock +64 -21
- data/README.md +19 -14
- data/Rakefile +12 -8
- data/Test Results - discovery_interface.html +862 -0
- data/bin/occi +333 -83
- data/examples/dsl_example.rb +6 -6
- data/examples/x509auth_example.rb +6 -6
- data/features/common/step_definitions/common_steps.rb +32 -0
- data/features/occi/core/create/create.feature +17 -0
- data/features/occi/core/create/step_definitions/create_steps.rb +0 -0
- data/features/occi/core/delete/delete.feature +14 -0
- data/features/occi/core/delete/step_definitions/delete_steps.rb +0 -0
- data/features/occi/core/discovery_interface/discovery_interface.feature +35 -0
- data/features/occi/core/discovery_interface/step_definitions/discovery_interface_steps.rb +19 -0
- data/features/occi/core/miscellaneous/miscellaneous.feature +14 -0
- data/features/occi/core/miscellaneous/step_definitions/miscellaneous_steps.rb +0 -0
- data/features/occi/core/read/read.feature +14 -0
- data/features/occi/core/read/step_definitions/read_steps.rb +0 -0
- data/features/occi/core/update/step_definitions/update_steps.rb +0 -0
- data/features/occi/core/update/update.feature +14 -0
- data/features/occi/infrastructure/create/create.feature +14 -0
- data/features/occi/infrastructure/create/step_definitions/create_steps.rb +0 -0
- data/features/support/env.rb +4 -0
- data/lib/occi.rb +29 -3
- data/lib/occi/api/client/client_amqp.rb +756 -0
- data/lib/occi/api/client/client_http.rb +922 -0
- data/lib/occi/api/client/http/httparty_fix.rb +53 -0
- data/lib/occi/api/client/http/net_http_fix.rb +46 -0
- data/lib/occi/api/dsl.rb +77 -73
- data/lib/occi/bin/helpers.rb +91 -0
- data/lib/occi/bin/occi_opts.rb +251 -0
- data/lib/occi/bin/resource_output_factory.rb +90 -0
- data/lib/occi/bin/templates/compute.erb +15 -0
- data/lib/occi/bin/templates/network.erb +11 -0
- data/lib/occi/bin/templates/os_tpl.erb +9 -0
- data/lib/occi/bin/templates/resource_tpl.erb +9 -0
- data/lib/occi/bin/templates/storage.erb +10 -0
- data/lib/occi/collection.rb +122 -25
- data/lib/occi/core.rb +18 -9
- data/lib/occi/core/action.rb +20 -4
- data/lib/occi/core/action_instance.rb +24 -0
- data/lib/occi/core/actions.rb +22 -0
- data/lib/occi/core/attribute_properties.rb +33 -84
- data/lib/occi/core/attributes.rb +32 -14
- data/lib/occi/core/categories.rb +46 -0
- data/lib/occi/core/category.rb +94 -20
- data/lib/occi/core/entities.rb +50 -0
- data/lib/occi/core/entity.rb +130 -89
- data/lib/occi/core/kind.rb +28 -35
- data/lib/occi/core/kinds.rb +22 -0
- data/lib/occi/core/link.rb +43 -40
- data/lib/occi/core/links.rb +34 -0
- data/lib/occi/core/mixin.rb +28 -23
- data/lib/occi/core/mixins.rb +22 -0
- data/lib/occi/core/related.rb +20 -0
- data/lib/occi/core/resource.rb +40 -40
- data/lib/occi/core/resources.rb +14 -0
- data/lib/occi/infrastructure.rb +27 -0
- data/lib/occi/infrastructure/compute.rb +159 -0
- data/lib/occi/infrastructure/network.rb +131 -0
- data/lib/occi/infrastructure/network/ipnetwork.rb +34 -0
- data/lib/occi/infrastructure/networkinterface.rb +124 -0
- data/lib/occi/infrastructure/networkinterface/ipnetworkinterface.rb +34 -0
- data/lib/occi/infrastructure/os_tpl.rb +19 -0
- data/lib/occi/infrastructure/resource_tpl.rb +19 -0
- data/lib/occi/infrastructure/storage.rb +96 -0
- data/lib/occi/infrastructure/storagelink.rb +73 -0
- data/lib/occi/log.rb +6 -2
- data/lib/occi/model.rb +38 -70
- data/lib/occi/parser.rb +108 -88
- data/lib/occi/version.rb +2 -2
- data/lib/occiantlr/OCCIANTLR.g +6 -5
- data/lib/occiantlr/OCCIANTLRLexer.rb +52 -52
- data/lib/occiantlr/OCCIANTLRParser.rb +678 -569
- data/lib/occiantlr/README.md +1 -1
- data/occi.gemspec +2 -1
- data/spec/cassettes/client_http_text_plain.yml +1066 -0
- data/spec/occi/api/client/client_amqp_spec.rb +148 -0
- data/spec/occi/api/client/client_http_0.5_spec.rb +292 -0
- data/spec/occi/api/client/client_http_spec.rb +259 -0
- data/spec/occi/api/dsl_spec.rb +0 -0
- data/spec/occi/collection_spec.rb +23 -10
- data/spec/occi/core/categories_spec.rb +30 -0
- data/spec/occi/core/category_spec.rb +41 -0
- data/spec/occi/core/entity_spec.rb +52 -0
- data/spec/occi/core/resource_spec.rb +21 -0
- data/spec/occi/infrastructure/compute_spec.rb +32 -0
- data/spec/occi/log_spec.rb +10 -10
- data/spec/occi/model_spec.rb +24 -24
- data/spec/occi/parser_spec.rb +89 -39
- data/spec/occi/test.json +22 -58
- data/spec/occiantlr/parser_spec.rb +5 -7
- data/spec/spec_helper.rb +13 -3
- metadata +116 -19
- data/etc/model/infrastructure/compute.json +0 -108
- data/etc/model/infrastructure/ipnetwork.json +0 -40
- data/etc/model/infrastructure/ipnetworkinterface.json +0 -40
- data/etc/model/infrastructure/network.json +0 -55
- data/etc/model/infrastructure/networkinterface.json +0 -38
- data/etc/model/infrastructure/os_template.json +0 -9
- data/etc/model/infrastructure/resource_template.json +0 -9
- data/etc/model/infrastructure/storage.json +0 -72
- data/etc/model/infrastructure/storagelink.json +0 -38
- data/lib/occi/api/client.rb +0 -596
- data/lib/occi/client/occiopts.rb +0 -146
- data/spec/occi/client_spec.rb +0 -12
@@ -0,0 +1,131 @@
|
|
1
|
+
module Occi
|
2
|
+
module Infrastructure
|
3
|
+
class Network < Occi::Core::Resource
|
4
|
+
|
5
|
+
require 'occi/infrastructure/network/ipnetwork'
|
6
|
+
|
7
|
+
def self.mixins
|
8
|
+
Occi::Core::Mixins.new << Occi::Infrastructure::Network::Ipnetwork.new
|
9
|
+
end
|
10
|
+
|
11
|
+
class Up < Occi::Core::Action
|
12
|
+
def initialize(scheme='http://schemas.ogf.org/occi/infrastructure/network/action#',
|
13
|
+
term='up',
|
14
|
+
title='activate network')
|
15
|
+
super
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
class Down < Occi::Core::Action
|
20
|
+
def initialize(scheme='http://schemas.ogf.org/occi/infrastructure/network/action#',
|
21
|
+
term='down',
|
22
|
+
title='deactivate network')
|
23
|
+
super
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.actions
|
28
|
+
Occi::Core::Actions.new << Up.new << Down.new
|
29
|
+
end
|
30
|
+
|
31
|
+
begin
|
32
|
+
@kind = Occi::Core::Kind.new('http://schemas.ogf.org/occi/infrastructure#', 'network')
|
33
|
+
|
34
|
+
@kind.title = "network resource"
|
35
|
+
|
36
|
+
@kind.related << Occi::Core::Resource.kind
|
37
|
+
|
38
|
+
@kind.attributes.occi!.network!.vlan = Occi::Core::AttributeProperties.new(
|
39
|
+
{ :type => 'number',
|
40
|
+
:mutable => true,
|
41
|
+
:pattern => 'x86|x64' })
|
42
|
+
|
43
|
+
@kind.attributes.occi!.network!.label = Occi::Core::AttributeProperties.new(
|
44
|
+
{ :mutable => true })
|
45
|
+
|
46
|
+
@kind.attributes.occi!.network!.state = Occi::Core::AttributeProperties.new(
|
47
|
+
{ :pattern => 'active|inactive|error',
|
48
|
+
:default => 'inactive' })
|
49
|
+
|
50
|
+
@kind.location = '/network/'
|
51
|
+
|
52
|
+
@kind.actions = self.actions
|
53
|
+
|
54
|
+
@kind
|
55
|
+
end
|
56
|
+
|
57
|
+
def ipnetwork(boolean=true)
|
58
|
+
if boolean
|
59
|
+
require 'occi/infrastructure/network/ipnetwork'
|
60
|
+
self.class.send(:include, Occi::Infrastructure::Network::Ipnetwork)
|
61
|
+
mixins << Occi::Infrastructure::Network::Ipnetwork.mixin.type_identifier
|
62
|
+
else
|
63
|
+
mixins.delete Occi::Infrastructure::Network::Ipnetwork.mixin.type_identifier
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def vlan
|
68
|
+
@attributes.occi.nework.vlan if @attributes.occi.network if @attributes.occi
|
69
|
+
end
|
70
|
+
|
71
|
+
def vlan=(vlan)
|
72
|
+
@attributes.occi!.network!.vlan = vlan
|
73
|
+
end
|
74
|
+
|
75
|
+
def label
|
76
|
+
@attributes.occi.nework.label if @attributes.occi.network if @attributes.occi
|
77
|
+
end
|
78
|
+
|
79
|
+
def label=(label)
|
80
|
+
@attributes.occi!.network!.label = label
|
81
|
+
end
|
82
|
+
|
83
|
+
def state
|
84
|
+
@attributes.occi.nework.state if @attributes.occi.network if @attributes.occi
|
85
|
+
end
|
86
|
+
|
87
|
+
def state=(state)
|
88
|
+
@attributes.occi!.network!.state = state
|
89
|
+
end
|
90
|
+
|
91
|
+
# IPNetwork Mixin attributes
|
92
|
+
|
93
|
+
def address
|
94
|
+
@attributes.occi.network.address if @attributes.occi.network if @attributes.occi
|
95
|
+
end
|
96
|
+
|
97
|
+
def address=(address)
|
98
|
+
if @mixins.select { |mixin| mixin.kind_of? Occi::Infrastructure::Network::Ipnetwork }.empty?
|
99
|
+
Occi::Log.info 'Adding mixin IPNetwork mixin'
|
100
|
+
@mixins << Occi::Infrastructure::Network::Ipnetwork.new
|
101
|
+
end
|
102
|
+
@attributes.occi!.network!.address = address
|
103
|
+
end
|
104
|
+
|
105
|
+
def gateway
|
106
|
+
@attributes.occi.network.gateway if @attributes.occi.network if @attributes.occi
|
107
|
+
end
|
108
|
+
|
109
|
+
def gateway=(gateway)
|
110
|
+
if @mixins.select { |mixin| mixin.kind_of? Occi::Infrastructure::Network::Ipnetwork }.empty?
|
111
|
+
Occi::Log.info 'Adding mixin IP network'
|
112
|
+
@mixins << Occi::Infrastructure::Network::Ipnetwork.new
|
113
|
+
end
|
114
|
+
@attributes.occi!.network!.gateway = gateway
|
115
|
+
end
|
116
|
+
|
117
|
+
def allocation
|
118
|
+
@attributes.occi.network.allocation if @attributes.occi.network if @attributes.occi
|
119
|
+
end
|
120
|
+
|
121
|
+
def allocation=(allocation)
|
122
|
+
if @mixins.select { |mixin| mixin.kind_of? Occi::Infrastructure::Network::Ipnetwork }.empty?
|
123
|
+
Occi::Log.info 'Adding mixin IPNetwork mixin'
|
124
|
+
@mixins << Occi::Infrastructure::Network::Ipnetwork.new
|
125
|
+
end
|
126
|
+
@attributes.occi!.network!.allocation = allocation
|
127
|
+
end
|
128
|
+
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module Occi
|
2
|
+
module Infrastructure
|
3
|
+
class Network
|
4
|
+
class Ipnetwork < Occi::Core::Mixin
|
5
|
+
|
6
|
+
def initialize(scheme='http://schemas.ogf.org/occi/infrastructure/network#',
|
7
|
+
term='ipnetwork',
|
8
|
+
title='IP network mixin',
|
9
|
+
attributes=Occi::Core::Attributes.new,
|
10
|
+
related=Occi::Core::Categories.new,
|
11
|
+
actions=Occi::Core::Actions.new,
|
12
|
+
location='/mixins/ipnetwork/')
|
13
|
+
|
14
|
+
super(scheme, term, title, attributes, related, actions, location)
|
15
|
+
|
16
|
+
self.attributes.occi!.network!.address = Occi::Core::AttributeProperties.new(
|
17
|
+
{ :mutable => true,
|
18
|
+
:pattern => '(^\\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:)))(%.+)?\\s*(\\/(\\d|\\d\\d|1[0-1]\\d|12[0-8]))$)|(^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\\/(\\d|[1-2]\\d|3[0-2]))$)' })
|
19
|
+
|
20
|
+
self.attributes.occi!.network!.gateway = Occi::Core::AttributeProperties.new(
|
21
|
+
{ :mutable => true,
|
22
|
+
:pattern => '(^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$)|(^\\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:)))(%.+)?\\s*)' })
|
23
|
+
|
24
|
+
self.attributes.occi!.network!.allocation = Occi::Core::AttributeProperties.new(
|
25
|
+
{ :mutable => true,
|
26
|
+
:pattern => 'dynamic|static' })
|
27
|
+
|
28
|
+
self.related << Occi::Infrastructure::Network.kind
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,124 @@
|
|
1
|
+
module Occi
|
2
|
+
module Infrastructure
|
3
|
+
class Networkinterface < Occi::Core::Link
|
4
|
+
|
5
|
+
require 'occi/infrastructure/networkinterface/ipnetworkinterface'
|
6
|
+
|
7
|
+
def self.mixins
|
8
|
+
Occi::Core::Mixins.new << Occi::Infrastructure::Networkinterface::Ipnetworkinterface.new
|
9
|
+
end
|
10
|
+
|
11
|
+
class Up < Occi::Core::Action
|
12
|
+
def initialize(scheme='http://schemas.ogf.org/occi/infrastructure/networkinterface/action#',
|
13
|
+
term='up',
|
14
|
+
title='activate networkinterface')
|
15
|
+
super
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
class Down < Occi::Core::Action
|
20
|
+
def initialize(scheme='http://schemas.ogf.org/occi/infrastructure/networkinterface/action#',
|
21
|
+
term='down',
|
22
|
+
title='deactivate networkinterface')
|
23
|
+
super
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.actions
|
28
|
+
Occi::Core::Actions.new << Up.new << Down.new
|
29
|
+
end
|
30
|
+
|
31
|
+
begin
|
32
|
+
@kind = Occi::Core::Kind.new('http://schemas.ogf.org/occi/infrastructure#', 'networkinterface')
|
33
|
+
|
34
|
+
@kind.title = "networkinterface link"
|
35
|
+
|
36
|
+
@kind.related << Occi::Core::Link.kind
|
37
|
+
|
38
|
+
@kind.attributes.occi!.networkinterface!.interface = Occi::Core::AttributeProperties.new(
|
39
|
+
{ :mutable => true })
|
40
|
+
|
41
|
+
@kind.attributes.occi!.networkinterface!.mac = Occi::Core::AttributeProperties.new(
|
42
|
+
{ :mutable => true,
|
43
|
+
:pattern => '^([0-9a-fA-F]{2}[:-]){5}([0-9a-fA-F]{2})$' })
|
44
|
+
|
45
|
+
@kind.attributes.occi!.networkinterface!.state = Occi::Core::AttributeProperties.new(
|
46
|
+
{ :pattern => 'active|inactive|error',
|
47
|
+
:default => 'inactive' })
|
48
|
+
|
49
|
+
@kind.location = '/networkinterface/'
|
50
|
+
|
51
|
+
@kind.actions = self.actions
|
52
|
+
end
|
53
|
+
|
54
|
+
def ipnetworkinterface(boolean=true)
|
55
|
+
if boolean
|
56
|
+
@mixins << Occi::Infrastructure::Networkinterface::Ipnetworkinterface.type_identifier
|
57
|
+
else
|
58
|
+
mixins.delete Occi::Infrastructure::Networkinterface::Ipnetworkinterface.type_identifier
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def interface
|
63
|
+
@attributes.occi.networkinterface.interface if @attributes.occi.networkinterface if @attributes.occi
|
64
|
+
end
|
65
|
+
|
66
|
+
def interface=(interface)
|
67
|
+
@attributes.occi!.networkinterface!.interface = interface
|
68
|
+
end
|
69
|
+
|
70
|
+
def mac
|
71
|
+
@attributes.occi.networkinterface.mac if @attributes.occi.networkinterface if @attributes.occi
|
72
|
+
end
|
73
|
+
|
74
|
+
def mac=(mac)
|
75
|
+
@attributes.occi!.networkinterface!.mac = mac
|
76
|
+
end
|
77
|
+
|
78
|
+
def state
|
79
|
+
@attributes.occi.networkinterface.state if @attributes.occi.networkinterface if @attributes.occi
|
80
|
+
end
|
81
|
+
|
82
|
+
def state=(state)
|
83
|
+
@attributes.occi!.networkinterface!.state = state
|
84
|
+
end
|
85
|
+
|
86
|
+
def address
|
87
|
+
@attributes.occi.networkinterface.address if @attributes.occi.networkinterface if @attributes.occi
|
88
|
+
end
|
89
|
+
|
90
|
+
def address=(address)
|
91
|
+
if @mixins.select { |mixin| mixin.kind_of? Occi::Infrastructure::Networkinterface::Ipnetworkinterface }.empty?
|
92
|
+
Occi::Log.info 'Adding mixin IP network interface'
|
93
|
+
@mixins << Occi::Infrastructure::Networkinterface::Ipnetworkinterface.new
|
94
|
+
end
|
95
|
+
@attributes.occi!.networkinterface!.address = address
|
96
|
+
end
|
97
|
+
|
98
|
+
def gateway
|
99
|
+
@attributes.occi.networkinterface.gateway if @attributes.occi.networkinterface if @attributes.occi
|
100
|
+
end
|
101
|
+
|
102
|
+
def gateway=(gateway)
|
103
|
+
if @mixins.select { |mixin| mixin.kind_of? Occi::Infrastructure::Networkinterface::Ipnetworkinterface }.empty?
|
104
|
+
Occi::Log.info 'Adding mixin IP network interface'
|
105
|
+
@mixins << Occi::Infrastructure::Networkinterface::Ipnetworkinterface.new
|
106
|
+
end
|
107
|
+
@attributes.occi!.networkinterface!.gateway = gateway
|
108
|
+
end
|
109
|
+
|
110
|
+
def allocation
|
111
|
+
@attributes.occi.networkinterface.allocation if @attributes.occi.networkinterface if @attributes.occi
|
112
|
+
end
|
113
|
+
|
114
|
+
def allocation=(allocation)
|
115
|
+
if @mixins.select { |mixin| mixin.kind_of? Occi::Infrastructure::Networkinterface::Ipnetworkinterface }.empty?
|
116
|
+
Occi::Log.info 'Adding mixin IP network interface'
|
117
|
+
@mixins << Occi::Infrastructure::Networkinterface::Ipnetworkinterface.new
|
118
|
+
end
|
119
|
+
@attributes.occi!.networkinterface!.allocation = allocation
|
120
|
+
end
|
121
|
+
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module Occi
|
2
|
+
module Infrastructure
|
3
|
+
class Networkinterface
|
4
|
+
class Ipnetworkinterface < Occi::Core::Mixin
|
5
|
+
|
6
|
+
def initialize(scheme='http://schemas.ogf.org/occi/infrastructure/networkinterface#',
|
7
|
+
term='ipnetworkinterface',
|
8
|
+
title='IP network interface mixin',
|
9
|
+
attributes=Occi::Core::Attributes.new,
|
10
|
+
related=Occi::Core::Categories.new,
|
11
|
+
actions=Occi::Core::Actions.new,
|
12
|
+
location='/mixins/ipnetworkinterface/')
|
13
|
+
|
14
|
+
super(scheme, term, title, attributes, related, actions, location)
|
15
|
+
|
16
|
+
self.attributes.occi!.networkinterface!.address = Occi::Core::AttributeProperties.new(
|
17
|
+
{ :mutable => true,
|
18
|
+
:pattern => '(^\\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:)))(%.+)?\\s*(\\/(\\d|\\d\\d|1[0-1]\\d|12[0-8]))$)|(^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\\/(\\d|[1-2]\\d|3[0-2]))$)' })
|
19
|
+
|
20
|
+
self.attributes.occi!.networkinterface!.gateway = Occi::Core::AttributeProperties.new(
|
21
|
+
{ :mutable => true,
|
22
|
+
:pattern => '(^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$)|(^\\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:)))(%.+)?\\s*)' })
|
23
|
+
|
24
|
+
self.attributes.occi!.networkinterface!.allocation = Occi::Core::AttributeProperties.new(
|
25
|
+
{ :mutable => true,
|
26
|
+
:pattern => 'dynamic|static' })
|
27
|
+
|
28
|
+
self.related << Occi::Infrastructure::Networkinterface.kind
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Occi
|
2
|
+
module Infrastructure
|
3
|
+
class Os_tpl < Occi::Core::Mixin
|
4
|
+
|
5
|
+
def initialize(scheme='http://schemas.ogf.org/occi/infrastructure#',
|
6
|
+
term='os_tpl',
|
7
|
+
title='operating system template',
|
8
|
+
attributes=Occi::Core::Attributes.new,
|
9
|
+
related=Occi::Core::Categories.new,
|
10
|
+
actions=Occi::Core::Actions.new,
|
11
|
+
location='/mixins/os_tpl/')
|
12
|
+
|
13
|
+
super(scheme, term, title, attributes, related, actions, location)
|
14
|
+
self.related << Occi::Infrastructure::Compute.kind
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Occi
|
2
|
+
module Infrastructure
|
3
|
+
class Resource_tpl < Occi::Core::Mixin
|
4
|
+
|
5
|
+
def initialize(scheme='http://schemas.ogf.org/occi/infrastructure#',
|
6
|
+
term='resource_tpl',
|
7
|
+
title='resource template',
|
8
|
+
attributes=Occi::Core::Attributes.new,
|
9
|
+
related=Occi::Core::Categories.new,
|
10
|
+
actions=Occi::Core::Actions.new,
|
11
|
+
location='/mixins/resource_tpl/')
|
12
|
+
|
13
|
+
super(scheme, term, title, attributes, related, actions, location)
|
14
|
+
self.related << Occi::Infrastructure::Compute.kind
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,96 @@
|
|
1
|
+
module Occi
|
2
|
+
module Infrastructure
|
3
|
+
class Storage < Occi::Core::Resource
|
4
|
+
|
5
|
+
class Online < Occi::Core::Action
|
6
|
+
def initialize(scheme='http://schemas.ogf.org/occi/infrastructure/storage/action#',
|
7
|
+
term='online',
|
8
|
+
title='activate storage')
|
9
|
+
super
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
class Offline < Occi::Core::Action
|
14
|
+
def initialize(scheme='http://schemas.ogf.org/occi/infrastructure/storage/action#',
|
15
|
+
term='offline',
|
16
|
+
title='deactivate storage')
|
17
|
+
super
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
class Backup < Occi::Core::Action
|
22
|
+
def initialize(scheme='http://schemas.ogf.org/occi/infrastructure/storage/action#',
|
23
|
+
term='backup',
|
24
|
+
title='backup storage')
|
25
|
+
super
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
class Snapshot < Occi::Core::Action
|
30
|
+
def initialize(scheme='http://schemas.ogf.org/occi/infrastructure/storage/action#',
|
31
|
+
term='snapshot',
|
32
|
+
title='snapshot storage')
|
33
|
+
super
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
class Resize < Occi::Core::Action
|
38
|
+
def initialize(scheme='http://schemas.ogf.org/occi/infrastructure/storage/action#',
|
39
|
+
term='resize',
|
40
|
+
title='resize storage')
|
41
|
+
super
|
42
|
+
@attributes.size = Occi::Core::AttributeProperties.new(
|
43
|
+
{ :type => 'number',
|
44
|
+
:mutable => true })
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def self.actions
|
49
|
+
Occi::Core::Actions.new << Online.new << Offline.new << Backup.new << Snapshot.new
|
50
|
+
end
|
51
|
+
|
52
|
+
begin
|
53
|
+
@kind = Occi::Core::Kind.new('http://schemas.ogf.org/occi/infrastructure#', 'storage')
|
54
|
+
|
55
|
+
@kind.title = "storage resource"
|
56
|
+
|
57
|
+
@kind.related << Occi::Core::Resource.kind
|
58
|
+
|
59
|
+
@kind.attributes.occi!.storage!.size = Occi::Core::AttributeProperties.new(
|
60
|
+
{ :type => 'number',
|
61
|
+
:mutable => true })
|
62
|
+
|
63
|
+
@kind.attributes.occi!.storage!.state = Occi::Core::AttributeProperties.new(
|
64
|
+
{ :pattern => 'online|offline|backup|snapshot|resize|degraded',
|
65
|
+
:default => 'offline' })
|
66
|
+
|
67
|
+
@kind.location = '/storage/'
|
68
|
+
|
69
|
+
@kind.actions = [
|
70
|
+
"http://schemas.ogf.org/occi/infrastructure/storage/action#online",
|
71
|
+
"http://schemas.ogf.org/occi/infrastructure/storage/action#offline",
|
72
|
+
"http://schemas.ogf.org/occi/infrastructure/storage/action#backup",
|
73
|
+
"http://schemas.ogf.org/occi/infrastructure/storage/action#snapshot",
|
74
|
+
"http://schemas.ogf.org/occi/infrastructure/storage/action#resize"
|
75
|
+
]
|
76
|
+
end
|
77
|
+
|
78
|
+
def size
|
79
|
+
@attributes.occi.storage.size if @attributes.occi.storage if @attributes.occi
|
80
|
+
end
|
81
|
+
|
82
|
+
def size=(size)
|
83
|
+
@attributes.occi!.storage!.size = size
|
84
|
+
end
|
85
|
+
|
86
|
+
def state
|
87
|
+
@attributes.occi.storage.state if @attributes.occi.storage if @attributes.occi
|
88
|
+
end
|
89
|
+
|
90
|
+
def state=(state)
|
91
|
+
@attributes.occi!.storage!.state = state
|
92
|
+
end
|
93
|
+
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|