def convert(self, value, param, ctx):
resource = tower_cli.get_resource(self.resource_name)<EOL>if value is None:<EOL><INDENT>return None<EOL><DEDENT>if isinstance(value, int):<EOL><INDENT>return value<EOL><DEDENT>if re.match(r'<STR_LIT>', value):<EOL><INDENT>return int(value)<EOL><DEDENT>if value == '<STR_LIT:null>':<EOL><INDENT>return value<EOL><DEDENT>try:<EOL><INDENT>debug.log('<STR_LIT>'<EOL>'<STR_LIT>' % param.name, header='<STR_LIT>')<EOL>lookup_data = {resource.identity[-<NUM_LIT:1>]: value}<EOL>rel = resource.get(**lookup_data)<EOL><DEDENT>except exc.MultipleResults:<EOL><INDENT>raise exc.MultipleRelatedError(<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'.format(self.resource_name,<EOL>value),<EOL>)<EOL><DEDENT>except exc.TowerCLIError as ex:<EOL><INDENT>raise exc.RelatedError('<STR_LIT>' %<EOL>(self.resource_name, str(ex)))<EOL><DEDENT>return rel['<STR_LIT:id>']<EOL>
Return the appropriate integer value. If a non-integer is
        provided, attempt a name-based lookup and return the primary key.