示例#1
0
    def _delete_cluster_bucket(self):
        logger.info("Deleting applatix-cluster bucket contents for cluster %s ...", self._name_id)
        cluster_bucket = Cloud().get_bucket(AXClusterConfigPath(name_id=self._name_id).bucket(),
                                            aws_profile=self._aws_profile, region=self._aws_region)

        idobj = AXClusterId(name=self._name_id)
        cluster_config_path = AXClusterConfigPath(name_id=self._name_id)
        cluster_name = idobj.get_cluster_name()
        prefix = cluster_name + "/"

        # TODO: Not idempotent here.
        # Consider the following case: if there is exception thrown when deleting S3 objects, install stage 1
        # information has already been deleted but not everything are successfully deleted, the next time user
        # executes "delete", this program will assume install stage 1 has been cleaned up.
        exempt = [idobj.get_cluster_id_s3_key(), cluster_config_path.cluster_install_stage0_key()]
        logger.info("Deleting objects for cluster %s from bucket %s. This may take some while.",
                    cluster_name,
                    cluster_bucket.get_bucket_name())
        cluster_bucket.delete_all(obj_prefix=prefix, exempt=exempt)
        logger.info("Deleting objects for cluster %s from bucket %s ... DONE",
                    cluster_name, cluster_bucket.get_bucket_name())
        logger.info("Deleting stage0 information ...")
        for item in exempt:
            cluster_bucket.delete_object(item)
        logger.info("Deleting stage0 information ... DONE")
示例#2
0
 def _delete_data_bucket(self):
     logger.info("Deleting applatix-data bucket contents for cluster %s ...", self._name_id)
     data_bucket = Cloud().get_bucket(AXClusterDataPath(name_id=self._name_id).bucket(),
                                      aws_profile=self._aws_profile, region=self._aws_region)
     cluster_name = AXClusterId(name=self._name_id).get_cluster_name()
     prefix = cluster_name + "/"
     logger.info("Deleting objects for cluster %s from bucket %s. This may take some while.",
                 cluster_name,
                 data_bucket.get_bucket_name())
     data_bucket.delete_all(obj_prefix=prefix)
     logger.info("Deleting objects for cluster %s from bucket %s ... DONE",
                 cluster_name, data_bucket.get_bucket_name())