コード例 #1
0
def get_target_s3_zdb_config(target_name):
    zos = get_zos()
    for sol_dict in solutions.list_minio_solutions():
        if sol_dict["Name"] != target_name:
            continue
        minio_wid = sol_dict["wids"][0]
        workload = zos.workloads.get(minio_wid)
        sol_uuid = solutions.get_solution_uuid(workload)
        if not sol_uuid:
            continue
        solution_workloads = solutions.get_workloads_by_uuid(sol_uuid)
        cluster_zdb_configs = []
        for workload in solution_workloads:
            if workload.info.workload_type != WorkloadType.Zdb:
                continue
            # check the password
            # if no password, then it is old not supported

            # metadata is json serializable as the workload was identitified by solution_uuid
            metadata = serializers.json.loads(
                deployer.decrypt_metadata(workload.info.metadata))
            password = metadata.get("password")
            if not password:
                j.logger.error(
                    f"AUTO_TOPUP: zdb workload {workload.id} doesn't include password in metadata in s3 solution {sol_dict['Name']}"
                )
                raise j.exceptions.Validation(
                    f"AUTO_TOPUP: zdb workload {workload.id} doesn't include password in metadata in s3 solution {sol_dict['Name']}"
                )
            zdb_url = deployer.get_zdb_url(workload.id,
                                           password,
                                           workload=workload)
            splits = zdb_url.split("@")
            zdb_dict = {
                "address": splits[1],
                "namespace": splits[0].split(":")[0],
                "password": password
            }
            cluster_zdb_configs.append(zdb_dict)

        if not cluster_zdb_configs:
            j.logger.error(
                f"AUTO_TOPUP: can't retrive zdb config of s3 solution {sol_dict['Name']} because of invalid zdb metadata"
            )
            raise j.exceptions.Runtime(
                f"AUTO_TOPUP: can't retrive zdb config of s3 solution {sol_dict['Name']} because of invalid zdb metadata"
            )

        return cluster_zdb_configs
コード例 #2
0
    def minio_reservation(self):
        zdb_configs = []
        for zid in self.zdb_result:
            zdb_configs.append(deployer.get_zdb_url(zid, self.password))

        metadata = {
            "name": self.solution_name,
            "form_info": {
                "chatflow": "minio",
                "Solution name": self.solution_name,
                "zdb_password": self.password
            },
        }
        self.solution_metadata.update(metadata)

        if self.mode == "Master/Slave":
            metadata["form_info"]["Slave IP"] = self.ip_addresses[1]

        self.minio_result = deployer.deploy_minio_containers(
            pool_id=self.minio_pool_ids[0],
            network_name=self.network_view.name,
            minio_nodes=[n.node_id for n in self.minio_nodes],
            minio_ip_addresses=self.ip_addresses,
            zdb_configs=zdb_configs,
            ak=self.ak,
            sk=self.sk,
            ssh_key=self.public_ssh_key,
            cpu=self.minio_cont_resources["cpu"],
            memory=self.minio_cont_resources["memory"],
            data=self.data,
            parity=self.parity,
            disk_size=1,
            log_config=self.log_config,
            mode=self.mode,
            bot=self,
            pool_ids=self.minio_pool_ids,
            solution_uuid=self.solution_id,
            public_ipv6=self.public_ipv6,
            **self.solution_metadata,
        )
        for resv_id in self.minio_result:
            success = deployer.wait_workload(resv_id, self)
            if not success:
                raise DeploymentFailed(
                    f"Failed to deploy Minio container workload {resv_id}",
                    solution_uuid=self.solution_id,
                    wid=resv_id)
コード例 #3
0
    def deploy_s3_minio_container(self, pool_id, ak, sk, ssh_key, scheduler,
                                  zdb_wids, solution_uuid, password):
        zdb_configs = []
        self.vdc_deployer.info(f"deploying minio for zdbs: {zdb_wids}")
        for zid in zdb_wids:
            zdb_configs.append(
                deployer.get_zdb_url(
                    zid, password, identity_name=self.identity.instance_name))
        self.vdc_deployer.info(f"zdb_configs: {zdb_configs}")

        network_view = deployer.get_network_view(
            self.vdc_name, identity_name=self.identity.instance_name)
        for node in scheduler.nodes_by_capacity(cru=MINIO_CPU,
                                                mru=MINIO_MEMORY / 1024,
                                                sru=MINIO_DISK / 1024,
                                                ip_version="IPv6"):
            self.vdc_deployer.info(f"node {node.node_id} selected for minio")
            try:
                result = deployer.add_network_node(self.vdc_name, node,
                                                   pool_id, network_view,
                                                   self.bot,
                                                   self.identity.instance_name)
                if result:
                    for wid in result["ids"]:
                        success = deployer.wait_workload(
                            wid,
                            self.bot,
                            5,
                            identity_name=self.identity.instance_name,
                            cancel_by_uuid=False)
                        if not success:
                            self.vdc_deployer.error(
                                f"workload {wid} failed when adding node to network"
                            )
                            raise DeploymentFailed()
            except DeploymentFailed:
                self.vdc_deployer.error(
                    f"failed to deploy minio network on node {node.node_id}.")
                continue

            network_view = network_view.copy()
            ip_address = network_view.get_free_ip(node)
            self.vdc_deployer.info(f"minio ip address {ip_address}")
            try:
                result = deployer.deploy_minio_containers(
                    pool_id,
                    self.vdc_name,
                    [node.node_id],
                    [ip_address],
                    zdb_configs,
                    ak,
                    sk,
                    ssh_key,
                    MINIO_CPU,
                    MINIO_MEMORY,
                    S3_NO_DATA_NODES,
                    S3_NO_PARITY_NODES,
                    public_ipv6=True,
                    disk_size=int(MINIO_DISK / 1024),
                    bot=self.bot,
                    identity_name=self.identity.instance_name,
                    # form_info={"chatflow": "minio"},
                    # name=self.vdc_name,
                    solution_uuid=solution_uuid,
                    description=self.vdc_deployer.description,
                )
            except DeploymentFailed as e:
                if e.wid:
                    workload = self.zos.workloads.get(e.wid)
                    self.vdc_deployer.error(
                        f"failed to deploy minio volume wid: {e.wid} on node {workload.info.node_id}"
                    )
                else:
                    self.vdc_deployer.error(
                        f"failed to deploy minio volume due to error {str(e)}")
                continue
            wid = result[0]
            try:
                success = deployer.wait_workload(
                    wid,
                    self.bot,
                    identity_name=self.identity.instance_name,
                    cancel_by_uuid=False)
                if not success:
                    raise DeploymentFailed()
                self.vdc_deployer.info(
                    f"minio container deployed successfully wid: {wid}")
                return wid
            except DeploymentFailed:
                self.vdc_deployer.error(
                    f"failed to deploy minio container wid: {wid}")
                continue
        self.vdc_deployer.error("no nodes available to deploy minio container")