<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def add_instance(self, role, instance, username='root', key_filename=None, output_shell=False):
 """ Add instance to the setup @param role: instance's role @type role: str @param instance: host parameters we would like to establish connection to @type instance: dict @param username: user name for creating ssh connection @type username: str @param key_filename: file name with ssh private key @type key_filename: str @param output_shell: write output from this connection to standard output @type output_shell: bool """

        if not role in self.Instances.keys():
            self.Instances[role] = []
        self.logger.debug('Adding ' + role + ' with private_hostname ' +
                          instance['private_hostname'] +
                          ', public_hostname ' + instance['public_hostname'])
        self.Instances[role].append(Connection(instance,
                                               username,
                                               key_filename,
                                               output_shell=output_shell))