<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def deploy(self, driver, location_id=config.DEFAULT_LOCATION_ID, size=config.DEFAULT_SIZE):
 """Use driver to deploy node, with optional ability to specify location id and size id. First, obtain location object from driver. Next, get the size. Then, get the image. Finally, deploy node, and return NodeProxy. """


        logger.debug('deploying node %s using driver %s' % (self.name, driver))

        args = {'name': self.name}

        if hasattr(config, 'SSH_KEY_NAME'):
            args['ex_keyname'] = config.SSH_KEY_NAME

        if hasattr(config, 'EX_USERDATA'):
            args['ex_userdata'] = config.EX_USERDATA

        args['location'] = driver.list_locations()[location_id]
        logger.debug('location %s' % args['location'])

        args['size'] = size_from_name(size, driver.list_sizes())
        logger.debug('size %s' % args['size'])

        logger.debug('image name %s' % config.IMAGE_NAMES[self.image_name])
        args['image'] = image_from_name(
            config.IMAGE_NAMES[self.image_name], driver.list_images())
        logger.debug('image %s' % args['image'])

        logger.debug('creating node with args: %s' % args)
        node = driver.create_node(**args)
        logger.debug('node created')

        # password must be extracted before _wait_until_running(), where it goes away
        logger.debug('driver.features %s' % driver.features)
        password = node.extra.get('password') \
            if 'generates_password' in driver.features['create_node'] else None

        logger.debug('waiting for node to obtain %s' % config.SSH_INTERFACE)
        node, ip_addresses = driver._wait_until_running(
            node, timeout=1200, ssh_interface=config.SSH_INTERFACE)

        ssh_args = {'hostname': ip_addresses[0], 'port': 22, 'timeout': 10}
        if password:
            ssh_args['password'] = password
        else:
            ssh_args['key'] = config.SSH_KEY_PATH if hasattr(config, 'SSH_KEY_PATH') else None

        logger.debug('initializing ssh client with %s' % ssh_args)
        ssh_client = libcloud.compute.ssh.SSHClient(**ssh_args)

        logger.debug('ssh client attempting to connect')
        ssh_client = driver._ssh_client_connect(ssh_client)
        logger.debug('ssh client connected')

        logger.debug('starting node deployment with %s steps' % len(self.deployment.steps))
        driver._run_deployment_script(self.deployment, node, ssh_client)

        node.script_deployments = self.script_deployments # retain exit_status, stdout, stderr

        logger.debug('node.extra["imageId"] %s' % node.extra['imageId'])

        return NodeProxy(node, args['image'])