Exemplo n.º 1
0
    def get_templates_dict(self):

        """
            Returns a dictionary with all parameters of this Network
            Configuration
        """

        clean_name = ConfigurationItem.clean_string_for_template(self.name)

        tpl_dict = { "network.{name}.forward_mode" \
                         .format(name=clean_name) : str(self.forward_mode),
                     "network.{name}.bridge_name" \
                         .format(name=clean_name) : str(self.bridge_name),
                     "network.{name}.ip_host" \
                         .format(name=clean_name) : str(self.ip_host),
                     "network.{name}.netmask" \
                         .format(name=clean_name) : str(self.netmask),
                     "network.{name}.dhcp_start" \
                         .format(name=clean_name) : str(self.dhcp_start),
                     "network.{name}.dhcp_end" \
                         .format(name=clean_name) : str(self.dhcp_end),
                     "network.{name}.pxe_tftp_dir" \
                         .format(name=clean_name) : str(self.pxe_tftp_dir),
                     "network.{name}.pxe_boot_file" \
                         .format(name=clean_name) : str(self.pxe_boot_file) }

        # port is hard-coded in HTTPServer class
        if self.ip_host is not None:
            http_server = "http://" + self.ip_host + ":5432"
            tpl_dict["network.{name}.http_server" \
                     .format(name=clean_name)] = http_server

        return tpl_dict
Exemplo n.º 2
0
    def get_templates_dict(self):

        """ Returns a dictionary with all parameters for the Storage Pool """

        clean_name = ConfigurationItem.clean_string_for_template(self.name)

        return { "storagepool.{name}.path" \
                     .format(name=clean_name) : str(self.path) }
Exemplo n.º 3
0
    def get_templates_dict(self, prefix):

        """
            Returns a dictionary with all parameters of the Domain Configuration
        """

        clean_name = ConfigurationItem.clean_string_for_template(self.name)
        domain_dict = { "{prefix}.name" \
                            .format(prefix=prefix) : str(clean_name),
                        "{prefix}.cpu" \
                            .format(prefix=prefix) : str(self.sockets * self.cores * self.threads),
                        "{prefix}.sockets" \
                            .format(prefix=prefix) : str(self.sockets),
                        "{prefix}.cores" \
                            .format(prefix=prefix) : str(self.cores),
                        "{prefix}.threads" \
                            .format(prefix=prefix) : str(self.threads),
                        "{prefix}.memory" \
                            .format(prefix=prefix) : str(self.memory),
                        "{prefix}.graphics" \
                            .format(prefix=prefix) : str(self.graphics),
                      }

        # add netifs
        for netif in self.netifs:
            if netif.has_key("ip"):
                network_clean_name = \
                    ConfigurationItem.clean_string_for_template(netif['network'])
                key = "{prefix}.{network}.ip" \
                          .format(prefix=prefix,
                                  network=network_clean_name)
                domain_dict[key] = str(netif["ip"])

        tpl_vars_dict = {}

        for var_key, var_value in self._template_vars.items():
            full_key = "{prefix}.tpl.{var_name}" \
                           .format(prefix=prefix, var_name=var_key)
            tpl_vars_dict[full_key] = str(var_value)

        domain_dict.update(tpl_vars_dict)

        return domain_dict
Exemplo n.º 4
0
    def get_absolute_templates_dict(self):

        """
            Returns a dictionary with all parameters of the Domain Configuration
            with absolute prefix
        """

        clean_name = ConfigurationItem.clean_string_for_template(self.name)
        return self.get_templates_dict(prefix = \
                                       "domain.{name}".format(name=clean_name))
Exemplo n.º 5
0
    def get_templates_dict(self):

        """
            Returns a dictionary with all parameters of the Storage Volume in
            Configuration
        """

        clean_name = ConfigurationItem.clean_string_for_template(self.name)

        return { "storagevolume.{name}.format"      \
                     .format(name=clean_name) : str(self.format),
                 "storagevolume.{name}.size"        \
                     .format(name=clean_name) : str(self.size),
                 "storagevolume.{name}.storagepool" \
                     .format(name=clean_name) : str(self.storage_pool) }