async def get_lxd_devices(self): self.devices = { 'networks': await app.provider.get_networks(), 'storage-pools': await app.provider.get_storage_pools() } self.view = LXDSetupView(self.devices, self.finish) self.view.show()
def render(self): """ Render """ track_screen("LXD Setup") view = LXDSetupView(app, cb=self.finish) app.ui.set_header(title="Configure LXD", ) app.ui.set_body(view)
def render(self): """ Render """ track_screen("LXD Setup") self.view = LXDSetupView(app, self.finish) app.ui.set_header(title="Setup LXD Bridge", ) app.ui.set_body(self.view)
def render(self): """ Render """ utils.pollinate(app.session_id, 'L001') self.view = LXDSetupView(app, self.finish) app.ui.set_header( title="Setup LXD Bridge", ) app.ui.set_body(self.view)
class LXDSetupController(common.BaseLXDSetupController): async def get_lxd_devices(self): self.devices = { 'networks': await app.provider.get_networks(), 'storage-pools': await app.provider.get_storage_pools() } self.view = LXDSetupView(self.devices, self.finish) self.view.show() async def set_lxd_info(self, network, storage_pool): self.set_state('lxd-network-name', network['name']) phys_iface_addr = utils.get_physical_network_ipaddr(network['name']) iface = ipaddress.IPv4Interface(phys_iface_addr) self.set_state('lxd-network', iface.network) self.set_state('lxd-gateway', iface.ip) self.set_state('lxd-network-dhcp-range-start', iface.ip + 1) # To account for current interface taking 1 ip number_of_hosts = len(list(iface.network.hosts())) - 1 self.set_state('lxd-network-dhcp-range-stop', "{}".format(iface.ip + number_of_hosts)) self.set_state('lxd-storage-pool', storage_pool['name']) app.log.debug('LXD Info set: ' '(name: {}) ' '(network: {}) ' '(gateway: {}) ' '(dhcp-range-start: {}) ' '(dhcp-range-stop: {})'.format( self.get_state('lxd-network-name'), self.get_state('lxd-network'), self.get_state('lxd-gateway'), self.get_state('lxd-network-dhcp-range-start'), self.get_state('lxd-network-dhcp-range-stop'))) def finish(self, network, storage): app.loop.create_task(self.set_lxd_info(network, storage)) return self.next_screen() def render(self): app.loop.create_task(self.get_lxd_devices())
def render(self): if len(self.ifaces) == 1: return self.setup(self.ifaces[0]) view = LXDSetupView(self.schema, self.setup) view.show()
class LXDSetupController(common.BaseLXDSetupController): async def get_lxd_devices(self): self.devices = { 'networks': await app.provider.get_networks(), 'storage-pools': await app.provider.get_storage_pools() } self.view = LXDSetupView(self.devices, self.finish, self.back) self.view.show() async def set_lxd_info(self, network, storage_pool): self.set_state('lxd-network-name', network['name']) # If using custom bridge names other than `lxdbr0` the # default lxd profile has to be updated to reflect that. This # is because Juju only checks the `default` profile for the # bridge to utilize when bootstraping and deploying. # See: https://git.io/vbp5X try: ret, _, _ = await utils.arun([ app.provider.lxc_bin, "profile", "device", "set", "default", "eth0", "parent", network['name'] ]) except CalledProcessError as e: app.log.error('Unable to set the default profiles parent network' 'device: {}'.format(e.stderr)) raise phys_iface_addr = utils.get_physical_network_ipaddr(network['name']) try: iface = ipaddress.IPv4Interface("{}/24".format(phys_iface_addr)) except ipaddress.AddressValueError: raise errors.LXDSetupControllerError( "Unable to determine ip address of {network}, please double " "check `lxc network edit {network}` and make " "sure an address is associated with that bridge.".format( network=network['name'])) self.set_state('lxd-network', iface.network) self.set_state('lxd-gateway', iface.ip) self.set_state('lxd-network-dhcp-range-start', iface.ip + 1) # To account for current interface taking 1 ip number_of_hosts = len(list(iface.network.hosts())) - 1 self.set_state('lxd-network-dhcp-range-stop', "{}".format(iface.ip + number_of_hosts)) self.set_state('lxd-storage-pool', storage_pool['name']) app.log.debug('LXD Info set: ' '(name: {}) ' '(network: {}) ' '(gateway: {}) ' '(dhcp-range-start: {}) ' '(dhcp-range-stop: {})'.format( self.get_state('lxd-network-name'), self.get_state('lxd-network'), self.get_state('lxd-gateway'), self.get_state('lxd-network-dhcp-range-start'), self.get_state('lxd-network-dhcp-range-stop'))) def finish(self, network, storage): app.loop.create_task(self.set_lxd_info(network, storage)) return self.next_screen() def render(self): app.loop.create_task(self.get_lxd_devices()) def back(self): controllers.use('providersetup').render(going_back=True)