Which api to make OS to ptable and arch relationships?

Trying to find out how to make the associations between OS, ptables, and
arch.

While trying to create hosts via api, I get

TablaP F16 / Grub2 no pertenece al sistema operativo Fedora 19
Arquitectura x86_64 no pertenece al sistema operativo Fedora 19

indicating that my F19 OS is not associated with the ptable and arch… I
think? Not sure how to get my hammer CLI messages to output in anything but
Spanish. :slight_smile:

Guidance appreciated!

Thanks!

Martin, Tomas, & Joseph,

I posted to foreman-users but didn't see a response to this question. Is this possible currently? If it's not, would you suggest the routes I could add to which controllers. I'll need to know which direction the relationships should be made: OS to arch, or arch to OS, or both.

Thanks!

··· ----- Original Message ----- > From: "Thomas McKay" > To: foreman-users@googlegroups.com > Sent: Saturday, November 16, 2013 6:49:10 PM > Subject: [foreman-users] which api to make OS to ptable and arch relationships? > > > Trying to find out how to make the associations between OS, ptables, and > arch. > > While trying to create hosts via api, I get > > TablaP F16 / Grub2 no pertenece al sistema operativo Fedora 19 > Arquitectura x86_64 no pertenece al sistema operativo Fedora 19 > > indicating that my F19 OS is not associated with the ptable and arch... I > think? Not sure how to get my hammer CLI messages to output in anything but > Spanish. :) > > Guidance appreciated! > > Thanks! > > -- > You received this message because you are subscribed to the Google Groups > "Foreman users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to foreman-users+unsubscribe@googlegroups.com. > To post to this group, send email to foreman-users@googlegroups.com. > Visit this group at http://groups.google.com/group/foreman-users. > For more options, visit https://groups.google.com/groups/opt_out. >

Hi,
It is possible to create the required associations via Hammer. In the
Success story tracker bug [1] there are some handy examples. You can
find the same also in the manual [2], but it is a bit outdated.

associate OS with architecture

 hammer os update --id 1 --architecture-ids 1

associate OS with part table

 hammer os update --id 1 --ptable-ids 1

As for the Spanish messages, they are retrieved from the server so check
the locales and settings there.

[1] Bug #3297: CLI success story tracker - Hammer CLI - Foreman
[2] Foreman :: Manual

If that doesn't resolve the problem, please, let me know.

Martin

··· On 11/17/2013 12:49 AM, Thomas McKay wrote: > > Trying to find out how to make the associations between OS, ptables, > and arch. > > While trying to create hosts via api, I get > > TablaP F16 / Grub2 no pertenece al sistema operativo Fedora 19 > Arquitectura x86_64 no pertenece al sistema operativo Fedora 19 > > indicating that my F19 OS is not associated with the ptable and > arch... I think? Not sure how to get my hammer CLI messages to output > in anything but Spanish. :) > > Guidance appreciated! > > Thanks! > -- > You received this message because you are subscribed to the Google > Groups "Foreman users" group. > To unsubscribe from this group and stop receiving emails from it, send > an email to foreman-users+unsubscribe@googlegroups.com. > To post to this group, send email to foreman-users@googlegroups.com. > Visit this group at http://groups.google.com/group/foreman-users. > For more options, visit https://groups.google.com/groups/opt_out.

Hi Tom,

The API v1 does not have nested routes and API v2 only have a few so far. In order to add relationships, you need to update (PUT) the object and pass *_ids data attribute.

For example, Architecture and Operatingsystem have a has_and_belongs_to_many relationship. Therefore you can get the operatingsystem id's for a particular architecture like this

Architecture.find(77).operatingsystem_ids and it will give an array of ids, ex. [1,3,5,99]

If you want to add an operatingsystem_id, let's say 100, you need to do this.

curl -u admin:secret -H 'Accept:application/json' -H "Content-Type:application/json" -X PUT -d "{"operatingsystem_ids":[1,3,5,99,100]}" http://0.0.0.0:3000/api/architectures/77

I hope that helps.

Regards,

Joseph

