Exemple #1
0
 def migrate_lun(self, src_id, dst_id, rate=VNXMigrationRate.HIGH):
     cmd = ['migrate', '-start']
     cmd += int_var('-source', src_id)
     cmd += int_var('-dest', dst_id)
     cmd += enum_var('-rate', rate, VNXMigrationRate)
     cmd.append('-o')
     return cmd
Exemple #2
0
 def sg_add_hlu(self, sg_name, hlu_id, alu_id):
     cmd = ['storagegroup', '-addhlu']
     cmd += int_var('-hlu', hlu_id)
     cmd += int_var('-alu', alu_id)
     cmd += text_var('-gname', sg_name)
     cmd.append('-o')
     return cmd
 def modify_ioclass(self,
                    name,
                    new_name=None,
                    iotype=None,
                    lun_ids=None,
                    smp_names=None,
                    ctrlmethod=None,
                    minsize=None,
                    maxsize=None):
     cmd = ['nqm', '-ioclass', '-modify', '-name', name]
     cmd += text_var('-newname', new_name)
     cmd += text_var('-iotype', iotype)
     cmd += int_var('-minsize', minsize)
     cmd += int_var('-maxsize', maxsize)
     # Currently we do not support reset to anyio
     # if anyio is True:
     #     cmd += text_var('-anyio')
     cmd += list_var('-luns', lun_ids)
     cmd += list_var('-snapshots', smp_names)
     # Currently we do not support clear all luns
     # if (lun_ids and len(lun_ids) == 0)
     # and (smp_names and len(smp_names) == 0):
     #     cmd += ['-nolun']
     cmd += VNXCtrlMethod.parse_cmd(ctrlmethod)
     cmd.append('-o')
     return cmd
Exemple #4
0
 def migrate_lun(self, src_id, dst_id, rate=VNXMigrationRate.HIGH):
     cmd = ['migrate', '-start']
     cmd += int_var('-source', src_id)
     cmd += int_var('-dest', dst_id)
     cmd += enum_var('-rate', rate, VNXMigrationRate)
     cmd.append('-o')
     return cmd
Exemple #5
0
 def sg_add_hlu(self, sg_name, hlu_id, alu_id):
     cmd = ['storagegroup', '-addhlu']
     cmd += int_var('-hlu', hlu_id)
     cmd += int_var('-alu', alu_id)
     cmd += text_var('-gname', sg_name)
     cmd.append('-o')
     return cmd
Exemple #6
0
    def delete_iscsi_ip(self, sp, port_id, vport_id=None):
        if vport_id is None:
            vport_id = 0

        cmd = ['connection', '-delport']
        cmd += ['-sp', VNXSPEnum.get_sp_index(sp)]
        cmd += int_var('-portid', port_id)
        cmd += int_var('-vportid', vport_id)
        cmd.append('-o')
        return cmd
Exemple #7
0
    def get_connection_port(self, sp=None, port_id=None, vport_id=None):
        cmd = 'connection -getport -all'.split()
        if sp is not None:
            cmd += ['-sp', VNXSPEnum.get_sp_index(sp)]

        cmd += int_var('-portid', port_id)
        if port_id is not None:
            cmd += int_var('-vportid', vport_id)

        return cmd
Exemple #8
0
    def delete_iscsi_ip(self, sp, port_id, vport_id=None):
        if vport_id is None:
            vport_id = 0

        cmd = ['connection', '-delport']
        cmd += ['-sp', VNXSPEnum.get_sp_index(sp)]
        cmd += int_var('-portid', port_id)
        cmd += int_var('-vportid', vport_id)
        cmd.append('-o')
        return cmd
Exemple #9
0
    def get_connection_port(self, sp=None, port_id=None, vport_id=None):
        cmd = 'connection -getport -all'.split()
        if sp is not None:
            cmd += ['-sp', VNXSPEnum.get_sp_index(sp)]

        cmd += int_var('-portid', port_id)
        if port_id is not None:
            cmd += int_var('-vportid', vport_id)

        return cmd
