occi-core 4.0.0.alpha.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (73) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +15 -0
  3. data/.rspec +1 -0
  4. data/.travis.yml +43 -0
  5. data/.yardopts +1 -0
  6. data/AUTHORS +9 -0
  7. data/Gemfile +11 -0
  8. data/LICENSE +13 -0
  9. data/README.md +212 -0
  10. data/Rakefile +28 -0
  11. data/config/occi.yml +4 -0
  12. data/ext/mkrf_conf.rb +35 -0
  13. data/lib/occi/collection.rb +192 -0
  14. data/lib/occi/core/action.rb +32 -0
  15. data/lib/occi/core/action_instance.rb +38 -0
  16. data/lib/occi/core/actions.rb +20 -0
  17. data/lib/occi/core/attribute.rb +99 -0
  18. data/lib/occi/core/attributes.rb +172 -0
  19. data/lib/occi/core/categories.rb +51 -0
  20. data/lib/occi/core/category.rb +153 -0
  21. data/lib/occi/core/entities.rb +47 -0
  22. data/lib/occi/core/entity.rb +264 -0
  23. data/lib/occi/core/kind.rb +58 -0
  24. data/lib/occi/core/kinds.rb +22 -0
  25. data/lib/occi/core/link.rb +95 -0
  26. data/lib/occi/core/links.rb +34 -0
  27. data/lib/occi/core/mixin.rb +55 -0
  28. data/lib/occi/core/mixins.rb +41 -0
  29. data/lib/occi/core/properties.rb +35 -0
  30. data/lib/occi/core/related.rb +7 -0
  31. data/lib/occi/core/resource.rb +78 -0
  32. data/lib/occi/core/resources.rb +14 -0
  33. data/lib/occi/core.rb +31 -0
  34. data/lib/occi/helpers/inspect.rb +12 -0
  35. data/lib/occi/infrastructure/compute.rb +122 -0
  36. data/lib/occi/infrastructure/network/ipnetwork.rb +27 -0
  37. data/lib/occi/infrastructure/network.rb +107 -0
  38. data/lib/occi/infrastructure/networkinterface/ipnetworkinterface.rb +27 -0
  39. data/lib/occi/infrastructure/networkinterface.rb +103 -0
  40. data/lib/occi/infrastructure/os_tpl.rb +19 -0
  41. data/lib/occi/infrastructure/resource_tpl.rb +19 -0
  42. data/lib/occi/infrastructure/storage.rb +61 -0
  43. data/lib/occi/infrastructure/storagelink.rb +56 -0
  44. data/lib/occi/infrastructure.rb +25 -0
  45. data/lib/occi/log.rb +66 -0
  46. data/lib/occi/model.rb +86 -0
  47. data/lib/occi/parser/json.rb +34 -0
  48. data/lib/occi/parser/ova.rb +35 -0
  49. data/lib/occi/parser/ovf.rb +154 -0
  50. data/lib/occi/parser/text.rb +234 -0
  51. data/lib/occi/parser/xml.rb +18 -0
  52. data/lib/occi/parser.rb +78 -0
  53. data/lib/occi/settings.rb +9 -0
  54. data/lib/occi/version.rb +3 -0
  55. data/lib/occi-core.rb +50 -0
  56. data/occi-core.gemspec +36 -0
  57. data/spec/occi/collection_spec.rb +38 -0
  58. data/spec/occi/core/attribute_spec.rb +0 -0
  59. data/spec/occi/core/attributes_spec.rb +42 -0
  60. data/spec/occi/core/categories_spec.rb +27 -0
  61. data/spec/occi/core/category_spec.rb +38 -0
  62. data/spec/occi/core/entity_spec.rb +46 -0
  63. data/spec/occi/core/resource_spec.rb +18 -0
  64. data/spec/occi/infrastructure/compute_spec.rb +29 -0
  65. data/spec/occi/log_spec.rb +14 -0
  66. data/spec/occi/model_spec.rb +50 -0
  67. data/spec/occi/parser/text_spec.rb +31 -0
  68. data/spec/occi/parser_spec.rb +114 -0
  69. data/spec/occi/test.json +33 -0
  70. data/spec/occi/test.ova +0 -0
  71. data/spec/occi/test.ovf +198 -0
  72. data/spec/spec_helper.rb +25 -0
  73. metadata +304 -0
