Пример #1
0
    def render(self, going_back=False):
        "Pick or create a cloud to bootstrap a new controller on"
        all_clouds = juju.get_clouds()
        compatible_clouds = juju.get_compatible_clouds()
        cloud_types = juju.get_cloud_types_by_name()
        # filter to only public clouds
        public_clouds = sorted(name for name, info in all_clouds.items()
                               if info['defined'] == 'public')
        # filter to custom clouds
        # exclude localhost because we treat that as "configuring a new cloud"
        custom_clouds = sorted(name for name, info in all_clouds.items()
                               if info['defined'] != 'public'
                               and cloud_types[name] != 'localhost')

        prev_screen = self.prev_screen
        if app.alias_given or (app.spell_given and not app.addons):
            # we were given an alias (so spell and addons are locked)
            # or we were given a spell and there are no addons to change
            # so we disable the back button
            prev_screen = None
        self.view = CloudView(app,
                              public_clouds,
                              custom_clouds,
                              compatible_clouds,
                              cb=self.finish,
                              back=prev_screen)

        if 'localhost' in compatible_clouds:
            app.log.debug(
                "Starting watcher for verifying LXD server is available.")
            self.cancel_monitor.clear()
            app.loop.create_task(self._monitor_localhost(LocalhostProvider()))
        self.view.show()
Пример #2
0
    def render(self):
        "Pick or create a cloud to bootstrap a new controller on"
        track_screen("Cloud Select")

        all_clouds = juju.get_clouds()
        compatible_clouds = juju.get_compatible_clouds()
        cloud_types = juju.get_cloud_types_by_name()
        # filter to only public clouds
        public_clouds = sorted(
            name for name, info in all_clouds.items()
            if info['defined'] == 'public' and
            cloud_types[name] in compatible_clouds)
        # filter to custom clouds
        # exclude localhost because we treat that as "configuring a new cloud"
        custom_clouds = sorted(
            name for name, info in all_clouds.items()
            if info['defined'] != 'public' and
            cloud_types[name] != 'localhost' and
            cloud_types[name] in compatible_clouds)

        excerpt = app.config.get(
            'description',
            "Where would you like to deploy?")
        view = CloudView(app,
                         public_clouds,
                         custom_clouds,
                         cb=self.finish)

        app.ui.set_header(
            title="Choose a Cloud",
            excerpt=excerpt
        )
        app.ui.set_body(view)
        app.ui.set_footer('Please press [ENTER] on highlighted '
                          'Cloud to proceed.')
Пример #3
0
    def render(self):
        "Pick or create a cloud to bootstrap a new controller on"
        track_screen("Cloud Select")

        all_clouds = juju.get_clouds()
        compatible_clouds = juju.get_compatible_clouds()
        cloud_types = juju.get_cloud_types_by_name()
        # filter to only public clouds
        public_clouds = sorted(name for name, info in all_clouds.items()
                               if info['defined'] == 'public')
        # filter to custom clouds
        # exclude localhost because we treat that as "configuring a new cloud"
        custom_clouds = sorted(name for name, info in all_clouds.items()
                               if info['defined'] != 'public'
                               and cloud_types[name] != 'localhost')

        excerpt = app.config.get('description',
                                 "Where would you like to deploy?")

        self.view = CloudView(app,
                              public_clouds,
                              custom_clouds,
                              compatible_clouds,
                              cb=self.finish)

        if 'localhost' in compatible_clouds:
            app.log.debug(
                "Starting watcher for verifying LXD server is available.")
            app.loop.create_task(
                self._monitor_localhost(LocalhostProvider(),
                                        self.view._enable_localhost_widget))

        app.ui.set_header(title="Choose a Cloud", excerpt=excerpt)
        app.ui.set_body(self.view)
        app.ui.set_footer('')
Пример #4
0
    def render(self):
        clouds = list_clouds()
        excerpt = app.config.get(
            'description', "Please select from a list of available clouds")
        view = CloudView(app, clouds, self.finish)

        app.ui.set_header(title="Choose a Cloud", excerpt=excerpt)
        app.ui.set_body(view)
Пример #5
0
    def render(self):
        clouds = list_clouds()
        excerpt = app.config.get(
            'description', "Please select from a list of available clouds")
        view = CloudView(app, clouds, self.finish)

        app.ui.set_header(title="Choose a Cloud", excerpt=excerpt)
        app.ui.set_body(view)
        app.ui.set_footer('Please press [ENTER] on highlighted '
                          'Cloud to proceed.')
Пример #6
0
    def render(self):
        "Pick or create a cloud to bootstrap a new controller on"
        track_screen("Cloud Select")
        clouds = list_clouds()
        excerpt = app.config.get(
            'description', "Please select from a list of available clouds")
        view = CloudView(app, clouds, cb=self.finish)

        app.ui.set_header(title="Choose a Cloud", excerpt=excerpt)
        app.ui.set_body(view)
        app.ui.set_footer('Please press [ENTER] on highlighted '
                          'Cloud to proceed.')
Пример #7
0
    def render(self):
        "Pick or create a cloud to bootstrap a new controller on"
        track_screen("Cloud Select")

        compatible_clouds = juju.get_compatible_clouds()
        all_clouds = juju.get_clouds()
        clouds = []

        for k, v in all_clouds.items():
            if v['type'] in compatible_clouds:
                clouds.append(k)

        excerpt = app.config.get(
            'description', "Please select from a list of available clouds")
        view = CloudView(app, sorted(clouds), cb=self.finish)

        app.ui.set_header(title="Choose a Cloud", excerpt=excerpt)
        app.ui.set_body(view)
        app.ui.set_footer('Please press [ENTER] on highlighted '
                          'Cloud to proceed.')
Пример #8
0
class CloudsController(BaseCloudController):
    cancel_monitor = asyncio.Event()

    def __init__(self):
        self.view = None

    def finish(self, cloud):
        """ Load the selected cloud provider
        """
        self.cancel_monitor.set()

        if cloud in CUSTOM_PROVIDERS:
            app.provider = load_schema(cloud)
        else:
            app.provider = load_schema(juju.get_cloud_types_by_name()[cloud])

        if app.provider.cloud_type == cloud_types.LOCALHOST:
            app.provider._set_lxd_dir_env()

        try:
            app.provider.load(cloud)
        except errors.SchemaCloudError:
            app.provider.cloud = utils.gen_cloud()

        if app.provider.model is None:
            app.provider.model = utils.gen_model()

        track_event("Cloud selection", app.provider.cloud, "")

        return controllers.use('credentials').render()

    def render(self, going_back=False):
        "Pick or create a cloud to bootstrap a new controller on"
        all_clouds = juju.get_clouds()
        compatible_clouds = juju.get_compatible_clouds()
        cloud_types = juju.get_cloud_types_by_name()
        # filter to only public clouds
        public_clouds = sorted(name for name, info in all_clouds.items()
                               if info['defined'] == 'public')
        # filter to custom clouds
        # exclude localhost because we treat that as "configuring a new cloud"
        custom_clouds = sorted(name for name, info in all_clouds.items()
                               if info['defined'] != 'public'
                               and cloud_types[name] != 'localhost')

        prev_screen = self.prev_screen
        if app.alias_given or (app.spell_given and not app.addons):
            # we were given an alias (so spell and addons are locked)
            # or we were given a spell and there are no addons to change
            # so we disable the back button
            prev_screen = None
        self.view = CloudView(app,
                              public_clouds,
                              custom_clouds,
                              compatible_clouds,
                              cb=self.finish,
                              back=prev_screen)

        if 'localhost' in compatible_clouds:
            app.log.debug(
                "Starting watcher for verifying LXD server is available.")
            self.cancel_monitor.clear()
            app.loop.create_task(self._monitor_localhost(LocalhostProvider()))
        self.view.show()

    async def _monitor_localhost(self, provider):
        """ Checks that localhost/lxd is available and listening,
        updates widget accordingly
        """

        while not self.cancel_monitor.is_set():
            try:
                provider._set_lxd_dir_env()
                client_compatible = await provider.is_client_compatible()
                server_compatible = await provider.is_server_compatible()
                has_network_bridge = await provider.get_networks()
                has_storage_pools = await provider.get_storage_pools()
                if not (client_compatible and server_compatible):
                    raise errors.LXDCompatibilityError()
                elif not has_network_bridge:
                    raise errors.LXDNetworkError()
                elif not has_storage_pools:
                    raise errors.LXDStorageError()

                events.LXDAvailable.set()
                self.cancel_monitor.set()
                self.view._update_localhost_widget(True)
                return
            except errors.LXDError as e:
                self.view._update_localhost_widget(False, e.message)
            await run_with_interrupt(asyncio.sleep(2), self.cancel_monitor)

    def prev_screen(self):
        self.cancel_monitor.set()
        controllers.use('addons').render(going_back=True)