@Greg Sutcliffe: Yes, I am.
@Ohad: Let me try to be more clear.
By dissociating the IM1 from OS, the current media-host association doesn't change in the DB. This means that When I want to completely delete the media, I will not be allowed, there will be errors like "Cannot do that, host blah is using medium IM1.". That's quite OK.
But I IIRC it also means that if I click BUILD now, the host will get built from the old media IM1, not from the IM2 which is shown on the hosts page.
Following the description in the very first commit, I have state:
[root@puppet ~]# psql foreman foreman <<< 'select id, name from media';
id | name
----+----------------------
...
15 | IM1
16 | IM2
(12 rows)
We don't have the IM1 associated with the selected OS (of id 8):
[root@puppet ~]# psql foreman foreman <<< 'select * from media_operatingsystems where operatingsystem_id = 8'
medium_id | operatingsystem_id
-----------+--------------------
16 | 8
Now check what will (IIRC) be used when clicked on BUILD:
[root@puppet ~]# psql foreman foreman <<< 'SELECT hosts.id, hosts.name, media.id, media.name as mn FROM hosts JOIN media ON (hosts.medium_id = media.id);'
id | name | id | mn
-----+------------------------------------------------------+----+--------------------
127 | foo.xxx.redhat.com | 15 | IM1
But in the Operating System, it looks like the media IM2 would be used, as it is the only media associated with the OS