Exemplo n.º 1
0
    def finish(self):
        if app.argv.cloud == "localhost":
            if not utils.check_bridge_exists():
                back = "{} to localhost".format(app.argv.config['spell'])
                os.execl("/usr/share/conjure-up/run-lxd-config",
                         "/usr/share/conjure-up/run-lxd-config",
                         back)
        if app.argv.controller:
            existing_controller = app.argv.controller
            if juju.get_controller(existing_controller) is None:
                utils.error("Specified controller '{}' "
                            "could not be found in cloud '{}'.".format(
                                existing_controller, app.argv.cloud))
                sys.exit(1)
        else:
            existing_controller = juju.get_controller_in_cloud(app.argv.cloud)

        if existing_controller is None:
            return controllers.use('newcloud').render(app.argv.cloud)

        utils.info("Using controller '{}'".format(existing_controller))

        app.current_controller = existing_controller
        app.current_model = petname.Name()
        utils.info("Creating new juju model named '{}', "
                   "please wait.".format(app.current_model))
        juju.add_model(app.current_model, app.current_controller)

        return controllers.use('deploy').render()
Exemplo n.º 2
0
    def finish(self):
        app.current_cloud = app.argv.cloud

        if app.argv.model:
            app.current_model = app.argv.model
        else:
            app.current_model = "conjure-up-{}-{}".format(
                app.env['CONJURE_UP_SPELL'], utils.gen_hash())

        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 self.__get_existing_controller(app.current_controller) is None:
            return controllers.use('newcloud').render()
        else:
            utils.info("Using controller '{}'".format(app.current_controller))
            utils.info("Creating new deployment named '{}', "
                       "please wait.".format(app.current_model))
            juju.add_model(app.current_model, app.current_controller)
            return controllers.use('deploy').render()

        utils.error("Something happened with the controller or model, "
                    "please check the logs.")
        sys.exit(1)
Exemplo n.º 3
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))
            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.")
        sys.exit(1)
Exemplo n.º 4
0
    def finish(self, controller):
        if controller is None:
            app.current_controller = "conjure-up-{}-{}".format(
                app.current_cloud, utils.gen_hash())
            return controllers.use('bootstrap').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
            app.current_controller = app.jaas_controller
            app.is_jaas = True
        else:
            app.current_controller = controller

        if app.current_controller not in juju.get_controllers()['controllers']:
            return controllers.use('bootstrap').render()

        events.Bootstrapped.set()

        app.loop.create_task(
            juju.add_model(app.current_model, app.current_controller,
                           app.current_cloud))
        return controllers.use('deploy').render()
Exemplo n.º 5
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()
Exemplo n.º 6
0
    def finish(self):
        if app.argv.cloud == "localhost":
            if not utils.check_bridge_exists():
                back = "{} to localhost".format(app.argv.config['spell'])
                os.execl("/usr/share/conjure-up/run-lxd-config",
                         "/usr/share/conjure-up/run-lxd-config",
                         back)

        existing_controller = juju.get_controller_in_cloud(app.argv.cloud)
        if existing_controller is None:
            return controllers.use('newcloud').render(app.argv.cloud)

        app.current_controller = existing_controller
        app.current_model = petname.Name()
        utils.info("Creating new juju model named '{}', "
                   "please wait.".format(app.current_model))
        juju.add_model(app.current_model, app.current_controller)

        return controllers.use('deploy').render()
Exemplo n.º 7
0
    def finish(self):
        if app.argv.cloud == "localhost":
            if not utils.check_bridge_exists():
                back = "{} to localhost".format(app.argv.config['spell'])
                os.execl("/usr/share/conjure-up/run-lxd-config",
                         "/usr/share/conjure-up/run-lxd-config", back)

        existing_controller = get_controller_in_cloud(app.argv.cloud)
        if existing_controller is None:
            return controllers.use('newcloud').render(app.argv.cloud)

        app.current_controller = existing_controller
        juju.switch_controller(app.current_controller)
        app.current_model = petname.Name()
        utils.info("Creating new juju model named '{}', "
                   "please wait.".format(app.current_model))
        juju.add_model(app.current_model)
        juju.switch_model(app.current_model)

        return controllers.use('deploy').render()
Exemplo n.º 8
0
    def finish(self):
        if app.argv.controller:
            existing_controller = app.argv.controller
            if juju.get_controller(existing_controller) is None:
                utils.error("Specified controller '{}' "
                            "could not be found in cloud '{}'.".format(
                                existing_controller, app.argv.cloud))
                sys.exit(1)
        else:
            existing_controller = juju.get_controller_in_cloud(app.argv.cloud)

        if existing_controller is None:
            app.current_cloud = app.argv.cloud
            return controllers.use('newcloud').render()

        utils.info("Using controller '{}'".format(existing_controller))

        app.current_controller = existing_controller
        app.current_model = petname.Name()
        utils.info("Creating new juju model named '{}', "
                   "please wait.".format(app.current_model))
        juju.add_model(app.current_model, app.current_controller)

        return controllers.use('deploy').render()
Exemplo n.º 9
0
 def render(self):
     if not app.jaas_ok:
         utils.error('JaaS not compatible with specified cloud')
         return events.Shutdown.set(1)
     if not app.jaas_controller:
         utils.error('No JaaS controller registered')
         return events.Shutdown.set(1)
     if not juju.has_jaas_auth():
         utils.error('JaaS controller not authenticated')
         return events.Shutdown.set(1)
     app.is_jaas = True
     events.Bootstrapped.set()
     app.loop.create_task(
         juju.add_model(app.current_model, app.current_controller,
                        app.current_cloud))
     controllers.use('deploy').render()
Exemplo n.º 10
0
 async def _register(self, email, password, twofa):
     if not await juju.register_controller(app.jaas_controller,
                                           JAAS_DOMAIN,
                                           email,
                                           password,
                                           twofa,
                                           fail_cb=self.fail,
                                           timeout_cb=self.timeout):
         return
     app.current_controller = app.jaas_controller
     app.is_jaas = True
     self.authenticating.clear()
     events.Bootstrapped.set()
     app.log.info('JAAS is registered')
     app.loop.create_task(
         juju.add_model(app.current_model, app.current_controller,
                        app.current_cloud))
     controllers.use('deploy').render()
Exemplo n.º 11
0
 def __add_model(self):
     juju.switch_controller(app.current_controller)
     juju.add_model(app.current_model)
     juju.switch_model(app.current_model)
Exemplo n.º 12
0
 def __add_model(self):
     juju.switch_controller(app.current_controller)
     juju.add_model(app.current_model)
     juju.switch_model(app.current_model)