ubuntu openstack installer documentation - read the · pdf fileubuntu openstack installer...

27
Ubuntu Openstack Installer Documentation Release 0.19+git20140715 Solutions Engineering August 28, 2014

Upload: trinhquynh

Post on 23-Mar-2018

282 views

Category:

Documents


3 download

TRANSCRIPT

Ubuntu Openstack InstallerDocumentation

Release 0.19+git20140715

Solutions Engineering

August 28, 2014

Contents

1 Guides 31.1 Developer Guide . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31.2 Single Installer Guide . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51.3 Multi Installer Guide . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61.4 Using Juju in Openstack . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

2 Reference 92.1 cloudinstall.charms — Juju Charm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92.2 cloudinstall.config — Config . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112.3 cloudinstall.juju — Juju interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112.4 cloudinstall.maas — Maas interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122.5 cloudinstall.ui — UI Widgets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152.6 cloudinstall.core — Core logic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152.7 cloudinstall.gui — GUI Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152.8 cloudinstall.log — Log Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172.9 cloudinstall.machine — Maas/Juju machine representation . . . . . . . . . . . . . . . . . . 182.10 cloudinstall.service — Service Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . 192.11 cloudinstall.utils — Utility helpers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20

Python Module Index 23

i

ii

Ubuntu Openstack Installer Documentation, Release 0.19+git20140715

Github project page

Contents 1

Ubuntu Openstack Installer Documentation, Release 0.19+git20140715

2 Contents

CHAPTER 1

Guides

1.1 Developer Guide

The document walks you through installing the necessary packages and environment preparations in order to build thecloud installer.

1.1.1 Base system

Development and testing is done on Ubuntu and using a release of Trusty or later.

1.1.2 Building cloud installer

Note: Although not required, Sbuild is the preferred way for building the package set. Please refer to this wiki pageon setting up sbuild.

Just like the base system the sbuild chroots need to be Trusty or later, but the architecture of the chroots does notmatter.

Once sbuild is configured, checkout the source code of the installer:

$ git clone https://github.com/Ubuntu-Solutions-Engineering/cloud-installer.git ~/cloud-installer$ cd cloud-installer

Use the target ‘install-dependencies’ to install a custom binary package for the build dependencies:

$ make install-dependencies

From here you can build the entire package set by running:

$ make sbuild# or, if you prefer not to use sbuild:$ make deb

Once finished your packages will be stored in the top level directory where your cloud-installer project is kept.

