how to use cim and openlmi to manage your systemdevconf/openlmi-tools-0.5-2.fc18.noarch.rpm...

95
How to use CIM and OpenLMI to manage your system Red Hat Czech, Platform Engineering Peter Hatina <[email protected]> February 23, 2013

Upload: others

Post on 10-Oct-2020

0 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: How to use CIM and OpenLMI to manage your systemdevconf/openlmi-tools-0.5-2.fc18.noarch.rpm Noadditionalstepsrequired,justruntheshell Peter Hatina How to use CIM and OpenLMI to manage

How to use CIM and OpenLMI to manageyour system

Red Hat Czech, Platform Engineering

Peter Hatina <[email protected]>

February 23, 2013

Page 2: How to use CIM and OpenLMI to manage your systemdevconf/openlmi-tools-0.5-2.fc18.noarch.rpm Noadditionalstepsrequired,justruntheshell Peter Hatina How to use CIM and OpenLMI to manage

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

Page 3: How to use CIM and OpenLMI to manage your systemdevconf/openlmi-tools-0.5-2.fc18.noarch.rpm Noadditionalstepsrequired,justruntheshell Peter Hatina How to use CIM and OpenLMI to manage

Section 1Basic theory

Page 4: How to use CIM and OpenLMI to manage your systemdevconf/openlmi-tools-0.5-2.fc18.noarch.rpm Noadditionalstepsrequired,justruntheshell Peter Hatina How to use CIM and OpenLMI to manage

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

Page 5: How to use CIM and OpenLMI to manage your systemdevconf/openlmi-tools-0.5-2.fc18.noarch.rpm Noadditionalstepsrequired,justruntheshell Peter Hatina How to use CIM and OpenLMI to manage

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

Page 6: How to use CIM and OpenLMI to manage your systemdevconf/openlmi-tools-0.5-2.fc18.noarch.rpm Noadditionalstepsrequired,justruntheshell Peter Hatina How to use CIM and OpenLMI to manage

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

Page 7: How to use CIM and OpenLMI to manage your systemdevconf/openlmi-tools-0.5-2.fc18.noarch.rpm Noadditionalstepsrequired,justruntheshell Peter Hatina How to use CIM and OpenLMI to manage

Section 2Installation and setup

Page 8: How to use CIM and OpenLMI to manage your systemdevconf/openlmi-tools-0.5-2.fc18.noarch.rpm Noadditionalstepsrequired,justruntheshell Peter Hatina How to use CIM and OpenLMI to manage

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

Page 9: How to use CIM and OpenLMI to manage your systemdevconf/openlmi-tools-0.5-2.fc18.noarch.rpm Noadditionalstepsrequired,justruntheshell Peter Hatina How to use CIM and OpenLMI to manage

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

Page 10: How to use CIM and OpenLMI to manage your systemdevconf/openlmi-tools-0.5-2.fc18.noarch.rpm Noadditionalstepsrequired,justruntheshell Peter Hatina How to use CIM and OpenLMI to manage

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

Page 11: How to use CIM and OpenLMI to manage your systemdevconf/openlmi-tools-0.5-2.fc18.noarch.rpm Noadditionalstepsrequired,justruntheshell Peter Hatina How to use CIM and OpenLMI to manage

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

Page 12: How to use CIM and OpenLMI to manage your systemdevconf/openlmi-tools-0.5-2.fc18.noarch.rpm Noadditionalstepsrequired,justruntheshell Peter Hatina How to use CIM and OpenLMI to manage

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

Page 13: How to use CIM and OpenLMI to manage your systemdevconf/openlmi-tools-0.5-2.fc18.noarch.rpm Noadditionalstepsrequired,justruntheshell Peter Hatina How to use CIM and OpenLMI to manage

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

Page 14: How to use CIM and OpenLMI to manage your systemdevconf/openlmi-tools-0.5-2.fc18.noarch.rpm Noadditionalstepsrequired,justruntheshell Peter Hatina How to use CIM and OpenLMI to manage

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

