示例#1
0
    def _service_add(self, cmd):
        svc_type = cmd['svc_type']
        if svc_type == "osd":
            device_spec = cmd['svc_arg']
            try:
                node_name, block_device = device_spec.split(":")
            except TypeError:
                return -errno.EINVAL, "", "Invalid device spec, should be <node>:<device>"

            spec = orchestrator.OsdCreationSpec()
            spec.node = node_name
            spec.format = "bluestore"
            spec.drive_group = orchestrator.DriveGroupSpec([block_device])

            completion = self._oremote("create_osds", spec)
            self._wait([completion])

            return 0, "", "Success."

        elif svc_type == "mds":
            fs_name = cmd['svc_arg']

            spec = orchestrator.StatelessServiceSpec()
            spec.name = fs_name

            completion = self._oremote("add_stateless_service", svc_type, spec)
            self._wait([completion])

            return 0, "", "Success."
        else:
            raise NotImplementedError(svc_type)
示例#2
0
文件: module.py 项目: tmj5441302/ceph
    def _create_osd(self, svc_arg=None, inbuf=None):
        # type: (str, str) -> HandleCommandResult
        """Create one or more OSDs"""

        usage = """
Usage:
  ceph orchestrator osd create -i <json_file>
  ceph orchestrator osd create host:device1,device2,...
"""

        if inbuf:
            try:
                drive_group = orchestrator.DriveGroupSpec.from_json(
                    json.loads(inbuf))
            except ValueError as e:
                msg = 'Failed to read JSON input: {}'.format(str(e)) + usage
                return HandleCommandResult(-errno.EINVAL, stderr=msg)

        elif svc_arg:
            try:
                node_name, block_device = svc_arg.split(":")
                block_devices = block_device.split(',')
            except (TypeError, KeyError, ValueError):
                msg = "Invalid host:device spec: '{}'".format(svc_arg) + usage
                return HandleCommandResult(-errno.EINVAL, stderr=msg)

            devs = orchestrator.DeviceSelection(paths=block_devices)
            drive_group = orchestrator.DriveGroupSpec(node_name,
                                                      data_devices=devs)
        else:
            return HandleCommandResult(-errno.EINVAL, stderr=usage)

        # TODO: Remove this and make the orchestrator composable
        #   Like a future or so.
        host_completion = self.get_hosts()
        self._orchestrator_wait([host_completion])
        orchestrator.raise_if_exception(host_completion)
        all_hosts = [h.name for h in host_completion.result]

        try:
            drive_group.validate(all_hosts)
        except orchestrator.DriveGroupValidationError as e:
            return HandleCommandResult(-errno.EINVAL, stderr=str(e))

        completion = self.create_osds(drive_group, all_hosts)
        self._orchestrator_wait([completion])
        orchestrator.raise_if_exception(completion)
        self.log.warning(str(completion.result))
        return HandleCommandResult(stdout=str(completion.result))
示例#3
0
    def _osd_add(self, cmd):
        device_spec = cmd['svc_arg']
        try:
            node_name, block_device = device_spec.split(":")
        except TypeError:
            return HandleCommandResult(-errno.EINVAL,
                                       stderr="Invalid device spec, should be <node>:<device>")

        spec = orchestrator.OsdCreationSpec()
        spec.node = node_name
        spec.format = "bluestore"
        spec.drive_group = orchestrator.DriveGroupSpec([block_device])

        completion = self.create_osds(spec)
        self._orchestrator_wait([completion])

        return HandleCommandResult()
示例#4
0
文件: module.py 项目: shylesh/ceph
    def _osd_add(self, cmd):
        device_spec = cmd['svc_arg']
        try:
            node_name, block_device = device_spec.split(":")
        except TypeError:
            return HandleCommandResult(-errno.EINVAL,
                                       stderr="Invalid device spec, should be <node>:<device>")

        devs = orchestrator.DeviceSelection(paths=block_device)
        spec = orchestrator.DriveGroupSpec(node_name, data_devices=devs)

        # TODO: Remove this and make the orchestrator composable
        # or
        # Probably this should be moved to each of the orchestrators,
        # then we wouldn't need the "all_hosts" parameter at all.
        host_completion = self.get_hosts()
        self.wait([host_completion])
        all_hosts = [h.name for h in host_completion.result]

        completion = self.create_osds(spec, all_hosts=all_hosts)
        self._orchestrator_wait([completion])

        return HandleCommandResult()