Exemple #10
0
 def enable_compression(self, lun_id=None, rate=None, pool_id=None,
                        pool_name=None, ignore_thresholds=False):
     cmd = ['compression', '-on']
     cmd += int_var('-l', lun_id)
     cmd += int_var('-destPoolId', pool_id)
     cmd += text_var('-destPoolName', pool_name)
     cmd += enum_var('-rate', rate, VNXCompressionRate)
     if ignore_thresholds:
         cmd.append('-ignoreThresholds')
     cmd.append('-o')
     return cmd
 def create_policy(self,
                   name,
                   ioclasses=None,
                   fail_action=None,
                   time_limit=None,
                   eval_window=None):
     cmd = ['nqm', '-policy', '-create', '-name', name]
     cmd += list_var('-ioclasses', ioclasses)
     cmd += text_var('-failaction', fail_action)
     cmd += int_var('-timelimit', time_limit)
     cmd += int_var('-evalwindow', eval_window)
     return cmd
Exemple #12
0
    def set_path(self, sg_name, hba_uid, sp, port_id, ip, host, vport_id=None):

        cmd = ['storagegroup', '-setpath']
        cmd += text_var('-gname', sg_name)
        cmd += text_var('-hbauid', hba_uid)
        cmd += ['-sp', VNXSPEnum.get_sp_index(sp)]
        cmd += int_var('-spport', port_id)
        cmd += int_var('-spvport', vport_id)
        cmd += text_var('-ip', ip)
        cmd += text_var('-host', host)
        cmd.append('-o')
        return cmd
Exemple #13
0
    def set_path(self, sg_name, hba_uid, sp, port_id,
                 ip, host, vport_id=None):

        cmd = ['storagegroup', '-setpath']
        cmd += text_var('-gname', sg_name)
        cmd += text_var('-hbauid', hba_uid)
        cmd += ['-sp', VNXSPEnum.get_sp_index(sp)]
        cmd += int_var('-spport', port_id)
        cmd += int_var('-spvport', vport_id)
        cmd += ['-ip', ip]
        cmd += text_var('-host', host)
        cmd.append('-o')
        return cmd
Exemple #14
0
 def enable_compression(self,
                        lun_id=None,
                        rate=None,
                        pool_id=None,
                        pool_name=None,
                        ignore_thresholds=False):
     cmd = ['compression', '-on']
     cmd += int_var('-l', lun_id)
     cmd += int_var('-destPoolId', pool_id)
     cmd += text_var('-destPoolName', pool_name)
     cmd += enum_var('-rate', rate, VNXCompressionRate)
     if ignore_thresholds:
         cmd.append('-ignoreThresholds')
     cmd.append('-o')
     return cmd
 def create_ioclass(self,
                    name,
                    iotype='rw',
                    lun_ids=None,
                    smp_names=None,
                    ctrlmethod=VNXCtrlMethod.NO_CTRL,
                    minsize=None,
                    maxsize=None):
     cmd = ['nqm', '-ioclass', '-create', '-name', name, '-iotype', iotype]
     cmd += int_var('-minsize', minsize)
     cmd += int_var('-maxsize', maxsize)
     cmd += list_var('-luns', lun_ids)
     cmd += list_var('-snapshots', smp_names)
     cmd += VNXCtrlMethod.parse_cmd(ctrlmethod)
     return cmd
Exemple #16
0
    def config_iscsi_ip(self, sp, port_id, ip, netmask, gateway,
                        vport_id=None, vlan_id=None):
        if vport_id is None:
            vport_id = 0

        cmd = ['connection', '-setport', '-iscsi']
        cmd += ['-sp', VNXSPEnum.get_sp_index(sp)]
        cmd += int_var('-portid', port_id)
        cmd += int_var('-vportid', vport_id)
        cmd += int_var('-vlanid', vlan_id)
        cmd += text_var('-address', ip)
        cmd += text_var('-subnetmask', netmask)
        cmd += text_var('-gateway', gateway)
        cmd.append('-o')
        return cmd