Page 15: How to use CIM and OpenLMI to manage your systemdevconf/openlmi-tools-0.5-2.fc18.noarch.rpm Noadditionalstepsrequired,justruntheshell Peter Hatina How to use CIM and OpenLMI to manage

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

Page 16: How to use CIM and OpenLMI to manage your systemdevconf/openlmi-tools-0.5-2.fc18.noarch.rpm Noadditionalstepsrequired,justruntheshell Peter Hatina How to use CIM and OpenLMI to manage

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

Page 17: How to use CIM and OpenLMI to manage your systemdevconf/openlmi-tools-0.5-2.fc18.noarch.rpm Noadditionalstepsrequired,justruntheshell Peter Hatina How to use CIM and OpenLMI to manage

Section 3GUI tool

Page 18: How to use CIM and OpenLMI to manage your systemdevconf/openlmi-tools-0.5-2.fc18.noarch.rpm Noadditionalstepsrequired,justruntheshell Peter Hatina How to use CIM and OpenLMI to manage

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

Page 19: How to use CIM and OpenLMI to manage your systemdevconf/openlmi-tools-0.5-2.fc18.noarch.rpm Noadditionalstepsrequired,justruntheshell Peter Hatina How to use CIM and OpenLMI to manage

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

Page 20: How to use CIM and OpenLMI to manage your systemdevconf/openlmi-tools-0.5-2.fc18.noarch.rpm Noadditionalstepsrequired,justruntheshell Peter Hatina How to use CIM and OpenLMI to manage

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

Page 21: How to use CIM and OpenLMI to manage your systemdevconf/openlmi-tools-0.5-2.fc18.noarch.rpm Noadditionalstepsrequired,justruntheshell Peter Hatina How to use CIM and OpenLMI to manage

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

Page 22: How to use CIM and OpenLMI to manage your systemdevconf/openlmi-tools-0.5-2.fc18.noarch.rpm Noadditionalstepsrequired,justruntheshell Peter Hatina How to use CIM and OpenLMI to manage

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

Page 23: How to use CIM and OpenLMI to manage your systemdevconf/openlmi-tools-0.5-2.fc18.noarch.rpm Noadditionalstepsrequired,justruntheshell Peter Hatina How to use CIM and OpenLMI to manage

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

Page 24: How to use CIM and OpenLMI to manage your systemdevconf/openlmi-tools-0.5-2.fc18.noarch.rpm Noadditionalstepsrequired,justruntheshell Peter Hatina How to use CIM and OpenLMI to manage

Section 4CLI tools

Page 25: How to use CIM and OpenLMI to manage your systemdevconf/openlmi-tools-0.5-2.fc18.noarch.rpm Noadditionalstepsrequired,justruntheshell Peter Hatina How to use CIM and OpenLMI to manage

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

Page 26: How to use CIM and OpenLMI to manage your systemdevconf/openlmi-tools-0.5-2.fc18.noarch.rpm Noadditionalstepsrequired,justruntheshell Peter Hatina How to use CIM and OpenLMI to manage

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

Page 27: How to use CIM and OpenLMI to manage your systemdevconf/openlmi-tools-0.5-2.fc18.noarch.rpm Noadditionalstepsrequired,justruntheshell Peter Hatina How to use CIM and OpenLMI to manage

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

Page 28: How to use CIM and OpenLMI to manage your systemdevconf/openlmi-tools-0.5-2.fc18.noarch.rpm Noadditionalstepsrequired,justruntheshell Peter Hatina How to use CIM and OpenLMI to manage

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

Page 29: How to use CIM and OpenLMI to manage your systemdevconf/openlmi-tools-0.5-2.fc18.noarch.rpm Noadditionalstepsrequired,justruntheshell Peter Hatina How to use CIM and OpenLMI to manage

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

Page 30: How to use CIM and OpenLMI to manage your systemdevconf/openlmi-tools-0.5-2.fc18.noarch.rpm Noadditionalstepsrequired,justruntheshell Peter Hatina How to use CIM and OpenLMI to manage

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

