示例#1
0
    def create_export(self, context, volume):
        """Creates an export for a logical volume."""
        #BOOKMARK(jdg)

        iscsi_name = "%s%s" % (FLAGS.iscsi_target_prefix, volume['name'])
        volume_path = "/dev/%s/%s" % (FLAGS.volume_group, volume['name'])
        model_update = {}

        # TODO(jdg): In the future move all of the dependent stuff into the
        # cooresponding target admin class
        if not isinstance(self.tgtadm, iscsi.TgtAdm):
            lun = 0
            self._ensure_iscsi_targets(context, volume['host'])
            iscsi_target = self.db.volume_allocate_iscsi_target(
                context, volume['id'], volume['host'])
        else:
            lun = 1  # For tgtadm the controller is lun 0, dev starts at lun 1
            iscsi_target = 0  # NOTE(jdg): Not used by tgtadm

        # Use the same method to generate the username and the password.
        chap_username = utils.generate_username()
        chap_password = utils.generate_password()
        chap_auth = _iscsi_authentication('IncomingUser', chap_username,
                                          chap_password)
        # NOTE(jdg): For TgtAdm case iscsi_name is the ONLY param we need
        # should clean this all up at some point in the future
        tid = self.tgtadm.create_iscsi_target(iscsi_name, iscsi_target, 0,
                                              volume_path, chap_auth)
        model_update['provider_location'] = _iscsi_location(
            FLAGS.iscsi_ip_address, tid, iscsi_name, lun)
        model_update['provider_auth'] = _iscsi_authentication(
            'CHAP', chap_username, chap_password)
        return model_update
示例#2
0
文件: lvm.py 项目: q00189493/cinder
    def create_export(self, context, volume):
        """Creates an export for a logical volume."""

        iscsi_name = "%s%s" % (self.configuration.iscsi_target_prefix, volume["name"])
        volume_path = "/dev/%s/%s" % (self.configuration.volume_group, volume["name"])
        model_update = {}

        # TODO(jdg): In the future move all of the dependent stuff into the
        # cooresponding target admin class
        if not isinstance(self.tgtadm, iscsi.TgtAdm):
            lun = 0
            self._ensure_iscsi_targets(context, volume["host"])
            iscsi_target = self.db.volume_allocate_iscsi_target(context, volume["id"], volume["host"])
        else:
            lun = 1  # For tgtadm the controller is lun 0, dev starts at lun 1
            iscsi_target = 0  # NOTE(jdg): Not used by tgtadm

        # Use the same method to generate the username and the password.
        chap_username = utils.generate_username()
        chap_password = utils.generate_password()
        chap_auth = self._iscsi_authentication("IncomingUser", chap_username, chap_password)
        # NOTE(jdg): For TgtAdm case iscsi_name is the ONLY param we need
        # should clean this all up at some point in the future
        tid = self.tgtadm.create_iscsi_target(iscsi_name, iscsi_target, 0, volume_path, chap_auth)
        model_update["provider_location"] = self._iscsi_location(
            self.configuration.iscsi_ip_address, tid, iscsi_name, lun
        )
        model_update["provider_auth"] = self._iscsi_authentication("CHAP", chap_username, chap_password)
        return model_update
示例#3
0
    def create_export(self, context, volume, volume_path, conf):
        """Creates an export for a logical volume."""
        iscsi_name = "%s%s" % (conf.iscsi_target_prefix,
                               volume['name'])
        max_targets = conf.safe_get('iscsi_num_targets')
        (iscsi_target, lun) = self._get_target_and_lun(context,
                                                       volume,
                                                       max_targets)

        chap_username = utils.generate_username()
        chap_password = utils.generate_password()
        chap_auth = self._iscsi_authentication('IncomingUser',
                                               chap_username,
                                               chap_password)
        # NOTE(jdg): For TgtAdm case iscsi_name is the ONLY param we need
        # should clean this all up at some point in the future
        tid = self.create_iscsi_target(iscsi_name,
                                       iscsi_target,
                                       0,
                                       volume_path,
                                       chap_auth)
        data = {}
        data['location'] = self._iscsi_location(
            conf.iscsi_ip_address, tid, iscsi_name, conf.iscsi_port, lun)
        data['auth'] = self._iscsi_authentication(
            'CHAP', chap_username, chap_password)
        return data
