Sorry for the late reply. Thanks for your time!

I will to try explain it better.


In app/models/operatingsystem.rb:
> @@ -117,7 +117,7 @@ def pxe_files(medium, arch)
>    end
>  
>    def as_json(options={})
> -    {:operatingsystem => {:name => to_s, :id => id, :media => media, :architectures => architectures, :ptables => ptables, :config_templates => config_templates}}


it shows all related templates including template data, also the data of templates which are not selected. 

???  I only get the templates that were selected.


            
I meant to say it shows all associated templates.

-----------------------------------------------

Here are some examples:

In this example I have associated the following templates to operating system id 1 (Debian 6.0) in Provisioning Templates
Preseed Debian PXElinux
Preseed Default

And I have selected those two templates in Operating System templates section.

jpoppe@astray98:~/git/foremanbuddy$ ./foremanbuddy.py -d operatingsystem info 1
debug: url "http://foreman.overlord001.b.c.m.e:3000/operatingsystems/1?format=json"
debug: json data """"
{u'operatingsystem': {u'architectures': [{u'architecture': {u'id': 1,
                                                            u'name': u'x86_64'}}],
                      u'config_templates': [{u'config_template': {u'id': 23,
                                                                  u'name': u'Preseed Debian PXElinux',
                                                                  u'snippet': None,
                                                                  u'template': u'default linux\nlabel linux\nkernel <%= @kernel %>\nappend initrd=<%= @initrd %> interface=auto url=<%= foreman_url("provision")%> ramdisk_size=10800 root=/dev/rd/0 rw auto hostname=unassigned-hostname locale=en_US console-setup/ask_detect=false console-setup/layout=USA console-setup/variant=USA keyboard-configuration/layoutcode=us domain=test.ebuddy.com text countrychooser/shortlist=US console-keymaps-at/keymap=us\n',
                                                                  u'template_kind': {u'id': 1,
                                                                                     u'name': u'PXELinux'}}},
                                            {u'config_template': {u'id': 5,
                                                                  u'name': u'Preseed Default',
                                                                  u'snippet': None,
                                                                  u'template': u'# Locale, country and keyboard settings\nd-i debian-installer/locale string en_US\nd-i console-setup/ask_detect boolean false\nd-i console-setup/modelcode string pc105\nd-i console-setup/variant USA\nd-i console-setup/layout USA\nd-i console-setup/layoutcode string us\n\n# Network configuration\nd-i netcfg/choose_interface select auto\nd-i netcfg/get_hostname string <%= @host %>\nd-i netcfg/get_domain string <%= @host.domain %>\nd-i netcfg/wireless_wep string\n\nd-i hw-detect/load_firmware boolean true\n\n# Mirror settings\nd-i mirror/country string manual\nd-i mirror/http/hostname string <%= @preseed_server %>\nd-i mirror/http/directory string <%= @preseed_path %>\nd-i mirror/http/proxy string\nd-i mirror/codename string <%= @host.operatingsystem.release_name %>\nd-i mirror/suite string <%= @host.operatingsystem.release_name %>\nd-i mirror/udeb/suite string <%= @host.operatingsystem.release_name %>\n\n# Time settings\nd-i clock-setup/utc boolean true\nd-i time/zone string UTC\n\n# NTP\nd-i clock-setup/ntp boolean true\nd-i clock-setup/ntp-server string ntp\n\n# Set alignment for automatic partitioning\n# Choices: cylinder, minimal, optimal\n#d-i partman/alignment select cylinder\n\n<%= @host.diskLayout %>\n\n# Install different kernel\n#d-i base-installer/kernel/image string linux-server\n\n# User settings\nd-i passwd/root-password-crypted password <%= root_pass %>\nuser-setup-udeb passwd/root-login boolean true\nd-i passwd passwd/make-user boolean false\nuser-setup-udeb passwd/make-user boolean false\n\n# Install minimal task set (see tasksel --task-packages minimal)\ntasksel tasksel/first multiselect minimal\n\n# Install some base packages\nd-i pkgsel/include string puppet lsb-release openssh-server\nd-i pkgsel/update-policy select unattended-upgrades\n\npopularity-contest popularity-contest/participate boolean false\n\n# Boot loader settings\n#grub-pc grub-pc/hidden_timeout boolean false\n#grub-pc grub-pc/timeout string 10\nd-i grub-installer/only_debian boolean true\nd-i grub-installer/with_other_os boolean true\n\nd-i finish-install/reboot_in_progress note\n\nd-i preseed/late_command string wget <%= foreman_url("finish") %> -O /target/tmp/finish.sh && in-target chmod +x /tmp/finish.sh && in-target /tmp/finish.sh\n',
                                                                  u'template_kind': {u'id': 3,
                                                                                     u'name': u'provision'}}}],
                      u'id': 1,
                      u'media': [{u'medium': {u'id': 6,
                                              u'name': u'Debian Mirror'}}],
                      u'name': u'Debian 6.0',
                      u'os_default_templates': [{u'os_default_template': {u'config_template_id': 23,
                                                                          u'created_at': u'2012-10-22T12:27:11Z',
                                                                          u'id': 1,
                                                                          u'operatingsystem_id': 1,
                                                                          u'template_kind_id': 1,
                                                                          u'updated_at': u'2012-10-22T12:27:11Z'}},
                                                {u'os_default_template': {u'config_template_id': 5,
                                                                          u'created_at': u'2012-10-22T12:27:11Z',
                                                                          u'id': 2,
                                                                          u'operatingsystem_id': 1,
                                                                          u'template_kind_id': 3,
                                                                          u'updated_at': u'2012-10-22T12:27:11Z'}}],
                      u'ptables': [{u'ptable': {u'id': 11,
                                                u'name': u'Debian Entire Disk KVM'}}]}}

------------------------------------------------------------------------------------------

If I now also assoiciate the 'Preseed Default Linux' template in Provisioning Templates with the operating system, it will also show this template while it is not selected. IMHO this data should be shown when i query the template information (what it a;sp does).

In other words: If I associate 20 templates to the operating system, and select 2 in the Operating system template it will show me all the 20 associated templates instead of the 2 selected ones.

jpoppe@astray98:~/git/foremanbuddy$ ./foremanbuddy.py -d operatingsystem info 1
debug: url "http://foreman.overlord001.b.c.m.e:3000/operatingsystems/1?format=json"
debug: json data """"
{u'operatingsystem': {u'architectures': [{u'architecture': {u'id': 1,
                                                            u'name': u'x86_64'}}],
                      u'config_templates': [{u'config_template': {u'id': 23,
                                                                  u'name': u'Preseed Debian PXElinux',
                                                                  u'snippet': None,
                                                                  u'template': u'default linux\nlabel linux\nkernel <%= @kernel %>\nappend initrd=<%= @initrd %> interface=auto url=<%= foreman_url("provision")%> ramdisk_size=10800 root=/dev/rd/0 rw auto hostname=unassigned-hostname locale=en_US console-setup/ask_detect=false console-setup/layout=USA console-setup/variant=USA keyboard-configuration/layoutcode=us domain=test.ebuddy.com text countrychooser/shortlist=US console-keymaps-at/keymap=us\n',
                                                                  u'template_kind': {u'id': 1,
                                                                                     u'name': u'PXELinux'}}},
                                            {u'config_template': {u'id': 5,
                                                                  u'name': u'Preseed Default',
                                                                  u'snippet': None,
                                                                  u'template': u'# Locale, country and keyboard settings\nd-i debian-installer/locale string en_US\nd-i console-setup/ask_detect boolean false\nd-i console-setup/modelcode string pc105\nd-i console-setup/variant USA\nd-i console-setup/layout USA\nd-i console-setup/layoutcode string us\n\n# Network configuration\nd-i netcfg/choose_interface select auto\nd-i netcfg/get_hostname string <%= @host %>\nd-i netcfg/get_domain string <%= @host.domain %>\nd-i netcfg/wireless_wep string\n\nd-i hw-detect/load_firmware boolean true\n\n# Mirror settings\nd-i mirror/country string manual\nd-i mirror/http/hostname string <%= @preseed_server %>\nd-i mirror/http/directory string <%= @preseed_path %>\nd-i mirror/http/proxy string\nd-i mirror/codename string <%= @host.operatingsystem.release_name %>\nd-i mirror/suite string <%= @host.operatingsystem.release_name %>\nd-i mirror/udeb/suite string <%= @host.operatingsystem.release_name %>\n\n# Time settings\nd-i clock-setup/utc boolean true\nd-i time/zone string UTC\n\n# NTP\nd-i clock-setup/ntp boolean true\nd-i clock-setup/ntp-server string ntp\n\n# Set alignment for automatic partitioning\n# Choices: cylinder, minimal, optimal\n#d-i partman/alignment select cylinder\n\n<%= @host.diskLayout %>\n\n# Install different kernel\n#d-i base-installer/kernel/image string linux-server\n\n# User settings\nd-i passwd/root-password-crypted password <%= root_pass %>\nuser-setup-udeb passwd/root-login boolean true\nd-i passwd passwd/make-user boolean false\nuser-setup-udeb passwd/make-user boolean false\n\n# Install minimal task set (see tasksel --task-packages minimal)\ntasksel tasksel/first multiselect minimal\n\n# Install some base packages\nd-i pkgsel/include string puppet lsb-release openssh-server\nd-i pkgsel/update-policy select unattended-upgrades\n\npopularity-contest popularity-contest/participate boolean false\n\n# Boot loader settings\n#grub-pc grub-pc/hidden_timeout boolean false\n#grub-pc grub-pc/timeout string 10\nd-i grub-installer/only_debian boolean true\nd-i grub-installer/with_other_os boolean true\n\nd-i finish-install/reboot_in_progress note\n\nd-i preseed/late_command string wget <%= foreman_url("finish") %> -O /target/tmp/finish.sh && in-target chmod +x /tmp/finish.sh && in-target /tmp/finish.sh\n',
                                                                  u'template_kind': {u'id': 3,
                                                                                     u'name': u'provision'}}},
                                            {u'config_template': {u'id': 2,
                                                                  u'name': u'Preseed default PXElinux',
                                                                  u'snippet': False,
                                                                  u'template': u'default linux\nlabel linux\nkernel <%= @kernel %>\nappend initrd=<%= @initrd %> interface=auto url=<%= foreman_url("provision")%> ramdisk_size=10800 root=/dev/rd/0 rw auto hostname=unassigned-hostname locale=en_US console-setup/ask_detect=false console-setup/layout=USA console-setup/variant=USA keyboard-configuration/layoutcode=us\n',
                                                                  u'template_kind': {u'id': 1,
                                                                                     u'name': u'PXELinux'}}}],
                      u'id': 1,
                      u'media': [{u'medium': {u'id': 6,
                                              u'name': u'Debian Mirror'}}],
                      u'name': u'Debian 6.0',
                      u'os_default_templates': [{u'os_default_template': {u'config_template_id': 23,
                                                                          u'created_at': u'2012-10-22T12:27:11Z',
                                                                          u'id': 1,
                                                                          u'operatingsystem_id': 1,
                                                                          u'template_kind_id': 1,
                                                                          u'updated_at': u'2012-10-22T12:27:11Z'}},
                                                {u'os_default_template': {u'config_template_id': 5,
                                                                          u'created_at': u'2012-10-22T12:27:11Z',
                                                                          u'id': 2,
                                                                          u'operatingsystem_id': 1,
                                                                          u'template_kind_id': 3,
                                                                          u'updated_at': u'2012-10-22T12:27:11Z'}}],
                      u'ptables': [{u'ptable': {u'id': 11,
                                                u'name': u'Debian Entire Disk KVM'}}]}}
jpoppe@astray98:~/git/foremanbuddy$ 

I hope it is now more clear, and again thanks for your time!