Page 31: How to use CIM and OpenLMI to manage your systemdevconf/openlmi-tools-0.5-2.fc18.noarch.rpm Noadditionalstepsrequired,justruntheshell Peter Hatina How to use CIM and OpenLMI to manage

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

Page 32: How to use CIM and OpenLMI to manage your systemdevconf/openlmi-tools-0.5-2.fc18.noarch.rpm Noadditionalstepsrequired,justruntheshell Peter Hatina How to use CIM and OpenLMI to manage

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

Page 33: How to use CIM and OpenLMI to manage your systemdevconf/openlmi-tools-0.5-2.fc18.noarch.rpm Noadditionalstepsrequired,justruntheshell Peter Hatina How to use CIM and OpenLMI to manage

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

Page 34: How to use CIM and OpenLMI to manage your systemdevconf/openlmi-tools-0.5-2.fc18.noarch.rpm Noadditionalstepsrequired,justruntheshell Peter Hatina How to use CIM and OpenLMI to manage

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

Page 35: How to use CIM and OpenLMI to manage your systemdevconf/openlmi-tools-0.5-2.fc18.noarch.rpm Noadditionalstepsrequired,justruntheshell Peter Hatina How to use CIM and OpenLMI to manage

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

Page 36: How to use CIM and OpenLMI to manage your systemdevconf/openlmi-tools-0.5-2.fc18.noarch.rpm Noadditionalstepsrequired,justruntheshell Peter Hatina How to use CIM and OpenLMI to manage

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

Page 37: How to use CIM and OpenLMI to manage your systemdevconf/openlmi-tools-0.5-2.fc18.noarch.rpm Noadditionalstepsrequired,justruntheshell Peter Hatina How to use CIM and OpenLMI to manage

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

Page 38: How to use CIM and OpenLMI to manage your systemdevconf/openlmi-tools-0.5-2.fc18.noarch.rpm Noadditionalstepsrequired,justruntheshell Peter Hatina How to use CIM and OpenLMI to manage

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

Page 39: How to use CIM and OpenLMI to manage your systemdevconf/openlmi-tools-0.5-2.fc18.noarch.rpm Noadditionalstepsrequired,justruntheshell Peter Hatina How to use CIM and OpenLMI to manage

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

Page 40: How to use CIM and OpenLMI to manage your systemdevconf/openlmi-tools-0.5-2.fc18.noarch.rpm Noadditionalstepsrequired,justruntheshell Peter Hatina How to use CIM and OpenLMI to manage

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

Page 41: How to use CIM and OpenLMI to manage your systemdevconf/openlmi-tools-0.5-2.fc18.noarch.rpm Noadditionalstepsrequired,justruntheshell Peter Hatina How to use CIM and OpenLMI to manage

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

Page 42: How to use CIM and OpenLMI to manage your systemdevconf/openlmi-tools-0.5-2.fc18.noarch.rpm Noadditionalstepsrequired,justruntheshell Peter Hatina How to use CIM and OpenLMI to manage

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

Page 43: How to use CIM and OpenLMI to manage your systemdevconf/openlmi-tools-0.5-2.fc18.noarch.rpm Noadditionalstepsrequired,justruntheshell Peter Hatina How to use CIM and OpenLMI to manage

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

Page 44: How to use CIM and OpenLMI to manage your systemdevconf/openlmi-tools-0.5-2.fc18.noarch.rpm Noadditionalstepsrequired,justruntheshell Peter Hatina How to use CIM and OpenLMI to manage

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

Page 45: How to use CIM and OpenLMI to manage your systemdevconf/openlmi-tools-0.5-2.fc18.noarch.rpm Noadditionalstepsrequired,justruntheshell Peter Hatina How to use CIM and OpenLMI to manage

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

Page 46: How to use CIM and OpenLMI to manage your systemdevconf/openlmi-tools-0.5-2.fc18.noarch.rpm Noadditionalstepsrequired,justruntheshell Peter Hatina How to use CIM and OpenLMI to manage

Section 5Examples

