diff options
author | 2017-05-29 13:13:32 +0200 | |
---|---|---|
committer | 2017-05-29 13:13:32 +0200 | |
commit | a836e5c16ea7df38646c46f2e9ffc6163ab05f06 (patch) | |
tree | d5cf3b799af7e9a328db245647a5cdce0ba744f4 /vicn/resource/lxd | |
parent | be0b435d307173598c30fcacc421b17112137099 (diff) |
Misc bug fixes
*IP assignment
*Node is a key attribute
*Up-to-date packages
*Trailing whitespaces
...
Change-Id: Id8e2a5f7b2c4506f326b3c4bc991fa65f53fca5c
Signed-off-by: Marcel Enguehard <mengueha+fdio@cisco.com>
Diffstat (limited to 'vicn/resource/lxd')
-rw-r--r-- | vicn/resource/lxd/lxc_container.py | 26 | ||||
-rw-r--r-- | vicn/resource/lxd/lxc_image.py | 20 |
2 files changed, 13 insertions, 33 deletions
diff --git a/vicn/resource/lxd/lxc_container.py b/vicn/resource/lxd/lxc_container.py index 5670d1a2..654b3bc5 100644 --- a/vicn/resource/lxd/lxc_container.py +++ b/vicn/resource/lxd/lxc_container.py @@ -128,9 +128,6 @@ class LxcContainer(Node): if iface.get_type() == "dpdkdevice": self.node.vpp_host.dpdk_devices.append(iface.pci_address) - if 'vpp' in self.profiles: - dummy = self.node.vpp_host.uio_devices - @task def __get__(self): client = self.node.lxd_hypervisor.client @@ -158,7 +155,6 @@ class LxcContainer(Node): log.debug('Container description: {}'.format(container)) client = self.node.lxd_hypervisor.client self._container = client.containers.create(container, wait=True) - #self._container.start(wait = True) def _get_container_description(self): # Base configuration @@ -188,23 +184,6 @@ class LxcContainer(Node): 'path' : '/dev/{}'.format(device), 'type' : 'unix-char' } -# # NETWORK (not for images) -# -# if not self.is_image: -# container['config']['user.network_mode'] = 'link-local' -# device = { -# 'type' : 'nic', -# 'name' : self.host_interface.device_name, -# 'nictype' : 'bridged', -# 'parent' : self.node.bridge.device_name, -# } -# device['hwaddr'] = AddressManager().get_mac(self) -# prefix = 'veth-{}'.format(self.container_name) -# device['host_name'] = AddressManager().get('device_name', self, -# prefix = prefix, scope = prefix) -# -# container['devices'][device['name']] = device - # SOURCE image_names = [alias['name'] for alias in self.node.lxd_hypervisor.aliases] @@ -231,7 +210,6 @@ class LxcContainer(Node): @task def __delete__(self): log.info("Delete container {}".format(self.container_name)) - import pdb; pdb.set_trace() self.node.lxd_hypervisor.client.containers.remove(self.name) #-------------------------------------------------------------------------- @@ -308,6 +286,10 @@ class LxcContainer(Node): We don't currently use an eventually available SSH connection. """ + if not self._container: + log.error("Executing command on uninitialized container", self, command) + import os; os._exit(1) + ret = self._container.execute(shlex.split(command)) # NOTE: pylxd documents the return value as a tuple, while it is in diff --git a/vicn/resource/lxd/lxc_image.py b/vicn/resource/lxd/lxc_image.py index 2cc7220d..a3a03245 100644 --- a/vicn/resource/lxd/lxc_image.py +++ b/vicn/resource/lxd/lxc_image.py @@ -43,22 +43,22 @@ class LxcImage(Resource): image = Attribute(Self, description = 'image', default = None) applications = Attribute(Application, multiplicity = Multiplicity.OneToMany) - #--------------------------------------------------------------------------- + #--------------------------------------------------------------------------- # Constructor / Accessors - #--------------------------------------------------------------------------- + #--------------------------------------------------------------------------- def __init__(self, *args, **kwargs): self.fingerprint = None self._tmp_container = None super().__init__(*args, **kwargs) - #--------------------------------------------------------------------------- + #--------------------------------------------------------------------------- # Resource lifecycle - #--------------------------------------------------------------------------- + #--------------------------------------------------------------------------- @task def __get__(self): - aliases = [alias['name'] for images in self.node.lxd_hypervisor.client.images.all() + aliases = [alias['name'] for images in self.node.lxd_hypervisor.client.images.all() for alias in images.aliases] if not self.image in aliases: raise ResourceNotFound @@ -75,10 +75,8 @@ class LxcImage(Resource): Image creation consists in setting up a temporary container, stopping it, publishing an image of it, setting an alias, and deleting it. """ - - tmp_container.setup() - + print("TODO: Installing applications...") for application in self.applications: print('Installing application on image') @@ -103,13 +101,13 @@ class LxcImage(Resource): def __delete__(self): self.node.lxd_hypervisor.client.images.delete(self.name) - #--------------------------------------------------------------------------- + #--------------------------------------------------------------------------- # Public methods - #--------------------------------------------------------------------------- + #--------------------------------------------------------------------------- def set_alias(self): alias_dict = { - "description": "Ubuntu 14.04 image with ICN software already installed", + "description": "Ubuntu 16.04 image with ICN software already installed", "target": self.fingerprint, "name": self.name } |