Compute Resource : Associate VM

Is there a way I can enable debugging such that it shows the queries being
made against the DB?

The associate VM (from an OpenStack compute resource) ends up picking the
wrong host, every time. I tried looking at the code but not sure exactly
what it is doing. It appears to be trying to match on the
floating_ip_address or private_ip_address. Would live to see what values it
is using for those if possible.

Assuming this is the code called in the openstack.rb file:

def associated_host(vm)
associate_by("ip", [vm.floating_ip_address, vm.private_ip_address])
end

def associate_by(name, attributes) Host.authorized(:view_hosts, Host).joins(
:primary_interface). where(:nics => {:primary => true}). where("nics.#{name}
" => attributes). readonly(false). first end The VM and host have neither
the same MAC or IP.

Hi Matthew,

Yes, starting with version 1.9 you can enable or disable specific loggers
in the settings.yaml file.
Specifically for SQL logging, you can add the following lines:
:loggers:
:sql:
:enabled: false

You can take a look at [1] for more details.

[1] Foreman :: Manual

··· On Sun, Jul 10, 2016 at 3:30 AM, Matthew Ceroni wrote:

Is there a way I can enable debugging such that it shows the queries being
made against the DB?

The associate VM (from an OpenStack compute resource) ends up picking the
wrong host, every time. I tried looking at the code but not sure exactly
what it is doing. It appears to be trying to match on the
floating_ip_address or private_ip_address. Would live to see what values it
is using for those if possible.

Assuming this is the code called in the openstack.rb file:

def associated_host(vm)
associate_by(“ip”, [vm.floating_ip_address, vm.private_ip_address])
end

def associate_by(name, attributes) Host.authorized(:view_hosts, Host
).joins(:primary_interface). where(:nics => {:primary => true}). where(“
nics.#{name}” => attributes). readonly(false). first end The VM and host
have neither the same MAC or IP.


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


Have a nice day,
Tomer Brisker
Red Hat Engineering

Thanks.

That allowed me to get around the issue. We aren't using floating_ip, so
that value is null and the SQL generated matches on any hosts that have
does not have IP null, which is all of them, so it was always picking the
first one.

Ended up with some other issues (foreman IP != Openstack IP != real system
IP) so modified to match on name and was able to associate all VMs.

Shouldn't be an issue going forward as all creation and deletion will now
be done through Foreman.

··· On Sunday, July 10, 2016 at 12:33:29 AM UTC-7, Tomer Brisker wrote: > > Hi Matthew, > > Yes, starting with version 1.9 you can enable or disable specific loggers > in the settings.yaml file. > Specifically for SQL logging, you can add the following lines: > :loggers: > :sql: > :enabled: false > > You can take a look at [1] for more details. > > > [1] https://theforeman.org/manuals/1.11/index.html#loggers > > On Sun, Jul 10, 2016 at 3:30 AM, Matthew Ceroni > wrote: > >> Is there a way I can enable debugging such that it shows the queries >> being made against the DB? >> >> The associate VM (from an OpenStack compute resource) ends up picking the >> wrong host, every time. I tried looking at the code but not sure exactly >> what it is doing. It appears to be trying to match on the >> floating_ip_address or private_ip_address. Would live to see what values it >> is using for those if possible. >> >> Assuming this is the code called in the openstack.rb file: >> >> def associated_host(vm) >> associate_by("ip", [vm.floating_ip_address, vm.private_ip_address]) >> end >> >> def associate_by(name, attributes) Host.authorized(:view_hosts, Host >> ).joins(:primary_interface). where(:nics => {:primary => true}). where(" >> nics.#{name}" => attributes). readonly(false). first end The VM and host >> have neither the same MAC or IP. >> >> >> >> -- >> You received this message because you are subscribed to the Google Groups >> "foreman-dev" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to foreman-dev...@googlegroups.com . >> For more options, visit https://groups.google.com/d/optout. >> > > > > -- > Have a nice day, > Tomer Brisker > Red Hat Engineering >