Cities of the second class and villages shall have power to grant a franchise subject to the conditions of this section or section 17-528.02. Such franchise may run for a period not exceeding twenty-five years, and it may be granted to any person, company, or association, whether publicly or privately owned, and to his, her, or its assigns. Such franchise may permit the person, company, or association to erect and maintain poles, lines, wires, and conductors for electricity in the streets, lanes, alleys, and public places of such city or village and for furnishing electricity to the inhabitants of such city or village. Such franchise may establish the amount that may be charged during such period for electricity and provide that such city or village may, after such period, make any reasonable regulation with reference to any person, firm, or corporation holding such franchise either as to charges for electricity or otherwise. Such city or village is further authorized to contract, lease, or rent the plant, from any person, firm, or corporation, furnishing electricity, within such city or village, for power or the lighting of streets, lanes, alleys, and public places of such city or village, but not for a period longer than five years. Such city or village may levy a tax for the purpose of paying the cost of such lighting of streets, lanes, alleys, or public places of such city or village or to pay the rent under such lease. No public service company, whether publicly or privately owned, shall sell to any city of the second class or village, generating its own electric energy for all or a major portion of its electric requirements, unless first authorized so to do by a vote of the electors of such city or village, in the same manner and subject to the same conditions as are set forth in section 18-412. If no tax or issuance of bonds is required, any city of the second class or village may by resolution of the city council or village board of trustees contract for the furnishing of electricity at retail to such city or village, or to any electric plant within such city or village, with any public power district or an electric cooperative which cooperative has an approved retail service area adjoining such city or village.