··· ----- Original Message ----- > From: "Tom McKay" > To: "Martin Bacovsky" , "Joseph Magen" , "Tomas Strachota" > > Cc: foreman-users@googlegroups.com > Sent: Monday, November 18, 2013 2:38:43 PM > Subject: Re: [foreman-users] which api to make OS to ptable and arch relationships? > > > Martin, Tomas, & Joseph, > > I posted to foreman-users but didn't see a response to this question. Is this > possible currently? If it's not, would you suggest the routes I could add to > which controllers. I'll need to know which direction the relationships > should be made: OS to arch, or arch to OS, or both. > > Thanks! > > ----- Original Message ----- > > From: "Thomas McKay" > > To: foreman-users@googlegroups.com > > Sent: Saturday, November 16, 2013 6:49:10 PM > > Subject: [foreman-users] which api to make OS to ptable and arch > > relationships? > > > > > > Trying to find out how to make the associations between OS, ptables, and > > arch. > > > > While trying to create hosts via api, I get > > > > TablaP F16 / Grub2 no pertenece al sistema operativo Fedora 19 > > Arquitectura x86_64 no pertenece al sistema operativo Fedora 19 > > > > indicating that my F19 OS is not associated with the ptable and arch... I > > think? Not sure how to get my hammer CLI messages to output in anything but > > Spanish. :) > > > > Guidance appreciated! > > > > Thanks! > > > > -- > > You received this message because you are subscribed to the Google Groups > > "Foreman users" group. > > To unsubscribe from this group and stop receiving emails from it, send an > > email to foreman-users+unsubscribe@googlegroups.com. > > To post to this group, send email to foreman-users@googlegroups.com. > > Visit this group at http://groups.google.com/group/foreman-users. > > For more options, visit https://groups.google.com/groups/opt_out. > > > > -- > You received this message because you are subscribed to the Google Groups > "Foreman users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to foreman-users+unsubscribe@googlegroups.com. > To post to this group, send email to foreman-users@googlegroups.com. > Visit this group at http://groups.google.com/group/foreman-users. > For more options, visit https://groups.google.com/groups/opt_out. >

> Hi Tom,
>
> The API v1 does not have nested routes and API v2 only have a few so far. In order to add relationships, you need to update (PUT) the object and pass *_ids data attribute.

I believe it would work on POST too.

··· On Mon, Nov 18, 2013 at 7:59 AM, Joseph Magen wrote:

For example, Architecture and Operatingsystem have a has_and_belongs_to_many relationship. Therefore you can get the operatingsystem id’s for a particular architecture like this

Architecture.find(77).operatingsystem_ids and it will give an array of ids, ex. [1,3,5,99]

If you want to add an operatingsystem_id, let’s say 100, you need to do this.

curl -u admin:secret -H ‘Accept:application/json’ -H “Content-Type:application/json” -X PUT -d “{“operatingsystem_ids”:[1,3,5,99,100]}” http://0.0.0.0:3000/api/architectures/77

I hope that helps.

Regards,

Joseph

----- Original Message -----

From: “Tom McKay” thomasmckay@redhat.com
To: “Martin Bacovsky” mbacovsk@redhat.com, “Joseph Magen” jmagen@redhat.com, "Tomas Strachota"
tstracho@redhat.com
Cc: foreman-users@googlegroups.com
Sent: Monday, November 18, 2013 2:38:43 PM
Subject: Re: [foreman-users] which api to make OS to ptable and arch relationships?

Martin, Tomas, & Joseph,

I posted to foreman-users but didn’t see a response to this question. Is this
possible currently? If it’s not, would you suggest the routes I could add to
which controllers. I’ll need to know which direction the relationships
should be made: OS to arch, or arch to OS, or both.

Thanks!

----- Original Message -----

From: “Thomas McKay” thomasfmckay@gmail.com
To: foreman-users@googlegroups.com
Sent: Saturday, November 16, 2013 6:49:10 PM
Subject: [foreman-users] which api to make OS to ptable and arch
relationships?

Trying to find out how to make the associations between OS, ptables, and
arch.

While trying to create hosts via api, I get

TablaP F16 / Grub2 no pertenece al sistema operativo Fedora 19
Arquitectura x86_64 no pertenece al sistema operativo Fedora 19

indicating that my F19 OS is not associated with the ptable and arch… I
think? Not sure how to get my hammer CLI messages to output in anything but
Spanish. :slight_smile:

Guidance appreciated!

Thanks!


You received this message because you are subscribed to the Google Groups
"Foreman users" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to foreman-users+unsubscribe@googlegroups.com.
To post to this group, send email to foreman-users@googlegroups.com.
Visit this group at http://groups.google.com/group/foreman-users.
For more options, visit https://groups.google.com/groups/opt_out.


You received this message because you are subscribed to the Google Groups
"Foreman users" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to foreman-users+unsubscribe@googlegroups.com.
To post to this group, send email to foreman-users@googlegroups.com.
Visit this group at http://groups.google.com/group/foreman-users.
For more options, visit https://groups.google.com/groups/opt_out.


