Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
Red Hat Satellite engineering is moving the tracking of its product development work on Satellite to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "Satellite project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs will be migrated starting at the end of May. If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "Satellite project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/SAT-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 1702636

Summary: [Kubevirt-Foreman] compute resource organisation errors
Product: Red Hat Satellite Reporter: Vatsal Parekh <vparekh>
Component: Compute Resources - CNVAssignee: Shira Maximov <mshira>
Status: CLOSED NOTABUG QA Contact: Lukáš Hellebrandt <lhellebr>
Severity: high Docs Contact:
Priority: unspecified    
Version: 6.6.0CC: masayag
Target Milestone: Unspecified   
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2019-04-28 14:15:11 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Vatsal Parekh 2019-04-24 10:21:11 UTC
Description of problem:
When trying to create a host via API, i get this error even if the compute resource id is correct and shows under correct org
```
{
    "error": {
        "id": null,
        "errors": {
            "interfaces.compute_resource_id": [
                "is not defined for host's organization"
            ]
        },
        "full_messages": [
            "Interfaces.compute resource is not defined for host's organization"
        ]
    }
}
```

If I edit the Organisation and select 'All compute resource' under Compute resource section, and create the host again then it does not complain about this. 
But now the Create host from UI shows the error `	
with id 1 doesn't exist or is not assigned to proper organisation and/or location`

The thing to note is that the compute resource already shows under the org, and still shows this behaviour 

Version-Release number of selected component (if applicable):
nightly+plugin master

How reproducible:


Steps to Reproduce:
1.
2.
3.

Actual results:
Wrong errors regarding the organisation even when it is part of the selected org

Expected results:


Additional info:

Comment 3 Vatsal Parekh 2019-04-24 10:25:46 UTC
REQUEST SENT:
{  "location_id" : "1",
  "organization_id" : "2",
  "host" : {
    "name" : "test-api-host",
    "location_id" : 1,
    "organization_id" : 1,
   
    "compute_resource_id" : 1,
    "provision_method":"build",
    "compute_attributes" : {
      "cores" : "1",
      "memory": 1024,
      "volumes_attributes": {
  "0": { "storage_class": "gluster-default-volume", "capacity": "1"}
}
    },
    "operatingsystem_id": 1,
    "architecture_id" : 1,
    "interfaces_attributes": {
       "0" : {
       	"domain_id" : "3",
       	"name" : "test-api-host",
       	"ip": "172.16.0.152",
       	"subnet_id" : "2",
       	"mac" : "a2:a2:a2:a2:a2:a2",
		"managed" : "1",
		"primary" : "1",
		"provision" : "1",
		"type": "Nic::Managed",
		"virtual" : "0",
		"compute_attributes" : {
			"cni_provider":"multus",
			"network": "default"
		}
	}
    }
  }
}

Comment 4 Vatsal Parekh 2019-04-24 10:29:50 UTC
Production log
```
2019-04-24T10:29:19 [I|app|e70eb7ae] Started POST "/api/hosts" for 10.65.223.213 at 2019-04-24 10:29:19 +0000
2019-04-24T10:29:19 [I|app|e70eb7ae] Processing by Api::V2::HostsController#create as JSON
2019-04-24T10:29:19 [I|app|e70eb7ae]   Parameters: {"location_id"=>"1", "organization_id"=>"2", "host"=>{"name"=>"test-api-host", "location_id"=>1, "organization_id"=>1, "compute_resource_id"=>1, "provision_method"=>"build", "compute_attributes"=>{"cores"=>"1", "memory"=>1024, "volumes_attributes"=>{"0"=>{"storage_class"=>"gluster-default-volume", "capacity"=>"1"}}}, "operatingsystem_id"=>1, "architecture_id"=>1, "interfaces_attributes"=>{"0"=>{"domain_id"=>"3", "name"=>"test-api-host", "ip"=>"172.16.0.152", "subnet_id"=>"2", "mac"=>"a2:a2:a2:a2:a2:a2", "managed"=>"1", "primary"=>"1", "provision"=>"1", "type"=>"Nic::Managed", "virtual"=>"0", "compute_attributes"=>{"cni_provider"=>"multus", "network"=>"default"}}}}, "apiv"=>"v2"}
2019-04-24T10:29:19 [I|app|e70eb7ae] Current user set to admin (admin)
2019-04-24T10:29:20 [W|app|e70eb7ae] Not queueing Nic::Managed: ["Compute resource is not defined for host's organization"]
2019-04-24T10:29:20 [W|app|e70eb7ae] Not queueing Nic::Managed: ["Compute resource is not defined for host's organization"]
2019-04-24T10:29:20 [W|app|e70eb7ae] Not queueing Nic::Managed: ["Compute resource is not defined for host's organization"]
2019-04-24T10:29:20 [W|app|e70eb7ae] Not queueing Host::Managed: ["Interfaces.compute resource is not defined for host's organization"]
2019-04-24T10:29:20 [W|app|e70eb7ae] Not queueing Host::Managed: ["Interfaces.compute resource is not defined for host's organization"]
2019-04-24T10:29:20 [W|app|e70eb7ae] Not queueing Host::Managed: ["Interfaces.compute resource is not defined for host's organization"]
2019-04-24T10:29:20 [E|app|e70eb7ae] Unprocessable entity Host::Managed (id: new):
  Interfaces.compute resource is not defined for host's organization

2019-04-24T10:29:20 [I|app|e70eb7ae]   Rendering api/v2/errors/unprocessable_entity.json.rabl within api/v2/layouts/error_layout
2019-04-24T10:29:20 [I|app|e70eb7ae]   Rendered api/v2/errors/unprocessable_entity.json.rabl within api/v2/layouts/error_layout (2.0ms)
2019-04-24T10:29:20 [I|app|e70eb7ae] Completed 422 Unprocessable Entity in 682ms (Views: 4.5ms | ActiveRecord: 40.3ms)
```

Comment 5 Shira Maximov 2019-04-28 14:15:11 UTC
Vatsal, 
Please see that you are using the organization_id twice, with id 1 and with 2. 
please choose the one that relevant and send the request again.