design summit - navigating the manageiq object model - brad ascar

25
Navigating the ManageIQ Object Model Brad Ascar Red Hat Field Product Manager - CloudForms

Upload: manageiq

Post on 30-Jun-2015

246 views

Category:

Technology


9 download

DESCRIPTION

Learn how the ManageIQ data and object models stack up. If you're trying to extend ManageIQ with customized applications, you will need to reference this talk. More more on ManageIQ, see http://manageiq.org/

TRANSCRIPT

Page 1: Design Summit - Navigating the ManageIQ Object Model - Brad Ascar

Navigating the ManageIQ

Object Model

Brad Ascar Red Hat

Field Product Manager - CloudForms

Page 2: Design Summit - Navigating the ManageIQ Object Model - Brad Ascar

Objects 1 Objects are items within Classes. Their instantiation become instances of the classes.

There are a number of objects available out of the box, as an example the virtual machines have information, that information is backed by schema that is all available from an object. In this example we have the name of the virtual machine. Name – Bob This is known as key value pair and is stored on the VM object. So we have an object called VM, it has a Key that is Name with a Value of Bob. Referencing values is done by Value = Object.key Our example would be value = vm.name The value variable would contain our value of “bob”

Page 3: Design Summit - Navigating the ManageIQ Object Model - Brad Ascar

Objects 2 Objects can contain simple key/value pairs as well as more complex data types, Examples Nested Arrays – You can have a value in one object that maybe an array of data not just a single value. Nested Hashes – You can have a value in one object that maybe a hash of data not just a single value. Arrays of Hashes – Yes even multiple hashes within arrays in a single value of an object can exist.

Page 4: Design Summit - Navigating the ManageIQ Object Model - Brad Ascar

Objects 3 Options ManageIQ uses hashes quite frequently and offers some helper methods to get to the data easily, these are known as option methods as the data is always stored in a key called “options”. There are two methods •  Get_option – object.get_option(:hash_key) •  Set_option – object.set_option(:hash_key, [value])

Page 5: Design Summit - Navigating the ManageIQ Object Model - Brad Ascar

Where are you? The thing about objects is that it is all relational…. What you are interacting with also has context. Where are you? •  Provisioning •  Acting off of a button on a press •  In a statemachine •  During policy enforcement

Page 6: Design Summit - Navigating the ManageIQ Object Model - Brad Ascar

What are the most common objects? That really depends on what you are doing, but the following objects or properties are referenced a lot during automation: •  VM or instance •  Provisioning object •  Providers •  TAGS,TAGS, and more TAGS

Page 7: Design Summit - Navigating the ManageIQ Object Model - Brad Ascar

Object Methods inspect Returns a string containing a list of attributes of the object. See the InspectMe method in Samples class inspect_all Returns all information for an object virtual_column_names Returns the objects virtual columns names virtual_columns_inspect Returns the objects virtual columns and values reload Returns to original object to prevent the internal object from being returned

Page 8: Design Summit - Navigating the ManageIQ Object Model - Brad Ascar

Object Methods model_suffix Returns objects suffix. For an object of type MiqAeServiceVmVmware, returns "Vmware" tagged_with?(category, name) Is the object tagged with the category and name specified? tags(category = nil) -- this means that category is an optional parameter, with a default of nil Returns the tags. tag_assign(tag) Assigns tag to the object, * except for the miq_provision object, which uses add_tag (category, tag _name)

Page 9: Design Summit - Navigating the ManageIQ Object Model - Brad Ascar

Object Methods 2 Every object also has its own methods! VM for example has; rebootGuest Reboots the guest operating system. reconfigured_hardware_value? Checks if hardware value has been reconfigured. refresh Refresh power states and relationships of the object. registered? Is the object registered? remove_all_snapshots Remove all of the objects snapshots. remove_from_disk Removes the object from disk. remove_from_vmdb Removes the object from the VMDB.

Page 10: Design Summit - Navigating the ManageIQ Object Model - Brad Ascar

Object Methods 3 The object also has nested objects and virtual columns you can access through to as follows; files Returns number of files on the object. group=(group) Sets objects group. guest_applications Returns objects Guest Application list. hardware Returns objects Hardware. host Returns objects Host.

Page 11: Design Summit - Navigating the ManageIQ Object Model - Brad Ascar

Relationship and access Accessing through to another object is easy, it done simply by Object.key.nested_object_key Example: Vm.host.name will return you the name of the host that the virtual machine resides on. This is the true power of ManageIQ, its ability to present all relationships not only visually in the UI but also through its Automation engine. Not matter where you are, you can find the relationships of that object and traverse forwards or backup, up or down to find the data you want. Sometimes though you may want to find something that has no relationship to the objects that are within your scope, here you can use vmdb search….. More on that later.

Page 12: Design Summit - Navigating the ManageIQ Object Model - Brad Ascar

Methods Available for Automation There is an entire document related to the various methods available for each object type in ManageIQ. It is the document with the clever name:

Methods Available for Automation Another place with data on the methods and properties is the document:

Lifecycle and Automation Guide These can really help you start to see the objects available and all of their methods.

Page 13: Design Summit - Navigating the ManageIQ Object Model - Brad Ascar

