Esempio n. 1
0
    def get_cont(self, pool, cont_uuid):
        """Get an existing container.

        Args:
            pool (TestPool): pool to open the container in.
            cont_uuid (str): container uuid.

        Returns:
            TestContainer: the container object

        """
        # Open the container
        # Create a TestContainer instance
        container = TestContainer(pool, daos_command=self.get_daos_command())

        # Create the underlying DaosContainer instance
        container.container = DaosContainer(pool.context)
        container.container.uuid = str_to_c_uuid(cont_uuid)
        container.uuid = container.container.get_uuid_str()
        container.container.poh = pool.pool.handle

        # Save container and uuid
        self.container.append(container)
        self.uuids.append(str(container.uuid))

        return container
Esempio n. 2
0
    def create(self, uuid=None, con_in=None):
        """Create a container.

        Args:
            uuid (str, optional): contianer uuid. Defaults to None.
        """
        self.destroy()
        self.log.info("Creating a container with pool handle %s",
                      self.pool.pool.handle.value)
        self.container = DaosContainer(self.pool.context)

        if self.control_method.value == self.USE_API:
            # Create a container with the API method
            kwargs = {"poh": self.pool.pool.handle}
            if uuid is not None:
                kwargs["con_uuid"] = uuid

            # Refer daos_api for setting input params for DaosContainer.
            if con_in is not None:
                cop = self.input_params.get_con_create_params()
                cop.type = con_in[0]
                cop.enable_chksum = con_in[1]
                cop.srv_verify = con_in[2]
                cop.chksum_type = con_in[3]
                cop.chunk_size = con_in[4]
                kwargs["con_prop"] = cop

            self._call_method(self.container.create, kwargs)

        elif self.control_method.value == self.USE_DAOS and self.daos:
            # Create a container with the daos command
            kwargs = {
                "pool": self.pool.uuid,
                "sys_name": self.pool.name.value,
                "svc": ",".join(str(rank) for rank in self.pool.svc_ranks),
                "cont": uuid,
                "path": self.path.value,
                "cont_type": self.type.value,
                "oclass": self.oclass.value,
                "chunk_size": self.chunk_size.value,
                "properties": self.properties.value,
            }
            self._log_method("daos.container_create", kwargs)
            uuid = self.daos.get_output("container_create", **kwargs)[0]

            # Populte the empty DaosContainer object with the properties of the
            # container created with daos container create.
            self.container.uuid = str_to_c_uuid(uuid)
            self.container.attached = 1

        elif self.control_method.value == self.USE_DAOS:
            self.log.error("Error: Undefined daos command")

        else:
            self.log.error("Error: Undefined control_method: %s",
                           self.control_method.value)

        self.uuid = self.container.get_uuid_str()
        self.log.info("  Container created with uuid %s", self.uuid)
Esempio n. 3
0
    def create(self, uuid=None, con_in=None, acl_file=None):
        """Create a container.

        Args:
            uuid (str, optional): container uuid. Defaults to None.
            con_in (optional): to be defined. Defaults to None.
            acl_file (str, optional): path of the ACL file. Defaults to None.
        """
        self.destroy()
        if not self.silent.value:
            self.log.info("Creating a container with pool handle %s",
                          self.pool.pool.handle.value)
        self.container = DaosContainer(self.pool.context)

        if self.control_method.value == self.USE_API:
            # Create a container with the API method
            kwargs = {"poh": self.pool.pool.handle}
            if uuid is not None:
                kwargs["con_uuid"] = uuid

            # Refer daos_api for setting input params for DaosContainer.
            if con_in is not None:
                cop = self.input_params.get_con_create_params()
                cop.type = con_in[0]
                cop.enable_chksum = con_in[1]
                cop.srv_verify = con_in[2]
                cop.chksum_type = con_in[3]
                cop.chunk_size = con_in[4]
                kwargs["con_prop"] = cop

            self._call_method(self.container.create, kwargs)

        elif self.control_method.value == self.USE_DAOS and self.daos:
            # Disconnect the pool if connected
            self.pool.disconnect()

            # Create a container with the daos command
            kwargs = {
                "pool": self.pool.uuid,
                "sys_name": self.pool.name.value,
                "cont": uuid,
                "path": self.path.value,
                "cont_type": self.type.value,
                "oclass": self.oclass.value,
                "chunk_size": self.chunk_size.value,
                "properties": self.properties.value,
                "acl_file": acl_file,
            }

            self._log_method("daos.container_create", kwargs)
            try:
                uuid = self.daos.container_create(
                    **kwargs)["response"]["container_uuid"]
            except KeyError as error:
                raise CommandFailure(
                    "Error: Unexpected daos container create output"
                ) from error
            # Populate the empty DaosContainer object with the properties of the
            # container created with daos container create.
            self.container.uuid = str_to_c_uuid(uuid)
            self.container.attached = 1
            self.container.poh = self.pool.pool.handle

        elif self.control_method.value == self.USE_DAOS:
            self.log.error("Error: Undefined daos command")

        else:
            self.log.error("Error: Undefined control_method: %s",
                           self.control_method.value)

        self.uuid = self.container.get_uuid_str()
        if not self.silent.value:
            self.log.info("  Container created with uuid %s", self.uuid)