<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def create_stack(self, name):
 """ Creates stack if necessary. """

        deployment = find_exact(self.api.deployments, name=name)
        if not deployment:
            try:
                # TODO: replace when python-rightscale handles non-json
                self.api.client.post(
                        '/api/deployments',
                        data={'deployment[name]': name},
                        )
            except HTTPError as e:
                log.error(
                        'Failed to create stack %s. '
                        'RightScale returned %d:\n%s'
                        % (name, e.response.status_code, e.response.content)
                        )