Page 47: How to use CIM and OpenLMI to manage your systemdevconf/openlmi-tools-0.5-2.fc18.noarch.rpm Noadditionalstepsrequired,justruntheshell Peter Hatina How to use CIM and OpenLMI to manage

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

Page 48: How to use CIM and OpenLMI to manage your systemdevconf/openlmi-tools-0.5-2.fc18.noarch.rpm Noadditionalstepsrequired,justruntheshell Peter Hatina How to use CIM and OpenLMI to manage

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

Page 49: How to use CIM and OpenLMI to manage your systemdevconf/openlmi-tools-0.5-2.fc18.noarch.rpm Noadditionalstepsrequired,justruntheshell Peter Hatina How to use CIM and OpenLMI to manage

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

Page 50: How to use CIM and OpenLMI to manage your systemdevconf/openlmi-tools-0.5-2.fc18.noarch.rpm Noadditionalstepsrequired,justruntheshell Peter Hatina How to use CIM and OpenLMI to manage

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

Page 51: How to use CIM and OpenLMI to manage your systemdevconf/openlmi-tools-0.5-2.fc18.noarch.rpm Noadditionalstepsrequired,justruntheshell Peter Hatina How to use CIM and OpenLMI to manage

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

Page 52: How to use CIM and OpenLMI to manage your systemdevconf/openlmi-tools-0.5-2.fc18.noarch.rpm Noadditionalstepsrequired,justruntheshell Peter Hatina How to use CIM and OpenLMI to manage

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

Page 53: How to use CIM and OpenLMI to manage your systemdevconf/openlmi-tools-0.5-2.fc18.noarch.rpm Noadditionalstepsrequired,justruntheshell Peter Hatina How to use CIM and OpenLMI to manage

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

Page 54: How to use CIM and OpenLMI to manage your systemdevconf/openlmi-tools-0.5-2.fc18.noarch.rpm Noadditionalstepsrequired,justruntheshell Peter Hatina How to use CIM and OpenLMI to manage

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

Page 55: How to use CIM and OpenLMI to manage your systemdevconf/openlmi-tools-0.5-2.fc18.noarch.rpm Noadditionalstepsrequired,justruntheshell Peter Hatina How to use CIM and OpenLMI to manage

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

Page 56: How to use CIM and OpenLMI to manage your systemdevconf/openlmi-tools-0.5-2.fc18.noarch.rpm Noadditionalstepsrequired,justruntheshell Peter Hatina How to use CIM and OpenLMI to manage

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

Page 57: How to use CIM and OpenLMI to manage your systemdevconf/openlmi-tools-0.5-2.fc18.noarch.rpm Noadditionalstepsrequired,justruntheshell Peter Hatina How to use CIM and OpenLMI to manage

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

Page 58: How to use CIM and OpenLMI to manage your systemdevconf/openlmi-tools-0.5-2.fc18.noarch.rpm Noadditionalstepsrequired,justruntheshell Peter Hatina How to use CIM and OpenLMI to manage

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

Page 59: How to use CIM and OpenLMI to manage your systemdevconf/openlmi-tools-0.5-2.fc18.noarch.rpm Noadditionalstepsrequired,justruntheshell Peter Hatina How to use CIM and OpenLMI to manage

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

Page 60: How to use CIM and OpenLMI to manage your systemdevconf/openlmi-tools-0.5-2.fc18.noarch.rpm Noadditionalstepsrequired,justruntheshell Peter Hatina How to use CIM and OpenLMI to manage

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

Page 61: How to use CIM and OpenLMI to manage your systemdevconf/openlmi-tools-0.5-2.fc18.noarch.rpm Noadditionalstepsrequired,justruntheshell Peter Hatina How to use CIM and OpenLMI to manage

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

Page 62: How to use CIM and OpenLMI to manage your systemdevconf/openlmi-tools-0.5-2.fc18.noarch.rpm Noadditionalstepsrequired,justruntheshell Peter Hatina How to use CIM and OpenLMI to manage

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

Page 63: How to use CIM and OpenLMI to manage your systemdevconf/openlmi-tools-0.5-2.fc18.noarch.rpm Noadditionalstepsrequired,justruntheshell Peter Hatina How to use CIM and OpenLMI to manage

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

