| OLD | NEW |
| (Empty) | |
| 1 # Copyright (c) 2010 Spotify AB |
| 2 # Copyright (c) 2010 Jeremy Thurgood <firxen+boto@gmail.com> |
| 3 # Copyright (c) 2010-2011 Yelp |
| 4 # |
| 5 # Permission is hereby granted, free of charge, to any person obtaining a |
| 6 # copy of this software and associated documentation files (the |
| 7 # "Software"), to deal in the Software without restriction, including |
| 8 # without limitation the rights to use, copy, modify, merge, publish, dis- |
| 9 # tribute, sublicense, and/or sell copies of the Software, and to permit |
| 10 # persons to whom the Software is furnished to do so, subject to the fol- |
| 11 # lowing conditions: |
| 12 # |
| 13 # The above copyright notice and this permission notice shall be included |
| 14 # in all copies or substantial portions of the Software. |
| 15 # |
| 16 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
| 17 # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL- |
| 18 # ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT |
| 19 # SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, |
| 20 # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 21 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS |
| 22 # IN THE SOFTWARE. |
| 23 |
| 24 """ |
| 25 This module contains EMR response objects |
| 26 """ |
| 27 |
| 28 from boto.resultset import ResultSet |
| 29 |
| 30 |
| 31 class EmrObject(object): |
| 32 Fields = set() |
| 33 |
| 34 def __init__(self, connection=None): |
| 35 self.connection = connection |
| 36 |
| 37 def startElement(self, name, attrs, connection): |
| 38 pass |
| 39 |
| 40 def endElement(self, name, value, connection): |
| 41 if name in self.Fields: |
| 42 setattr(self, name.lower(), value) |
| 43 |
| 44 |
| 45 class RunJobFlowResponse(EmrObject): |
| 46 Fields = set(['JobFlowId']) |
| 47 |
| 48 class AddInstanceGroupsResponse(EmrObject): |
| 49 Fields = set(['InstanceGroupIds', 'JobFlowId']) |
| 50 |
| 51 class ModifyInstanceGroupsResponse(EmrObject): |
| 52 Fields = set(['RequestId']) |
| 53 |
| 54 |
| 55 class Arg(EmrObject): |
| 56 def __init__(self, connection=None): |
| 57 self.value = None |
| 58 |
| 59 def endElement(self, name, value, connection): |
| 60 self.value = value |
| 61 |
| 62 |
| 63 class BootstrapAction(EmrObject): |
| 64 Fields = set([ |
| 65 'Args', |
| 66 'Name', |
| 67 'Path', |
| 68 ]) |
| 69 |
| 70 def startElement(self, name, attrs, connection): |
| 71 if name == 'Args': |
| 72 self.args = ResultSet([('member', Arg)]) |
| 73 return self.args |
| 74 |
| 75 |
| 76 class KeyValue(EmrObject): |
| 77 Fields = set([ |
| 78 'Key', |
| 79 'Value', |
| 80 ]) |
| 81 |
| 82 |
| 83 class Step(EmrObject): |
| 84 Fields = set([ |
| 85 'ActionOnFailure', |
| 86 'CreationDateTime', |
| 87 'EndDateTime', |
| 88 'Jar', |
| 89 'LastStateChangeReason', |
| 90 'MainClass', |
| 91 'Name', |
| 92 'StartDateTime', |
| 93 'State', |
| 94 ]) |
| 95 |
| 96 def __init__(self, connection=None): |
| 97 self.connection = connection |
| 98 self.args = None |
| 99 |
| 100 def startElement(self, name, attrs, connection): |
| 101 if name == 'Args': |
| 102 self.args = ResultSet([('member', Arg)]) |
| 103 return self.args |
| 104 if name == 'Properties': |
| 105 self.properties = ResultSet([('member', KeyValue)]) |
| 106 return self.properties |
| 107 |
| 108 |
| 109 class InstanceGroup(EmrObject): |
| 110 Fields = set([ |
| 111 'BidPrice', |
| 112 'CreationDateTime', |
| 113 'EndDateTime', |
| 114 'InstanceGroupId', |
| 115 'InstanceRequestCount', |
| 116 'InstanceRole', |
| 117 'InstanceRunningCount', |
| 118 'InstanceType', |
| 119 'LastStateChangeReason', |
| 120 'LaunchGroup', |
| 121 'Market', |
| 122 'Name', |
| 123 'ReadyDateTime', |
| 124 'StartDateTime', |
| 125 'State', |
| 126 ]) |
| 127 |
| 128 |
| 129 class JobFlow(EmrObject): |
| 130 Fields = set([ |
| 131 'AmiVersion', |
| 132 'AvailabilityZone', |
| 133 'CreationDateTime', |
| 134 'Ec2KeyName', |
| 135 'EndDateTime', |
| 136 'HadoopVersion', |
| 137 'Id', |
| 138 'InstanceCount', |
| 139 'JobFlowId', |
| 140 'KeepJobFlowAliveWhenNoSteps', |
| 141 'LastStateChangeReason', |
| 142 'LogUri', |
| 143 'MasterInstanceId', |
| 144 'MasterInstanceType', |
| 145 'MasterPublicDnsName', |
| 146 'Name', |
| 147 'NormalizedInstanceHours', |
| 148 'ReadyDateTime', |
| 149 'RequestId', |
| 150 'SlaveInstanceType', |
| 151 'StartDateTime', |
| 152 'State', |
| 153 'TerminationProtected', |
| 154 'Type', |
| 155 'Value', |
| 156 ]) |
| 157 |
| 158 def __init__(self, connection=None): |
| 159 self.connection = connection |
| 160 self.steps = None |
| 161 self.instancegroups = None |
| 162 self.bootstrapactions = None |
| 163 |
| 164 def startElement(self, name, attrs, connection): |
| 165 if name == 'Steps': |
| 166 self.steps = ResultSet([('member', Step)]) |
| 167 return self.steps |
| 168 elif name == 'InstanceGroups': |
| 169 self.instancegroups = ResultSet([('member', InstanceGroup)]) |
| 170 return self.instancegroups |
| 171 elif name == 'BootstrapActions': |
| 172 self.bootstrapactions = ResultSet([('member', BootstrapAction)]) |
| 173 return self.bootstrapactions |
| 174 else: |
| 175 return None |
| OLD | NEW |