$ ls ../*.deb

3

Ubuntu Openstack Installer Documentation, Release 0.19+git20140715

1.1.3 Running the cloud installer

Running the installer for test currently requires installing the packages. After building the packages using either ‘makedeb’ or ‘make sbuild’, you can install and run with the ‘run’ target:

$ sudo make run type=single# or$ sudo make run type=multi

You can also set the MAAS_HTTP_PROXY env var for the cloud-install command like this:

$ sudo make run type=single proxy=http://myproxy/

If you are running the landscape installer, you will want to use the ‘landscape’ target:

$ sudo make landscape proxy=http://myproxy/

1.1.4 Running the Pegasus status screen

If you have run the installer and are working on changes to the status screen (in cloudinstall/), you can re-run the statusscreen with the correct python path using this target:

$ make status

If you are testing the status screen’s code for deploying charms, you may need to first start your juju environment overfrom scratch:

$ juju destroy-environment local$ juju bootstrap$ make status

1.1.5 Changing the log level

The cloud-status program logs to ~/.cloud-install/commands.log. The default log level for that log is “DEBUG”. Mostof the program logs at the DEBUG level, which is the most verbose that is currently defined. If you want a different loglevel, you can set the UCI_LOGLEVEL environment variable. Your choices are “DEBUG”, “INFO”, “WARNING”,“ERROR”, and “CRITICAL”.

$ UCI_LOGLEVEL=ERROR cloud-status

1.1.6 Building documentation

Documentation will be built in docs/_build/html, and requires Sphinx to build.

$ cd docs && make html

1.1.7 Running Tests

Tests can be ran against a set of exported data(default) or a live machine. In order to test against live data the followingenvironment variable is used.

$ JUJU_LIVE=1 nosetests3 test

4 Chapter 1. Guides

Ubuntu Openstack Installer Documentation, Release 0.19+git20140715

For the python code, using pep8 and pyflakes is encouraged:

$ make pyflakes$ make pep8

1.2 Single Installer Guide

1.2.1 Pre-requisites

Add the cloud-installer ppa to your system.

$ sudo apt-add-repository ppa:juju/stable$ sudo apt-add-repository ppa:cloud-installer/experimental$ sudo apt-get update

Note: Adding the ppa is only necessary until an official release to the archives has been announced.

1.2.2 Recommended Hardware

The installer would work best with at least:

• 12G RAM

• 100G HDD (SSD for optimal performance)

• 8 CPUS

1.2.3 Installation

Install the cloud-installer via apt-get

$ sudo apt-get install cloud-installer

1.2.4 Start the installation

To start the installation run the following command

$ sudo cloud-install

Note: The installer should be run as a non-root user.

Optional Flags

Options:-c <file> POSIX shell script to be sourced by installer

automating install by pre-setting menu responses.-s enable swift-storage-i install only (don’t invoke cloud-status)-u uninstall the cloud-h print this message

1.2. Single Installer Guide 5

Ubuntu Openstack Installer Documentation, Release 0.19+git20140715

Note: Enabling swift storage requires at least 3 instances and another additional instance for swift-proxy.

Note: If you wish to deploy services to this openstack using juju you will need to enable swift storage.

An initial dialog box will appear asking you to select which type of install, choose Single system.

1.2.5 Setting a password

When asked to set the openstack password it should be noted that this password is used throughout all openstackrelated services (ie Horizon login password).

1.2.6 Installing of Services

The installer will run through a series of steps starting with making sure the necessary bits are available for a singlesystem installation and ending with a juju bootstrapped system.

When the bootstrapping has finished it will immediately load the status screen. From there you can see the nodes listedalong with the deployed charms necessary to start your private openstack cloud.

Adding additional compute nodes, block storage, object storage, and controllers can be done by pressing A and makingthe selection on the dialog box.

Finally, once those nodes are displayed and the charms deployed the horizon dashboard will be available to you formanaging your openstack cloud.

1.2.7 Logging into Horizon (Openstack Dashboard)

The login credentials for the dashboard are:

• username: ubuntu

• password: “password that was set during installation”

1.2.8 Troubleshooting

The installer keeps its own logs in $HOME/.cloud-install/commands.log.

1.2.9 Uninstalling

To uninstall and cleanup your system run the following

$ sudo cloud-install -u

1.3 Multi Installer Guide

1.3.1 Pre-requisites

Multi-Installer has been tested on Ubuntu Server, which is the recommended OS for the cloud installer.

6 Chapter 1. Guides

Ubuntu Openstack Installer Documentation, Release 0.19+git20140715

Add the cloud-installer ppa to your system.

$ sudo apt-add-repository ppa:juju/stable$ sudo apt-add-repository ppa:maas-maintainers/stable$ sudo apt-add-repository ppa:cloud-installer/ppa$ sudo apt-get update

Note: Adding the ppa is only necessary until an official release to the archives has been announced.

1.3.2 Installation

Install the cloud-installer via apt-get

$ sudo apt-get install cloud-installer

1.3.3 Start the installation

To start the installation run the following command

$ sudo cloud-install

Note: The installer should be run as a non-root user.

An initial dialog box will appear asking you to select which type of install, choose Multi-system.

1.3.4 Setting a password

When asked to set the openstack password it should be noted that this password is used throughout all openstackrelated services (ie Horizon login password). The only service that does not use this password is juju-gui.

1.3.5 Next Steps

The installer will run through a series of steps starting with making sure the necessary bits are available for a multisystem installation and ending with a juju bootstrapped system.

1.3.6 Troubleshooting

The installer keeps its own logs in $HOME/.cloud-install/commands.log.

1.3.7 Uninstalling

To uninstall and cleanup your system run the following

$ sudo cloud-install -u

1.3. Multi Installer Guide 7

Ubuntu Openstack Installer Documentation, Release 0.19+git20140715

1.4 Using Juju in Openstack

Once the Openstack cloud has been deployed there are only a couple of steps to enable juju to deploy charms into theprivate cloud.

Note: Juju requires swift storage so this needs to have been enabled during the install.

1.4.1 Update ~/.juju/environments.yaml

In the users ~/.juju/environments.yaml file there is a a openstack stanza.

openstack:type: openstackuse-floating-ip: trueuse-default-secgroup: truenetwork: ubuntu-netauth-url: http://keystoneurl:5000/v2.0/tenant-name: ubunturegion: RegionOneauth-mode: userpassusername: ubuntupassword: pass

The credentials are already filled out for you, however, you’ll need to set the auth-url to your Keystone public address.

1.4.2 Bootstrap Juju

Once the environments are updated run:

$ juju switch openstack$ juju metadata generate-image -i <image_id> -s trusty$ juju sync-tools$ juju bootstrap --metadata-source /home/ubuntu

Now you can deploy charms within your Openstack cloud.

Note: <image_id> is found in the horizon dashboard http://<public-ip>/horizon/project/images/

8 Chapter 1. Guides

CHAPTER 2

Reference

2.1 cloudinstall.charms — Juju Charm

class cloudinstall.charms.CharmBase(juju=None, juju_state=None, machine=None, ui=None)Bases: builtins.object

Base charm class

allow_multi_units = False

charm_name = None

constraints = None

deploy_priority = 9223372036854775807

disabled = False

display_name = None

display_priority = 0

is_related(charm, relations)test for existence of charm relation

Parameters

• charm (str) – charm to verify

• relations (list) – related charms

Returns True if existing relation found, False otherwise

Return type bool

isolate = False

machine_id = ‘’

menuable = False

classmethod name(class_)Return charm name

Returns name of charm

Return type lowercase str

optional = False

9

Ubuntu Openstack Installer Documentation, Release 0.19+git20140715

post_proc()Perform any post processing

i.e. setting configuration variables for a charm

Override in charm classes

related = []

set_relations()Setup charm relations

Override in charm specific.

setup()Deploy charm and configuration options

The default should be sufficient but if more functionality is needed this should be overridden.

returns True if deploy command was deferred for some reason. returns False if no error occurred anddeploy command was issued.

Note that the False (no-error) return value does not indicate that service is up and running.

wait_for_agent(svcs=None)Waits for service agent to be reachable

Parameters svcs – List of services to check or empty for calling service

Return type Unit()

Returns True if all svcs are started, False otherwise

class cloudinstall.charms.CharmQueue(ui)Bases: builtins.object

charm queue for handling relations in the background

add_post_proc(charm)

add_relation(charm)

add_setup(charm)

watch_post_proc()

watch_relations()

watch_setup()

class cloudinstall.charms.DisplayPrioritiesBases: builtins.object

A fake enum

Compute = 10

Core = 0

Error = 1

Other = 30

Storage = 20

cloudinstall.charms.get_charm(charm_name, juju, juju_state, ui)returns single charm class

Parameters

10 Chapter 2. Reference

Ubuntu Openstack Installer Documentation, Release 0.19+git20140715

• charm_name (str) – name of charm to query

• juju_state – status of juju

Return type Charm

Returns charm class

cloudinstall.charms.query_cs(charm, series=’trusty’)This helper routine will query the charm store to pull latest revisions and charmstore url for the api.

Parameters

• charm (str) – charm name

• series (str) – series, defaults. trusty

2.2 cloudinstall.config — Config

class cloudinstall.config.ConfigBases: builtins.object

STYLES = [(‘body’, ‘white’, ‘black’), (‘header_menu’, ‘light gray’, ‘dark gray’), (‘header_title’, ‘light gray,bold’, ‘dark magenta’), (‘focus’, ‘white’, ‘dark gray’), (‘dialog’, ‘black’, ‘light gray’), (‘status_extra’, ‘light gray,bold’, ‘dark gray’), (‘error’, ‘white’, ‘dark red’), (‘info’, ‘light green’, ‘default’), (‘label’, ‘dark gray’, ‘default’), (‘error_icon’, ‘light red,bold’, ‘default’), (‘pending_icon_on’, ‘light blue,bold’, ‘default’), (‘pending_icon’, ‘dark blue’, ‘default’), (‘success_icon’, ‘light green’, ‘default’), (‘button’, ‘light gray’, ‘dark gray’)]

cfg_pathtop level configuration path

is_multi

is_single

juju_api_password

juju_envparses current juju environment

openstack_password

tmpl_pathtemplate path

update_environments_yaml(key, val, provider=’local’)updates environments.yaml base file

exception cloudinstall.config.ConfigExceptionBases: builtins.Exception

2.3 cloudinstall.juju — Juju interface

Represents a juju status

class cloudinstall.juju.JujuState(juju)Bases: builtins.object

Represents a global Juju state

base_machine(machine_id)returns machine if given a numeric machine id, or machine hosting the container if given a container id

NOTE: KVMs are treated as base machines.

2.2. cloudinstall.config — Config 11

Ubuntu Openstack Installer Documentation, Release 0.19+git20140715

invalidate_status_cache()Invalidates cache of status. Use this to force fetching from server more often than every 20 seconds.

machine(machine_id)Return single machine state

Parameters machine_id (str) – machine machine_id

Returns machine

Return type Machine

machine_or_container(machine_id)returns machine or container matching the id

machines()Machines property

Returns machines known to juju (except bootstrap)

Return type list

machines_allocated()Machines allocated property

Returns all machines in an allocated state (see self.valid_states)

Return type list

machines_summary()Returns summary of known machines and their status Excludes bootstrap.

networksJuju netwoks property

service(name)Return a single service entry

Parameters name (str) – service/charm name

Returns a service entry or None

Return type Service

servicesJuju services property

Returns Service() of all loaded services

Return type list

status()Returns juju status. Caches value for 20 seconds.

Call invalidate_status_cache() to force next status call to fetch from server.

2.4 cloudinstall.maas — Maas interface

class cloudinstall.maas.MaasMachine(machine_id, machine)Bases: cloudinstall.machine.Machine

Single maas machine

12 Chapter 2. Reference

Ubuntu Openstack Installer Documentation, Release 0.19+git20140715

archReturn architecture

Returns architecture type

Return type str

cpu_coresReturns number of cpu-cores

Returns number of cpus

Return type str

hostnameQuery hostname reported by MaaS

Returns hostname

Return type str

instance_idReturns instance-id of a machine

Returns instance-id of machine

Return type str

ip_addressesIp addresses for machine

Returns ip addresses

Return type list

mac_addressMacaddress set of maas machine

Returns mac_address and resource_uri

Return type dict

memReturn memory

Returns memory size

Return type str

ownerMachine owner

Returns owner

Return type str

power_typeMachine power type

Returns machines power type

Return type str

statusStatus of machine state

Returns status enum

2.4. cloudinstall.maas — Maas interface 13

Ubuntu Openstack Installer Documentation, Release 0.19+git20140715

Return type MaasMachineStatus

storageReturn storage

Returns storage size

Return type str

system_idReturns system id of a maas machine

Returns system id of machine

Return type str

tagMachine tag

Returns tag defined

Return type str

tag_namesTag names for machine

Returns tags associated with machine

Return type list

zoneZone information

Returns zone information

Return type dict

class cloudinstall.maas.MaasMachineStatusBases: enum.Enum

Symbolic names for maas API status numbers.

-1, UNKNOWN is never returned by maas API. It’s used here to denote a MaasMachine object that wasn’tcreated from a Maas API return.

class cloudinstall.maas.MaasState(maas_client)Bases: builtins.object

Represents global MaaS state

machine(instance_id)Return single machine state

Parameters instance_id (str) – machine instance_id

Returns machine

Return type cloudinstall.maas.MaasMachine

machines(state=None)Maas Machines

:param state

Returns machines known to Maas, except for juju bootstrap

machine, matching state type, or all if state=None

14 Chapter 2. Reference

Ubuntu Openstack Installer Documentation, Release 0.19+git20140715

Return type list of MaasMachine

nodes()Cache MAAS nodes

2.5 cloudinstall.ui — UI Widgets

re-usable widgets

class cloudinstall.ui.ScrollableBases: builtins.object

A interface that makes widgets scrollable.

scroll_bottom()

scroll_down()

scroll_top()

scroll_up()

class cloudinstall.ui.ScrollableListBox(contents, offset=1)Bases: builtins.ListBox, cloudinstall.ui.Scrollable

A urwid.ListBox subclass that implements the Scrollable interface.

scroll_bottom()

scroll_down()

scroll_top()

scroll_up()

class cloudinstall.ui.ScrollableWidgetWrap(contents=None)Bases: builtins.WidgetWrap, cloudinstall.ui.Scrollable

A urwid.WidgetWrap for Scrollable, list-like widgets.

scroll_bottom()

scroll_down()

scroll_top()

scroll_up()

2.6 cloudinstall.core — Core logic

2.7 cloudinstall.gui — GUI Interface

Pegasus - gui interface to Installer

class cloudinstall.gui.AddCharmDialog(charm_classes, cb, **kwargs)Bases: builtins.WidgetWrap

Adding charm dialog

Parameters

2.5. cloudinstall.ui — UI Widgets 15

Ubuntu Openstack Installer Documentation, Release 0.19+git20140715

• charms (list) – list of charms that can be added

• cb – callback routine to process submit/cancel actions

Returns input from dialog

cancel()Handle cancel action

emit_done_signal(*args)

no(button)

signals = [’done’]

submit()Handle OK submit

yes(button)

class cloudinstall.gui.BannerBases: cloudinstall.ui.ScrollableWidgetWrap

class cloudinstall.gui.HeaderBases: builtins.WidgetWrap

class cloudinstall.gui.NodeInstallWaitModeBases: cloudinstall.ui.ScrollableWidgetWrap

class cloudinstall.gui.NodeViewMode(nodes, juju_state, maas_state, **kwargs)Bases: cloudinstall.ui.ScrollableWidgetWrap

class cloudinstall.gui.PegasusGUIBases: builtins.WidgetWrap

clear_status()

focus_first()

focus_last()

focus_next()

focus_previous()

hide_add_charm_info()

hide_help_info()

hide_step_info()

hide_widget_on_top()Hide the topmost widget (if any).

render_node_install_wait(**kwargs)

render_nodes(nodes, juju_state, maas_state, **kwargs)

show_add_charm_info(charms, cb)

show_help_info()

show_step_info(msg=None)

show_widget_on_top(widget, width, height, align=’center’, valign=’middle’, min_height=0,min_width=0)

Show widget on top of frame.

status_dashboard_url(ip)

16 Chapter 2. Reference

Ubuntu Openstack Installer Documentation, Release 0.19+git20140715

status_error_message(message)

status_info_message(message)

status_jujugui_url(ip)

status_message(text)

class cloudinstall.gui.StatusBar(text=’‘)Bases: builtins.WidgetWrap

Displays text.

ARROW = ‘ ‘

ERROR = ‘[ERROR]’

INFO = ‘[INFO]’

clear()Clear the text.

error_message(text)

info_message(text)

message(text)Write text on the footer.

set_dashboard_url(ip=None)sets horizon dashboard url

set_jujugui_url(ip=None)sets juju gui url

class cloudinstall.gui.StepInfo(msg=None)Bases: builtins.WidgetWrap

2.8 cloudinstall.log — Log Interface

Logging interface

class cloudinstall.log.PrettyLog(obj)Bases: builtins.object

cloudinstall.log.setup_logger(name=’cloudinstall.log’)setup logging

Overridding the default log level(debug) can be done via an environment variable UCI_LOGLEVEL

Available levels:

•CRITICAL

•ERROR

•WARNING

•INFO

•DEBUG

2.8. cloudinstall.log — Log Interface 17

Ubuntu Openstack Installer Documentation, Release 0.19+git20140715

Note: This filters only cloudinstall logging info. Set your environment var to UCI_NOFILTER to see debugginglog statements from imported libraries (ie macumba)

# Running cloud-status from cli$ UCI_LOGLEVEL=INFO cloud-status

# Disable log filtering$ UCI_NOFILTER=1 cloud-status

Params str name logger name

Returns a log object

2.9 cloudinstall.machine — Maas/Juju machine representation

class cloudinstall.machine.Machine(machine_id, machine)Bases: builtins.object

Base machine class

archReturn architecture

Returns architecture type

Return type str

container(container_id)Inspect a container

Parameters container_id (int) – lxc container id

Returns Returns a dictionary of the container information for specific machine and lxc id.

Return type dict

containersReturn containers for machine

Return type generator

cpu_coresReturn number of cpu-cores

Returns number of cpus

Return type str

hardware(spec)Get hardware information

Parameters spec (str) – a hardware specification

Returns hardware of spec

Return type str

instance_idReturns InstanceId

Returns instance ID

18 Chapter 2. Reference

Ubuntu Openstack Installer Documentation, Release 0.19+git20140715

Return type str

memReturn memory

Returns memory size

Return type str

storageReturn storage

Returns storage size

Return type str

2.10 cloudinstall.service — Service Interface

Represents a Juju service

class cloudinstall.service.Relation(relation_name, charms)Bases: builtins.object

Relation class

is_relation(charm)Is a charm already related?

class cloudinstall.service.Service(service_name, service)Bases: builtins.object

Service class

relation(name)Single relation entry

Params str name name of relation

Returns a Relation entry

Return type Relation()

relationsService relations

Returns iterator of relations for service

Return type Relation()

unit(name)Single unit entry

Params str name name of unit

Returns a Unit entry

Return type Unit()

unitsService units

Returns iterator of associated units for service

Return type Unit()

2.10. cloudinstall.service — Service Interface 19

Ubuntu Openstack Installer Documentation, Release 0.19+git20140715

class cloudinstall.service.Unit(unit_name, unit)Bases: builtins.object

Unit class

agent_stateUnit’s agent state

Returns agent state

Return type str

agent_state_infoGets unit state info

Usually prints a error message if unit failed to deploy :returns: error :rtype: str

is_cloud_controllerIs machine housing the cloud-controller?

Returns True/False

Return type bool

is_computeIs machine a compute node?

Returns True/False

Return type bool

is_horizonIs machine housing the dashboard?

Returns True/False

Return type bool

is_jujuguiIs machine juju-gui?

Returns True/False

Return type bool

machine_idAssociate machine for unit

Returns machine id

Return type str

public_addressPublic address of unit

Returns address of unit

Return type str

2.11 cloudinstall.utils — Utility helpers

class cloudinstall.utils.ExceptionLoggingThread(group=None, target=None, name=None,args=(), kwargs=None, *, dae-mon=None)

Bases: threading.Thread

20 Chapter 2. Reference

Ubuntu Openstack Installer Documentation, Release 0.19+git20140715

run()

cloudinstall.utils.async(func)Decorator for executing a function in a separate thread.

cloudinstall.utils.console_blank()

cloudinstall.utils.container_ip(name)gets container ip of named container

cloudinstall.utils.container_run(name, cmd)run command in container

Parameters

• name (str) – name of container

• cmd (str) – command to run

cloudinstall.utils.find(file_pattern, top_dir, max_depth=None, path_pattern=None)generator function to find files recursively. Usage:

for filename in find("*.properties", "/var/log/foobar"):print filename

cloudinstall.utils.get_command_output(command, timeout=300, combine_output=True)Execute command through system shell

Parameters

• command (str) – command to run

• timeout – (optional) use ‘timeout’ to limit time. default 300

• combine_output – (optional) combine stderr and stdout. default True.

Returns {ret: returncode, stdout: stdout, stderr: stderr)

Return type dict

# Get output of juju statuscmd_dict = utils.get_command_output(’juju status’)

cloudinstall.utils.get_host_cpu_cores()Get host cpu-cores

A backup if no data can be pulled from Machine()

cloudinstall.utils.get_host_mem()Get host memory

Mostly used as a backup if no data can be pulled from the normal means in Machine()

cloudinstall.utils.get_host_storage()Get host storage

LXC doesn’t report storage so we pull from host

cloudinstall.utils.get_network_interface(iface)Get network interface properties

Parameters iface (str) – Interface to query (ex. eth0)

Returns interface properties or empty if none

Return type dict

2.11. cloudinstall.utils — Utility helpers 21

Ubuntu Openstack Installer Documentation, Release 0.19+git20140715

# Get address, broadcast, and netmask of eth0iface = utils.get_network_interface(’eth0’)

cloudinstall.utils.get_network_interfaces()Get network interfaces

Returns available interfaces and their properties

Return type generator

cloudinstall.utils.global_exchandler(type, value, tb)helper routine capturing tracebacks and printing to log file

cloudinstall.utils.load_charm_byname(name)Load a charm by name

Parameters name (str) – name of charm

cloudinstall.utils.load_charms()Load known charm modules

cloudinstall.utils.partition(pred, iterable)Returns tuple of allocated and unallocated systems

Parameters

• pred (function) – status predicate

• iterable (list) – machine data

Returns ([allocated], [unallocated])

Return type tuple

def is_allocated(d):allocated_states = [’started’, ’pending’, ’down’]return ’charms’ in d or d[’agent_state’] in allocated_states

allocated, unallocated = utils.partition(is_allocated,[{state: ’pending’}])

cloudinstall.utils.randomString(size=6, chars=’ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789’)Generate a random string

Parameters

• size (int) – number of string characters

• chars (str) – range of characters (optional)

Returns a random string

Return type str

cloudinstall.utils.remote_cp(machine_id, src, dst)

cloudinstall.utils.remote_run(machine_id, cmds)

cloudinstall.utils.reset_blanking()

cloudinstall.utils.time()Time helper

Returns formatted current time string

Return type str

22 Chapter 2. Reference

Python Module Index

ccloudinstall.config, 11cloudinstall.log, 17cloudinstall.maas, 12

23