@@ -0,0 +1,14 @@
1
+ module Occi
2
+ module Core
3
+ class Resources < Occi::Core::Entities
4
+
5
+ def create(*args)
6
+ resource = Occi::Core::Resource.new(*args)
7
+ resource.model = @model
8
+ self << resource
9
+ resource
10
+ end
11
+
12
+ end
13
+ end
14
+ end
data/lib/occi/core.rb ADDED
@@ -0,0 +1,31 @@
1
+ require 'occi/core/properties'
2
+ require 'occi/core/attribute'
3
+ require 'occi/core/attributes'
4
+ require 'occi/core/category'
5
+ require 'occi/core/categories'
6
+ require 'occi/core/related'
7
+ require 'occi/core/kind'
8
+ require 'occi/core/kinds'
9
+ require 'occi/core/mixin'
10
+ require 'occi/core/mixins'
11
+ require 'occi/core/action'
12
+ require 'occi/core/action_instance'
13
+ require 'occi/core/actions'
14
+ require 'occi/core/entities'
15
+ require 'occi/core/entity'
16
+ require 'occi/core/link'
17
+ require 'occi/core/links'
18
+ require 'occi/core/resource'
19
+ require 'occi/core/resources'
20
+
21
+ module Occi
22
+ module Core
23
+
24
+ extend Occi
25
+
26
+ def self.kinds
27
+ Occi::Core::Kinds.new << Occi::Core::Entity.kind << Occi::Core::Link.kind << Occi::Core::Resource.kind
28
+ end
29
+
30
+ end
31
+ end
@@ -0,0 +1,12 @@
1
+ module Occi
2
+ module Helpers
3
+ module Inspect
4
+
5
+ # @return [String] json representation
6
+ def inspect
7
+ JSON.pretty_generate(JSON.parse(to_json))
8
+ end
9
+
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,122 @@
1
+ module Occi
2
+ module Infrastructure
3
+ class Compute < Occi::Core::Resource
4
+
5
+ start = Occi::Core::Action.new scheme='http://schemas.ogf.org/occi/infrastructure/compute/action#',
6
+ term='start',
7
+ title='start compute instance'
8
+
9
+ stop = Occi::Core::Action.new scheme='http://schemas.ogf.org/occi/infrastructure/compute/action#',
10
+ term='stop',
11
+ title='stop compute instance'
12
+ stop.attributes['method'] = {:mutable => true,
13
+ :pattern => 'graceful|acpioff|poweroff',
14
+ :default => 'poweroff'}
15
+
16
+ restart = Occi::Core::Action.new scheme='http://schemas.ogf.org/occi/infrastructure/compute/action#',
17
+ term='restart',
18
+ title='restart compute instance'
19
+ restart.attributes['method'] = {:mutable => true,
20
+ :pattern => 'graceful|warm|cold',
21
+ :default => 'cold'}
22
+
23
+ suspend = Occi::Core::Action.new scheme='http://schemas.ogf.org/occi/infrastructure/compute/action#',
24
+ term='suspend',
25
+ title='suspend compute instance'
26
+ suspend.attributes['metod'] = {:mutable => true,
27
+ :pattern => 'hibernate|suspend',
28
+ :default => 'suspend'}
29
+
30
+ self.actions = Occi::Core::Actions.new << start << stop << restart << suspend
31
+
32
+ self.attributes = Occi::Core::Attributes.new
33
+ self.attributes['occi.compute.architecture'] = {:mutable => true,
34
+ :pattern => 'x86|x64'}
35
+ self.attributes['occi.compute.cores'] = {:type => 'number',
36
+ :mutable => true}
37
+ self.attributes['occi.compute.hostname'] = {:mutable => true,
38
+ :pattern => '(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\\-]*[a-zA-Z0-9])\\.)*'}
39
+ self.attributes['occi.compute.memory'] = {:type => 'number',
40
+ :mutable => true}
41
+ self.attributes['occi.compute.state'] = {:pattern => 'inactive|active|suspended|error',
42
+ :default => 'inactive'}
43
+
44
+ self.kind = Occi::Core::Kind.new scheme='http://schemas.ogf.org/occi/infrastructure#',
45
+ term='compute',
46
+ title = 'compute resource',
47
+ attributes=self.attributes,
48
+ related=Occi::Core::Related.new << Occi::Core::Resource.kind,
49
+ actions = self.actions,
50
+ location = '/compute/'
51
+
52
+ require 'occi/infrastructure/resource_tpl'
53
+ require 'occi/infrastructure/os_tpl'
54
+ self.mixins = Occi::Core::Mixins.new << Occi::Infrastructure::Resource_tpl.mixin << Occi::Infrastructure::Os_tpl.mixin
55
+
56
+ def architecture
57
+ @attributes.occi.compute.architecture if @attributes.occi.compute if @attributes.occi
58
+ end
59
+
60
+ def architecture=(architecture)
61
+ @attributes.occi!.compute!.architecture = architecture
62
+ end
63
+
64
+ def cores
65
+ @attributes.occi.compute.cores if @attributes.occi.compute if @attributes.occi
66
+ end
67
+
68
+ def cores=(cores)
69
+ @attributes.occi!.compute!.cores = cores
70
+ end
71
+
72
+ def hostname
73
+ @attributes.occi.compute.hostname if @attributes.occi.compute if @attributes.occi
74
+ end
75
+
76
+ def hostname=(hostname)
77
+ @attributes.occi!.compute!.hostname = hostname
78
+ end
79
+
80
+ def speed
81
+ @attributes.occi.compute.speed if @attributes.occi.compute if @attributes.occi
82
+ end
83
+
84
+ def speed=(speed)
85
+ @attributes.occi!.compute!.speed = speed
86
+ end
87
+
88
+ def memory
89
+ @attributes.occi.compute.memory if @attributes.occi.compute if @attributes.occi
90
+ end
91
+
92
+ def memory=(memory)
93
+ @attributes.occi!.compute!.memory = memory
94
+ end
95
+
96
+ def state
97
+ @attributes.occi.compute.state if @attributes.occi.compute if @attributes.occi
98
+ end
99
+
100
+ def state=(state)
101
+ @attributes.occi!.compute!.state = state
102
+ end
103
+
104
+ def storagelink(target, mixins=[], attributes=Occi::Core::Attributes.new)
105
+ link(target, Occi::Infrastructure::Storagelink.kind, mixins, attributes, rel=Occi::Infrastructure::Storage.type_identifier)
106
+ end
107
+
108
+ def networkinterface(target, mixins=[], attributes=Occi::Core::Attributes.new)
109
+ link(target, Occi::Infrastructure::Networkinterface.kind, mixins, attributes)
110
+ end
111
+
112
+ def storagelinks
113
+ @links.select { |link| link.kind == Occi::Infrastructure::Storagelink.kind }
114
+ end
115
+
116
+ def networkinterfaces
117
+ @links.select { |link| link.kind == Occi::Infrastructure::Networkinterface.kind }
118
+ end
119
+
120
+ end
121
+ end
122
+ end
@@ -0,0 +1,27 @@
1
+ module Occi
2
+ module Infrastructure
3
+ class Network
4
+ module Ipnetwork
5
+
6
+ mattr_accessor :attributes, :mixin
7
+
8
+ self.attributes = Occi::Core::Attributes.new
9
+ self.attributes['occi.network.address'] = {:mutable => true,
10
+ :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]))$)'}
11
+ self.attributes['occi.network.gateway'] = {:mutable => true,
12
+ :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*)'}
13
+ self.attributes['occi.network.allocation'] = {:mutable => true,
14
+ :pattern => 'dynamic|static'}
15
+
16
+ self.mixin = Occi::Core::Mixin.new scheme='http://schemas.ogf.org/occi/infrastructure/network#',
17
+ term='ipnetwork',
18
+ title='IP network mixin',
19
+ attributes=self.attributes,
20
+ related=Occi::Core::Related.new << Occi::Infrastructure::Network.kind,
21
+ actions=Occi::Core::Actions.new,
22
+ location='/mixins/ipnetwork/'
23
+
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,107 @@
1
+ module Occi
2
+ module Infrastructure
3
+ class Network < Occi::Core::Resource
4
+
5
+ up = Occi::Core::Action.new scheme='http://schemas.ogf.org/occi/infrastructure/network/action#',
6
+ term='up',
7
+ title='activate network'
8
+
9
+ down = Occi::Core::Action.new scheme='http://schemas.ogf.org/occi/infrastructure/network/action#',
10
+ term='down',
11
+ title='deactivate network'
12
+
13
+ self.actions = Occi::Core::Actions.new << up << down
14
+
15
+ self.attributes = Occi::Core::Attributes.new
16
+ self.attributes['occi.network.vlan'] = {:type => 'number',
17
+ :mutable => true,
18
+ :pattern => 'x86|x64'}
19
+ self.attributes['occi.network.label'] = {:type => 'number',
20
+ :mutable => true}
21
+ self.attributes['occi.network.state'] ={:pattern => 'active|inactive|error',
22
+ :default => 'inactive'}
23
+
24
+ self.kind = Occi::Core::Kind.new scheme='http://schemas.ogf.org/occi/infrastructure#',
25
+ term='network',
26
+ title = 'network resource',
27
+ attributes=self.attributes,
28
+ related=Occi::Core::Related.new << Occi::Core::Resource.kind,
29
+ actions = self.actions,
30
+ location = '/network/'
31
+
32
+ require 'occi/infrastructure/network/ipnetwork'
33
+ self.mixins = Occi::Core::Mixins.new << Occi::Infrastructure::Network::Ipnetwork.mixin
34
+
35
+ def ipnetwork(boolean=true)
36
+ if boolean
37
+ mixins << Occi::Infrastructure::Network::Ipnetwork.mixin.type_identifier
38
+ else
39
+ mixins.delete Occi::Infrastructure::Network::Ipnetwork.mixin.type_identifier
40
+ end
41
+ end
42
+
43
+ def vlan
44
+ @attributes.occi.nework.vlan if @attributes.occi.network if @attributes.occi
45
+ end
46
+
47
+ def vlan=(vlan)
48
+ @attributes.occi!.network!.vlan = vlan
49
+ end
50
+
51
+ def label
52
+ @attributes.occi.nework.label if @attributes.occi.network if @attributes.occi
53
+ end
54
+
55
+ def label=(label)
56
+ @attributes.occi!.network!.label = label
57
+ end
58
+
59
+ def state
60
+ @attributes.occi.nework.state if @attributes.occi.network if @attributes.occi
61
+ end
62
+
63
+ def state=(state)
64
+ @attributes.occi!.network!.state = state
65
+ end
66
+
67
+ # IPNetwork Mixin attributes
68
+
69
+ def address
70
+ @attributes.occi.network.address if @attributes.occi.network if @attributes.occi
71
+ end
72
+
73
+ def address=(address)
74
+ if @mixins.select { |mixin| mixin.kind_of? Occi::Infrastructure::Network::Ipnetwork }.empty?
75
+ Occi::Log.info 'Adding mixin IPNetwork mixin'
76
+ @mixins << Occi::Infrastructure::Network::Ipnetwork.new
77
+ end
78
+ @attributes.occi!.network!.address = address
79
+ end
80
+
81
+ def gateway
82
+ @attributes.occi.network.gateway if @attributes.occi.network if @attributes.occi
83
+ end
84
+
85
+ def gateway=(gateway)
86
+ if @mixins.select { |mixin| mixin.kind_of? Occi::Infrastructure::Network::Ipnetwork }.empty?
87
+ Occi::Log.info 'Adding mixin IP network'
88
+ @mixins << Occi::Infrastructure::Network::Ipnetwork.new
89
+ end
90
+ @attributes.occi!.network!.gateway = gateway
91
+ end
92
+
93
+ def allocation
94
+ @attributes.occi.network.allocation if @attributes.occi.network if @attributes.occi
95
+ end
96
+
97
+ def allocation=(allocation)
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!.allocation = allocation
103
+ end
104
+
105
+ end
106
+ end
107
+ end
@@ -0,0 +1,27 @@
1
+ module Occi
2
+ module Infrastructure
3
+ class Networkinterface
4
+ module Ipnetworkinterface
5
+
6
+ mattr_accessor :attributes, :mixin
7
+
8
+ self.attributes = Occi::Core::Attributes.new
9
+ self.attributes['occi.networkinterface.address'] = {:mutable => true,
10
+ :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]))$)'}
11
+ self.attributes['occi.networkinterface.gateway'] = {:mutable => true,
12
+ :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*)'}
13
+ self.attributes['occi.networkinterface.allocation'] = {:mutable => true,
14
+ :pattern => 'dynamic|static'}
15
+
16
+ self.mixin = Occi::Core::Mixin.new scheme='http://schemas.ogf.org/occi/infrastructure/networkinterface#',
17
+ term='ipnetworkinterface',
18
+ title='IP network interface mixin',
19
+ attributes=self.attributes,
20
+ related=Occi::Core::Related.new << Occi::Infrastructure::Networkinterface.kind,
21
+ actions=Occi::Core::Actions.new,
22
+ location='/mixins/ipnetworkinterface/'
23
+
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,103 @@
1
+ module Occi
2
+ module Infrastructure
3
+ class Networkinterface < Occi::Core::Link
4
+
5
+ up = Occi::Core::Action.new scheme='http://schemas.ogf.org/occi/infrastructure/networkinterface/action#',
6
+ term='up',
7
+ title='activate networkinterface'
8
+
9
+ down = Occi::Core::Action.new scheme='http://schemas.ogf.org/occi/infrastructure/networkinterface/action#',
10
+ term='down',
11
+ title='deactivate networkinterface'
12
+
13
+ self.actions = Occi::Core::Actions.new << up << down
14
+
15
+ self.attributes = Occi::Core::Attributes.new
16
+ self.attributes['occi.networkinterface.interface'] ={:mutable => true}
17
+ self.attributes['occi.networkinterface.mac'] = {:mutable => true,
18
+ :pattern => '^([0-9a-fA-F]{2}[:-]){5}([0-9a-fA-F]{2})$'}
19
+ self.attributes['occi.networkinterface.state'] = {:pattern => 'active|inactive|error',
20
+ :default => 'inactive'}
21
+
22
+ self.kind = Occi::Core::Kind.new scheme='http://schemas.ogf.org/occi/infrastructure#',
23
+ term='networkinterface',
24
+ title = 'networkinterface link',
25
+ attributes = self.attributes,
26
+ related = Occi::Core::Related.new << Occi::Core::Link.kind,
27
+ actions = self.actions,
28
+ location = '/networkinterface/'
29
+
30
+ require 'occi/infrastructure/networkinterface/ipnetworkinterface'
31
+ self.mixins = Occi::Core::Mixins.new << Occi::Infrastructure::Networkinterface::Ipnetworkinterface.mixin
32
+
33
+ def ipnetworkinterface(boolean=true)
34
+ if boolean
35
+ @mixins << Occi::Infrastructure::Networkinterface::Ipnetworkinterface.type_identifier
36
+ else
37
+ mixins.delete Occi::Infrastructure::Networkinterface::Ipnetworkinterface.type_identifier
38
+ end
39
+ end
40
+
41
+ def interface
42
+ @attributes.occi.networkinterface.interface if @attributes.occi.networkinterface if @attributes.occi
43
+ end
44
+
45
+ def interface=(interface)
46
+ @attributes.occi!.networkinterface!.interface = interface
47
+ end
48
+
49
+ def mac
50
+ @attributes.occi.networkinterface.mac if @attributes.occi.networkinterface if @attributes.occi
51
+ end
52
+
53
+ def mac=(mac)
54
+ @attributes.occi!.networkinterface!.mac = mac
55
+ end
56
+
57
+ def state
58
+ @attributes.occi.networkinterface.state if @attributes.occi.networkinterface if @attributes.occi
59
+ end
60
+
61
+ def state=(state)
62
+ @attributes.occi!.networkinterface!.state = state
63
+ end
64
+
65
+ def address
66
+ @attributes.occi.networkinterface.address if @attributes.occi.networkinterface if @attributes.occi
67
+ end
68
+
69
+ def address=(address)
70
+ if @mixins.select { |mixin| mixin.kind_of? Occi::Infrastructure::Networkinterface::Ipnetworkinterface }.empty?
71
+ Occi::Log.info 'Adding mixin IP network interface'
72
+ @mixins << Occi::Infrastructure::Networkinterface::Ipnetworkinterface.new
73
+ end
74
+ @attributes.occi!.networkinterface!.address = address
75
+ end
76
+
77
+ def gateway
78
+ @attributes.occi.networkinterface.gateway if @attributes.occi.networkinterface if @attributes.occi
79
+ end
80
+
81
+ def gateway=(gateway)
82
+ if @mixins.select { |mixin| mixin.kind_of? Occi::Infrastructure::Networkinterface::Ipnetworkinterface }.empty?
83
+ Occi::Log.info 'Adding mixin IP network interface'
84
+ @mixins << Occi::Infrastructure::Networkinterface::Ipnetworkinterface.new
85
+ end
86
+ @attributes.occi!.networkinterface!.gateway = gateway
87
+ end
88
+
89
+ def allocation
90
+ @attributes.occi.networkinterface.allocation if @attributes.occi.networkinterface if @attributes.occi
91
+ end
92
+
93
+ def allocation=(allocation)
94
+ if @mixins.select { |mixin| mixin.kind_of? Occi::Infrastructure::Networkinterface::Ipnetworkinterface }.empty?
95
+ Occi::Log.info 'Adding mixin IP network interface'
96
+ @mixins << Occi::Infrastructure::Networkinterface::Ipnetworkinterface.new
97
+ end
98
+ @attributes.occi!.networkinterface!.allocation = allocation
99
+ end
100
+
101
+ end
102
+ end
103
+ end
@@ -0,0 +1,19 @@
1
+ module Occi
2
+ module Infrastructure
3
+ module Os_tpl
4
+
5
+ mattr_accessor :attributes, :mixin
6
+
7
+ self.attributes = Occi::Core::Attributes.new
8
+
9
+ self.mixin = Occi::Core::Mixin.new scheme='http://schemas.ogf.org/occi/infrastructure#',
10
+ term='os_tpl',
11
+ title='operating system template',
12
+ attributes=self.attributes,
13
+ related=Occi::Core::Categories.new << Occi::Infrastructure::Compute.kind,
14
+ actions=Occi::Core::Actions.new,
15
+ location='/mixins/os_tpl/'
16
+ end
17
+
18
+ end
19
+ end
@@ -0,0 +1,19 @@
1
+ module Occi
2
+ module Infrastructure
3
+ module Resource_tpl
4
+
5
+ mattr_accessor :attributes, :mixin
6
+
7
+ self.attributes = Occi::Core::Attributes.new
8
+
9
+ self.mixin = Occi::Core::Mixin.new scheme='http://schemas.ogf.org/occi/infrastructure#',
10
+ term='resource_tpl',
11
+ title='resource template',
12
+ attributes=self.attributes,
13
+ related=Occi::Core::Categories.new << Occi::Infrastructure::Compute.kind,
14
+ actions=Occi::Core::Actions.new,
15
+ location='/mixins/resource_tpl/'
16
+ end
17
+
18
+ end
19
+ end
@@ -0,0 +1,61 @@
1
+ module Occi
2
+ module Infrastructure
3
+ class Storage < Occi::Core::Resource
4
+
5
+ online = Occi::Core::Action.new scheme='http://schemas.ogf.org/occi/infrastructure/storage/action#',
6
+ term='online',
7
+ title='activate storage'
8
+
9
+ offline = Occi::Core::Action.new scheme='http://schemas.ogf.org/occi/infrastructure/storage/action#',
10
+ term='offline',
11
+ title='deactivate storage'
12
+
13
+ backup = Occi::Core::Action.new scheme='http://schemas.ogf.org/occi/infrastructure/storage/action#',
14
+ term='backup',
15
+ title='backup storage'
16
+
17
+ snapshot = Occi::Core::Action.new scheme='http://schemas.ogf.org/occi/infrastructure/storage/action#',
18
+ term='snapshot',
19
+ title='snapshot storage'
20
+
21
+ resize = Occi::Core::Action.new scheme='http://schemas.ogf.org/occi/infrastructure/storage/action#',
22
+ term='resize',
23
+ title='resize storage'
24
+ resize.attributes['size'] = {:type => 'number',
25
+ :mutable => true}
26
+
27
+ self.actions = Occi::Core::Actions.new << online << offline << backup << snapshot << resize
28
+
29
+ self.attributes = Occi::Core::Attributes.new
30
+ self.attributes['occi.storage.size'] = {:type => 'number',
31
+ :mutable => true}
32
+ self.attributes['occi.storage.state'] = {:pattern => 'online|offline|backup|snapshot|resize|degraded',
33
+ :default => 'offline'}
34
+
35
+ self.kind = Occi::Core::Kind.new scheme='http://schemas.ogf.org/occi/infrastructure#',
36
+ term='storage',
37
+ title = 'storage resource',
38
+ attributes = self.attributes,
39
+ related = Occi::Core::Related.new << Occi::Core::Resource.kind,
40
+ actions = self.actions,
41
+ location = '/storage/'
42
+
43
+ def size
44
+ @attributes.occi.storage.size if @attributes.occi.storage if @attributes.occi
45
+ end
46
+
47
+ def size=(size)
48
+ @attributes.occi!.storage!.size = size
49
+ end
50
+
51
+ def state
52
+ @attributes.occi.storage.state if @attributes.occi.storage if @attributes.occi
53
+ end
54
+
55
+ def state=(state)
56
+ @attributes.occi!.storage!.state = state
57
+ end
58
+
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,56 @@
1
+ module Occi
2
+ module Infrastructure
3
+ class Storagelink < Occi::Core::Link
4
+
5
+ online = Occi::Core::Action.new scheme='http://schemas.ogf.org/occi/infrastructure/storagelink/action#',
6
+ term='online',
7
+ title='activate storagelink'
8
+
9
+ offline = Occi::Core::Action.new scheme='http://schemas.ogf.org/occi/infrastructure/storagelink/action#',
10
+ term='offline',
11
+ title='deactivate storagelink'
12
+
13
+ self.actions = Occi::Core::Actions.new << online << offline
14
+
15
+ self.attributes = Occi::Core::Attributes.new
16
+ self.attributes['occi.storagelink.deviceid'] = {:mutable => true}
17
+ self.attributes['occi.storagelink.mountpoint'] = {:mutable => true}
18
+ self.attributes['occi.storagelink.state'] = {:pattern => 'active|inactive|error',
19
+ :default => 'inactive'}
20
+
21
+ self.kind = Occi::Core::Kind.new scheme='http://schemas.ogf.org/occi/infrastructure#',
22
+ term='storagelink',
23
+ title = 'storage link',
24
+ attributes = self.attributes,
25
+ related = Occi::Core::Related.new << Occi::Core::Link.kind,
26
+ actions = self.actions,
27
+ location = '/storagelink/'
28
+
29
+
30
+ def deviceid
31
+ @attributes.occi.storagelink.deviceid if @attributes.occi.storagelink if @attributes.occi
32
+ end
33
+
34
+ def deviceid=(deviceid)
35
+ @attributes.occi!.storagelink!.deviceid = deviceid
36
+ end
37
+
38
+ def mountpoint
39
+ @attributes.occi.storagelink.mountpoint if @attributes.occi.storagelink if @attributes.occi
40
+ end
41
+
42
+ def mountpoint=(mountpoint)
43
+ @attributes.occi!.storagelink!.mountpoint = mountpoint
44
+ end
45
+
46
+ def state
47
+ @attributes.occi.storagelink.state if @attributes.occi.storagelink if @attributes.occi
48
+ end
49
+
50
+ def state=(state)
51
+ @attributes.occi!.storagelink!.state = state
52
+ end
53
+
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,25 @@
1
+ require 'occi/infrastructure/compute'
2
+ require 'occi/infrastructure/storage'
3
+ require 'occi/infrastructure/storagelink'
4
+ require 'occi/infrastructure/network'
5
+ require 'occi/infrastructure/networkinterface'
6
+
7
+ module Occi
8
+ module Infrastructure
9
+
10
+ extend Occi
11
+
12
+ def self.kinds
13
+ Occi::Core::Kinds.new << Occi::Infrastructure::Compute.kind << Occi::Infrastructure::Storage.kind << Occi::Infrastructure::Network.kind << Occi::Infrastructure::Networkinterface.kind << Occi::Infrastructure::Storagelink.kind
14
+ end
15
+
16
+ def self.mixins
17
+ Occi::Infrastructure::Compute.mixins + Occi::Infrastructure::Storage.mixins + Occi::Infrastructure::Network.mixins + Occi::Infrastructure::Networkinterface.mixins + Occi::Infrastructure::Storagelink.mixins
18
+ end
19
+
20
+ def self.actions
21
+ Occi::Infrastructure::Compute.actions + Occi::Infrastructure::Storage.actions + Occi::Infrastructure::Network.actions + Occi::Infrastructure::Networkinterface.actions + Occi::Infrastructure::Storagelink.actions
22
+ end
23
+
24
+ end
25
+ end