Ejemplo n.º 1
0
    def finish(self):
        if app.conjurefile['model']:
            app.provider.model = app.conjurefile['model']
        else:
            app.provider.model = utils.gen_model()

        return controllers.use('credentials').render()
Ejemplo n.º 2
0
    def finish(self):
        if app.argv.model:
            app.current_model = app.argv.model
        else:
            app.current_model = utils.gen_model()

        return controllers.use('regions').render()
Ejemplo n.º 3
0
    def finish(self):
        if app.argv.model:
            app.provider.model = app.argv.model
        else:
            app.provider.model = utils.gen_model()

        return controllers.use('credentials').render()
Ejemplo n.º 4
0
    def finish(self, controller):
        if controller is None:
            return controllers.use('clouds').render()

        if controller == 'jaas':
            if not app.jaas_controller or not juju.has_jaas_auth():
                # jaas is either not registered or not logged in
                return controllers.use('jaaslogin').render()
            # jaas already registered, but we they still need to pick a cloud
            app.current_controller = app.jaas_controller
            app.is_jaas = True
            events.Bootstrapped.set()
            return controllers.use('clouds').render()

        app.current_controller = controller
        app.current_model = utils.gen_model()

        c_info = juju.get_controller_info(app.current_controller)
        app.current_cloud = c_info['details']['cloud']

        events.Bootstrapped.set()

        app.loop.create_task(
            juju.add_model(app.current_model, app.current_controller,
                           app.current_cloud))
        return controllers.use('deploy').render()
Ejemplo n.º 5
0
    def finish(self):
        if app.argv.model:
            app.current_model = app.argv.model
        else:
            app.current_model = utils.gen_model()

        if not app.argv.controller:
            app.current_controller = "conjure-up-{}-{}".format(
                app.current_cloud, utils.gen_hash())

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

        app.current_controller = app.argv.controller
        if not self.__controller_exists(app.current_controller):
            return controllers.use('newcloud').render()
        else:
            utils.info("Using controller '{}'".format(app.current_controller))
            utils.info("Creating new model named '{}', "
                       "please wait.".format(app.current_model))
            app.loop.create_task(
                juju.add_model(app.current_model,
                               app.current_controller,
                               app.current_cloud,
                               allow_exists=True))
            return controllers.use('deploy').render()

        utils.error("Something happened with the controller or model, "
                    "please check the logs.")
        events.Shutdown.set(1)
Ejemplo n.º 6
0
    def render(self):
        track_screen("Cloud Creation")

        if app.current_controller is None:
            app.current_controller = "conjure-up-{}-{}".format(
                app.current_cloud, utils.gen_hash())

        if app.current_model is None:
            app.current_model = utils.gen_model()

        cloud_type = juju.get_cloud_types_by_name()[app.current_cloud]

        # LXD is a special case as we want to make sure a bridge
        # is configured. If not we'll bring up a new view to allow
        # a user to configure a LXD bridge with suggested network
        # information.
        if cloud_type == 'localhost':
            lxd = common.is_lxd_ready()
            if not lxd['ready']:
                return controllers.use('lxdsetup').render(lxd['msg'])
            # lxd doesn't require user-provided credentials,
            # so never show the editor for localhost
            return self.finish()

        creds = common.try_get_creds(app.current_cloud)
        try:
            endpoint = juju.get_cloud(app.current_cloud).get('endpoint', None)
        except LookupError:
            endpoint = None
        if creds and (endpoint or cloud_type != 'maas'):
            return self.finish()

        # show credentials editor otherwise
        try:
            creds = load_schema(app.current_cloud)
        except Exception as e:
            track_exception("Credentials Error: {}".format(e))
            app.log.exception("Credentials Error: {}".format(e))
            return app.ui.show_exception_message(
                Exception("Unable to find credentials for {}, "
                          "you can double check what credentials you "
                          "do have available by running "
                          "`juju credentials`. Please see `juju help "
                          "add-credential` for more information.".format(
                              app.current_cloud)))

        regions = []
        # No regions for these providers
        if cloud_type not in ['maas', 'vsphere']:
            regions = sorted(juju.get_regions(app.current_cloud).keys())
        view = NewCloudView(creds, regions, self.finish)

        app.ui.set_header(title="New cloud setup", )
        app.ui.set_body(view)
        app.ui.set_footer("")
Ejemplo n.º 7
0
    def finish(self, cloud):
        """Save the selected cloud and move on to the region selection screen.

        """
        if cloud == 'maas':
            app.current_cloud_type = 'maas'
            app.current_cloud = utils.gen_cloud()
        else:
            app.current_cloud_type = juju.get_cloud_types_by_name()[cloud]
            app.current_cloud = cloud

        if app.current_model is None:
            app.current_model = utils.gen_model()

        track_event("Cloud selection", app.current_cloud, "")
        return controllers.use('regions').render()
Ejemplo n.º 8
0
    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])

        try:
            app.provider.load(cloud)
        except SchemaErrorUnknownCloud:
            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()
Ejemplo n.º 9
0
    def render(self):
        track_screen("Cloud Creation")
        self.cloud_type = juju.get_cloud_types_by_name()[app.current_cloud]

        if app.current_controller is None:
            app.current_controller = "conjure-up-{}-{}".format(
                app.current_cloud,
                utils.gen_hash())

        if app.current_model is None:
            app.current_model = utils.gen_model()

        # LXD is a special case as we want to make sure a bridge
        # is configured. If not we'll bring up a new view to allow
        # a user to configure a LXD bridge with suggested network
        # information.
        if self.cloud_type == 'localhost':
            lxd_setup_path = common.get_lxd_setup_path()
            app.log.debug("Determining if embedded LXD is setup and ready.")
            if lxd_setup_path.exists():
                return self.finish()
            else:
                self.render_newcloud()

        # TODO: Prompt user to select credentials and set a region
        creds = common.try_get_creds(app.current_cloud)
        try:
            endpoint = juju.get_cloud(app.current_cloud).get(
                'endpoint', None)
        except LookupError:
            endpoint = None
        if creds and (endpoint or self.cloud_type != 'maas'):
            return self.finish()

        # No existing credentials found, start credential editor
        self.render_newcloud()