canonical/pylxd

How do I create a new profile inside a project?

Closed this issue · 1 comments

Am using pylxd 2.3.1 and I've creating a new project and then attempting to clone in the default profile into the project.

However I've not sure how this is done via pylxd as neither profiles.create or project classes appear to have a 'project' argument. Any help would be appreciated..

if not self.lxd.projects.exists(self.project):
    # Could put in configrable options here like description,cpu/memory limits HERE
    self.lxd.projects.create(self.project)
    project=self.lxd.projects.get(self.project)

    # create a new project and copy over the default profile
    dflt=self.lxd.profiles.get('default')
    project.profiles.create('default', config=dflt.config, devices=dflt.devices)

Ok I solved the issue with two Client connections the first detects if the project exists and creates it if not.

then open a second and that one specifies the project and then I can create/modify profiles using that 2nd object.