Exemple #17
0
 def cancel_migrate_lun(self, src_id):
     if src_id is None:
         raise ValueError('source LUN id missing for cancel migration.')
     cmd = ['migrate', '-cancel']
     cmd += int_var('-source', src_id)
     cmd.append('-o')
     return cmd
 def restore_snap(self, snap_name, res_id, backup_snap=None):
     cmd = ['snap', '-restore']
     cmd += text_var('-id', snap_name)
     cmd += int_var('-res', res_id)
     if backup_snap:
         cmd += text_var('-bakName', backup_snap)
     return cmd
Exemple #19
0
 def disable_compression(self, lun_id, ignore_thresholds=False):
     cmd = ['compression', '-off']
     cmd += int_var('-l', lun_id)
     if ignore_thresholds:
         cmd.append('-ignoreThresholds')
     cmd.append('-o')
     return cmd
Exemple #20
0
 def cancel_migrate_lun(self, src_id):
     if src_id is None:
         raise ValueError('source LUN id missing for cancel migration.')
     cmd = ['migrate', '-cancel']
     cmd += int_var('-source', src_id)
     cmd.append('-o')
     return cmd
Exemple #21
0
 def disable_compression(self, lun_id, ignore_thresholds=False):
     cmd = ['compression', '-off']
     cmd += int_var('-l', lun_id)
     if ignore_thresholds:
         cmd.append('-ignoreThresholds')
     cmd.append('-o')
     return cmd
Exemple #22
0
 def _get_id_name_opt(cls, _id, name, allow_empty=False):
     try:
         ret = cls._select_one(
             [int_var('-id', _id), text_var('-name', name)],
             allow_empty)
     except OptionMissingError:
         raise ValueError('id or name need to be specified.')
     return ret
Exemple #23
0
 def _get_id_name_opt(cls, _id, name, allow_empty=False):
     try:
         ret = cls._select_one(
             [int_var('-id', _id),
              text_var('-name', name)], allow_empty)
     except OptionMissingError:
         raise ValueError('id or name need to be specified.')
     return ret
Exemple #24
0
 def _get_pool_opt(cls, pool_id, pool_name, allow_empty=False):
     try:
         ret = cls._select_one([int_var('-poolId', pool_id),
                                text_var('-poolName', pool_name)],
                               allow_empty=allow_empty)
     except OptionMissingError:
         raise ValueError('pool_id or pool_name need to be specified.')
     return ret
Exemple #25
0
 def _get_primary_lun_opt(cls, primary_lun_id=None, primary_lun_name=None):
     try:
         ret = cls._select_one([int_var('-primaryLun', primary_lun_id),
                                text_var('-primaryLunName',
                                         primary_lun_name)])
     except OptionMissingError:
         raise ValueError(
             'primary_lun_id or primary_lun_name need to be specified.')
     return ret
 def modify_policy(self,
                   name,
                   new_name=None,
                   new_ioclasses=None,
                   time_limit=None,
                   fail_action=None,
                   eval_window=None):
     cmd = ['nqm', '-policy', '-modify', '-name', name]
     cmd += text_var('-newname', new_name)
     # This will clear all existing ioclasses
     if new_ioclasses is not None and len(new_ioclasses) == 0:
         cmd.append('-noclass')
     else:
         cmd += list_var('-ioclasses', new_ioclasses)
     cmd += text_var('-failaction', fail_action)
     cmd += int_var('-timelimit', time_limit)
     cmd += int_var('-evalwindow', eval_window)
     return cmd
Exemple #27
0
 def add_mirror_view_image(self, name, sp_ip, lun_id,
                           recovery_policy=VNXMirrorViewRecoveryPolicy.AUTO,
                           sync_rate=VNXMirrorViewSyncRate.HIGH):
     cmd = 'mirror -sync -addimage'.split()
     cmd += text_var('-name', name)
     cmd += text_var('-arrayhost', sp_ip)
     cmd += int_var('-lun', lun_id)
     cmd += VNXMirrorViewRecoveryPolicy.get_opt(recovery_policy)
     cmd += enum_var('-syncrate', sync_rate, VNXMirrorViewSyncRate)
     return cmd