Page 64: How to use CIM and OpenLMI to manage your systemdevconf/openlmi-tools-0.5-2.fc18.noarch.rpm Noadditionalstepsrequired,justruntheshell Peter Hatina How to use CIM and OpenLMI to manage

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

Page 65: How to use CIM and OpenLMI to manage your systemdevconf/openlmi-tools-0.5-2.fc18.noarch.rpm Noadditionalstepsrequired,justruntheshell Peter Hatina How to use CIM and OpenLMI to manage

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

Page 66: How to use CIM and OpenLMI to manage your systemdevconf/openlmi-tools-0.5-2.fc18.noarch.rpm Noadditionalstepsrequired,justruntheshell Peter Hatina How to use CIM and OpenLMI to manage

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

Page 67: How to use CIM and OpenLMI to manage your systemdevconf/openlmi-tools-0.5-2.fc18.noarch.rpm Noadditionalstepsrequired,justruntheshell Peter Hatina How to use CIM and OpenLMI to manage

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

Page 68: How to use CIM and OpenLMI to manage your systemdevconf/openlmi-tools-0.5-2.fc18.noarch.rpm Noadditionalstepsrequired,justruntheshell Peter Hatina How to use CIM and OpenLMI to manage

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

Page 69: How to use CIM and OpenLMI to manage your systemdevconf/openlmi-tools-0.5-2.fc18.noarch.rpm Noadditionalstepsrequired,justruntheshell Peter Hatina How to use CIM and OpenLMI to manage

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

Page 70: How to use CIM and OpenLMI to manage your systemdevconf/openlmi-tools-0.5-2.fc18.noarch.rpm Noadditionalstepsrequired,justruntheshell Peter Hatina How to use CIM and OpenLMI to manage

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

Page 71: How to use CIM and OpenLMI to manage your systemdevconf/openlmi-tools-0.5-2.fc18.noarch.rpm Noadditionalstepsrequired,justruntheshell Peter Hatina How to use CIM and OpenLMI to manage

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

Page 72: How to use CIM and OpenLMI to manage your systemdevconf/openlmi-tools-0.5-2.fc18.noarch.rpm Noadditionalstepsrequired,justruntheshell Peter Hatina How to use CIM and OpenLMI to manage

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

Page 73: How to use CIM and OpenLMI to manage your systemdevconf/openlmi-tools-0.5-2.fc18.noarch.rpm Noadditionalstepsrequired,justruntheshell Peter Hatina How to use CIM and OpenLMI to manage

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

Page 74: How to use CIM and OpenLMI to manage your systemdevconf/openlmi-tools-0.5-2.fc18.noarch.rpm Noadditionalstepsrequired,justruntheshell Peter Hatina How to use CIM and OpenLMI to manage

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

Page 75: How to use CIM and OpenLMI to manage your systemdevconf/openlmi-tools-0.5-2.fc18.noarch.rpm Noadditionalstepsrequired,justruntheshell Peter Hatina How to use CIM and OpenLMI to manage

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

Page 76: How to use CIM and OpenLMI to manage your systemdevconf/openlmi-tools-0.5-2.fc18.noarch.rpm Noadditionalstepsrequired,justruntheshell Peter Hatina How to use CIM and OpenLMI to manage

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

Page 77: How to use CIM and OpenLMI to manage your systemdevconf/openlmi-tools-0.5-2.fc18.noarch.rpm Noadditionalstepsrequired,justruntheshell Peter Hatina How to use CIM and OpenLMI to manage

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

Page 78: How to use CIM and OpenLMI to manage your systemdevconf/openlmi-tools-0.5-2.fc18.noarch.rpm Noadditionalstepsrequired,justruntheshell Peter Hatina How to use CIM and OpenLMI to manage

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

Page 79: How to use CIM and OpenLMI to manage your systemdevconf/openlmi-tools-0.5-2.fc18.noarch.rpm Noadditionalstepsrequired,justruntheshell Peter Hatina How to use CIM and OpenLMI to manage

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

