1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 '''
20 OCCI's core model.
21
22 Created on Jun 27, 2011
23
24 @author: tmetsch
25 '''
26
27
28
29
30
31
32
33
34
35
37 '''
38 OCCI Category.
39 '''
40
41 - def __init__(self, scheme, term, title, attributes, location):
42 self.scheme = scheme
43 self.term = term
44 self.title = title
45 self.attributes = attributes
46
47
48 self.location = location
49 self.extras = None
50
52 if instance is None or not isinstance(instance, Category):
53 return False
54 if self.term == instance.term and self.scheme == instance.scheme \
55 and self.extras == instance.extras:
56 return True
57 else:
58 return False
59
61 return hash(self.scheme) ^ hash(self.term) ^ hash(str(self.extras))
62
64 return self.scheme + self.term
65
66
67 -class Kind(Category):
68 '''
69 OCCI Kind.
70 '''
71
72 - def __init__(self, scheme, term, related=None, actions=None, title='',
73 attributes=None, location=None):
74 super(Kind, self).__init__(scheme, term, title, attributes or {},
75 location or '/' + term + '/')
76 self.related = related or []
77 self.actions = actions or []
78
81
82
84 '''
85 OCCI Action.
86 '''
87
88 - def __init__(self, scheme, term, title='', attributes=None):
89 super(Action, self).__init__(scheme, term, title, attributes or {},
90 location=None)
91
94
95
97 '''
98 OCCI Mixin.
99 '''
100
101 - def __init__(self, scheme, term, related=None, actions=None, title='',
102 attributes=None, location=None):
103 super(Mixin, self).__init__(scheme, term, title, attributes or {},
104 location or '/' + term + '/')
105 self.related = related or []
106 self.actions = actions or []
107
110
111
112
113
114
115
116
118 '''
119 OCCI Entity.
120 '''
121
122 - def __init__(self, identifier, title, kind, mixins):
123 self.identifier = identifier
124 self.title = title
125 self.kind = kind
126 self.mixins = mixins
127
128
129 self.attributes = {}
130 self.actions = []
131 self.extras = None
132
133
135 '''
136 OCCI Resource.
137 '''
138
139 kind = Kind('http://schemas.ogf.org/occi/core#', 'resource')
140
141 - def __init__(self, identifier, kind, mixins, links=None, summary=None,
142 title=None):
143 super(Resource, self).__init__(identifier, title, kind, mixins)
144 self.links = links or []
145 self.summary = summary
146
147
149 '''
150 OCCI Link.
151 '''
152
153 kind = Kind('http://schemas.ogf.org/occi/core#', 'link')
154
155 - def __init__(self, identifier, kind, mixins, source, target, title=None):
156 super(Link, self).__init__(identifier, title, kind, mixins)
157 self.source = source
158 self.target = target
159