Project

General

Profile

Actions

Bug #1905

closed

os_default_templates should be exposed instead of config_templates when calling operatingsystems

Added by Jasper Poppe over 11 years ago. Updated almost 11 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
API
Target version:
Difficulty:
trivial
Triaged:
Fixed in Releases:
Found in Releases:

Description

I am working on a Foreman CLI script

One of the issues I encountered is that the os_default_templates variables were not exposed, I need to check those to be able to determine what kind of JSON request I need to send for adding or binding other templates to operatingsystems.

I have changed the following line in app/models/operatingsystem.rb:

{:operatingsystem => {:name => to_s, :id => id, :media => media, :architectures => architectures, :ptables => ptables, :config_templates => config_templates}

to: {:operatingsystem => {:name => to_s, :id => id, :media => media, :architectures => architectures, :ptables => ptables, :os_default_templates => os_default_templates}

I think this is a bug because returning the all the operating system associated configuration templates including data when you query operating system information does not make sense. You could get this data by querying config_templates instead.

I could make a Git pull request if that is preferred.

Actions #1

Updated by Ohad Levy over 11 years ago

thanks Jasper

Does it work correctly if you use the api/operatingsystems namespace instead?

thanks,
Ohad

Actions #2

Updated by Ohad Levy over 11 years ago

and pull requests are mostly welcomed!

btw: we are working on CLI as well, checkout the rake apipie:client task.

Actions #3

Updated by Jasper Poppe over 11 years ago

btw: we are working on CLI as well, checkout the rake apipie:client task.

I didn't checkout that one, but I have tried a few: foremanhammer, foremancli, for-cli but they were all pretty basic. I am pretty far with my CLI script and we needed it now, it works like this. Is the new CLI already that advanced? The CLI I am working on does almost everything we need. And sorry it is in Python ;).

  1. Add a smart proxy
    ./foremanbuddy.py -u admin -p changeme smart_proxy add --name overlord001.b.c.m.e --url http://overlord001.b.c.m.e:8443
  1. Add a smart proxy DNS service to the b.c.m.e domain and set the full domain name
    ./foremanbuddy.py -u admin -p changeme domain modify b.c.m.e --dns_id 1 --fullname b.c.m.e
  1. Modify the x86_64 architecture, bind related operating system
    ./foremanbuddy.py -u admin -p changeme architecture modify x86_64 --operatingsystem_ids 1
  1. Add a subnet
    ./foremanbuddy.py -u admin -p changeme subnet add --name b.c.m.e --network 192.168.21.0 --mask 255.255.255.0 --dns_id 1 --tftp_id 1 --dhcp_id 1 --domain_ids=1
  1. Add Debian installation media
    ./foremanbuddy.py -u admin -p changeme media add --name 'Debian Mirror' --path http://ftp.debian.org/debian --os_family Debian
  1. Add a Debian PXElinux template
    ./foremanbuddy.py -u admin -p changeme template add --name 'Preseed Debian PXElinux' --file_name templates/preseed_debian_pxelinux.template --template_kind 1
  1. Add a partition table
    ./foremanbuddy.py -u admin -p changeme ptable add --name 'Debian Entire Disk KVM' --file_name templates/debian_entire_disk_kvm.template --os_family Debian
  1. Bind the Preseed Default to operating system with id 1 (Debian 6.0)
    ./foremanbuddy.py -u admin -p changeme info --config_templates
    ./foremanbuddy.py -u admin -p changeme template modify 5 --operatingsystem_ids 1
    ./foremanbuddy.py -u admin -p changeme template modify 23 --operatingsystem_ids 1
  1. Deploy the default pxe template to all smart proxies
    ./foremanbuddy.py -u admin -p changeme template build
  1. Modify the Debian Operating system FIXME :(
    #./foremanbuddy.py -u admin -p changeme operatingsystem modify 1 --name Debian --major 6.0 --release_name squeeze --medium_ids 6 --minor 0 --architecture_ids 1 --ptable_ids 11 --family Debian --config_template_id 5
    #./foremanbuddy.py -u admin -p changeme operatingsystem modify 1 --name Debian --major 6.0 --release_name squeeze --medium_ids 6 --minor 0 --architecture_ids 1 --ptable_ids 11 --family Debian
    ./foremanbuddy.py -u admin -p changeme operatingsystem modify 1 --medium_ids 6 --ptable_ids 11 --architecture_ids 1 --provision_template_id 5 --pxelinux_template_id 23
  1. Add 2 hosts
    ./foremanbuddy.py -u admin -p changeme host add --name minion001.b.c.m.e --environment_id 1 --architecture_id 1 --operatingsystem_id 1 --domain_id 1 --mac 52:54:c0:a8:14:65 --ip 192.168.21.101 --ptable_id 11 --puppet_proxy_id 1 --subnet_id 2 --medium_id 6
    ./foremanbuddy.py -u admin -p changeme host add --name minion002.b.c.m.e --environment_id 1 --architecture_id 1 --operatingsystem_id 1 --domain_id 1 --mac 52:54:c0:a8:14:66 --ip 192.168.21.102 --ptable_id 11 --puppet_proxy_id 1 --subnet_id 2 --medium_id 6
  1. Enable host for unattended installation
    ./foremanbuddy.py -u admin -p changeme host action --set_build minion001.b.c.m.e
  1. Disable host for unattended installation
    ./foremanbuddy.py -u admin -p changeme host action --cancel_build minion001.b.c.m.e
  1. Add a user to foreman
    ./foremanbuddy.py -u admin -p changeme user add --login jpoppe --firstname Jasper --lastname Poppe --mail --auth_source_id 1 --password 123 --admin True
  1. Add a compute resource
    ./foremanbuddy.py -u admin -p changeme compute_resource add --name astray98 --url "qemu+ssh:/system" --provider Libvirt

We are using the latest Debian packages there is no api/operatingsystems namespace in this version so I did not check. I could check in the near future, but my time is limited ATM.

Actions #4

Updated by Jasper Poppe over 11 years ago

Ohad Levy wrote:

thanks Jasper

Does it work correctly if you use the api/operatingsystems namespace instead?

thanks,
Ohad

Yes it works correctly, pull request made: https://github.com/theforeman/foreman/pull/200

Actions #5

Updated by Joseph Magen over 11 years ago

  • Assignee set to Joseph Magen
  • Target version set to Bug scrub
Actions #6

Updated by Joseph Magen over 11 years ago

  • Status changed from New to Ready For Testing
Actions #7

Updated by Benjamin Papillon almost 11 years ago

  • Status changed from Ready For Testing to Closed

The issue is resolved. Now the API exposes os_defautl_templates.
If it does not solve your problem, feel free to open the ticket again.

Thanks !

Actions

Also available in: Atom PDF