Exemple #28
0
 def create_mirror_view(self, name, lun_id, use_write_intent_log=True):
     cmd = 'mirror -sync -create'.split()
     cmd += text_var('-name', name)
     cmd += int_var('-lun', lun_id)
     if use_write_intent_log:
         cmd.append('-usewriteintentlog')
     else:
         cmd.append('-nowriteintentlog')
     cmd.append('-o')
     return cmd
Exemple #29
0
 def _get_pool_opt(cls, pool_id, pool_name, allow_empty=False):
     try:
         ret = cls._select_one([
             int_var('-poolId', pool_id),
             text_var('-poolName', pool_name)
         ],
                               allow_empty=allow_empty)
     except OptionMissingError:
         raise ValueError('pool_id or pool_name need to be specified.')
     return ret
Exemple #30
0
 def expand_pool_lun(self, new_size, lun_id=None, lun_name=None,
                     ignore_thresholds=False):
     cmd = ['lun', '-expand']
     cmd += self._get_lun_opt(lun_id, lun_name)
     cmd += int_var('-capacity', new_size)
     cmd += ['-sq', 'gb']
     if ignore_thresholds:
         cmd += ['-ignoreThresholds']
     cmd.append('-o')
     return cmd
Exemple #31
0
 def _get_primary_lun_opt(cls, primary_lun_id=None, primary_lun_name=None):
     try:
         ret = cls._select_one([
             int_var('-primaryLun', primary_lun_id),
             text_var('-primaryLunName', primary_lun_name)
         ])
     except OptionMissingError:
         raise ValueError(
             'primary_lun_id or primary_lun_name need to be specified.')
     return ret
Exemple #32
0
 def _get_lun_opt(cls, lun_id=None, lun_name=None,
                  lun_type=None, allow_empty=False):
     try:
         ret = cls._select_one([int_var('-l', lun_id),
                                text_var('-name', lun_name),
                                enum_var('-showOnly', lun_type,
                                         VNXLunType)],
                               allow_empty=allow_empty)
     except OptionMissingError:
         raise ValueError(
             'lun_id, lun_name or lun_type need to be specified.')
     return ret
Exemple #33
0
    def config_iscsi_ip(self,
                        sp,
                        port_id,
                        ip,
                        netmask,
                        gateway,
                        vport_id=None,
                        vlan_id=None):
        if vport_id is None:
            vport_id = 0

        cmd = ['connection', '-setport', '-iscsi']
        cmd += ['-sp', VNXSPEnum.get_sp_index(sp)]
        cmd += int_var('-portid', port_id)
        cmd += int_var('-vportid', vport_id)
        cmd += int_var('-vlanid', vlan_id)
        cmd += text_var('-address', ip)
        cmd += text_var('-subnetmask', netmask)
        cmd += text_var('-gateway', gateway)
        cmd.append('-o')
        return cmd
Exemple #34
0
 def expand_pool_lun(self,
                     new_size,
                     lun_id=None,
                     lun_name=None,
                     ignore_thresholds=False):
     cmd = ['lun', '-expand']
     cmd += self._get_lun_opt(lun_id, lun_name)
     cmd += int_var('-capacity', new_size)
     cmd += ['-sq', 'gb']
     if ignore_thresholds:
         cmd += ['-ignoreThresholds']
     cmd.append('-o')
     return cmd
Exemple #35
0
 def create_rg(self, disks=None, rg_id=None, raid_type=None):
     if rg_id is None:
         raise ValueError('RAID group id not specified.')
     if not disks:
         raise ValueError('disks not specified.')
     if raid_type is None:
         raid_type = VNXRaidType.RAID5
     cmd = ['createrg']
     cmd += int_var(None, rg_id)
     cmd += disks
     cmd += enum_var('-raidtype', raid_type, VNXRaidType)
     cmd.append('-o')
     return cmd