示例#4
0
    def create_export(self, context, volume):
        """Creates an export for a logical volume."""

        iser_name = "%s%s" % (self.configuration.iscsi_target_prefix,
                              volume['name'])
        volume_path = "/dev/%s/%s" % (self.configuration.volume_group,
                                      volume['name'])
        model_update = {}

        # TODO(jdg): In the future move all of the dependent stuff into the
        # cooresponding target admin class
        if not isinstance(self.tgtadm, iscsi.TgtAdm):
            lun = 0
            self._ensure_iser_targets(context, volume['host'])
            iser_target = self.db.volume_allocate_iscsi_target(
                context, volume['id'], volume['host'])
        else:
            lun = 1  # For tgtadm the controller is lun 0, dev starts at lun 1
            iser_target = 0

        # Use the same method to generate the username and the password.
        chap_username = utils.generate_username()
        chap_password = utils.generate_password()
        chap_auth = self._iser_authentication('IncomingUser', chap_username,
                                              chap_password)
        tid = self.tgtadm.create_iscsi_target(iser_name, iser_target, 0,
                                              volume_path, chap_auth)
        model_update['provider_location'] = self._iser_location(
            self.configuration.iscsi_ip_address, tid, iser_name, lun)
        model_update['provider_auth'] = self._iser_authentication(
            'CHAP', chap_username, chap_password)
        return model_update
示例#5
0
 def create_export(self, context, volume, volume_path):
     """Creates an export for a logical volume."""
     iscsi_name = "%s%s" % (CONF.iscsi_target_prefix, volume['name'])
     iscsi_target, lun = self._get_target_and_lun(context, volume)
     chap_username = utils.generate_username()
     chap_password = utils.generate_password()
     chap_auth = self._iscsi_authentication('IncomingUser', chap_username,
                                            chap_password)
     # NOTE(jdg): For TgtAdm case iscsi_name is the ONLY param we need
     # should clean this all up at some point in the future
     tid = self.create_iscsi_target(iscsi_name, iscsi_target, 0,
                                    volume_path, chap_auth)
     data = {}
     data['location'] = self._iscsi_location(CONF.iscsi_ip_address, tid,
                                             iscsi_name, lun)
     data['auth'] = self._iscsi_authentication('CHAP', chap_username,
                                               chap_password)
     return data
示例#6
0
    def _create_export(self, context, volume, vg=None):
        """Creates an export for a logical volume."""
        if vg is None:
            vg = self.configuration.volume_group

        iscsi_name = "%s%s" % (self.configuration.iscsi_target_prefix,
                               volume['name'])
        volume_path = "/dev/%s/%s" % (vg, volume['name'])
        model_update = {}

        # TODO(jdg): In the future move all of the dependent stuff into the
        # corresponding target admin class
        if not isinstance(self.tgtadm, iscsi.TgtAdm):
            lun = 0
            self._ensure_iscsi_targets(context, volume['host'])
            iscsi_target = self.db.volume_allocate_iscsi_target(context,
                                                                volume['id'],
                                                                volume['host'])
        else:
            lun = 1  # For tgtadm the controller is lun 0, dev starts at lun 1
            iscsi_target = 0  # NOTE(jdg): Not used by tgtadm

        # Use the same method to generate the username and the password.
        chap_username = utils.generate_username()
        chap_password = utils.generate_password()
        chap_auth = self._iscsi_authentication('IncomingUser', chap_username,
                                               chap_password)

        tid = self._create_tgtadm_target(iscsi_name, iscsi_target,
                                         volume_path, chap_auth)

        model_update['provider_location'] = self._iscsi_location(
            self.configuration.iscsi_ip_address, tid, iscsi_name, lun)
        model_update['provider_auth'] = self._iscsi_authentication(
            'CHAP', chap_username, chap_password)
        return model_update