Page 80: How to use CIM and OpenLMI to manage your systemdevconf/openlmi-tools-0.5-2.fc18.noarch.rpm Noadditionalstepsrequired,justruntheshell Peter Hatina How to use CIM and OpenLMI to manage

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

Page 81: How to use CIM and OpenLMI to manage your systemdevconf/openlmi-tools-0.5-2.fc18.noarch.rpm Noadditionalstepsrequired,justruntheshell Peter Hatina How to use CIM and OpenLMI to manage

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

Page 82: How to use CIM and OpenLMI to manage your systemdevconf/openlmi-tools-0.5-2.fc18.noarch.rpm Noadditionalstepsrequired,justruntheshell Peter Hatina How to use CIM and OpenLMI to manage

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

Page 83: How to use CIM and OpenLMI to manage your systemdevconf/openlmi-tools-0.5-2.fc18.noarch.rpm Noadditionalstepsrequired,justruntheshell Peter Hatina How to use CIM and OpenLMI to manage

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

Page 84: How to use CIM and OpenLMI to manage your systemdevconf/openlmi-tools-0.5-2.fc18.noarch.rpm Noadditionalstepsrequired,justruntheshell Peter Hatina How to use CIM and OpenLMI to manage

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

Page 85: How to use CIM and OpenLMI to manage your systemdevconf/openlmi-tools-0.5-2.fc18.noarch.rpm Noadditionalstepsrequired,justruntheshell Peter Hatina How to use CIM and OpenLMI to manage

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

Page 86: How to use CIM and OpenLMI to manage your systemdevconf/openlmi-tools-0.5-2.fc18.noarch.rpm Noadditionalstepsrequired,justruntheshell Peter Hatina How to use CIM and OpenLMI to manage

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

Page 87: How to use CIM and OpenLMI to manage your systemdevconf/openlmi-tools-0.5-2.fc18.noarch.rpm Noadditionalstepsrequired,justruntheshell Peter Hatina How to use CIM and OpenLMI to manage

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

Page 88: How to use CIM and OpenLMI to manage your systemdevconf/openlmi-tools-0.5-2.fc18.noarch.rpm Noadditionalstepsrequired,justruntheshell Peter Hatina How to use CIM and OpenLMI to manage

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

Page 89: How to use CIM and OpenLMI to manage your systemdevconf/openlmi-tools-0.5-2.fc18.noarch.rpm Noadditionalstepsrequired,justruntheshell Peter Hatina How to use CIM and OpenLMI to manage

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

Page 90: How to use CIM and OpenLMI to manage your systemdevconf/openlmi-tools-0.5-2.fc18.noarch.rpm Noadditionalstepsrequired,justruntheshell Peter Hatina How to use CIM and OpenLMI to manage

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

Page 91: How to use CIM and OpenLMI to manage your systemdevconf/openlmi-tools-0.5-2.fc18.noarch.rpm Noadditionalstepsrequired,justruntheshell Peter Hatina How to use CIM and OpenLMI to manage

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

Page 92: How to use CIM and OpenLMI to manage your systemdevconf/openlmi-tools-0.5-2.fc18.noarch.rpm Noadditionalstepsrequired,justruntheshell Peter Hatina How to use CIM and OpenLMI to manage

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

Page 93: How to use CIM and OpenLMI to manage your systemdevconf/openlmi-tools-0.5-2.fc18.noarch.rpm Noadditionalstepsrequired,justruntheshell Peter Hatina How to use CIM and OpenLMI to manage

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

Page 94: How to use CIM and OpenLMI to manage your systemdevconf/openlmi-tools-0.5-2.fc18.noarch.rpm Noadditionalstepsrequired,justruntheshell Peter Hatina How to use CIM and OpenLMI to manage

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

Page 95: How to use CIM and OpenLMI to manage your systemdevconf/openlmi-tools-0.5-2.fc18.noarch.rpm Noadditionalstepsrequired,justruntheshell Peter Hatina How to use CIM and OpenLMI to manage

The end.Questions?