local site = {}

package.path = "/srv/http/?.lua;"..package.path

require("luamods/command")
require("config/rsm_conf")



function site:updatePort(site)
  if (site.siteID ~= nil) then
    cmd = rsm_conf.rsmc_path .. " SET:"
    cmd = cmd .. [[ TAG_SITE_CFG ]]
    cmd = cmd .. [[ TAG_SITE_LABEL=]]..site.label
    cmd = cmd .. [[ TAG_SITE_NMS_ADDRESS=]]..site.NMS
    command.ex(cmd)
  end
end


function site:getSite()

  local siteer = {}
  local siteConfig = command.ex(rsm_conf.rsmc_path..[[ GET: TAG_SITE_CFG]]) or ""

  local siteID = {}
  siteID.__value__ = siteConfig:match([[TAG_SITE_ID=%"([^%"]+)%"]]) or "unknown"
  siteer["siteID"] = siteID
  --siteer["siteID"] = siteConfig:match([[TAG_SITE_ID=%"([^%"]+)%"]]) or "unknown"


  local label = {}
  label.__value__ = siteConfig:match([[TAG_SITE_LABEL=%"([^%"]+)%"]]) or "unknown"
  siteer["label"] = label
  --siteer["label"] = siteConfig:match([[TAG_SITE_LABEL=%"([^%"]+)%"]]) or "unknown"


  local NMS = {}
  NMS.__value__ = siteConfig:match([[TAG_SITE_NMS_ADDRESS=%"([^%"]+)%"]]) or "unknown"
  siteer["NMS"] = NMS
  --siteer["NMS"] = siteConfig:match([[TAG_SITE_NMS_ADDRESS=%"([^%"]+)%"]]) or "unknown"

  return siteer

end

return site
