import jingrow

from jcloud.jcloud.pagetype.server.server import get_hostname_abbreviation


def execute():
	for pagetype in ["Server", "Database Server", "Proxy Server"]:
		jingrow.reload_pg("jcloud", "pagetype", pagetype)

		for pg in jingrow.get_all(pagetype, fields=["name", "hostname"]):
			abbr = get_hostname_abbreviation(pg.hostname)

			jingrow.db.set_value(
				pagetype, pg.name, "hostname_abbreviation", abbr, update_modified=False
			)
