how to use cim and openlmi to manage your systemdevconf/openlmi-tools-0.5-2.fc18.noarch.rpm...
TRANSCRIPT
How to use CIM and OpenLMI to manageyour system
Red Hat Czech, Platform Engineering
Peter Hatina <[email protected]>
February 23, 2013
Outline
1 Basic theory
2 Installation and setup
3 GUI tool
4 CLI tools
5 Examples
Peter Hatina How to use CIM and OpenLMI to manage your system February 23, 2013 1/45
Section 1Basic theory
Basic theory
WBEM/CIMIntroduction
Web Based Enterprise Management (WBEM)Set of technologies to unify management of computingenvironments
Common Information Model (CIM)One of the WBEM standards: object model defining themanagement information for the system
Defined and maintained by the Distributed Management TaskForce (DMTF)Industry “standard” for managing devices, services and evenprocesses
Peter Hatina How to use CIM and OpenLMI to manage your system February 23, 2013 2/45
Basic theory
CIM
Consists of: Specification + SchemaSpecification defines a metamodel/infrastructureSchema defines the actual model
Classes: properties, methods, qualifiersProperties: defined data types and property attributes
scalars, arrays, enums, strings, dates, references,. . .
Methods: take IN and OUT argumentsQualifiers: characterize the elements (e.g. the "Key" qualifierdefining the key property), predefined qualifier data types
Peter Hatina How to use CIM and OpenLMI to manage your system February 23, 2013 3/45
Basic theory
Architecture
CIMOM
Managed system(s)
Pro
vid
er
CMPIinterface
Pro
vid
er
Pro
vid
er
Pro
vid
er
WBEM protocolHTTPS+CIM+XML
Client system
Language bindings: Python, Java, C/C++, ...
Custom script
Custom applmishell wbemcli
Peter Hatina How to use CIM and OpenLMI to manage your system February 23, 2013 4/45
Section 2Installation and setup
Installation and setup
Red Hat’s notebooks
For all the examples, you can use Red Hats’ ThinkpadsLogins (username/password)
common user – redhat: redhatprivileged user – root: redhat
Prepared virtual machine for examples: openlmi-usagesame login accountsstart VM:
sudo virsh start openlmi-usageor via virt-manager
in case of breakdown, restore VM from a snapshot:sudo qemu-img snapshot -a install/var/lib/libvirt/images/openlmi-usage-root.img
Peter Hatina How to use CIM and OpenLMI to manage your system February 23, 2013 5/45
Installation and setup Packages
Installation
Install necessary components on the prepared VM:
CIMOM and Providers (as root in VM)1 yum install -y tog-pegasus # CIMOM
2 systemctl enable tog-pegasus
3 systemctl start tog-pegasus
4 yum install -y openlmi-\* # providers
Installation order!In case of reversed installation order, you will have to registerproviders manually.openlmi-mof-register register [mof] [reg]
Peter Hatina How to use CIM and OpenLMI to manage your system February 23, 2013 6/45
Installation and setup Packages
Installation
Install necessary components on the prepared VM:
CIMOM and Providers (as root in VM)1 yum install -y tog-pegasus # CIMOM
2 systemctl enable tog-pegasus
3 systemctl start tog-pegasus
4 yum install -y openlmi-\* # providers
Installation order!In case of reversed installation order, you will have to registerproviders manually.openlmi-mof-register register [mof] [reg]
Peter Hatina How to use CIM and OpenLMI to manage your system February 23, 2013 6/45
Installation and setup Packages
Installation
Install necessary components on the prepared VM:
CIMOM and Providers (as root in VM)1 yum install -y tog-pegasus # CIMOM
2 systemctl enable tog-pegasus
3 systemctl start tog-pegasus
4 yum install -y openlmi-\* # providers
Installation order!In case of reversed installation order, you will have to registerproviders manually.openlmi-mof-register register [mof] [reg]
Peter Hatina How to use CIM and OpenLMI to manage your system February 23, 2013 6/45
Installation and setup Packages
Installation
Install necessary components on the prepared VM:
CIMOM and Providers (as root in VM)1 yum install -y tog-pegasus # CIMOM
2 systemctl enable tog-pegasus
3 systemctl start tog-pegasus
4 yum install -y openlmi-\* # providers
Installation order!In case of reversed installation order, you will have to registerproviders manually.openlmi-mof-register register [mof] [reg]
Peter Hatina How to use CIM and OpenLMI to manage your system February 23, 2013 6/45
Installation and setup Packages
Installation
Install necessary components on the prepared VM:
CIMOM and Providers (as root in VM)1 yum install -y tog-pegasus # CIMOM
2 systemctl enable tog-pegasus
3 systemctl start tog-pegasus
4 yum install -y openlmi-\* # providers
Installation order!In case of reversed installation order, you will have to registerproviders manually.openlmi-mof-register register [mof] [reg]
Peter Hatina How to use CIM and OpenLMI to manage your system February 23, 2013 6/45
Installation and setup Pegasus
Setup
Setup Pegasus (as root in VM)
1 Setup SELinux, if in enforcing mode:semanage permissive -a pegasus_t
2 Add some user redhat into pegasus group:usermod -a -G pegasus redhat
3 Setup firewalld for Apache, if necessary:firewall-cmd --zone=public --add-port=5989/tcp--permanent
Peter Hatina How to use CIM and OpenLMI to manage your system February 23, 2013 7/45
Installation and setup Pegasus
Setup
Setup Pegasus (as root in VM)
1 Setup SELinux, if in enforcing mode:semanage permissive -a pegasus_t
2 Add some user redhat into pegasus group:usermod -a -G pegasus redhat
3 Setup firewalld for Apache, if necessary:firewall-cmd --zone=public --add-port=5989/tcp--permanent
Peter Hatina How to use CIM and OpenLMI to manage your system February 23, 2013 7/45
Installation and setup Pegasus
Setup
Setup Pegasus (as root in VM)
1 Setup SELinux, if in enforcing mode:semanage permissive -a pegasus_t
2 Add some user redhat into pegasus group:usermod -a -G pegasus redhat
3 Setup firewalld for Apache, if necessary:firewall-cmd --zone=public --add-port=5989/tcp--permanent
Peter Hatina How to use CIM and OpenLMI to manage your system February 23, 2013 7/45
Section 3GUI tool
GUI tool YAWN
Yet Another WBEM Navigator
YAWN:Web-based CIM clientHandy tool for CIM classes, objects manipulationFine for browsing, not for automation . . .
Installation and setup in VM (as root)1 yum install -y httpd yawn
2 systemctl enable httpd
3 systemctl start httpd
4 setsebool -P httpd_can_network_connect 1
5 firewall-cmd –zone=public –add-port=80/tcp
Peter Hatina How to use CIM and OpenLMI to manage your system February 23, 2013 8/45
GUI tool YAWN
Yet Another WBEM Navigator
YAWN:Web-based CIM clientHandy tool for CIM classes, objects manipulationFine for browsing, not for automation . . .
Installation and setup in VM (as root)1 yum install -y httpd yawn
2 systemctl enable httpd
3 systemctl start httpd
4 setsebool -P httpd_can_network_connect 1
5 firewall-cmd –zone=public –add-port=80/tcp
Peter Hatina How to use CIM and OpenLMI to manage your system February 23, 2013 8/45
GUI tool YAWN
Yet Another WBEM Navigator
YAWN:Web-based CIM clientHandy tool for CIM classes, objects manipulationFine for browsing, not for automation . . .
Installation and setup in VM (as root)1 yum install -y httpd yawn
2 systemctl enable httpd
3 systemctl start httpd
4 setsebool -P httpd_can_network_connect 1
5 firewall-cmd –zone=public –add-port=80/tcp
Peter Hatina How to use CIM and OpenLMI to manage your system February 23, 2013 8/45
GUI tool YAWN
Yet Another WBEM Navigator
YAWN:Web-based CIM clientHandy tool for CIM classes, objects manipulationFine for browsing, not for automation . . .
Installation and setup in VM (as root)1 yum install -y httpd yawn
2 systemctl enable httpd
3 systemctl start httpd
4 setsebool -P httpd_can_network_connect 1
5 firewall-cmd –zone=public –add-port=80/tcp
Peter Hatina How to use CIM and OpenLMI to manage your system February 23, 2013 8/45
GUI tool YAWN
Yet Another WBEM Navigator
YAWN:Web-based CIM clientHandy tool for CIM classes, objects manipulationFine for browsing, not for automation . . .
Installation and setup in VM (as root)1 yum install -y httpd yawn
2 systemctl enable httpd
3 systemctl start httpd
4 setsebool -P httpd_can_network_connect 1
5 firewall-cmd –zone=public –add-port=80/tcp
Peter Hatina How to use CIM and OpenLMI to manage your system February 23, 2013 8/45
GUI tool YAWN
Yet Another WBEM Navigator
YAWN:Web-based CIM clientHandy tool for CIM classes, objects manipulationFine for browsing, not for automation . . .
Installation and setup in VM (as root)1 yum install -y httpd yawn
2 systemctl enable httpd
3 systemctl start httpd
4 setsebool -P httpd_can_network_connect 1
5 firewall-cmd –zone=public –add-port=80/tcp
Peter Hatina How to use CIM and OpenLMI to manage your system February 23, 2013 8/45
Section 4CLI tools
CLI tools OpenLMI-tools
OpenLMI-tools
OpenLMI-tools:http://git.fedorahosted.org/git/openlmi-tools.git
Set of example python scripts:lmiservicelmipowerlmiuserlmiip
lmishell
Peter Hatina How to use CIM and OpenLMI to manage your system February 23, 2013 9/45
CLI tools OpenLMI-tools
OpenLMI-tools
OpenLMI-tools:http://git.fedorahosted.org/git/openlmi-tools.git
Set of example python scripts:lmiservicelmipowerlmiuserlmiip
lmishell
Peter Hatina How to use CIM and OpenLMI to manage your system February 23, 2013 9/45
CLI tools LMIShell
LMIShellWhat it is
(Non) interactive python-based interpreterTool for easier work with CIM classes, objects, . . .Pywbem object wrapperAllows natural hierarchy members’ manipulationhttps://fedorahosted.org/openlmi/wiki/shell
_LmiNamespace
CIMClass
_LmiClass
CIMInstanceName
_LmiInstanceName
CIMInstance
_LmiInstance
...
OpenLMI Shell
Peter Hatina How to use CIM and OpenLMI to manage your system February 23, 2013 10/45
CLI tools LMIShell
LMIShellWhat it is
(Non) interactive python-based interpreterTool for easier work with CIM classes, objects, . . .Pywbem object wrapperAllows natural hierarchy members’ manipulationhttps://fedorahosted.org/openlmi/wiki/shell
_LmiNamespace
CIMClass
_LmiClass
CIMInstanceName
_LmiInstanceName
CIMInstance
_LmiInstance
...
OpenLMI Shell
Peter Hatina How to use CIM and OpenLMI to manage your system February 23, 2013 10/45
CLI tools LMIShell
LMIShellHierarchy
Connection root cimv2
interop
PG_InterOp
PG_Internal
Class
Class
Instance
Instance
Class Instance
Class Instance
Peter Hatina How to use CIM and OpenLMI to manage your system February 23, 2013 11/45
CLI tools LMIShell
LMIShellSetup
Installation (as root)yum install -y openlmi-tools
or
yum install -y http://phatina.fedorapeople.org/ \devconf/openlmi-tools-0.5-2.fc18.noarch.rpm
No additional steps required, just run the shell
Peter Hatina How to use CIM and OpenLMI to manage your system February 23, 2013 12/45
CLI tools LMIShell
LMIShellHow to use
Connect to CIMOM$ lmishell> c = connect("192.168.122.10", "redhat", "redhat")> c = connect("192.168.122.10", "redhat")password: <not echoed>
Connection object> c.hostnamehttps://192.168.122.10> c.namespaces[’root’]> c.print_namespaces()root
Peter Hatina How to use CIM and OpenLMI to manage your system February 23, 2013 13/45
CLI tools LMIShell
LMIShellHow to use
Connect to CIMOM$ lmishell> c = connect("192.168.122.10", "redhat", "redhat")> c = connect("192.168.122.10", "redhat")password: <not echoed>
Connection object> c.hostnamehttps://192.168.122.10> c.namespaces[’root’]> c.print_namespaces()root
Peter Hatina How to use CIM and OpenLMI to manage your system February 23, 2013 13/45
CLI tools LMIShell
LMIShellHow to use – Namespaces
Namespaces> root_namespace = c.root> cimv2_namespace = c.root.cimv2> PG_InterOp_namespace = c.root.PG_InterOp> PG_Internal_namespace = c.root.PG_Internal
cimv2 namespace> c.root.cimv2.classes()[ list of classes returned ]> c.root.cimv2.print_classes()> cimv2.wql(’select * from Class where condition’)> cimv2.cql(’...’)
Peter Hatina How to use CIM and OpenLMI to manage your system February 23, 2013 14/45
CLI tools LMIShell
LMIShellHow to use – Namespaces
Namespaces> root_namespace = c.root> cimv2_namespace = c.root.cimv2> PG_InterOp_namespace = c.root.PG_InterOp> PG_Internal_namespace = c.root.PG_Internal
cimv2 namespace> c.root.cimv2.classes()[ list of classes returned ]> c.root.cimv2.print_classes()> cimv2.wql(’select * from Class where condition’)> cimv2.cql(’...’)
Peter Hatina How to use CIM and OpenLMI to manage your system February 23, 2013 14/45
CLI tools LMIShell
LMIShellHow to use – Namespaces
Namespaces> root_namespace = c.root> cimv2_namespace = c.root.cimv2> PG_InterOp_namespace = c.root.PG_InterOp> PG_Internal_namespace = c.root.PG_Internal
cimv2 namespace> c.root.cimv2.classes()[ list of classes returned ]> c.root.cimv2.print_classes()> cimv2.wql(’select * from Class where condition’)> cimv2.cql(’...’)
Peter Hatina How to use CIM and OpenLMI to manage your system February 23, 2013 14/45
CLI tools LMIShell
LMIShellHow to use – Classes
How to get CIM classSimply by requesting an attribute of the namespace object> lmi_service_class = c.root.cimv2.LMI_Service
Useful methods/propertiessome_class.classname
some_class.namespace
some_class.methods()
some_class.properties()
some_class.print_methods()
some_class.print_properties()
some_class.doc()
Peter Hatina How to use CIM and OpenLMI to manage your system February 23, 2013 15/45
CLI tools LMIShell
LMIShellHow to use – Classes
How to get CIM classSimply by requesting an attribute of the namespace object> lmi_service_class = c.root.cimv2.LMI_Service
Useful methods/propertiessome_class.classname
some_class.namespace
some_class.methods()
some_class.properties()
some_class.print_methods()
some_class.print_properties()
some_class.doc()
Peter Hatina How to use CIM and OpenLMI to manage your system February 23, 2013 15/45
CLI tools LMIShell
LMIShellHow to use – Instances, part 1/3
How to get an instance(s)> instances = Class.instances(key="key", value="val")> instance = Class.first_instance()> instances = cimv2.wql(...)
Useful methods/properties
instance.classname instance.doc()instance.namespace instance.tomof()instance.path instance.push()instance.methods() instance.delete()instance.properties()
Peter Hatina How to use CIM and OpenLMI to manage your system February 23, 2013 16/45
CLI tools LMIShell
LMIShellHow to use – Instances, part 1/3
How to get an instance(s)> instances = Class.instances(key="key", value="val")> instance = Class.first_instance()> instances = cimv2.wql(...)
Useful methods/properties
instance.classname instance.doc()instance.namespace instance.tomof()instance.path instance.push()instance.methods() instance.delete()instance.properties()
Peter Hatina How to use CIM and OpenLMI to manage your system February 23, 2013 16/45
CLI tools LMIShell
LMIShellHow to use – Instances, part 2/3
How to get an object propertySimply by accessing the object’s attribute> attr = some_object.Property
How to set an object property> some_object.Property = new_value> some_object.push()
How to call an object’s methodEasily, call the method as if it was python’s object method> some_object.SomeMethod(Param1=value1, ...)
Peter Hatina How to use CIM and OpenLMI to manage your system February 23, 2013 17/45
CLI tools LMIShell
LMIShellHow to use – Instances, part 2/3
How to get an object propertySimply by accessing the object’s attribute> attr = some_object.Property
How to set an object property> some_object.Property = new_value> some_object.push()
How to call an object’s methodEasily, call the method as if it was python’s object method> some_object.SomeMethod(Param1=value1, ...)
Peter Hatina How to use CIM and OpenLMI to manage your system February 23, 2013 17/45
CLI tools LMIShell
LMIShellHow to use – Instances, part 2/3
How to get an object propertySimply by accessing the object’s attribute> attr = some_object.Property
How to set an object property> some_object.Property = new_value> some_object.push()
How to call an object’s methodEasily, call the method as if it was python’s object method> some_object.SomeMethod(Param1=value1, ...)
Peter Hatina How to use CIM and OpenLMI to manage your system February 23, 2013 17/45
CLI tools LMIShell
LMIShellHow to use – Instances, part 3/3
How to get associated objects within an object> assoc_objs = some_object.associators(AssocClass=
"AssociationClass", ResultClass="ResultClass",Role="Role", ResultRole="ResultRole")
> assoc_obj_names = some_object.associator_names()> assoc_obj = some_object.first_associator()*
How to get association objects> refs = some_object.references(ResultClass=
"ResultClass", Role="Role")> ref_names = some_object.reference_names()> ref = some_object.first_reference()> ref_name = some_object.first_reference_name()
Peter Hatina How to use CIM and OpenLMI to manage your system February 23, 2013 18/45
CLI tools LMIShell
LMIShellHow to use – Instances, part 3/3
How to get associated objects within an object> assoc_objs = some_object.associators(AssocClass=
"AssociationClass", ResultClass="ResultClass",Role="Role", ResultRole="ResultRole")
> assoc_obj_names = some_object.associator_names()> assoc_obj = some_object.first_associator()*
How to get association objects> refs = some_object.references(ResultClass=
"ResultClass", Role="Role")> ref_names = some_object.reference_names()> ref = some_object.first_reference()> ref_name = some_object.first_reference_name()
Peter Hatina How to use CIM and OpenLMI to manage your system February 23, 2013 18/45
CLI tools LMIShell
LMIShellInterface
Some useful featuresTab completionUses "display sugar" when calling CIM object methods> some_object.Method()http(s)://192.168.122.10: ok (0)> use_display_sugar(False)
By default, CIM exceptions are handled by shell> use_exceptions()
Uses history and reverse search as common shells> clear_history()
Peter Hatina How to use CIM and OpenLMI to manage your system February 23, 2013 19/45
Section 5Examples
Examples
Examples Outline
1 OS Statistics
2 Users accounts & groups
3 Power management
4 Networking
5 Storage
Peter Hatina How to use CIM and OpenLMI to manage your system February 23, 2013 20/45
Examples
Statistics
OS and CPU statistics> os = cimv2.Linux_OperatingSystem.first_instance()> os.VersionFedora release 18 (Spherical Cow)> os.Nameopenlmi-usage> os.NumberOfProcesses> cpu = cimv2.Linux_Processor.first_instance()> cpu.ElementNameQEMU Virtual CPU version 1.0.1> cpu.CurrentClockSpeed
Peter Hatina How to use CIM and OpenLMI to manage your system February 23, 2013 21/45
Examples
UsersHow to create an account
What we need:1 Linux_ComputerSystem2 LMI_AccountManagementService
Create the account> cs = cimv2.Linux_ComputerSystem.first_instance()> acc = cimv2.LMI_AccountManagementService \
.first_instance()> acc.CreateAccount(Name="newuser", System=cs)
Peter Hatina How to use CIM and OpenLMI to manage your system February 23, 2013 22/45
Examples
UsersHow to create an account
What we need:1 Linux_ComputerSystem2 LMI_AccountManagementService
Create the account> cs = cimv2.Linux_ComputerSystem.first_instance()> acc = cimv2.LMI_AccountManagementService \
.first_instance()> acc.CreateAccount(Name="newuser", System=cs)
Peter Hatina How to use CIM and OpenLMI to manage your system February 23, 2013 22/45
Examples
UsersHow to modify and delete an account
Change login shell> account.LoginShell = "/usr/bin/zsh"> account.push()
Delete account> account = cimv2.LMI_Account.first_instance(
value="newuser")> account.delete()
Peter Hatina How to use CIM and OpenLMI to manage your system February 23, 2013 23/45
Examples
UsersHow to modify and delete an account
Change login shell> account.LoginShell = "/usr/bin/zsh"> account.push()
Delete account> account = cimv2.LMI_Account.first_instance(
value="newuser")> account.delete()
Peter Hatina How to use CIM and OpenLMI to manage your system February 23, 2013 23/45
Examples
UsersHow to add an account to a group
What we need:1 LMI_MemberOfGroup2 LMI_Group3 LMI_Identity
Add specific user to the group> gr = cimv2.LMI_Group.first_instance(value="group")> id = cimv2.LMI_Identity.first_instance(
key="ElementName", value="user")> cimv2.LMI_MemberOfGroup.create_instance({
"Member" : id, "Collection" : gr})
Peter Hatina How to use CIM and OpenLMI to manage your system February 23, 2013 24/45
Examples
UsersHow to add an account to a group
What we need:1 LMI_MemberOfGroup2 LMI_Group3 LMI_Identity
Add specific user to the group> gr = cimv2.LMI_Group.first_instance(value="group")> id = cimv2.LMI_Identity.first_instance(
key="ElementName", value="user")> cimv2.LMI_MemberOfGroup.create_instance({
"Member" : id, "Collection" : gr})
Peter Hatina How to use CIM and OpenLMI to manage your system February 23, 2013 24/45
Examples
GroupsHow to create a group
What we need:1 Linux_ComputerSystem2 LMI_AccountManagementService
Create the group> cs = cimv2.Linux_ComputerSystem.first_instance()> acc = cimv2.LMI_AccountManagementService \
.first_instance()> acc.CreateGroup(Name="newgroup", System=cs)
Peter Hatina How to use CIM and OpenLMI to manage your system February 23, 2013 25/45
Examples
GroupsHow to create a group
What we need:1 Linux_ComputerSystem2 LMI_AccountManagementService
Create the group> cs = cimv2.Linux_ComputerSystem.first_instance()> acc = cimv2.LMI_AccountManagementService \
.first_instance()> acc.CreateGroup(Name="newgroup", System=cs)
Peter Hatina How to use CIM and OpenLMI to manage your system February 23, 2013 25/45
Examples
GroupsHow to delete a group
Delete the group> group = cimv2.LMI_Group.first_instance(
value="newgroup")> group.delete()
Peter Hatina How to use CIM and OpenLMI to manage your system February 23, 2013 26/45
Examples
Power managementHow to reboot the machine
What we need:1 LMI_PowerManagementService
Common power states:Suspend == 4Hibernate == 7Poweroff = 12Reboot == 15
Reboot the machine> pm = cimv2.LMI_PowerManagementService \
.first_instance()> pm.RequestPowerStateChange(PowerState = 15)
Peter Hatina How to use CIM and OpenLMI to manage your system February 23, 2013 27/45
Examples
Power managementHow to reboot the machine
What we need:1 LMI_PowerManagementService
Common power states:Suspend == 4Hibernate == 7Poweroff = 12Reboot == 15
Reboot the machine> pm = cimv2.LMI_PowerManagementService \
.first_instance()> pm.RequestPowerStateChange(PowerState = 15)
Peter Hatina How to use CIM and OpenLMI to manage your system February 23, 2013 27/45
Examples
NetworkingHow to list ethernet devices
What we need:1 LMI_EthernetPort
List ethernet devices> eths = cimv2.LMI_EthernetPort.instances()> for eth in eths:
print eth.DeviceID
Peter Hatina How to use CIM and OpenLMI to manage your system February 23, 2013 28/45
Examples
NetworkingHow to list ethernet devices
What we need:1 LMI_EthernetPort
List ethernet devices> eths = cimv2.LMI_EthernetPort.instances()> for eth in eths:
print eth.DeviceID
Peter Hatina How to use CIM and OpenLMI to manage your system February 23, 2013 28/45
Examples
NetworkingHow to list IP addresses
What we need:1 LMI_LANEndpoint2 LMI_IPProtocolEndpoint
List IP adddresses> lan_endpoint = cimv2.LMI_LANEndpoint.first_instance(
key="Name", value="eth1")> eth1_endpoints = lan_endpoint.associators(
ResultClass="LMI_IPProtocolEndpoint")> for i in eth1_endpoints:
if i.ProtocolIFType in (4096, 4098):print i.IPv4Address
if i.ProtocolIFType in (4097, 4098):print i.IPv6Address
Peter Hatina How to use CIM and OpenLMI to manage your system February 23, 2013 29/45
Examples
NetworkingHow to list IP addresses
What we need:1 LMI_LANEndpoint2 LMI_IPProtocolEndpoint
List IP adddresses> lan_endpoint = cimv2.LMI_LANEndpoint.first_instance(
key="Name", value="eth1")> eth1_endpoints = lan_endpoint.associators(
ResultClass="LMI_IPProtocolEndpoint")> for i in eth1_endpoints:
if i.ProtocolIFType in (4096, 4098):print i.IPv4Address
if i.ProtocolIFType in (4097, 4098):print i.IPv6Address
Peter Hatina How to use CIM and OpenLMI to manage your system February 23, 2013 29/45
Examples
StorageHow to list devices
What we need:1 LMI_StorageExtent
List the storage devices> storage_devs = cimv2.LMI_StorageExtent.instances()> for s in storage_devs:
print s.DeviceID
Peter Hatina How to use CIM and OpenLMI to manage your system February 23, 2013 30/45
Examples
StorageHow to list devices
What we need:1 LMI_StorageExtent
List the storage devices> storage_devs = cimv2.LMI_StorageExtent.instances()> for s in storage_devs:
print s.DeviceID
Peter Hatina How to use CIM and OpenLMI to manage your system February 23, 2013 30/45
Examples
StorageHow to list partitions within a device
What we need:1 LMI_StorageExtent2 LMI_PartitionBasedOn
List the partitions> dev = cimv2.LMI_StorageExtent.first_intance(
key="DeviceID", value="/dev/vda")> partitions = dev.references(ResultClass=
"LMI_PartitionBasedOn")> for p in partitions:
print p.Dependent["DeviceID"]
Peter Hatina How to use CIM and OpenLMI to manage your system February 23, 2013 31/45
Examples
StorageHow to list partitions within a device
What we need:1 LMI_StorageExtent2 LMI_PartitionBasedOn
List the partitions> dev = cimv2.LMI_StorageExtent.first_intance(
key="DeviceID", value="/dev/vda")> partitions = dev.references(ResultClass=
"LMI_PartitionBasedOn")> for p in partitions:
print p.Dependent["DeviceID"]
Peter Hatina How to use CIM and OpenLMI to manage your system February 23, 2013 31/45
Examples
StorageHow to create a partition table 1/2
What we need:1 LMI_StorageExtent2 LMI_DiskPartitionConfigurationCapabilities3 LMI_DiskPartitionConfigurationService
Create the partition table> dev = cimv2.LMI_StorageExtent.first_intance(
key="DeviceID", value="/dev/sda")> style = cimv2.LMI_DiskPartitionConfiguration \
Capabilities.first_instance(key="InstanceID"value="LMI:LMI_DiskPartitionConfiguration \Capabilities:MBR")
Peter Hatina How to use CIM and OpenLMI to manage your system February 23, 2013 32/45
Examples
StorageHow to create a partition table 1/2
What we need:1 LMI_StorageExtent2 LMI_DiskPartitionConfigurationCapabilities3 LMI_DiskPartitionConfigurationService
Create the partition table> dev = cimv2.LMI_StorageExtent.first_intance(
key="DeviceID", value="/dev/sda")> style = cimv2.LMI_DiskPartitionConfiguration \
Capabilities.first_instance(key="InstanceID"value="LMI:LMI_DiskPartitionConfiguration \Capabilities:MBR")
Peter Hatina How to use CIM and OpenLMI to manage your system February 23, 2013 32/45
Examples
StorageHow to create a partition table 2/2
Create partition table – continue> ps = cimv2.LMI_DiskPartitionConfigurationService \
.first_instance()> ps.SetPartitionStyle(Extent=dev,
PartitionStyle=style)
Peter Hatina How to use CIM and OpenLMI to manage your system February 23, 2013 33/45
Examples
StorageHow to create a partition
What we need:1 LMI_StorageExtent2 LMI_DiskPartitionConfigurationService
Create the partition> dev = cimv2.LMI_StorageExtent.first_intance(
key="DeviceID", value="/dev/sda")> ps = cimv2.LMI_DiskPartitionConfigurationService \
.first_instance()> ps.LMI_CreateOrModifyPartition(Extent=dev,
Size = 500 * 1024 * 1024)
Peter Hatina How to use CIM and OpenLMI to manage your system February 23, 2013 34/45
Examples
StorageHow to create a partition
What we need:1 LMI_StorageExtent2 LMI_DiskPartitionConfigurationService
Create the partition> dev = cimv2.LMI_StorageExtent.first_intance(
key="DeviceID", value="/dev/sda")> ps = cimv2.LMI_DiskPartitionConfigurationService \
.first_instance()> ps.LMI_CreateOrModifyPartition(Extent=dev,
Size = 500 * 1024 * 1024)
Peter Hatina How to use CIM and OpenLMI to manage your system February 23, 2013 34/45
Examples
StorageHow to delete a partition
What we need:1 LMI_DiskPartition
Delete the partition> partition = cimv2.LMI_DiskPartition.first_instance(
key="DeviceID", value="/dev/sda1")> partition.delete()
Peter Hatina How to use CIM and OpenLMI to manage your system February 23, 2013 35/45
Examples
StorageHow to delete a partition
What we need:1 LMI_DiskPartition
Delete the partition> partition = cimv2.LMI_DiskPartition.first_instance(
key="DeviceID", value="/dev/sda1")> partition.delete()
Peter Hatina How to use CIM and OpenLMI to manage your system February 23, 2013 35/45
Examples
StorageHow to create a volume group
What we need:1 LMI_StorageExtent2 LMI_StorageCofigurationService
Create the volume group> dev1 = cimv2.LMI_StorageExtent.first_intance(
key="DeviceID", value="/dev/sda")> dev2 = cimv2.LMI_StorageExtent.first_intance(
key="DeviceID", value="/dev/sdb")> ss = cimv2.LMI_StorageConfigurationService \
.first_instance()> ss.CreateOrModifyVG(ElementName="volgroup",
InExtents=[dev1, dev2])
Peter Hatina How to use CIM and OpenLMI to manage your system February 23, 2013 36/45
Examples
StorageHow to create a volume group
What we need:1 LMI_StorageExtent2 LMI_StorageCofigurationService
Create the volume group> dev1 = cimv2.LMI_StorageExtent.first_intance(
key="DeviceID", value="/dev/sda")> dev2 = cimv2.LMI_StorageExtent.first_intance(
key="DeviceID", value="/dev/sdb")> ss = cimv2.LMI_StorageConfigurationService \
.first_instance()> ss.CreateOrModifyVG(ElementName="volgroup",
InExtents=[dev1, dev2])
Peter Hatina How to use CIM and OpenLMI to manage your system February 23, 2013 36/45
Examples
StorageHow to create a logical volume
What we need:1 LMI_VGStoragePool2 LMI_StorageConfigurationService
Create the logical volume> volgr = cimv2.LMI_VGStoragePool.first_instance(
key="ElementName", value="volgroup")> ss = cimv2.LMI_StorageConfigurationService \
.first_instance()> ss.CreateOfModifyLV(ElementName="logvol"
InPool=volgr, Size = 500 * 1024 * 1024)
Peter Hatina How to use CIM and OpenLMI to manage your system February 23, 2013 37/45
Examples
StorageHow to create a logical volume
What we need:1 LMI_VGStoragePool2 LMI_StorageConfigurationService
Create the logical volume> volgr = cimv2.LMI_VGStoragePool.first_instance(
key="ElementName", value="volgroup")> ss = cimv2.LMI_StorageConfigurationService \
.first_instance()> ss.CreateOfModifyLV(ElementName="logvol"
InPool=volgr, Size = 500 * 1024 * 1024)
Peter Hatina How to use CIM and OpenLMI to manage your system February 23, 2013 37/45
Examples
StorageHow to list physical volumes of some volume group
What we need:1 LMI_VGStoragePool2 LMI_VGAssociatedComponentExtent
List the physical volumes> volgr = cimv2.LMI_VGStoragePool.first_instance(
key="ElementName", value="volgroup")> pvs_names = volgr.associator_names(
AssocClass="LMI_VGAssociatedComponentExtent")> for pv_name in pvs_names:
print pv_name.to_instance().DeviceID
Peter Hatina How to use CIM and OpenLMI to manage your system February 23, 2013 38/45
Examples
StorageHow to list physical volumes of some volume group
What we need:1 LMI_VGStoragePool2 LMI_VGAssociatedComponentExtent
List the physical volumes> volgr = cimv2.LMI_VGStoragePool.first_instance(
key="ElementName", value="volgroup")> pvs_names = volgr.associator_names(
AssocClass="LMI_VGAssociatedComponentExtent")> for pv_name in pvs_names:
print pv_name.to_instance().DeviceID
Peter Hatina How to use CIM and OpenLMI to manage your system February 23, 2013 38/45
Examples
StorageHow to list volume groups
What we need:1 LMI_VGStoragePool
List the volume groups> vol_groups = cimv2.LMI_VGStoragePool.instances()> for vol_gr in vol_groups:
print vol_gr.ElementName
Peter Hatina How to use CIM and OpenLMI to manage your system February 23, 2013 39/45
Examples
StorageHow to list volume groups
What we need:1 LMI_VGStoragePool
List the volume groups> vol_groups = cimv2.LMI_VGStoragePool.instances()> for vol_gr in vol_groups:
print vol_gr.ElementName
Peter Hatina How to use CIM and OpenLMI to manage your system February 23, 2013 39/45
Examples
StorageHow to list logical volumes
What we need:1 LMI_LVStorageExtent
List the logical volumes> log_volumes = cimv2.LMI_LVStorageExtent.instances()> for log_vol in log_volumes:
print log_vol.ElementName
Peter Hatina How to use CIM and OpenLMI to manage your system February 23, 2013 40/45
Examples
StorageHow to list logical volumes
What we need:1 LMI_LVStorageExtent
List the logical volumes> log_volumes = cimv2.LMI_LVStorageExtent.instances()> for log_vol in log_volumes:
print log_vol.ElementName
Peter Hatina How to use CIM and OpenLMI to manage your system February 23, 2013 40/45
Examples
StorageHow to delete a logical volume
What we need:1 LMI_LVStorageExtent
Delete the logical volume> logvol = cimv2.LMI_LVStorageExtent.first_instance(
key="ElementName", value="logvol")> logvol.delete()
Peter Hatina How to use CIM and OpenLMI to manage your system February 23, 2013 41/45
Examples
StorageHow to delete a logical volume
What we need:1 LMI_LVStorageExtent
Delete the logical volume> logvol = cimv2.LMI_LVStorageExtent.first_instance(
key="ElementName", value="logvol")> logvol.delete()
Peter Hatina How to use CIM and OpenLMI to manage your system February 23, 2013 41/45
Examples
StorageHow to delete a volume group
What we need:1 LMI_VGStoragePool
Delete the volume group> volgr = cimv2.LMI_VGStoragePool.first_intance(
key="ElementName", value="volgroup")> volgr.delete()
Peter Hatina How to use CIM and OpenLMI to manage your system February 23, 2013 42/45
Examples
StorageHow to delete a volume group
What we need:1 LMI_VGStoragePool
Delete the volume group> volgr = cimv2.LMI_VGStoragePool.first_intance(
key="ElementName", value="volgroup")> volgr.delete()
Peter Hatina How to use CIM and OpenLMI to manage your system February 23, 2013 42/45
Examples
StorageHow to create a RAID
What we need:1 LMI_StorageExtent2 LMI_StorageConfigurationService
Create the RAID 1> dev1 = cimv2.CIM_StorageExtent.first_instance(
key="DeviceID", value="/dev/sda1")> dev2 = cimv2.CIM_StorageExtent.first_instance(
key="DeviceID", value="/dev/sdb1")> ss = cimv2.LMI_StorageConfigurationService \
.first_instance()> ss.CreateOrModifyMDRAID(ElementName="mirror",
InExtents=[dev1, dev2], Level=1)
Peter Hatina How to use CIM and OpenLMI to manage your system February 23, 2013 43/45
Examples
StorageHow to create a RAID
What we need:1 LMI_StorageExtent2 LMI_StorageConfigurationService
Create the RAID 1> dev1 = cimv2.CIM_StorageExtent.first_instance(
key="DeviceID", value="/dev/sda1")> dev2 = cimv2.CIM_StorageExtent.first_instance(
key="DeviceID", value="/dev/sdb1")> ss = cimv2.LMI_StorageConfigurationService \
.first_instance()> ss.CreateOrModifyMDRAID(ElementName="mirror",
InExtents=[dev1, dev2], Level=1)
Peter Hatina How to use CIM and OpenLMI to manage your system February 23, 2013 43/45
Examples
StorageHow to list RAID devices
What we need:1 LMI_MDRAIDStorageExtent2 LMI_MDRAIDBasedOn
List the RAID devices> raid = cimv2.LMI_MDRAIDStorageExtent.first_instance(
key="ElementName", value="mirror")> dev_names = raid.associator_names(
AssocClass="LMI_MDRAIDBasedOn")> for dev_name in dev_names:
print dev_name.to_instance().DeviceID
Peter Hatina How to use CIM and OpenLMI to manage your system February 23, 2013 44/45
Examples
StorageHow to list RAID devices
What we need:1 LMI_MDRAIDStorageExtent2 LMI_MDRAIDBasedOn
List the RAID devices> raid = cimv2.LMI_MDRAIDStorageExtent.first_instance(
key="ElementName", value="mirror")> dev_names = raid.associator_names(
AssocClass="LMI_MDRAIDBasedOn")> for dev_name in dev_names:
print dev_name.to_instance().DeviceID
Peter Hatina How to use CIM and OpenLMI to manage your system February 23, 2013 44/45
Examples
StorageHow to delete a RAID
What we need:1 LMI_MDRAIDStorageExtent
Delete the RAID> raid = cimv2.LMI_MDRAIDStorageExtent.first_instance(
key="ElementName", value="mirror")> raid.delete()
Peter Hatina How to use CIM and OpenLMI to manage your system February 23, 2013 45/45
Examples
StorageHow to delete a RAID
What we need:1 LMI_MDRAIDStorageExtent
Delete the RAID> raid = cimv2.LMI_MDRAIDStorageExtent.first_instance(
key="ElementName", value="mirror")> raid.delete()
Peter Hatina How to use CIM and OpenLMI to manage your system February 23, 2013 45/45
The end.Questions?