support invoking lxd init

Bug #1522879 reported by Scott Moser
10
This bug affects 1 person
Affects Status Importance Assigned to Milestone
cloud-init
Fix Released
Medium
Unassigned

Bug Description

'lxd init' initializes lxd for use on a system.

The format might look something like:
  #cloud-config
  lxd:
    init_storage: 5G

That would ensure that lxd package is installed and then initialize storage to it.

The plan is to have lxd-init in the next couple weeks, this bug track cloud-init consumption.

Related branches

Revision history for this message
Stéphane Graber (stgraber) wrote :

lxd init is already implemented and in the archive, it's command line interface will remain identical, it's just a bit buggy in 0.23 but as far as mapping things into cloud-init, it's good to go.

Init options:
    --auto
        Automatic (non-interactive) mode
    --network-address ADDRESS
        Address to bind LXD to (default: none)
    --network-port PORT
        Port to bind LXD to (default: 8443)
    --storage-backend NAME
        Storage backend to use (zfs or dir, default: dir)
    --storage-create-device DEVICE
        Setup device based storage using DEVICE
    --storage-create-loop SIZE
        Setup loop based storage with SIZE in GB
    --storage-pool NAME
        Storage pool to use or create
    --trust-password PASSWORD
        Password required to add new clients

Those should probably be exposed as is through cloud-init and then, for those which were set, passed to lxd init along with the --auto flag.

Revision history for this message
Scott Moser (smoser) wrote :

Stephane,

 | #cloud-config
 | lxd:
 | init:
 | network_address: <string or None>
 | network_port: <string or None>
 | storage_backend: <string or None>
 | storage_create_device: <string or None>
 | storage_create_loop: <string or None>
 | storage_pool: <string or None>
 | trust_password: <string or None>

initially for cloud-init it will just take those known keys, replace '_' with '-'. Something like below. We wont do any checking on the sanity of that input.

keys = ('network_address', 'network_port', 'storage_backend',
        'storage_create_device', 'storage_create_loop', 'storage_pool',
        'trust_password')
init_dict = ...
cmd = [ 'lxd', 'init', '--auto' ] +
for k in keys:
    if init_dict.get(k):
        cmd.append('%s=%s' % (k.replace('_', '-', init_dict[v]))

Does that look sane to you?

Revision history for this message
Stéphane Graber (stgraber) wrote :

Yep, sounds good to me.

Revision history for this message
Wesley Wiedenmeier (wesley-wiedenmeier) wrote :

I've added a cc module cc_lxd.py and a unit test for it in a branch here: lp:~wesley-wiedenmeier/cloud-init/lxd-init that will run 'lxd init' with any of the flags listed above.

James Falcon (falcojr)
Changed in cloud-init:
status: Confirmed → Fix Released
Revision history for this message
James Falcon (falcojr) wrote :
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.