Exemple #36
0
 def add_mirror_view_image(self,
                           name,
                           sp_ip,
                           lun_id,
                           recovery_policy=VNXMirrorViewRecoveryPolicy.AUTO,
                           sync_rate=VNXMirrorViewSyncRate.HIGH):
     cmd = 'mirror -sync -addimage'.split()
     cmd += text_var('-name', name)
     cmd += text_var('-arrayhost', sp_ip)
     cmd += int_var('-lun', lun_id)
     cmd += VNXMirrorViewRecoveryPolicy.get_opt(recovery_policy)
     cmd += enum_var('-syncrate', sync_rate, VNXMirrorViewSyncRate)
     return cmd
Exemple #37
0
 def create_rg(self, disks=None, rg_id=None, raid_type=None):
     if rg_id is None:
         raise ValueError('RAID group id not specified.')
     if not disks:
         raise ValueError('disks not specified.')
     if raid_type is None:
         raid_type = VNXRaidType.RAID5
     cmd = ['createrg']
     cmd += int_var(None, rg_id)
     cmd += disks
     cmd += enum_var('-raidtype', raid_type, VNXRaidType)
     cmd.append('-o')
     return cmd
Exemple #38
0
    def create_snap(self, res_id, snap_name, allow_rw=True, auto_delete=False):
        cmd = ['snap', '-create']
        try:
            cmd += int_var('-res', res_id)
        except ValueError:
            # string type meaning cg name
            cmd += text_var('-res', res_id)
            cmd += ['-resType', 'CG']

        cmd += text_var('-name', snap_name)
        cmd += yes_no_var('-allowReadWrite', allow_rw)
        cmd += yes_no_var('-allowAutoDelete', auto_delete)
        return cmd
Exemple #39
0
    def create_snap(self, res_id, snap_name,
                    allow_rw=True, auto_delete=False):
        cmd = ['snap', '-create']
        try:
            cmd += int_var('-res', res_id)
        except ValueError:
            # string type meaning cg name
            cmd += text_var('-res', res_id)
            cmd += ['-resType', 'CG']

        cmd += text_var('-name', snap_name)
        cmd += yes_no_var('-allowReadWrite', allow_rw)
        cmd += yes_no_var('-allowAutoDelete', auto_delete)
        return cmd
Exemple #40
0
 def _get_lun_opt(cls,
                  lun_id=None,
                  lun_name=None,
                  lun_type=None,
                  allow_empty=False):
     try:
         ret = cls._select_one([
             int_var('-l', lun_id),
             text_var('-name', lun_name),
             enum_var('-showOnly', lun_type, VNXLunType)
         ],
                               allow_empty=allow_empty)
     except OptionMissingError:
         raise ValueError(
             'lun_id, lun_name or lun_type need to be specified.')
     return ret
Exemple #41
0
 def get_credentials(self):
     if self._username is None and self._password is None:
         # use security file
         if self._sec_file is not None:
             ret = text_var('-secfilepath', self._sec_file)
         else:
             ret = []
     elif self._username is None or self._password is None:
         raise ValueError('username or password missing.')
     else:
         ret = ['-user', self._username,
                '-password', self._password,
                '-scope', self._scope]
     if self.timeout is not None:
         ret += int_var('-t', self.timeout)
     return ret
Exemple #42
0
 def ping_node(self, address, sp, port_id, vport_id=None, packet_size=None,
               count=None, timeout=None, delay=None):
     if vport_id is None:
         vport_id = 0
     cmd = ['connection', '-pingnode']
     sp = VNXSPEnum.get_sp_index(sp)
     cmd += text_var('-sp', sp)
     cmd += int_var('-portid', port_id)
     cmd += int_var('-vportid', vport_id)
     cmd += text_var('-address', address)
     cmd += int_var('-packetSize', packet_size)
     cmd += int_var('-count', count)
     cmd += int_var('-timeout', timeout)
     cmd += int_var('-delay', delay)
     return cmd
