@@ -48,7 +48,8 @@ class codeGenerator(object):
4848 returned by API discovery or from the xml spec of commands generated by
4949 the ApiDocWriter. This class provides helper methods for these uses.
5050 """
51- space = " "
51+ space = ' '
52+ newline = '\n '
5253 cmdsName = []
5354
5455 def __init__ (self , outputFolder ):
@@ -86,11 +87,11 @@ def addAttribute(self, attr, pro):
8687 if desc is not None :
8788 self .code += self .space
8889 self .code += "''' " + pro .desc + " '''"
89- self .code += " \n "
90+ self .code += self . newline
9091
9192 self .code += self .space
9293 self .code += attr + " = " + str (value )
93- self .code += " \n "
94+ self .code += self . newline
9495
9596 def generateSubClass (self , name , properties ):
9697 '''generate code for sub list'''
@@ -114,7 +115,7 @@ def generate(self, cmd):
114115 self .cmd = cmd
115116 self .cmdsName .append (self .cmd .name )
116117 self .code = self .license
117- self .code += " \n "
118+ self .code += self . newline
118119 self .code += '"""%s"""\n ' % self .cmd .desc
119120 self .code += 'from baseCmd import *\n '
120121 self .code += 'from baseResponse import *\n '
@@ -147,7 +148,7 @@ def generate(self, cmd):
147148
148149 """generate response code"""
149150 subItems = {}
150- self .code += " \n "
151+ self .code += self . newline
151152 self .code += 'class %sResponse (baseResponse):\n ' % self .cmd .name
152153 self .code += self .space + "def __init__(self):\n "
153154 if len (self .cmd .response ) == 0 :
@@ -165,7 +166,7 @@ def generate(self, cmd):
165166 else :
166167 self .code += self .space + self .space
167168 self .code += 'self.%s = None\n ' % res .name
168- self .code += ' \n '
169+ self .code += self . newline
169170
170171 for subclass in self .subclass :
171172 self .code += subclass + "\n "
@@ -187,12 +188,33 @@ def finalize(self):
187188 body += "class CloudStackAPIClient(object):\n "
188189 body += self .space + 'def __init__(self, connection):\n '
189190 body += self .space + self .space + 'self.connection = connection\n '
190- body += "\n "
191+ body += self .space + self .space + 'self._id = None\n '
192+ body += self .newline
191193
192194 body += self .space + 'def __copy__(self):\n '
193195 body += self .space + self .space
194196 body += 'return CloudStackAPIClient(copy.copy(self.connection))\n '
195- body += "\n "
197+ body += self .newline
198+
199+ # The `id` property will be used to link the test with the cloud resource being created #
200+ # @property
201+ # def id(self):
202+ # return self._id
203+ #
204+ # @id.setter
205+ # def id(self, identifier):
206+ # self._id = identifier
207+
208+
209+ body += self .space + '@property' + self .newline
210+ body += self .space + 'def id(self):' + self .newline
211+ body += self .space * 2 + 'return self._id' + self .newline
212+ body += self .newline
213+
214+ body += self .space + '@id.setter' + self .newline
215+ body += self .space + 'def id(self, identifier):' + self .newline
216+ body += self .space * 2 + 'self._id = identifier' + self .newline
217+ body += self .newline
196218
197219 for cmdName in self .cmdsName :
198220 body += self .space
@@ -203,7 +225,7 @@ def finalize(self):
203225 body += 'response = self.connection.marvin_request(command,'
204226 body += ' response_type=response, method=method)\n '
205227 body += self .space + self .space + 'return response\n '
206- body += ' \n '
228+ body += self . newline
207229
208230 imports += 'from %s import %sResponse\n ' % (cmdName , cmdName )
209231 initCmdsList += '"%s",' % cmdName
0 commit comments