Changeset ef36c1e for fedd/fedd_allocate_project.py
- Timestamp:
- Aug 1, 2008 11:41:39 AM (16 years ago)
- Branches:
- axis_example, compt_changes, info-ops, master, version-1.30, version-2.00, version-3.01, version-3.02
- Children:
- 808889e
- Parents:
- 7da9da6
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
fedd/fedd_allocate_project.py
r7da9da6 ref36c1e 21 21 from fedd_util import * 22 22 import parse_detail 23 from service_error import * 23 24 24 25 class fedd_allocate_project_local: 25 def __init__(self, dp=False, url=None ):26 def __init__(self, dp=False, url=None, certs=None): 26 27 """ 27 28 Initializer. Parses a configuration if one is given. … … 58 59 59 60 60 def dynamic_project(self, req ):61 def dynamic_project(self, req, fedid=None): 61 62 """ 62 63 Create a dynamic project with ssh access … … 70 71 dir="/tmp") 71 72 72 print userfile 73 proj = req['project'] 73 if req.has_key('AllocateProjectRequestBody') and \ 74 req['AllocateProjectRequestBody'].has_key('project'): 75 proj = req['AllocateProjectRequestBody']['project'] 76 else: 77 raise service_error(service_error.req, 78 "Badly formed allocation request") 74 79 # Take the first user and ssh key 75 80 name = proj.get('name', None) or self.random_string("proj",4) … … 91 96 access = user.get('access', None) 92 97 if access != None: 93 ssh = access .get('sshPubkey', None)98 ssh = access[0].get('sshPubkey', None) 94 99 if ssh == None: 95 100 raise fedd_proj.service_error(fedd_proj.service_error.req, … … 177 182 } 178 183 return rv 184 185 186 class fedd_allocate_project_remote: 187 def __init__(self, dp=False, url=None, certs=None): 188 """ 189 Initializer. Parses a configuration if one is given. 190 """ 191 192 self.dynamic_projects = dp 193 self.url = url 194 195 if certs != None and isinstance(certs, type(tuple())): 196 self.cert_file, self.trusted_certs, self.cert_pwd = certs 197 # self.cert_file = certs[0] 198 # self.trusted_certs = certs[1] 199 # self.cert_pwd = certs[2] 200 else: 201 self.cert_file = None 202 self.trusted_certs = None 203 self.cert_pwd = None 204 205 def dynamic_project(self, req, fedid=None): 206 """ 207 Send req on to a remote project instantiator. 208 209 Req is just the projectAllocType object. This function re-wraps it. 210 It also rethrows any faults. 211 """ 212 # No retry loop here. Proxy servers must correctly authenticate 213 # themselves without help 214 try: 215 ctx = fedd_ssl_context(self.cert_file, self.trusted_certs, 216 password=self.cert_pwd) 217 except SSL.SSLError: 218 raise service_error(service_error.server_config, 219 "Server certificates misconfigured") 220 221 loc = feddServiceLocator(); 222 port = loc.getfeddPortType(self.url, 223 transport=M2Crypto.httpslib.HTTPSConnection, 224 transdict={ 'ssl_context' : ctx }) 225 226 if req.has_key('AllocateProjectRequestBody'): 227 req = req['AllocateProjectRequestBody'] 228 else: 229 raise service_error(service_error.req, "Bad formated request"); 230 231 # Reconstruct the full request message 232 msg = AllocateProjectRequestMessage() 233 msg.set_element_AllocateProjectRequestBody( 234 pack_soap(msg, "AllocateProjectRequestBody", req)) 235 try: 236 resp = port.AllocateProject(msg) 237 except ZSI.ParseException, e: 238 raise service_error(service_error.proxy, 239 "Bad format message (XMLRPC??): %s" % str(e)) 240 r = unpack_soap(resp) 241 242 if r.has_key('AllocateProjectResponseBody'): 243 return r['AllocateProjectResponseBody'] 244 else: 245 raise service_error(service_error.proxy, "Bad proxy response") 246
Note: See TracChangeset
for help on using the changeset viewer.