Ubuntu Openstack Installer Documentation Release 0.21 Solutions Engineering

Transcription

Ubuntu Openstack Installer Documentation Release 0.21 Solutions Engineering
Ubuntu Openstack Installer
Documentation
Release 0.21
Solutions Engineering
October 19, 2014
Contents
1
Getting Help
2
Guides
2.1 Developer Guide . . . .
2.2 Single Installer Guide .
2.3 Multi Installer Guide . .
2.4 Using Juju in Openstack
3
3
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
5
5
7
8
10
Reference
3.1 cloudinstall.charms — Juju Charm . . . . . . . . . . . . .
3.2 cloudinstall.config — Config . . . . . . . . . . . . . . .
3.3 cloudinstall.juju — Juju interface . . . . . . . . . . . . .
3.4 cloudinstall.maas — Maas interface . . . . . . . . . . . . .
3.5 cloudinstall.ui — UI Widgets . . . . . . . . . . . . . . . .
3.6 cloudinstall.core — Core logic . . . . . . . . . . . . . . .
3.7 cloudinstall.gui — GUI Interface . . . . . . . . . . . . . .
3.8 cloudinstall.log — Log Interface . . . . . . . . . . . . . .
3.9 cloudinstall.machine — Maas/Juju machine representation
3.10 cloudinstall.service — Service Interface . . . . . . . . .
3.11 cloudinstall.utils — Utility helpers . . . . . . . . . . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
11
11
13
14
15
17
18
20
22
22
23
25
Python Module Index
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
29
i
ii
Ubuntu Openstack Installer Documentation, Release 0.21
Github project page
Contents
1
Ubuntu Openstack Installer Documentation, Release 0.21
2
Contents
CHAPTER 1
Getting Help
We are on IRC, server: irc.freenode.net, channel: #ubuntu-solutions
3
Ubuntu Openstack Installer Documentation, Release 0.21
4
Chapter 1. Getting Help
CHAPTER 2
Guides
2.1 Developer Guide
The document walks you through installing the necessary packages and environment preparations in order to build the
cloud installer.
2.1.1 Base system
Development and testing is done on Ubuntu and using a release of Trusty or later.
2.1.2 Building cloud installer
Note: Although not required, Sbuild is the preferred way for building the package set. Please refer to this wiki page
on setting up sbuild.
Just like the base system the sbuild chroots need to be Trusty or later, but the architecture of the chroots does not
matter.
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
5
Ubuntu Openstack Installer Documentation, Release 0.21
2.1.3 Running the cloud installer
Running the installer for test currently requires installing the packages. After building the packages using either ‘make
deb’ 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/
2.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 status
screen 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 over
from scratch:
$ juju destroy-environment local
$ juju bootstrap
$ make status
2.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”. Most
of the program logs at the DEBUG level, which is the most verbose that is currently defined. If you want a different log
level, you can set the UCI_LOGLEVEL environment variable. Your choices are “DEBUG”, “INFO”, “WARNING”,
“ERROR”, and “CRITICAL”.
$ UCI_LOGLEVEL=ERROR cloud-status
2.1.6 Building documentation
Documentation will be built in docs/_build/html, and requires Sphinx to build.
$ cd docs && make html
2.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 following
environment variable is used.
$ JUJU_LIVE=1 nosetests3 test
6
Chapter 2. Guides
Ubuntu Openstack Installer Documentation, Release 0.21
For the python code, using pep8 and pyflakes is encouraged:
$ make pyflakes
$ make pep8
2.2 Single Installer Guide
2.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/ppa
$ sudo apt-get update
Note: Adding the ppa is only necessary until an official release to the archives has been announced.
2.2.2 Recommended Hardware
The installer would work best with at least:
• 12G RAM
• 100G HDD (SSD for optimal performance)
• 8 CPUS
2.2.3 Installation
Install the cloud-installer via apt-get
$ sudo apt-get install cloud-installer
2.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>
-s
-i
-u
-h
POSIX shell script to be sourced by installer
automating install by pre-setting menu responses.
enable swift-storage
install only (don’t invoke cloud-status)
uninstall the cloud
print this message
2.2. Single Installer Guide
7
Ubuntu Openstack Installer Documentation, Release 0.21
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.
2.2.5 Setting a password
When asked to set the openstack password it should be noted that this password is used throughout all openstack
related services (ie Horizon login password).
2.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 single
system 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 listed
along 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 making
the selection on the dialog box.
Finally, once those nodes are displayed and the charms deployed the horizon dashboard will be available to you for
managing your openstack cloud.
2.2.7 Logging into Horizon (Openstack Dashboard)
The login credentials for the dashboard are:
• username: ubuntu
• password: “password that was set during installation”
2.2.8 Troubleshooting
The installer keeps its own logs in $HOME/.cloud-install/commands.log.
2.2.9 Uninstalling
To uninstall and cleanup your system run the following
$ sudo cloud-install -u
2.3 Multi Installer Guide
2.3.1 Pre-requisites
Multi-Installer has been tested on Ubuntu Server, which is the recommended OS for the cloud installer.
8
Chapter 2. Guides
Ubuntu Openstack Installer Documentation, Release 0.21
Add the cloud-installer ppa to your system.
$
$
$
$
sudo
sudo
sudo
sudo
apt-add-repository ppa:juju/stable
apt-add-repository ppa:maas-maintainers/stable
apt-add-repository ppa:cloud-installer/ppa
apt-get update
Note: Adding the ppa is only necessary until an official release to the archives has been announced.
2.3.2 Installation
Install the cloud-installer via apt-get
$ sudo apt-get install cloud-installer
2.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.
2.3.4 Setting a password
When asked to set the openstack password it should be noted that this password is used throughout all openstack
related services (ie Horizon login password). The only service that does not use this password is juju-gui.
2.3.5 Next Steps
The installer will run through a series of steps starting with making sure the necessary bits are available for a multi
system installation and ending with a juju bootstrapped system.
2.3.6 Troubleshooting
The installer keeps its own logs in $HOME/.cloud-install/commands.log.
2.3.7 Uninstalling
To uninstall and cleanup your system run the following
$ sudo cloud-install -u
2.3. Multi Installer Guide
9
Ubuntu Openstack Installer Documentation, Release 0.21
2.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 the
private cloud.
Note: Juju requires swift storage so this needs to have been enabled during the install.
2.4.1 Update ~/.juju/environments.yaml
In the users ~/.juju/environments.yaml file there is a a openstack stanza.
openstack:
type: openstack
use-floating-ip: true
use-default-secgroup: true
network: ubuntu-net
auth-url: http://keystoneurl:5000/v2.0/
tenant-name: ubuntu
region: RegionOne
auth-mode: userpass
username: ubuntu
password: pass
The credentials are already filled out for you, however, you’ll need to set the auth-url to your Keystone public address.
2.4.2 Bootstrap Juju
Once the environments are updated run:
$
$
$
$
juju
juju
juju
juju
switch openstack
metadata generate-image -i <image_id> -s trusty
sync-tools
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/
10
Chapter 2. Guides
CHAPTER 3
Reference
3.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
11
Ubuntu Openstack Installer Documentation, Release 0.21
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 and
deploy 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.DisplayPriorities
Bases: 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
12
Chapter 3. Reference
Ubuntu Openstack Installer Documentation, Release 0.21
• 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
3.2 cloudinstall.config — Config
class cloudinstall.config.Config
Bases: builtins.object
STYLES = [(‘body’, ‘white’, ‘black’), (‘header_menu’, ‘light gray’, ‘dark gray’), (‘header_title’, ‘light gray,bold’, ‘dark m
bin_path
scripts located in non-default system path
cfg_path
top level configuration path
install_types
Installer types
is_multi
is_single
juju_api_password
juju_env
parses current juju environment
juju_environments_path
returns absolute path of juju environments.yaml
maas_creds
reads maascreds file
openstack_password
save_maas_creds(api_url, api_key)
Saves maas credentials for re-use
Parameters
• api_url (str) – maas address
• api_key (str) – api key of maas admin user
save_password(password)
tmpl_path
template path
3.2. cloudinstall.config — Config
13
Ubuntu Openstack Installer Documentation, Release 0.21
update_environments_yaml(key, val, provider=’local’)
updates environments.yaml base file
exception cloudinstall.config.ConfigException
Bases: builtins.Exception
3.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.
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.
networks
Juju netwoks property
service(name)
Return a single service entry
Parameters name (str) – service/charm name
Returns a service entry or None
Return type Service
14
Chapter 3. Reference
Ubuntu Openstack Installer Documentation, Release 0.21
services
Juju 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.
3.4 cloudinstall.maas — Maas interface
class cloudinstall.maas.MaasMachine(machine_id, machine)
Bases: cloudinstall.machine.Machine
Single maas machine
arch
Return architecture
Returns architecture type
Return type str
cpu_cores
Returns number of cpu-cores
Returns number of cpus
Return type str
hostname
Query hostname reported by MaaS
Returns hostname
Return type str
instance_id
Returns instance-id of a machine
Returns instance-id of machine
Return type str
ip_addresses
Ip addresses for machine
Returns ip addresses
Return type list
mac_address
Macaddress set of maas machine
Returns mac_address and resource_uri
Return type dict
mem
Return memory
Returns memory size
3.4. cloudinstall.maas — Maas interface
15
Ubuntu Openstack Installer Documentation, Release 0.21
Return type str
owner
Machine owner
Returns owner
Return type str
power_type
Machine power type
Returns machines power type
Return type str
status
Status of machine state
Returns status enum
Return type MaasMachineStatus
storage
Return storage
Returns storage size
Return type str
system_id
Returns system id of a maas machine
Returns system id of machine
Return type str
tag
Machine tag
Returns tag defined
Return type str
tag_names
Tag names for machine
Returns tags associated with machine
Return type list
zone
Zone information
Returns zone information
Return type dict
class cloudinstall.maas.MaasMachineStatus
Bases: 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’t
created from a Maas API return.
16
Chapter 3. Reference
Ubuntu Openstack Installer Documentation, Release 0.21
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
Return type list of MaasMachine
nodes()
Cache MAAS nodes
3.5 cloudinstall.ui — UI Widgets
re-usable widgets
class cloudinstall.ui.MaasServerInput(done_signal_handler)
Bases: builtins.WidgetWrap
Maas Server input dialog
cancel(button)
emit_done_signal(*args)
signals = [’done’]
submit(button)
class cloudinstall.ui.PasswordInput(title, done_signal_handler)
Bases: builtins.WidgetWrap
Password input dialog
cancel(button)
emit_done_signal(*args)
keypress(size, key)
signals = [’done’]
submit(button)
class cloudinstall.ui.Scrollable
Bases: builtins.object
A interface that makes widgets scrollable.
scroll_bottom()
3.5. cloudinstall.ui — UI Widgets
17
Ubuntu Openstack Installer Documentation, Release 0.21
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()
class cloudinstall.ui.Selector(title, opts, cb, **kwargs)
Bases: builtins.WidgetWrap
Simple selector box
Parameters
• title (str) – title of selections
• opts (list) – items to select
• cb – callback
Returns item selected from dialog
cancel(button)
emit_done_signal(*args)
keypress(size, key)
signals = [’done’]
submit(button)
3.6 cloudinstall.core — Core logic
class cloudinstall.core.Controller(**kwds)
Bases: cloudinstall.core.DisplayController
Controller for Juju deployments and Maas machine init
add_charm(count=0, charm=None)
configure_lxc_network()
18
Chapter 3. Reference
Ubuntu Openstack Installer Documentation, Release 0.21
configure_lxc_root_tarball(rootfs)
Use a local copy of the cloud rootfs tarball
enqueue_deployed_charms()
Send all deployed charms to CharmQueue for relation setting and post-proc.
get_controller_machine()
get_started_machine()
init_deploy_charms()
Deploy charms in order, waiting for any deferred charms. Then enqueue all charms for further processing
and return.
init_machine()
Handles initial deployment of a machine
init_machine_setup()
Setup initial machine network and controller
initialize()
authenticates against juju/maas and initializes a machine
wait_for_maas()
install and configure maas
class cloudinstall.core.DisplayController(ui=None, opts=None)
Bases: builtins.object
Controller for displaying juju and maas state.
authenticate_juju()
authenticate_maas()
clear_status()
error_message(message)
exit()
header_hotkeys(key)
info_message(message)
initialize()
authenticates against juju/maas and initializes a machine
main_loop()
redraw_screen()
render_node_install_wait(loop=None, user_data=None)
render_nodes(nodes, juju_state, maas_state)
set_dashboard_url(ip)
set_jujugui_url(ip)
show_maas_input(cb)
show_password_input(title, cb)
show_selector_info(title, install_types, cb)
start()
Starts controller processing
3.6. cloudinstall.core — Core logic
19
Ubuntu Openstack Installer Documentation, Release 0.21
step_info(message)
stop_rendering(alarm)
update_alarm(*args, **kwargs)
update_node_states()
Updating node states
3.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
• 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.Banner
Bases: cloudinstall.ui.ScrollableWidgetWrap
class cloudinstall.gui.Header
Bases: builtins.WidgetWrap
class cloudinstall.gui.InstallHeader
Bases: builtins.WidgetWrap
class cloudinstall.gui.NodeInstallWaitMode
Bases: cloudinstall.ui.ScrollableWidgetWrap
class cloudinstall.gui.NodeViewMode(nodes, juju_state, maas_state, **kwargs)
Bases: cloudinstall.ui.ScrollableWidgetWrap
class cloudinstall.gui.PegasusGUI(header=None, body=None, footer=None)
Bases: builtins.WidgetWrap
clear_status()
focus_first()
focus_last()
focus_next()
20
Chapter 3. Reference
Ubuntu Openstack Installer Documentation, Release 0.21
focus_previous()
hide_add_charm_info()
hide_help_info()
hide_selector_info()
hide_show_maas_input()
hide_show_password_input()
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)
set_pending_deploys(pending_charms)
show_add_charm_info(charms, cb)
show_help_info()
show_maas_input(cb)
show_password_input(title, cb)
show_selector_info(title, opts, cb)
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)
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.
3.7. cloudinstall.gui — GUI Interface
21
Ubuntu Openstack Installer Documentation, Release 0.21
set_dashboard_url(ip=None)
sets horizon dashboard url
set_jujugui_url(ip=None)
sets juju gui url
set_pending_deploys(pending_deploys)
class cloudinstall.gui.StepInfo(msg=None)
Bases: builtins.WidgetWrap
3.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
Note: This filters only cloudinstall logging info. Set your environment var to UCI_NOFILTER to see debugging
log 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
3.9 cloudinstall.machine — Maas/Juju machine representation
class cloudinstall.machine.Machine(machine_id, machine)
Bases: builtins.object
Base machine class
arch
Return architecture
22
Chapter 3. Reference
Ubuntu Openstack Installer Documentation, Release 0.21
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
containers
Return containers for machine
Return type generator
cpu_cores
Return 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_id
Returns InstanceId
Returns instance ID
Return type str
mem
Return memory
Returns memory size
Return type str
storage
Return storage
Returns storage size
Return type str
3.10 cloudinstall.service — Service Interface
Represents a Juju service
class cloudinstall.service.Relation(relation_name, charms)
Bases: builtins.object
Relation class
3.10. cloudinstall.service — Service Interface
23
Ubuntu Openstack Installer Documentation, Release 0.21
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()
relations
Service 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()
units
Service units
Returns iterator of associated units for service
Return type Unit()
class cloudinstall.service.Unit(unit_name, unit)
Bases: builtins.object
Unit class
agent_state
Unit’s agent state
Returns agent state
Return type str
agent_state_info
Gets unit state info
Usually prints a error message if unit failed to deploy :returns: error :rtype: str
is_cloud_controller
Is machine housing the cloud-controller?
Returns True/False
Return type bool
is_compute
Is machine a compute node?
Returns True/False
24
Chapter 3. Reference
Ubuntu Openstack Installer Documentation, Release 0.21
Return type bool
is_horizon
Is machine housing the dashboard?
Returns True/False
Return type bool
is_jujugui
Is machine juju-gui?
Returns True/False
Return type bool
machine_id
Associate machine for unit
Returns machine id
Return type str
public_address
Public address of unit
Returns address of unit
Return type str
3.11 cloudinstall.utils — Utility helpers
class cloudinstall.utils.ExceptionLoggingThread(group=None, target=None, name=None,
args=(),
kwargs=None,
*,
daemon=None)
Bases: threading.Thread
run()
cloudinstall.utils.async(func)
Decorator for executing a function in a separate thread.
cloudinstall.utils.console_blank()
cloudinstall.utils.container_cp(name, filepath, dst)
copy file to container
Parameters
• name (str) – name of container
• filepath (str) – file to copy to cintainer
• dst (str) – destination of remote path
cloudinstall.utils.container_create(name, userdata)
creates a container from ubuntu-cloud template
cloudinstall.utils.container_destroy(name)
destroys lxc container
Parameters name (str) – name of container
cloudinstall.utils.container_ip(name)
gets container ip of named container
3.11. cloudinstall.utils — Utility helpers
25
Ubuntu Openstack Installer Documentation, Release 0.21
cloudinstall.utils.container_run(name, cmd)
run command in container
Parameters
• name (str) – name of container
• cmd (str) – command to run
cloudinstall.utils.container_run_status(name, cmd)
Runs cloud-status in container
cloudinstall.utils.container_start(name)
starts lxc container
Parameters name (str) – name of container
cloudinstall.utils.container_stop(name)
stops lxc container
Parameters name (str) – name of container
cloudinstall.utils.container_wait(name)
waits for the container to be in a RUNNING state
Parameters name (str) – name of container
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, user_sudo=False)
Execute command through system shell
Parameters
• command (str) – command to run
• timeout – (optional) use ‘timeout’ to limit time. default 300
• user_sudo – (optional) sudo into install users env. default False.
Returns {ret: returncode, stdout: stdout, stderr: stderr)
Return type dict
# Get output of juju status
cmd_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
26
Chapter 3. Reference
Ubuntu Openstack Installer Documentation, Release 0.21
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
# Get address, broadcast, and netmask of eth0
iface = 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.install_home()
returns installer user home
cloudinstall.utils.install_user()
returns sudo user
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.load_template(name)
load template file
Parameters name (str) – name of template file
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
3.11. cloudinstall.utils — Utility helpers
27
Ubuntu Openstack Installer Documentation, Release 0.21
• 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.slurp(path)
Reads data from path
Parameters path (str) – path of file
cloudinstall.utils.spew(path, data, owner=None)
Writes data to path
Parameters
• path (str) – path of file to write to
• data (str) – contents to write
• owner (str) – optional owner of file
cloudinstall.utils.ssh_genkey()
Generates sshkey
cloudinstall.utils.ssh_privkey()
returns path of private key
cloudinstall.utils.ssh_pubkey()
returns path of ssh public key
cloudinstall.utils.ssh_readkey()
reads ssh key
cloudinstall.utils.time()
Time helper
Returns formatted current time string
Return type str
28
Chapter 3. Reference
Python Module Index
c
cloudinstall.config, 13
cloudinstall.core, 18
cloudinstall.log, 22
cloudinstall.maas, 15
29
Ubuntu Openstack Installer Documentation, Release 0.21
30
Python Module Index
Index
A
get_started_machine()
(cloudinstall.core.Controller
method), 19
add_charm() (cloudinstall.core.Controller method), 18
arch (cloudinstall.maas.MaasMachine attribute), 15
H
authenticate_juju() (cloudinstall.core.DisplayController
header_hotkeys()
(cloudinstall.core.DisplayController
method), 19
method), 19
authenticate_maas() (cloudinstall.core.DisplayController
hostname (cloudinstall.maas.MaasMachine attribute), 15
method), 19
I
B
info_message()
(cloudinstall.core.DisplayController
method), 19
C
init_deploy_charms()
(cloudinstall.core.Controller
method), 19
cfg_path (cloudinstall.config.Config attribute), 13
clear_status()
(cloudinstall.core.DisplayController init_machine() (cloudinstall.core.Controller method), 19
init_machine_setup()
(cloudinstall.core.Controller
method), 19
method), 19
cloudinstall.config (module), 13
initialize() (cloudinstall.core.Controller method), 19
cloudinstall.core (module), 18
initialize() (cloudinstall.core.DisplayController method),
cloudinstall.log (module), 22
19
cloudinstall.maas (module), 15
install_types (cloudinstall.config.Config attribute), 13
Config (class in cloudinstall.config), 13
instance_id (cloudinstall.maas.MaasMachine attribute),
ConfigException, 14
15
configure_lxc_network()
(cloudinstall.core.Controller
ip_addresses (cloudinstall.maas.MaasMachine attribute),
method), 18
15
configure_lxc_root_tarball() (cloudinstall.core.Controller
is_multi (cloudinstall.config.Config attribute), 13
method), 18
is_single (cloudinstall.config.Config attribute), 13
Controller (class in cloudinstall.core), 18
cpu_cores (cloudinstall.maas.MaasMachine attribute), 15
bin_path (cloudinstall.config.Config attribute), 13
D
J
juju_api_password (cloudinstall.config.Config attribute),
13
juju_env (cloudinstall.config.Config attribute), 13
juju_environments_path (cloudinstall.config.Config attribute), 13
(cloudin-
DisplayController (class in cloudinstall.core), 19
E
enqueue_deployed_charms()
stall.core.Controller method), 19
error_message()
(cloudinstall.core.DisplayController M
maas_creds (cloudinstall.config.Config attribute), 13
method), 19
MaasMachine (class in cloudinstall.maas), 15
exit() (cloudinstall.core.DisplayController method), 19
MaasMachineStatus (class in cloudinstall.maas), 16
G
MaasState (class in cloudinstall.maas), 16
get_controller_machine() (cloudinstall.core.Controller mac_address (cloudinstall.maas.MaasMachine attribute),
method), 19
15
31
Ubuntu Openstack Installer Documentation, Release 0.21
machine() (cloudinstall.maas.MaasState method), 17
tag_names (cloudinstall.maas.MaasMachine attribute), 16
machines() (cloudinstall.maas.MaasState method), 17
tmpl_path (cloudinstall.config.Config attribute), 13
main_loop()
(cloudinstall.core.DisplayController
U
method), 19
mem (cloudinstall.maas.MaasMachine attribute), 15
update_alarm()
(cloudinstall.core.DisplayController
method), 20
N
update_environments_yaml() (cloudinstall.config.Config
nodes() (cloudinstall.maas.MaasState method), 17
method), 13
update_node_states()
(cloudinO
stall.core.DisplayController method), 20
openstack_password (cloudinstall.config.Config attribute), 13
W
owner (cloudinstall.maas.MaasMachine attribute), 16
wait_for_maas() (cloudinstall.core.Controller method),
P
19
power_type (cloudinstall.maas.MaasMachine attribute), Z
16
zone (cloudinstall.maas.MaasMachine attribute), 16
PrettyLog (class in cloudinstall.log), 22
R
redraw_screen()
(cloudinstall.core.DisplayController
method), 19
render_node_install_wait()
(cloudinstall.core.DisplayController method), 19
render_nodes()
(cloudinstall.core.DisplayController
method), 19
S
save_maas_creds() (cloudinstall.config.Config method),
13
save_password() (cloudinstall.config.Config method), 13
set_dashboard_url() (cloudinstall.core.DisplayController
method), 19
set_jujugui_url()
(cloudinstall.core.DisplayController
method), 19
setup_logger() (in module cloudinstall.log), 22
show_maas_input() (cloudinstall.core.DisplayController
method), 19
show_password_input()
(cloudinstall.core.DisplayController method), 19
show_selector_info()
(cloudinstall.core.DisplayController method), 19
start() (cloudinstall.core.DisplayController method), 19
status (cloudinstall.maas.MaasMachine attribute), 16
step_info() (cloudinstall.core.DisplayController method),
19
stop_rendering()
(cloudinstall.core.DisplayController
method), 20
storage (cloudinstall.maas.MaasMachine attribute), 16
STYLES (cloudinstall.config.Config attribute), 13
system_id (cloudinstall.maas.MaasMachine attribute), 16
T
tag (cloudinstall.maas.MaasMachine attribute), 16
32
Index