Example #1
0
 def create_volume(self, volume_name):
     OzoneClient.__logger__.info("Creating Volume %s" % volume_name)
     command = [
         Command.ozone,
         "sh volume create /%s --user root" % volume_name
     ]
     util.run_docker_command(command, self.cluster.client)
Example #2
0
    def get_containers_on_datanode(self, datanode):
        """
        Returns all the container on given datanode.
        """
        container_parent_path = "%s/hdds/%s/current/containerDir0" % \
                                (self.datanode_dir, self.scm_uuid)
        command = "find %s -type f -name '*.container'" % container_parent_path
        exit_code, output = util.run_docker_command(command, datanode)
        containers = []

        container_list = map(str.strip, output.split("\n"))
        for container_path in container_list:
            # Reading the container file.
            exit_code, output = util.run_docker_command(
                "cat " + container_path, datanode)
            if exit_code is not 0:
                continue
            data = output.split("\n")
            # Reading key value pairs from container file.
            key_value = [x for x in data if re.search(r"\w+:\s\w+", x)]
            content = "\n".join(key_value)
            content_yaml = yaml.load(content)
            if content_yaml is None:
                continue
            containers.append(Container(content_yaml.get('containerID'), self))
        return containers
Example #3
0
 def create_bucket(self, volume_name, bucket_name):
     OzoneClient.__logger__.info("Creating Bucket %s in Volume %s" %
                                 (bucket_name, volume_name))
     command = [
         Command.ozone,
         "sh bucket create /%s/%s" % (volume_name, bucket_name)
     ]
     util.run_docker_command(command, self.cluster.client)
Example #4
0
    def put_key(self, source_file, volume_name, bucket_name, key_name, replication_factor=None):
        OzoneClient.__logger__.info("Creating Key %s in %s/%s" % (key_name, volume_name, bucket_name))
        exit_code, output = util.run_docker_command(
            "ls %s" % source_file, self.cluster.client)
        assert exit_code == 0, "%s does not exist" % source_file
        command = [Command.ozone, "sh key put /%s/%s/%s %s" %
                   (volume_name, bucket_name, key_name, source_file)]
        if replication_factor:
            command.append("--replication=%s" % replication_factor)

        exit_code, output = util.run_docker_command(command, self.cluster.client)
        assert exit_code == 0, "Ozone put Key failed with output=[%s]" % output
Example #5
0
 def get_conf_value(self, key):
     """
     Returns the value of given configuration key.
     """
     command = [Command.ozone, "getconf -confKey " + key]
     exit_code, output = util.run_docker_command(command, self.om)
     return str(output).strip()
Example #6
0
 def get_container(self, container_id):
     command = [
         Command.ozone, "scmcli list -c=1 -s=%s | grep containerID",
         container_id - 1
     ]
     exit_code, output = util.run_docker_command(command, self.om)
     if exit_code != 0:
         raise ContainerNotFoundError(container_id)
     return Container(container_id, self)
Example #7
0
 def is_container_replica_exist(self, container_id, datanode):
     container_parent_path = "%s/hdds/%s/current/containerDir0" % \
                             (self.datanode_dir, self.scm_uuid)
     command = "find %s -type f -name '%s.container'" % (
         container_parent_path, container_id)
     exit_code, output = util.run_docker_command(command, datanode)
     container_path = output.strip()
     if not container_path:
         return False
     return True
Example #8
0
 def get_key(self, volume_name, bucket_name, key_name, file_path='.'):
     OzoneClient.__logger__.info("Reading key %s from %s/%s" %
                                 (key_name, volume_name, bucket_name))
     command = [
         Command.ozone,
         "sh key get /%s/%s/%s %s" %
         (volume_name, bucket_name, key_name, file_path)
     ]
     exit_code, output = util.run_docker_command(command,
                                                 self.cluster.client)
     assert exit_code == 0, "Ozone get Key failed with output=[%s]" % output
Example #9
0
 def get_container_datanodes(self, container_id):
     result = []
     for datanode in self.datanodes:
         container_parent_path = "%s/hdds/%s/current/containerDir0" % \
                                 (self.datanode_dir, self.scm_uuid)
         command = "find %s -type f -name '%s.container'" % (
             container_parent_path, container_id)
         exit_code, output = util.run_docker_command(command, datanode)
         if output.strip():
             result.append(datanode)
     return result
Example #10
0
 def __get_scm_uuid__(self):
     """
     Returns SCM's UUID.
     """
     ozone_metadata_dir = self.get_conf_value("ozone.metadata.dirs")
     command = "cat %s/scm/current/VERSION" % ozone_metadata_dir
     exit_code, output = util.run_docker_command(command, self.scm)
     output_list = output.split("\n")
     key_value = [x for x in output_list if re.search(r"\w+=\w+", x)]
     uuid = [token for token in key_value if 'scmUuid' in token]
     return uuid.pop().split("=")[1].strip()
Example #11
0
    def get_container_state(self, container_id, datanode):
        container_parent_path = "%s/hdds/%s/current/containerDir0" % \
                                (self.datanode_dir, self.scm_uuid)
        command = "find %s -type f -name '%s.container'" % (
            container_parent_path, container_id)
        exit_code, output = util.run_docker_command(command, datanode)
        container_path = output.strip()
        if not container_path:
            raise ContainerNotFoundError("Container not found!")

        # Reading the container file.
        exit_code, output = util.run_docker_command("cat " + container_path,
                                                    datanode)
        if exit_code != 0:
            raise ContainerNotFoundError("Container not found!")
        data = output.split("\n")
        # Reading key value pairs from container file.
        key_value = [x for x in data if re.search(r"\w+:\s\w+", x)]
        content = "\n".join(key_value)
        content_yaml = yaml.load(content)
        return str(content_yaml.get('state')).lstrip()
Example #12
0
 def run_freon(self, num_volumes, num_buckets, num_keys, key_size,
               replication_type="RATIS", replication_factor="THREE"):
     """
     Runs freon on the cluster.
     """
     command = [Command.freon,
                " rk",
                " --numOfVolumes " + str(num_volumes),
                " --numOfBuckets " + str(num_buckets),
                " --numOfKeys " + str(num_keys),
                " --keySize " + str(key_size),
                " --replicationType " + replication_type,
                " --factor " + replication_factor]
     return util.run_docker_command(command, self.cluster.client)