def getHostTemplateVariables(self, host_id): """Returns a dictionary containing template variables for a host See the getTemplateVariables function for more details. """ # Determine the default class id values = self.getPropertyValues() default_class_id = values[DEFAULT_CLASS_PROPERTY] # Create an index of classes classes = {} for fclass in self.getFirewallClasses(): classes[fclass["firewall_class_id"]] = fclass["firewall_class_name"] # Call base class to get the basics variables = ccsd_service.getHostTemplateVariables(self, host_id) # Include interface configurations interfaces = {} for iface in self.getInterfaces(host_id): if iface["firewall_class_id"] != -1: class_name = classes[iface["firewall_class_id"]] else: class_name = classes[default_class_id] interfaces[iface["name"]] = class_name variables["interfaces"] = interfaces return variables
def getHostTemplateVariables(self, host_id): """Returns a dictionary containing template variables for a host See the getTemplateVariables function for more details. """ # Call base class to get the basics variables = ccsd_service.getHostTemplateVariables(self, host_id) return variables
def getHostTemplateVariables(self, host_id): """Returns a dictionary containing template variables for a host See the getTemplateVariables function for more details. """ # Call base class to get the basics variables = ccsd_service.getHostTemplateVariables(self, host_id) # Include interface configurations interfaces = {} for iface in self.getInterfaces(host_id): interfaces[iface["name"]] = iface variables["interfaces"] = interfaces # XXX: Statics return variables
def getHostTemplateVariables(self, host_id): """Returns a dictionary containing template variables for a host See the getTemplateVariables function for more details. """ md5_key = "" # Call base class to get the basics variables = ccsd_service.getHostTemplateVariables(self, host_id) # Network wide md5 key value try: md5_key = variables[MD5_KEY_PROPERTY] except KeyError: md5_key = "" # Include interface configurations interfaces = {} areas = [] for iface in self.getOSPFInterfaces(host_id): interfaces[iface["name"]] = iface if iface["md5_key"] is None or iface["md5_key"] == "": interfaces[iface["name"]]["md5_key"] = md5_key if iface["ospf_enabled"] and iface["area_no"] == "": iface["area_no"] = 0 areas.append(iface["area_no"]) variables["interfaces"] = interfaces # Choose a "default" area for this host, which is the lowest numbered # area that the host has an interface in, or 0 if the host has no # interfaces explicitly in an OSPF area areas.sort() if len(areas) > 0: variables["area_no"] = areas[0] else: variables["area_no"] = 0 # Include static routes statics = {} for static in self.getStaticRoutes(host_id): statics[static["prefix"]] = filter_keys(static) variables["statics"] = statics return variables
def getHostTemplateVariables(self, host_id): """Returns a dictionary containing template variables for all hosts See the getTemplateVariables function for more details. """ session = getSessionE(self._session_id) # Call base class to get the basics variables = ccsd_service.getHostTemplateVariables(self, host_id) # Make the function available to templates variables["rlacInterfaceEnabled"] = rlacInterfaceEnabled lns = session.query("SELECT ip_address FROM rlac_host JOIN rlac_lns USING (lns_id) WHERE host_id=%s", (host_id)) if len(lns) == 0: lns = session.query("SELECT ip_address FROM rlac_lns WHERE lns_id=%s", (1)) variables["lns"] = lns[0] return variables