PageRenderTime 29ms CodeModel.GetById 0ms RepoModel.GetById 0ms app.codeStats 0ms

/boto-2.5.2/boto/emr/emrobject.py

#
Python | 175 lines | 121 code | 29 blank | 25 comment | 8 complexity | 0485d7258d5dc18c26f497b2312b7291 MD5 | raw file
  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. This module contains EMR response objects
  25. """
  26. from boto.resultset import ResultSet
  27. class EmrObject(object):
  28. Fields = set()
  29. def __init__(self, connection=None):
  30. self.connection = connection
  31. def startElement(self, name, attrs, connection):
  32. pass
  33. def endElement(self, name, value, connection):
  34. if name in self.Fields:
  35. setattr(self, name.lower(), value)
  36. class RunJobFlowResponse(EmrObject):
  37. Fields = set(['JobFlowId'])
  38. class AddInstanceGroupsResponse(EmrObject):
  39. Fields = set(['InstanceGroupIds', 'JobFlowId'])
  40. class ModifyInstanceGroupsResponse(EmrObject):
  41. Fields = set(['RequestId'])
  42. class Arg(EmrObject):
  43. def __init__(self, connection=None):
  44. self.value = None
  45. def endElement(self, name, value, connection):
  46. self.value = value
  47. class BootstrapAction(EmrObject):
  48. Fields = set([
  49. 'Args',
  50. 'Name',
  51. 'Path',
  52. ])
  53. def startElement(self, name, attrs, connection):
  54. if name == 'Args':
  55. self.args = ResultSet([('member', Arg)])
  56. return self.args
  57. class KeyValue(EmrObject):
  58. Fields = set([
  59. 'Key',
  60. 'Value',
  61. ])
  62. class Step(EmrObject):
  63. Fields = set([
  64. 'ActionOnFailure',
  65. 'CreationDateTime',
  66. 'EndDateTime',
  67. 'Jar',
  68. 'LastStateChangeReason',
  69. 'MainClass',
  70. 'Name',
  71. 'StartDateTime',
  72. 'State',
  73. ])
  74. def __init__(self, connection=None):
  75. self.connection = connection
  76. self.args = None
  77. def startElement(self, name, attrs, connection):
  78. if name == 'Args':
  79. self.args = ResultSet([('member', Arg)])
  80. return self.args
  81. if name == 'Properties':
  82. self.properties = ResultSet([('member', KeyValue)])
  83. return self.properties
  84. class InstanceGroup(EmrObject):
  85. Fields = set([
  86. 'BidPrice',
  87. 'CreationDateTime',
  88. 'EndDateTime',
  89. 'InstanceGroupId',
  90. 'InstanceRequestCount',
  91. 'InstanceRole',
  92. 'InstanceRunningCount',
  93. 'InstanceType',
  94. 'LastStateChangeReason',
  95. 'LaunchGroup',
  96. 'Market',
  97. 'Name',
  98. 'ReadyDateTime',
  99. 'StartDateTime',
  100. 'State',
  101. ])
  102. class JobFlow(EmrObject):
  103. Fields = set([
  104. 'AmiVersion',
  105. 'AvailabilityZone',
  106. 'CreationDateTime',
  107. 'Ec2KeyName',
  108. 'EndDateTime',
  109. 'HadoopVersion',
  110. 'Id',
  111. 'InstanceCount',
  112. 'JobFlowId',
  113. 'KeepJobFlowAliveWhenNoSteps',
  114. 'LastStateChangeReason',
  115. 'LogUri',
  116. 'MasterInstanceId',
  117. 'MasterInstanceType',
  118. 'MasterPublicDnsName',
  119. 'Name',
  120. 'NormalizedInstanceHours',
  121. 'ReadyDateTime',
  122. 'RequestId',
  123. 'SlaveInstanceType',
  124. 'StartDateTime',
  125. 'State',
  126. 'TerminationProtected',
  127. 'Type',
  128. 'Value',
  129. ])
  130. def __init__(self, connection=None):
  131. self.connection = connection
  132. self.steps = None
  133. self.instancegroups = None
  134. self.bootstrapactions = None
  135. def startElement(self, name, attrs, connection):
  136. if name == 'Steps':
  137. self.steps = ResultSet([('member', Step)])
  138. return self.steps
  139. elif name == 'InstanceGroups':
  140. self.instancegroups = ResultSet([('member', InstanceGroup)])
  141. return self.instancegroups
  142. elif name == 'BootstrapActions':
  143. self.bootstrapactions = ResultSet([('member', BootstrapAction)])
  144. return self.bootstrapactions
  145. else:
  146. return None