[120] | 1 | #Licensed to the Apache Software Foundation (ASF) under one |
---|
| 2 | #or more contributor license agreements. See the NOTICE file |
---|
| 3 | #distributed with this work for additional information |
---|
| 4 | #regarding copyright ownership. The ASF licenses this file |
---|
| 5 | #to you under the Apache License, Version 2.0 (the |
---|
| 6 | #"License"); you may not use this file except in compliance |
---|
| 7 | #with the License. You may obtain a copy of the License at |
---|
| 8 | |
---|
| 9 | # http://www.apache.org/licenses/LICENSE-2.0 |
---|
| 10 | |
---|
| 11 | #Unless required by applicable law or agreed to in writing, software |
---|
| 12 | #distributed under the License is distributed on an "AS IS" BASIS, |
---|
| 13 | #WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
---|
| 14 | #See the License for the specific language governing permissions and |
---|
| 15 | #limitations under the License. |
---|
| 16 | """manage hod configuration""" |
---|
| 17 | # -*- python -*- |
---|
| 18 | |
---|
| 19 | import sys, csv, os |
---|
| 20 | from optparse import Option, OptionParser |
---|
| 21 | from xml.dom import minidom |
---|
| 22 | from sets import Set |
---|
| 23 | from select import select, poll, POLLIN |
---|
| 24 | |
---|
| 25 | from hodlib.Common.desc import * |
---|
| 26 | |
---|
| 27 | class DescGenerator: |
---|
| 28 | """Contains the conversion to descriptors and other method calls |
---|
| 29 | to config""" |
---|
| 30 | def __init__(self, hodConfig): |
---|
| 31 | """parse all the descriptors""" |
---|
| 32 | |
---|
| 33 | self.hodConfig = hodConfig |
---|
| 34 | |
---|
| 35 | def initializeDesc(self): |
---|
| 36 | self.hodConfig['nodepooldesc'] = self.createNodePoolDesc() |
---|
| 37 | self.hodConfig['servicedesc'] = self.createServiceDescDict() |
---|
| 38 | |
---|
| 39 | return self.hodConfig |
---|
| 40 | |
---|
| 41 | def getServices(self): |
---|
| 42 | """get all the services from the config""" |
---|
| 43 | |
---|
| 44 | sdd = {} |
---|
| 45 | for keys in self.hodConfig: |
---|
| 46 | if keys.startswith('gridservice-'): |
---|
| 47 | str = keys.split('-') |
---|
| 48 | dict = self.hodConfig[keys] |
---|
| 49 | if 'server-params' in dict: dict['attrs'] = dict['server-params'] |
---|
| 50 | if 'final-server-params' in dict: dict['final-attrs'] = dict['final-server-params'] |
---|
| 51 | dict['id'] = str[1] |
---|
| 52 | desc = ServiceDesc(dict) |
---|
| 53 | sdd[desc.getName()] = desc |
---|
| 54 | |
---|
| 55 | return sdd |
---|
| 56 | |
---|
| 57 | def createNodePoolDesc(self): |
---|
| 58 | """ create a node pool descriptor and store |
---|
| 59 | it in hodconfig""" |
---|
| 60 | |
---|
| 61 | desc = NodePoolDesc(self.hodConfig['resource_manager']) |
---|
| 62 | return desc |
---|
| 63 | |
---|
| 64 | def createServiceDescDict(self): |
---|
| 65 | """create a service descriptor for |
---|
| 66 | all the services and store it in the |
---|
| 67 | hodconfig""" |
---|
| 68 | |
---|
| 69 | sdd = self.getServices() |
---|
| 70 | return sdd |
---|
| 71 | |
---|
| 72 | |
---|