Exemple #43
0
    def create_snap(self,
                    res_id,
                    snap_name,
                    allow_rw=True,
                    auto_delete=False,
                    keep_for=None):
        cmd = ['snap', '-create']
        try:
            cmd += int_var('-res', res_id)
        except ValueError:
            # string type meaning cg name
            cmd += text_var('-res', res_id)
            cmd += ['-resType', 'CG']

        cmd += text_var('-name', snap_name)
        # -keepFor and -allowAutoDelete cannot co-exist
        if keep_for:
            cmd += text_var('-keepFor', keep_for)
        else:
            cmd += yes_no_var('-allowAutoDelete', auto_delete)
        cmd += yes_no_var('-allowReadWrite', allow_rw)

        return cmd
Exemple #44
0
 def ping_node(self,
               address,
               sp,
               port_id,
               vport_id=None,
               packet_size=None,
               count=None,
               timeout=None,
               delay=None):
     if vport_id is None:
         vport_id = 0
     cmd = ['connection', '-pingnode']
     sp = VNXSPEnum.get_sp_index(sp)
     cmd += text_var('-sp', sp)
     cmd += int_var('-portid', port_id)
     cmd += int_var('-vportid', vport_id)
     cmd += text_var('-address', address)
     cmd += int_var('-packetSize', packet_size)
     cmd += int_var('-count', count)
     cmd += int_var('-timeout', timeout)
     cmd += int_var('-delay', delay)
     return cmd
Exemple #45
0
 def get_rg(self, rg_id=None):
     cmd = ['getrg']
     cmd += int_var(None, rg_id)
     return cmd
Exemple #46
0
 def get_snap(self, name=None, res=None):
     cmd = ['snap', '-list']
     cmd += text_var('-id', name)
     cmd += int_var('-res', res)
     cmd.append('-detail')
     return cmd
Exemple #47
0
 def create_mirror_view(self, name, lun_id):
     cmd = 'mirror -sync -create'.split()
     cmd += text_var('-name', name)
     cmd += int_var('-lun', lun_id)
     cmd += ['-usewriteintentlog', '-o']
     return cmd
Exemple #48
0
 def sg_remove_hlu(self, sg_name, hlu_id):
     cmd = ['storagegroup', '-removehlu']
     cmd += int_var('-hlu', hlu_id)
     cmd += text_var('-gname', sg_name)
     cmd.append('-o')
     return cmd
Exemple #49
0
 def test_int_var(self):
     assert_that(int_var('-a', '1'), only_contains('-a', 1))
     assert_that(int_var(None, '1'), only_contains(1))
     assert_that(int_var('-a', None), equal_to([]))
Exemple #50
0
 def get_migration_session(self, src_id=None):
     cmd = ['migrate', '-list']
     if src_id is not None:
         cmd += int_var('-source', src_id)
     return cmd
Exemple #51
0
 def sg_delete_hlu(self, sg_name, hlu_id):
     cmd = ['storagegroup', '-removehlu']
     cmd += int_var('-hlu', hlu_id)
     cmd += text_var('-gname', sg_name)
     cmd.append('-o')
     return cmd
Exemple #52
0
 def get_rg(self, rg_id=None):
     cmd = ['getrg']
     cmd += int_var(None, rg_id)
     return cmd
Exemple #53
0
 def delete_rg(self, rg_id):
     cmd = ['removerg']
     cmd += int_var(None, rg_id)
     return cmd
Exemple #54
0
 def remove_rg(self, rg_id):
     cmd = ['removerg']
     cmd += int_var(None, rg_id)
     return cmd
Exemple #55
0
 def get_snap(self, name=None, res=None):
     cmd = ['snap', '-list']
     cmd += text_var('-id', name)
     cmd += int_var('-res', res)
     cmd.append('-detail')
     return cmd