Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for copy and compare of automate class, instance and methods #73

Merged
merged 1 commit into from
Jul 1, 2014

Conversation

mkanoor
Copy link
Contributor

@mkanoor mkanoor commented Jun 23, 2014

The UI needs backend support for copying classes, instances and methods from a readonly domain like ManageIQ to an editable customer domain. Before an instance can be copied we have to compare the class schema, before overlaying an instance or a method we need to compare the values and the scripts. Comparison is a precursor to copying the automation components.
The comparison functions can also be used to compare automation components stored in YAML when importing automation models.

The comparison functions return 3 status values

  • CONGRUENT to indicate that the component matches completely (class schema is identical, instance values are identical, method parameters and scripts are identical)
  • COMPATIBLE to indicate that the component doesn't have a identical match but is compatible (e.g. class schema has new fields, instances have new values)
  • INCOMPATIBLE to indicate that the components don't match at all(e.g datatype/aetype are different in class schema)

By default an instance can only be copied if the Class Schema is either CONGRUENT or COMPATIBLE. A user can still force a copy of instances with INCOMPATIBLE schemas but would have to edit the instance after it has been created.

@mkanoor
Copy link
Contributor Author

mkanoor commented Jun 23, 2014

@@ -0,0 +1,87 @@
class MiqAeClassCompareFields
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If these are specific to MiqAeClass, why not namespace them with MiqAeClass::CompareFields?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Fryguy
The Compare works with both MiqAeClass (AR) and MiqAeClassYaml (YAML). My goal is to switch MiqAeClass with MiqAeClassYaml down the road when we can have all AR functionality in the MiqAeClassYaml.

@Fryguy
Copy link
Member

Fryguy commented Jun 24, 2014

@mkanoor Before further reviewing, I wanted to take a step back. This seems like mostly copying of ActiveRecord objects. If so, why not use .clone, which is meant for duplicating ActiveRecord objects?

@mkanoor
Copy link
Contributor Author

mkanoor commented Jun 24, 2014

@Fryguy
From what I have read on the AR clone @ http://apidock.com/rails/ActiveRecord/Base/clone it says
It is good for shallow copying and doesn't deal with associations. It says for deep cloning the logic is best left to the application

Some of the differences between clone and this copy is
(1) We copy selective associations not all associations. For example when copying a class we only need to copy the Schema defined in MiqAeFields. We only copy selective instances. From a use case perspective we don't want to clone the entire class (schema+all instances) we only need those instances/methods that the user wants to override.

(2)The Copy functions can start at the Instance/Method Level and then copy the Instance/Method into a different domain. As part of instance/method copying the domain, namespace and class are created if they don't exit.

(3) The Class Schema can drift over a period of time so a comparison of the schema is necessary before forcing a copy.

@Fryguy
Copy link
Member

Fryguy commented Jun 24, 2014

@mkanoor Got it.

@mkanoor
Copy link
Contributor Author

mkanoor commented Jun 24, 2014

@Fryguy
Made the recommended changes.

end

context "clone the class to a new domain" do
before(:each) do
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mkanoor :each is the default so you do not need to specify it here. Applies to all the other specs in this PR as well.

 Allows for copy of class, instances and methods
 across domains.
@miq-bot
Copy link
Member

miq-bot commented Jun 30, 2014

Checked commit mkanoor@bb3167d with rubocop 0.21.0
21 files checked, 0 offenses detected
Everything looks good. 👍

@mkanoor
Copy link
Contributor Author

mkanoor commented Jun 30, 2014

@Fryguy @gmcculloug
Removed the before (:all) , trimmed the yaml files to only contain the relevant data. The data files are now split out.

@gmcculloug
Copy link
Member

@mkanoor Verified spec.

gmcculloug added a commit that referenced this pull request Jul 1, 2014
 Support for copy and compare of automate class, instance and methods
@gmcculloug gmcculloug merged commit 7505a09 into ManageIQ:master Jul 1, 2014
@mkanoor mkanoor deleted the automate_copy_compare branch July 7, 2014 21:01
simaishi pushed a commit that referenced this pull request May 25, 2017
Provisioning - First and Last names are not required.
(cherry picked from commit 67175793ffdefec56ae6ac4e7a91167a7828dd2d)

https://bugzilla.redhat.com/show_bug.cgi?id=1455686
simaishi pushed a commit that referenced this pull request Jun 9, 2017
Provisioning - First and Last names are not required.
(cherry picked from commit 67175793ffdefec56ae6ac4e7a91167a7828dd2d)

https://bugzilla.redhat.com/show_bug.cgi?id=1455685
simaishi pushed a commit that referenced this pull request Aug 16, 2017
…-found

Handle case where do_volume_creation_check gets a nil from Fog
(cherry picked from commit 752420bc07b2b4f606be119656e2eccc4b297374)

https://bugzilla.redhat.com/show_bug.cgi?id=1482170
d-m-u pushed a commit to d-m-u/manageiq that referenced this pull request Jun 6, 2018
…lume-not-found

Handle case where do_volume_creation_check gets a nil from Fog
(cherry picked from commit 752420bc07b2b4f606be119656e2eccc4b297374)

https://bugzilla.redhat.com/show_bug.cgi?id=1482170
d-m-u added a commit to d-m-u/manageiq that referenced this pull request Jun 29, 2020
more core ext's on 4.1.0

update for update sake

https://github.com/ManageIQ/more_core_extensions/compare/179bf40..e5b4501
 - Added Ruby 2.7 support [[ManageIQ#79](ManageIQ/more_core_extensions#79)]
 - Added Process#pause, Process#resume, and Process#alive? [[ManageIQ#73](ManageIQ/more_core_extensions#73)]

array added * `#compact_map` - Collect non-nil results from the block
array added `#tabular_sort` - Sorts an Array of Hashes by specific columns

hierarchy added `#descendant_get` - Returns the descendant with a given name

the two breaking changes:
- **BREAKING**: Moved Object#descendant_get to Class#descendant_get [[ManageIQ#75](ManageIQ/more_core_extensions#75)]
- **BREAKING**: Removed deprecated Enumerable#stable_sort_by [[ManageIQ#76](ManageIQ/more_core_extensions#76)]

a minor header output change was made that hasn't been released yet to make tableize more markdown compliant

see ManageIQ/linux_admin#221
d-m-u added a commit to d-m-u/manageiq that referenced this pull request Jul 14, 2020
more core ext's on 4.1.0

update for update sake

https://github.com/ManageIQ/more_core_extensions/compare/179bf40..e5b4501
 - Added Ruby 2.7 support [[ManageIQ#79](ManageIQ/more_core_extensions#79)]
 - Added Process#pause, Process#resume, and Process#alive? [[ManageIQ#73](ManageIQ/more_core_extensions#73)]

array added * `#compact_map` - Collect non-nil results from the block
array added `#tabular_sort` - Sorts an Array of Hashes by specific columns

hierarchy added `#descendant_get` - Returns the descendant with a given name

the two breaking changes:
- **BREAKING**: Moved Object#descendant_get to Class#descendant_get [[ManageIQ#75](ManageIQ/more_core_extensions#75)]
- **BREAKING**: Removed deprecated Enumerable#stable_sort_by [[ManageIQ#76](ManageIQ/more_core_extensions#76)]

a minor header output change was made that hasn't been released yet to make tableize more markdown compliant

see ManageIQ/linux_admin#221
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants