예제 #1
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.')
예제 #2
0
 def _build_widget(self):
     total_items = []
     if len(self.public_clouds) > 0:
         total_items.append(Text("Public Clouds"))
         total_items.append(HR())
         for item in self.public_clouds:
             total_items.append(
                 Color.body(menu_btn(label=item, on_press=self.submit),
                            focus_map='menu_button focus'))
         total_items.append(Padding.line_break(""))
     if len(self.custom_clouds) > 0:
         total_items.append(Text("Your Clouds"))
         total_items.append(HR())
         for item in self.custom_clouds:
             total_items.append(
                 Color.body(menu_btn(label=item, on_press=self.submit),
                            focus_map='menu_button focus'))
         total_items.append(Padding.line_break(""))
     new_clouds = juju.get_compatible_clouds(
         ['localhost', 'maas', 'vsphere'])
     if new_clouds:
         total_items.append(Text("Configure a New Cloud"))
         total_items.append(HR())
         for item in sorted(new_clouds):
             total_items.append(
                 Color.body(menu_btn(label=item, on_press=self.submit),
                            focus_map='menu_button focus'))
     return Padding.center_80(Filler(Pile(total_items), valign='top'))
예제 #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
파일: gui.py 프로젝트: ops-sandy/conjure-up
    def render(self):
        existing_controllers = juju.get_controllers()['controllers']
        clouds = juju.get_compatible_clouds()
        cloud_types = juju.get_cloud_types_by_name()

        app.jaas_ok = set(clouds) & JAAS_CLOUDS
        jaas_controller = {
            n
            for n, c in existing_controllers.items()
            if JAAS_ENDPOINT in c['api-endpoints']
        }
        if jaas_controller:
            app.jaas_controller = jaas_controller.pop()

        filtered_controllers = {
            n: d
            for n, d in existing_controllers.items()
            if cloud_types.get(d['cloud']) in clouds
        }

        if not app.jaas_ok and len(filtered_controllers) == 0:
            return controllers.use('clouds').render()

        track_screen("Controller Picker")
        excerpt = app.config.get(
            'description', "Please select an existing controller,"
            " or choose to bootstrap a new one.")
        view = ControllerListView(app, filtered_controllers, self.finish)

        app.ui.set_header(title="Choose a Controller or Create new",
                          excerpt=excerpt)
        app.ui.set_body(view)
예제 #5
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()
예제 #6
0
    def _build_widget(self):
        default_selection = None
        cloud_types_by_name = juju.get_cloud_types_by_name()
        if len(self.public_clouds) > 0:
            self._add_item(Text("Public Clouds"))
            self._add_item(HR())
            for cloud_name in self.public_clouds:
                cloud_type = cloud_types_by_name[cloud_name]
                allowed = cloud_type in self.compatible_cloud_types
                if allowed and default_selection is None:
                    default_selection = len(self.items.contents)
                self._add_item(
                    CloudWidget(name=cloud_name,
                                cb=self.submit,
                                enabled=allowed))
            self._add_item(Padding.line_break(""))
        if len(self.custom_clouds) > 0:
            self._add_item(Text("Your Clouds"))
            self._add_item(HR())
            for cloud_name in self.custom_clouds:
                cloud_type = cloud_types_by_name[cloud_name]
                allowed = cloud_type in self.compatible_cloud_types
                if allowed and default_selection is None:
                    default_selection = len(self.items.contents)
                self._add_item(
                    CloudWidget(name=cloud_name,
                                cb=self.submit,
                                enabled=allowed))
            self._add_item(Padding.line_break(""))
        new_clouds = juju.get_compatible_clouds(CUSTOM_PROVIDERS)
        if new_clouds:
            lxd_allowed = cloud_types.LOCALHOST in self.compatible_cloud_types
            self._add_item(Text("Configure a New Cloud"))
            self._add_item(HR())
            for cloud_type in sorted(CUSTOM_PROVIDERS):
                if cloud_type == cloud_types.LOCALHOST and lxd_allowed:
                    self._items_localhost_idx = len(self.items.contents)
                    if default_selection is None:
                        default_selection = len(self.items.contents)
                    self._add_item(
                        CloudWidget(name=cloud_type,
                                    cb=self.submit,
                                    enabled=events.LXDAvailable.is_set(),
                                    disabled_msg=self.lxd_unavailable_msg))
                else:
                    allowed = cloud_type in self.compatible_cloud_types
                    if allowed and default_selection is None:
                        default_selection = len(self.items.contents)
                    self._add_item(
                        CloudWidget(name=cloud_type,
                                    cb=self.submit,
                                    enabled=allowed))

        self.items.focus_position = default_selection or 2
        return self.items
예제 #7
0
    def _build_widget(self):
        if len(self.public_clouds) > 0:
            self._add_item(Text("Public Clouds"))
            self._add_item(HR())
            for item in self.public_clouds:
                self._add_item(
                    Color.body(menu_btn(label=item, on_press=self.submit),
                               focus_map='menu_button focus'))
            self._add_item(Padding.line_break(""))
        if len(self.custom_clouds) > 0:
            self._add_item(Text("Your Clouds"))
            self._add_item(HR())
            for item in self.custom_clouds:
                self._add_item(
                    Color.body(menu_btn(label=item, on_press=self.submit),
                               focus_map='menu_button focus'))
            self._add_item(Padding.line_break(""))
        new_clouds = juju.get_compatible_clouds(
            ['localhost', 'maas', 'vsphere'])
        if new_clouds:
            self._add_item(Text("Configure a New Cloud"))
            self._add_item(HR())
            for item in sorted(new_clouds):
                if item == 'localhost':
                    self._add_item(
                        Color.info_context(menu_btn(
                            label=cloud_types.LOCALHOST, on_press=None),
                                           focus_map='disabled_button'))
                    self._add_item(
                        Color.info_context(
                            Padding.center_90(
                                Text("LXD not found, please install and wait "
                                     "for this message to disappear:\n\n"
                                     "  $ sudo snap install lxd\n"
                                     "  $ /snap/bin/lxd init --auto\n"
                                     "  $ /snap/bin/lxc network create lxdbr0 "
                                     "ipv4.address=auto ipv4.nat=true "
                                     "ipv6.address=none ipv6.nat=false "))))
                else:
                    self._add_item(
                        Color.body(menu_btn(label=item, on_press=self.submit),
                                   focus_map='menu_button focus'))

        self.pile.focus_position = 2
        return self.pile
예제 #8
0
    def _build_widget(self):
        if len(self.public_clouds) > 0:
            self._add_item(Text("Public Clouds"))
            self._add_item(HR())
            for item in self.public_clouds:
                self._add_item(
                    Color.body(menu_btn(label=item, on_press=self.submit),
                               focus_map='menu_button focus'))
            self._add_item(Padding.line_break(""))
        if len(self.custom_clouds) > 0:
            self._add_item(Text("Your Clouds"))
            self._add_item(HR())
            for item in self.custom_clouds:
                self._add_item(
                    Color.body(menu_btn(label=item, on_press=self.submit),
                               focus_map='menu_button focus'))
            self._add_item(Padding.line_break(""))
        new_clouds = juju.get_compatible_clouds(
            ['localhost', 'maas', 'vsphere'])
        if new_clouds:
            self._add_item(Text("Configure a New Cloud"))
            self._add_item(HR())
            for item in sorted(new_clouds):
                if item == 'localhost':
                    self._add_item(
                        Color.info_context(menu_btn(
                            label=cloud_types.LOCALHOST, on_press=None),
                                           focus_map='disabled_button'))
                    self._add_item(
                        Color.info_context(
                            Padding.center_90(
                                Text("LXD not found, please install with "
                                     "`sudo snap install lxd && lxd init` "
                                     "and wait for this message to disappear.")
                            )))
                else:
                    self._add_item(
                        Color.body(menu_btn(label=item, on_press=self.submit),
                                   focus_map='menu_button focus'))

        self.pile.focus_position = 2
        return self.pile
예제 #9
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.')
예제 #10
0
 def _build_widget(self):
     total_items = []
     clouds = [x for x in self.clouds if 'localhost' != x]
     if len(clouds) > 0:
         total_items.append(Text("Choose a Cloud"))
         total_items.append(HR())
         for item in clouds:
             total_items.append(
                 Color.body(menu_btn(label=item, on_press=self.submit),
                            focus_map='menu_button focus'))
         total_items.append(Padding.line_break(""))
     # TODO: add vsphere
     new_clouds = juju.get_compatible_clouds(['localhost', 'maas'])
     if new_clouds:
         total_items.append(Text("Configure a New Cloud"))
         total_items.append(HR())
         for item in new_clouds:
             total_items.append(
                 Color.body(menu_btn(label=item, on_press=self.submit),
                            focus_map='menu_button focus'))
     return Padding.center_80(Filler(Pile(total_items), valign='top'))