def edit_entry(self, name, host, user, port, id_file): if not self.is_host_in(name): raise StormValueError('{0} doesn\'t exists in your sshconfig. use storm add command to add.'.format(name)) options = self.get_options(host, user, port, id_file) self.ssh_config.update_host(name, options) self.ssh_config.write_to_ssh_config() return True
def delete_host(self, host): found = 0 for index, host_entry in enumerate(self.config_data): if host_entry.get("host") == host: del self.config_data[index] found += 1 if found == 0: raise StormValueError('No host found') return self
def add_entry(self, name, host, user, port, id_file): if self.is_host_in(name): raise StormValueError('{0} is already in your sshconfig. use storm edit command to modify.'.format(name)) options = self.get_options(host, user, port, id_file) self.ssh_config.add_host(name, options) self.ssh_config.write_to_ssh_config() return True
def update_entry(self, name, **kwargs): if not self.is_host_in(name): raise StormValueError( '{0} doesn\'t exists in your sshconfig. use storm add command to add.' .format(name)) self.ssh_config.update_host(name, kwargs) self.ssh_config.write_to_ssh_config() return True