As a workaroud I tried to define a hostgroup,
-
A hostgroup with only specific environment
Host host = new Host();
host.setName("CGCentOs");
host.setHostgroupId(1);
host.setDomainId(1);
host.setArchitectureId(1);
host.setOperatingsystemId(1);
host.setComputeResourceId(1);
It gives:
Processing by Api::V2::HostsController#create as JSON
Parameters: {"name"=>"CGCentOs", "capabilities"=>nil, "parameters"=>nil,
"interfaces"=>nil, "puppetclasses"=>nil, "domain_id"=>1,
"architecture_id"=>1, "operatingsystem_id"=>1, "hostgroup_id"=>1,
"compute_resource_id"=>1, "all_puppetclasses"=>nil, "config_groups"=>nil,
"apiv"=>"v2", :host=>{"name"=>"CGCentOs", "domain_id"=>1,
"architecture_id"=>1, "operatingsystem_id"=>1, "hostgroup_id"=>1,
"compute_resource_id"=>1}}
Expire fragment views/tabs_and_title_records-3 (0.1ms)
Authorized user admin(Admin User)
domain_id is not allowed as nested parameter for hosts. Allowed parameters
are hostgroup_id, location_id, organization_id, environment_id
(RuntimeError)
So I specify domain_id in hostgroup too, it becomes
2.A hostgroup with specific environment and domain_id
Host host = new Host();
host.setName("CGCentOs");
host.setHostgroupId(1);
host.setArchitectureId(1);
host.setOperatingsystemId(1);
host.setComputeResourceId(1);
It gives:
Parameters: {"name"=>"CGCentOs", "capabilities"=>nil, "parameters"=>nil,
"interfaces"=>nil, "puppetclasses"=>nil, "architecture_id"=>1,
"operatingsystem_id"=>1, "hostgroup_id"=>1, "compute_resource_id"=>1,
"all_puppetclasses"=>nil, "config_groups"=>nil, "apiv"=>"v2",
:host=>{"name"=>"CGCentOs", "architecture_id"=>1, "operatingsystem_id"=>1,
"hostgroup_id"=>1, "compute_resource_id"=>1}}
Authorized user admin(Admin User)
architecture_id is not allowed as nested parameter for hosts. Allowed
parameters are hostgroup_id, location_id, organization_id, environment_id
(RuntimeError)
- I add architecture_id to host group
Host host = new Host();
host.setName("CGCentOs");
host.setHostgroupId(1);
host.setOperatingsystemId(1);
host.setComputeResourceId(1);
It gives:
Parameters: {"name"=>"CGCentOs", "capabilities"=>nil, "parameters"=>nil,
"interfaces"=>nil, "puppetclasses"=>nil, "operatingsystem_id"=>1,
"hostgroup_id"=>1, "compute_resource_id"=>1, "all_puppetclasses"=>nil,
"config_groups"=>nil, "apiv"=>"v2", :host=>{"name"=>"CGCentOs",
"operatingsystem_id"=>1, "hostgroup_id"=>1, "compute_resource_id"=>1}}
Authorized user admin(Admin User)
operatingsystem_id is not allowed as nested parameter for hosts. Allowed
parameters are hostgroup_id, location_id, organization_id, environment_id
(RuntimeError)
- I add operatingsystem_id to host group
Host host = new Host();
host.setName("CGCentOs");
host.setHostgroupId(1);
host.setComputeResourceId(1);
It gives:
Processing by Api::V2::HostsController#create as JSON
Parameters: {"name"=>"CGCentOs", "capabilities"=>nil, "parameters"=>nil,
"interfaces"=>nil, "puppetclasses"=>nil, "hostgroup_id"=>1,
"compute_resource_id"=>1, "all_puppetclasses"=>nil, "config_groups"=>nil,
"apiv"=>"v2", :host=>{"name"=>"CGCentOs", "hostgroup_id"=>1,
"compute_resource_id"=>1}}
Expire fragment views/tabs_and_title_records-3 (0.6ms)
Authorized user admin(Admin User)
compute_resource_id is not allowed as nested parameter for hosts. Allowed
parameters are hostgroup_id, location_id, organization_id, environment_id
(RuntimeError)
- I can't add compute_resource id to hostgroup… i just remove the line…
Host host = new Host();
host.setName("CGCentOs");
host.setHostgroupId(1);
It gives:
Processing by Api::V2::HostsController#create as JSON
Parameters: {"name"=>"CGCentOs", "capabilities"=>nil, "parameters"=>nil,
"interfaces"=>nil, "puppetclasses"=>nil, "hostgroup_id"=>1,
"all_puppetclasses"=>nil, "config_groups"=>nil, "apiv"=>"v2",
:host=>{"name"=>"CGCentOs", "hostgroup_id"=>1}}
Authorized user admin(Admin User)
Unprocessable entity Host::Managed (id: new):
MAC address is not a valid MAC address
MAC address can't be blank
Partition Table cant be blank unless a custom partition has been defined
I was expecting this because, coumpute resource defines its virtuality…
So, compute profiles and compute resources seem tight couple
I try this:
Host host = new Host();
host.setName("CGCentOs");
host.setHostgroupId(1);
host.setComputeProfileId(3);
It gives:
Processing by Api::V2::HostsController#create as JSON
Parameters: {"name"=>"CGCentOs", "capabilities"=>nil, "parameters"=>nil,
"interfaces"=>nil, "puppetclasses"=>nil, "hostgroup_id"=>1,
"compute_profile_id"=>3, "all_puppetclasses"=>nil, "config_groups"=>nil,
"apiv"=>"v2", :host=>{"name"=>"CGCentOs", "hostgroup_id"=>1,
"compute_profile_id"=>3}}
Authorized user admin(Admin User)
compute_profile_id is not allowed as nested parameter for hosts. Allowed
parameters are hostgroup_id, location_id, organization_id, environment_id
(RuntimeError)
I created a new compute profile and it appeared in the edit hos group
pane… so retrying:
Host host = new Host();
host.setName("CGCentOs");
host.setHostgroupId(1);
Again MAC adress problem:
Processing by Api::V2::HostsController#create as JSON
Parameters: {"name"=>"CGCentOs", "capabilities"=>nil, "parameters"=>nil,
"interfaces"=>nil, "puppetclasses"=>nil, "hostgroup_id"=>1,
"all_puppetclasses"=>nil, "config_groups"=>nil, "apiv"=>"v2",
:host=>{"name"=>"CGCentOs", "hostgroup_id"=>1}}
Expire fragment views/tabs_and_title_records-3 (0.1ms)
Authorized user admin(Admin User)
Unprocessable entity Host::Managed (id: new):
MAC address is not a valid MAC address
MAC address can't be blank
Partition Table cant be blank unless a custom partition has been defined
Also the 1.7 doc says that "Assuming the defaults are suitable, the host
has now been defined solely by selecting a host group and a profile."
http://theforeman.org/manuals/1.7/index.html#5.AdvancedForeman
At that point I don't have much to do more
I hope you can help me more
Using the software I wrote, at the end of the day, I just want to create a
centos virtual machine from a template with specific cpu/ram/hard disk
capacity, nothing more
···
On Wednesday, January 21, 2015 at 9:38:40 AM UTC+2, Mete Ozguz wrote:
>
> Hi, first I would like to thank you for developing foreman. It seems
> great. It is very easy to create a host. Probably it is very easy to create
> using api (v2) too but it seems I miss something constantly. I hope you can
> help me.
>
> I create a host through web ui with the following configuration:
> Name: testCentOsImageBased
> No Host Group
> Deploy on: cmptrsrc_VMWare (VMWare)
> Environment: production
> No puppet CA
> No puppet Master
> ---
> Domain: localdomain
> ---
> Architecture: x86_64
> Operating system: CentOS 6.5
> Provisioning Method: Image Based (CentOs6_5img)
>
> I am able to create this host. ( after applying this feature
> http://projects.theforeman.org/issues/1945 )
>
> According to apiV2, I set my host config as follow:
> host.setName("CGCentOs");
> host.setEnvironmentId("1");
> host.setDomainId("1");
> host.setArchitectureId("1");
> host.setOperatingsystemId("1");
> host.setComputeResourceId("1");
>
> And tailing production.log gives:
> domain_id is not allowed as nested parameter for hosts
>
> This is the case for some other parameters too. And It seems that I need
> to give image somehow, I have checked request of web ui while creating host
> but I could'nt applied extra parametes very successfully to apiV2 create
> host request.
>
> Is there any workaround except pulling develop branch? I use 1.7-stable
> version currently.
>
> Thank you in advance.
>
>