Example #1
0
    def run(self):
        _g_logger.debug("Initialize run")
        # verify that the parameters in initialize match what came in on the
        # connection
        try:
            plugin_utils.log_to_dcm_console_job_details(
                job_name=self.name,
                details="Renaming the host to %s" % self.args.serverName)
            res_obj = self.rename.run()
            if res_obj.get_return_code() != 0:
                res_obj.set_message(res_obj.get_message() + " : rename failed")
                return res_obj

            # add customer user
            plugin_utils.log_to_dcm_console_job_details(
                job_name=self.name, details="Adding the user")
            res_obj = self.add_user.run()
            if res_obj.get_return_code() != 0:
                res_obj.set_message(res_obj.get_message() +
                                    " : addUser failed")
                return res_obj

            self.conf.state = "RUNNING"
            return plugin_base.PluginReply(0, reply_type="void")
        except Exception as ex:
            _g_logger.exception("initialize failed: " + str(ex))
            return plugin_base.PluginReply(1, message=str(ex))
Example #2
0
    def run(self):
        _g_logger.debug("Initialize run")
        # verify that the parameters in initialize match what came in on the
        # connection
        try:
            plugin_utils.log_to_dcm_console_job_details(
                job_name=self.name, details="Renaming the host to %s" % self.args.serverName
            )
            res_obj = self.rename.run()
            if res_obj.get_return_code() != 0:
                res_obj.set_message(res_obj.get_message() + " : rename failed")
                return res_obj

            # add customer user
            plugin_utils.log_to_dcm_console_job_details(job_name=self.name, details="Adding the user")
            res_obj = self.add_user.run()
            if res_obj.get_return_code() != 0:
                res_obj.set_message(res_obj.get_message() + " : addUser failed")
                return res_obj

            self.conf.state = "RUNNING"
            return plugin_base.PluginReply(0, reply_type="void")
        except Exception as ex:
            _g_logger.exception("initialize failed: " + str(ex))
            return plugin_base.PluginReply(1, message=str(ex))
Example #3
0
    def run(self):
        key_file = self.conf.get_temp_file(self.args.userId + ".pub")

        try:
            if self.ssh_public_key:
                with open(key_file, "w") as f:
                    f.write(self.ssh_public_key)
                self.ordered_param_list.append(key_file)

            plugin_utils.log_to_dcm_console_job_details(
                job_name=self.name,
                details="Attempting to add the user %s." % self.args.userId)

            rc = super(AddUser, self).run()

            admin_bool = self.args.administrator.lower() == "true"
            self._db.add_user(
                self.conf.agent_id, self.args.userId, self.ssh_public_key,
                admin_bool)

            plugin_utils.log_to_dcm_console_job_details(
                job_name=self.name,
                details="The user %s was added." % self.args.userId)
            return rc
        finally:
            if os.path.exists(key_file):
                plugin_utils.secure_delete(self.conf, key_file)
Example #4
0
    def run(self):
        key_file = self.conf.get_temp_file(self.args.userId + ".pub")

        try:
            if self.ssh_public_key:
                with open(key_file, "w") as f:
                    f.write(self.ssh_public_key)
                self.ordered_param_list.append(key_file)

            plugin_utils.log_to_dcm_console_job_details(
                job_name=self.name,
                details="Attempting to add the user %s." % self.args.userId)

            rc = super(AddUser, self).run()

            admin_bool = self.args.administrator.lower() == "true"
            self._db.add_user(self.conf.agent_id, self.args.userId,
                              self.ssh_public_key, admin_bool)

            plugin_utils.log_to_dcm_console_job_details(
                job_name=self.name,
                details="The user %s was added." % self.args.userId)
            return rc
        finally:
            if os.path.exists(key_file):
                plugin_utils.secure_delete(self.conf, key_file)
Example #5
0
    def run(self):
        private_ips = self.conf.meta_data_object.get_ipv4_addresses()
        if not private_ips:
            return plugin_base.PluginReply(
                1, error_message="No IP Address was found")

        self.ordered_param_list.append(private_ips[0])
        plugin_utils.log_to_dcm_console_job_details(
            job_name=self.name,
            details="Renaming the server to %s with the local IP %s"
            % (self.args.serverName, private_ips[0]))

        return super(Rename, self).run()