Untitled

mail@pastecode.io avatar
unknown
plain_text
a month ago
1.4 kB
2
Indexable
Never
Similarly can you help me remove hard coding from this function?
def collect_csd_configs(self, instance_id, workflow_path):
        """
        Gather current CSD configs
        """
        credentials = self.get_pas_credentials(PAS_ADMIN_OPS_ROLE)
        cmds = self.get_rds_s3_file_transfer_template(
            credentials["AccessKeyId"], credentials["SecretAccessKey"]
        )
        cmds.append("export logfile=/rdsdbdata/tmp/csd_configs.log")
        cmds.append("sudo date >> $logfile 2>&1")
        cmds.append('sudo echo "Copy GetCsdConfigs.sh to /tmp" >> $logfile 2>&1')
        cmds.append(
            "aws s3 cp "
            + f"{self.base_s3_location}/aurora-db-logs/GetCsdConfigs.sh /tmp "
            + ">> $logfile 2>&1"
        )
        cmds.append('sudo echo "Run GetCsdConfigs.sh" >> $logfile 2>&1')
        cmds.append("sudo chmod +x /tmp/GetCsdConfigs.sh  >> $logfile 2>&1")
        cmds.append("sudo bash /tmp/GetCsdConfigs.sh  >> $logfile 2>&1")
        cmds.append('sudo echo "Copy /rdsdbdata/tmp/GetCsdConfigs.log to S3" >> $logfile 2>&1')
        cmds.append("sleep 2")
        cmds.append(
            "aws s3 cp ${logfile} "
            + f"{get_pas_logs_s3_dir_for_instance(workflow_path, instance_id[0].strip())} "
            + ">> $logfile 2>&1"
        )

        self.__ssm_client.run_cmd(
            instance_id[1],
            cmds,
        )
Leave a Comment