Pep Guardiola has ended speculation about his future as Manchester City manager by signing a new two-year deal.