A lot of helper methods too On many of the major objects (like host and vm) you will also find helper methods. Helper methods get you to data quicker and returned in a way that is useful without having to do a lot of traversing through the data model. Think of them as helpers or shortcuts, use them when they are available.

Page 14: Design Summit - Navigating the ManageIQ Object Model - Brad Ascar

$EVM Root When an Automate method is launched, it has one global variable: $evm. The $evm variable allows the method to communicate back to ManageIQ Management Engine. The $evm.root is the root object in the workspace, it provides access to the data currently loaded in the ManageIQ Management Engine model. It uses the objects data to solve more complex problems by integrating with ManageIQ Management Engine methods.

Page 15: Design Summit - Navigating the ManageIQ Object Model - Brad Ascar

OK, so all of that is in the docs So lets go get our hands dirty Some tools and tips on how to see what’s really going on in automate and how can I get even more data.

Page 16: Design Summit - Navigating the ManageIQ Object Model - Brad Ascar

Dump $evm.root Example  of  code  in  the  InspectMe  method  in  the  System\Request  Namespace:    #########################  #  #  Method:  dumpRoot  #  Description:  Dump  Root  information  #  ##########################  def    dumpRoot  $evm  .log("info"  ,  "#{@log_prefix}  -­‐  Root:<$evm.root>  Begin  Attributes"  )  $evm  .root.attributes.sort.each  {  |  k,  v|  $evm  .log("info"  ,  "#{@log_prefix}  -­‐      Root:<$evm.root>  Attributes  -­‐  #{  k}:  #{  v}"  )}  $evm  .log("info"  ,  "#{@log_prefix}  -­‐  Root:<$evm.root>  End  Attributes"  )  $evm  .log("info"  ,  ""  )  end  

Page 17: Design Summit - Navigating the ManageIQ Object Model - Brad Ascar

Dump output <User-­‐Defined  Method>  InspectMe  -­‐  Root:<$evm.root>  Begin  Attributes  <User-­‐Defined  Method>  InspectMe  -­‐  Root:<$evm.root>  Attributes  -­‐  miq_server:  #<MiqAeMethodService::MiqAeServiceMiqServer:0x000000160a7970>  <User-­‐Defined  Method>  InspectMe  -­‐  Root:<$evm.root>  Attributes  -­‐  miq_server_id:  1000000000001  <User-­‐Defined  Method>  InspectMe  -­‐  Root:<$evm.root>  Attributes  -­‐  object_name:  Request  <User-­‐Defined  Method>  InspectMe  -­‐  Root:<$evm.root>  Attributes  -­‐  request:  InspectMe  <User-­‐Defined  Method>  InspectMe  -­‐  Root:<$evm.root>  Attributes  -­‐  user:  #<MiqAeMethodService::MiqAeServiceUser:0x000000160bb740>  <User-­‐Defined  Method>  InspectMe  -­‐  Root:<$evm.root>  Attributes  -­‐  user_id:  1000000000001  <User-­‐Defined  Method>  InspectMe  -­‐  Root:<$evm.root>  End  Attributes  

Page 18: Design Summit - Navigating the ManageIQ Object Model - Brad Ascar

A better look at the dump Begin  Attributes  Attributes  -­‐  miq_server:  #<MiqAeMethodService::MiqAeServiceMiqServer:0x000000160a7970>  Attributes  -­‐  miq_server_id:  1000000000001  Attributes  -­‐  object_name:  Request  Attributes  -­‐  request:  InspectMe  Attributes  -­‐  user:  #<MiqAeMethodService::MiqAeServiceUser:0x000000160bb740>  Attributes  -­‐  user_id:  1000000000001  End  Attributes  

Page 19: Design Summit - Navigating the ManageIQ Object Model - Brad Ascar

Demo InspectMe (built in) InspectMe can be called in many ways. I will show you how to do it from the Simulate within ManageIQ.

DEMO

Page 20: Design Summit - Navigating the ManageIQ Object Model - Brad Ascar

A better InspectMe One of the Senior Solution Architects (Kevin Morey) at Red Hat and original ManageIQ employee has created an enhanced version of InspectMe that does some nice things with formatting, etc. He has a new version and a bit of polishing up to do and will post on github. Keep an eye out on the ManageIQ.org website for a new post that will have that updated code soon.

Page 21: Design Summit - Navigating the ManageIQ Object Model - Brad Ascar

Demo InspectMe (Enhanced)

DEMO

Enhanced InspectMe

Page 22: Design Summit - Navigating the ManageIQ Object Model - Brad Ascar

ObjectWalker OK, now for a *whole* lot more information.

A Senior Architect at Red Hat in the UK (Peter

McGowan) has created an additional tool that does even more introspection of the model when you

data needs may be even greater.

https://github.com/pemcg/objectWalker

Page 23: Design Summit - Navigating the ManageIQ Object Model - Brad Ascar

Demo ObjectWalker

DEMO

ObjectWalker and ObjectWalkerReader

Page 24: Design Summit - Navigating the ManageIQ Object Model - Brad Ascar

Wrapping it up

Q&A

Page 25: Design Summit - Navigating the ManageIQ Object Model - Brad Ascar

Contact info Brad Ascar  Red Hat, Inc.  Field Product Manager Cloud Management Products BU  [email protected]