You received this message because you are subscribed to the Google Groups “Foreman users” group.
To unsubscribe from this group and stop receiving emails from it, send an email to foreman-users+unsubscribe@googlegroups.com.
To post to this group, send email to foreman-users@googlegroups.com.
Visit this group at http://groups.google.com/group/foreman-users.
For more options, visit https://groups.google.com/groups/opt_out.

> From: "Ohad Levy" <ohadlevy@gmail.com>
> To: foreman-users@googlegroups.com
> Sent: Monday, November 18, 2013 3:08:55 PM
> Subject: Re: [foreman-users] which api to make OS to ptable and arch relationships?
>
> > Hi Tom,
> >
> > The API v1 does not have nested routes and API v2 only have a few so far.
> > In order to add relationships, you need to update (PUT) the object and
> > pass *_ids data attribute.
>
> I believe it would work on POST too.

Correct, *_ids can be passed as a data attribute when creating a new object (architecture, os, ptable, etc)

··· ----- Original Message ----- > On Mon, Nov 18, 2013 at 7:59 AM, Joseph Magen wrote:

For example, Architecture and Operatingsystem have a
has_and_belongs_to_many relationship. Therefore you can get the
operatingsystem id’s for a particular architecture like this

Architecture.find(77).operatingsystem_ids and it will give an array of ids,
ex. [1,3,5,99]

If you want to add an operatingsystem_id, let’s say 100, you need to do
this.

curl -u admin:secret -H ‘Accept:application/json’ -H
"Content-Type:application/json" -X PUT -d
"{“operatingsystem_ids”:[1,3,5,99,100]}"
http://0.0.0.0:3000/api/architectures/77

I hope that helps.

Regards,

Joseph

----- Original Message -----

From: “Tom McKay” thomasmckay@redhat.com
To: “Martin Bacovsky” mbacovsk@redhat.com, "Joseph Magen"
jmagen@redhat.com, "Tomas Strachota"
tstracho@redhat.com
Cc: foreman-users@googlegroups.com
Sent: Monday, November 18, 2013 2:38:43 PM
Subject: Re: [foreman-users] which api to make OS to ptable and arch
relationships?

Martin, Tomas, & Joseph,

I posted to foreman-users but didn’t see a response to this question. Is
this
possible currently? If it’s not, would you suggest the routes I could add
to
which controllers. I’ll need to know which direction the relationships
should be made: OS to arch, or arch to OS, or both.

Thanks!

----- Original Message -----

From: “Thomas McKay” thomasfmckay@gmail.com
To: foreman-users@googlegroups.com
Sent: Saturday, November 16, 2013 6:49:10 PM
Subject: [foreman-users] which api to make OS to ptable and arch
relationships?

Trying to find out how to make the associations between OS, ptables, and
arch.

While trying to create hosts via api, I get

TablaP F16 / Grub2 no pertenece al sistema operativo Fedora 19
Arquitectura x86_64 no pertenece al sistema operativo Fedora 19

indicating that my F19 OS is not associated with the ptable and arch…
I
think? Not sure how to get my hammer CLI messages to output in anything
but
Spanish. :slight_smile:

Guidance appreciated!

Thanks!


You received this message because you are subscribed to the Google
Groups
"Foreman users" group.
To unsubscribe from this group and stop receiving emails from it, send
an
email to foreman-users+unsubscribe@googlegroups.com.
To post to this group, send email to foreman-users@googlegroups.com.
Visit this group at http://groups.google.com/group/foreman-users.
For more options, visit https://groups.google.com/groups/opt_out.


You received this message because you are subscribed to the Google Groups
"Foreman users" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to foreman-users+unsubscribe@googlegroups.com.
To post to this group, send email to foreman-users@googlegroups.com.
Visit this group at http://groups.google.com/group/foreman-users.
For more options, visit https://groups.google.com/groups/opt_out.


You received this message because you are subscribed to the Google Groups
"Foreman users" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to foreman-users+unsubscribe@googlegroups.com.
To post to this group, send email to foreman-users@googlegroups.com.
Visit this group at http://groups.google.com/group/foreman-users.
For more options, visit https://groups.google.com/groups/opt_out.


You received this message because you are subscribed to the Google Groups
"Foreman users" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to foreman-users+unsubscribe@googlegroups.com.
To post to this group, send email to foreman-users@googlegroups.com.
Visit this group at http://groups.google.com/group/foreman-users.
For more options, visit https://groups.google.com/groups/opt_out.