Bug 1324100

Summary: RedHat Domain - Change placement methods to avoid read-only datastores
Product: Red Hat CloudForms Management Engine Reporter: Tina Fitzgerald <tfitzger>
Component: AutomateAssignee: William Fitzgerald <wfitzger>
Status: CLOSED CURRENTRELEASE QA Contact: Milan Falešník <mfalesni>
Severity: medium Docs Contact:
Priority: medium    
Version: 5.6.0CC: cpelland, greartes, jhardy, mfalesni, mkanoor, nachandr, ncatling, obarenbo, simaishi, tfitzger
Target Milestone: GAKeywords: FutureFeature, TestOnly, ZStream
Target Release: 5.7.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard: automate:datastore
Fixed In Version: 5.7.0.0 Doc Type: Enhancement
Doc Text:
Story Points: ---
Clone Of:
: 1351178 (view as bug list) Environment:
Last Closed: 2017-01-11 20:18:06 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:
Bug Depends On:    
Bug Blocks: 1351178    

Description Tina Fitzgerald 2016-04-05 14:04:42 UTC
Description of problem:
Change the RedHat methods to reflect changes made here:
https://github.com/ManageIQ/manageiq/pull/7662/commits/9b6e399705ee5a5eeded2fd6a4a78ceacfeb15e0

automate methods use .storages as shown below:
s = h.storages.max_by(&:free_space)

code should be changed to use .writable_storages as shown here:
s = h.writable_storages.max_by(&:free_space)

Actual results:
Eligible methods are including read only storages for eligible methods.

Expected results:
Eligible methods should NOT include read only storages for eligible methods.


Additional info:

Comment 2 CFME Bot 2016-05-13 19:42:27 UTC
New commit detected on cfme_productization/master:
https://code.engineering.redhat.com/gerrit/gitweb?p=cfme_productization.git;a=commit;h=79b9f8c5ee4d45eb5096803425232611021766c1

commit 79b9f8c5ee4d45eb5096803425232611021766c1
Merge: 51af974 00f8b8e
Author:     Greg McCullough <gmccullo>
AuthorDate: Fri May 13 15:22:16 2016 -0400
Commit:     Greg McCullough <gmccullo>
CommitDate: Fri May 13 15:22:16 2016 -0400

    Merge branch 'writable_storage' into 'master'
    
    Automate - RedHat Domain - Change placement methods to avoid read-only datastores.
    
    Code changed to use writable_storages.
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1324100
    
    See merge request !257

 .../Placement.class/__methods__/redhat_best_placement_with_scope.rb     | 2 +-
 .../Placement.class/__methods__/vmware_best_fit_with_scope.rb           | 2 +-
 .../Placement.class/__methods__/vmware_best_fit_with_tags.rb            | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

Comment 3 CFME Bot 2016-05-13 19:42:31 UTC
New commit detected on cfme_productization/master:
https://code.engineering.redhat.com/gerrit/gitweb?p=cfme_productization.git;a=commit;h=00f8b8e9742100e5c12fc4e3a4efc9fd402d5b47

commit 00f8b8e9742100e5c12fc4e3a4efc9fd402d5b47
Author:     william fitzgerald <wfitzger>
AuthorDate: Thu May 12 14:47:53 2016 -0400
Commit:     william fitzgerald <wfitzger>
CommitDate: Thu May 12 16:12:33 2016 -0400

    Automate - RedHat Domain - Change placement methods to avoid read-only datastores.
    
    Code changed to use .writable_storages.
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1324100

 .../Placement.class/__methods__/redhat_best_placement_with_scope.rb     | 2 +-
 .../Placement.class/__methods__/vmware_best_fit_with_scope.rb           | 2 +-
 .../Placement.class/__methods__/vmware_best_fit_with_tags.rb            | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

Comment 8 Milan Falešník 2016-09-16 14:26:01 UTC
Verified in 5.7.0.0 using our vSphere 5.5.

First I disabled the provider inventory role so it does not interfere with my database tinkering.

Then I issued this ruby code in the rails console that renders all datastores read only:

HostStorage.all.each {|hs| hs.read_only = true; hs.save! }

When I created a provisioning request, UI did not offer any datastore and when I checked the automatic placement, the provisioning ended with an error, as expected:

[EVM] VM [test_mfalesni_thisshouldnotprovision] Step [CheckProvisioned] Status [[MiqException::MiqProvisionError]: Destination placement_host_name not provided] Message [[MiqException::MiqProvisionError]: Destination placement_host_name not provided]

Then I enabled one of the storages:
irb(main):014:0> hs = HostStorage.all[2]
=> #<HostStorage storage_id: 17, host_id: 7, read_only: true, id: 29, ems_ref: "datastore-249">
irb(main):015:0> hs.storage.name
=> "cfme-esx-glob-na01a-s"
irb(main):016:0> hs.read_only
=> true
irb(main):017:0> hs.read_only = false
=> false
irb(main):018:0> hs.save!
=> true

I copied the provisioning request and issued it again. The VM got provisioned and a quick peek through the vSphere api suggests that the VM is provisioned on the right datastore successfully:

(In python, in the context of ManageIQ/integration_tests wrapanapi vsphere client)
In [8]: vm.datastore[0].name
Out[8]: cfme-esx-glob-na01a-s

Then I enabled the Inventory role in order for CFME to see the new VM on provider, and once it appeared, it also reveals it is on the right datastore:

Datastores	 cfme-esx-glob-na01a-s