Package occi :: Package extensions :: Module infrastructure
[hide private]
[frames] | no frames]

Source Code for Module occi.extensions.infrastructure

  1  # coding=utf-8 
  2  # 
  3  # Copyright (C) 2010-2012 Platform Computing 
  4  # 
  5  # This library is free software; you can redistribute it and/or 
  6  # modify it under the terms of the GNU Lesser General Public 
  7  # License as published by the Free Software Foundation; either 
  8  # version 2.1 of the License, or (at your option) any later version. 
  9  # 
 10  # This library is distributed in the hope that it will be useful, 
 11  # but WITHOUT ANY WARRANTY; without even the implied warranty of 
 12  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
 13  # Lesser General Public License for more details. 
 14  # 
 15  # You should have received a copy of the GNU Lesser General Public 
 16  # License along with this library; if not, write to the Free Software 
 17  # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA 
 18  # 
 19  ''' 
 20  The OCCI Infrastructure extension. 
 21   
 22  Created on Jul 20, 2011 
 23   
 24  @author: tmetsch 
 25  ''' 
 26   
 27  from occi.core_model import Action, Kind, Resource, Mixin, Link 
 28   
 29  #============================================================================== 
 30  # Compute 
 31  #============================================================================== 
 32   
 33  START = Action('http://schemas.ogf.org/occi/infrastructure/compute/action#', 
 34                 'start', 'Start a compute resource') 
 35   
 36  STOP = Action('http://schemas.ogf.org/occi/infrastructure/compute/action#', 
 37                'stop', 'Stop a compute resource', {'method': ''}) 
 38   
 39  RESTART = Action('http://schemas.ogf.org/occi/infrastructure/compute/action#', 
 40                   'restart', 'Restart a compute resource', {'method': ''}) 
 41   
 42  SUSPEND = Action('http://schemas.ogf.org/occi/infrastructure/compute/action#', 
 43                   'suspend', 'Suspend a compute resource', {'method': ''}) 
 44   
 45  COMPUTE_ATTRIBUTES = {'occi.compute.architecture': '', 
 46                        'occi.compute.cores': '', 
 47                        'occi.compute.hostname': '', 
 48                        'occi.compute.speed': '', 
 49                        'occi.compute.memory': '', 
 50                        'occi.compute.state': 'immutable'} 
 51   
 52  COMPUTE = Kind('http://schemas.ogf.org/occi/infrastructure#', 
 53                 'compute', 
 54                 [Resource.kind], 
 55                 [START, STOP, RESTART, SUSPEND], 
 56                 'Compute Resource', 
 57                 COMPUTE_ATTRIBUTES, 
 58                 '/compute/') 
 59   
 60  #============================================================================== 
 61  # Network 
 62  #============================================================================== 
 63   
 64  UP = Action('http://schemas.ogf.org/occi/infrastructure/network/action#', 
 65              'up', 'Bring up a network resource') 
 66   
 67  DOWN = Action('http://schemas.ogf.org/occi/infrastructure/network/action#', 
 68                'down', 'Bring down a network resource') 
 69   
 70  NETWORK_ATTRIBUTES = {'occi.network.vlan': '', 
 71                        'occi.network.label': '', 
 72                        'occi.network.state': 'immutable'} 
 73   
 74  NETWORK = Kind('http://schemas.ogf.org/occi/infrastructure#', 
 75                 'network', 
 76                 [Resource.kind], 
 77                 [UP, DOWN], 
 78                 'Network Resource', 
 79                 NETWORK_ATTRIBUTES, 
 80                 '/network/') 
 81   
 82  #IP networking mixin 
 83   
 84  IPNETWORK_ATTRIBUTES = {'occi.network.address': '', 
 85                          'occi.network.gateway': '', 
 86                          'occi.network.allocation': ''} 
 87   
 88  IPNETWORK = Mixin('http://schemas.ogf.org/occi/infrastructure/network#', 
 89                    'ipnetwork', attributes=IPNETWORK_ATTRIBUTES) 
 90   
 91  #============================================================================== 
 92  # Storage 
 93  #============================================================================== 
 94   
 95  ONLINE = Action('http://schemas.ogf.org/occi/infrastructure/storage/action#', 
 96                  'online', 'Bring storage online') 
 97   
 98  OFFLINE = Action('http://schemas.ogf.org/occi/infrastructure/storage/action#', 
 99                'offline', 'Bring storage offline') 
100   
101  BACKUP = Action('http://schemas.ogf.org/occi/infrastructure/storage/action#', 
102                  'backup', 'Backup storage resource') 
103   
104  SNAPSHOT = Action('http://schemas.ogf.org/occi/infrastructure/storage/action#', 
105                    'snapshot', 'Make a snapshot of storage resource') 
106   
107  RESIZE = Action('http://schemas.ogf.org/occi/infrastructure/storage/action#', 
108                  'resize', 'Resize storage resource', {'size': 'required'}) 
109   
110  STORAGE_ATTRIBUTES = {'occi.storage.size': '', 
111                        'occi.storage.state': 'immutable'} 
112   
113  STORAGE = Kind('http://schemas.ogf.org/occi/infrastructure#', 
114                 'storage', 
115                 [Resource.kind], 
116                 [ONLINE, OFFLINE, BACKUP, SNAPSHOT, RESIZE], 
117                 'Storage Resource', 
118                 STORAGE_ATTRIBUTES, 
119                 '/storage/') 
120   
121  #============================================================================== 
122  # Linking 
123  #============================================================================== 
124   
125  NETWORKINTERFACE_ATTRIBUTES = {'occi.networkinterface.interface': 'immutable', 
126                                 'occi.networkinterface.mac': '', 
127                                 'occi.networkinterface.state': 'immutable'} 
128   
129  NETWORKINTERFACE = Kind('http://schemas.ogf.org/occi/infrastructure#', 
130                          'networkinterface', 
131                          [Link.kind], 
132                          [], 
133                          'A L2 Network Interface', 
134                          NETWORKINTERFACE_ATTRIBUTES, 
135                          '/network/interface/') 
136   
137  IPNETWORKINTERFACE_ATTRIBUTES = {'occi.networkinterface.address': '', 
138                                   'occi.networkinterface.gateway': '', 
139                                   'occi.networkinterface.allocation': ''} 
140   
141  IPNETWORKINTERFACE = Mixin('http://schemas.ogf.org/occi/infrastructure/' 
142                             'networkinterface#', 
143                             'ipnetworkinterface', 
144                             [], 
145                             [], 
146                             'L3/L4 capabilities for L2 Network Interface', 
147                             IPNETWORKINTERFACE_ATTRIBUTES, 
148                             '/network/interface/ip/') 
149   
150  STORAGELINK_ATTRIBUTES = {'occi.storagelink.deviceid': '', 
151                            'occi.storagelink.mountpoint': '', 
152                            'occi.storagelink.state': 'immutable'} 
153   
154  STORAGELINK = Kind('http://schemas.ogf.org/occi/infrastructure#', 
155                     'storagelink', 
156                     [Link.kind], 
157                     [], 
158                     'A link to a storage resource', 
159                     STORAGELINK_ATTRIBUTES, 
160                     '/storage/link/') 
161   
162  #============================================================================== 
163  # Templates 
164  #============================================================================== 
165   
166  RESOURCE_TEMPLATE = Mixin('http://schemas.ogf.org/occi/infrastructure#', 
167                            'resource_tpl') 
168   
169  OS_TEMPLATE = Mixin('http://schemas.ogf.org/occi/infrastructure#', 'os_tpl') 
170