support invoking lxd init

Bug #1522879 reported by Scott Moser on 2015-12-04
This bug affects 1 person
Affects Status Importance Assigned to Milestone

Bug Description

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

The format might look something like:
    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

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:
        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.

Scott Moser (smoser) wrote :


 | #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',
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?

Stéphane Graber (stgraber) wrote :

Yep, sounds good to me.

I've added a cc module 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.

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers