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
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
def mount(mover_name, name, rw='rw', path=None): if path is None: path = '/{}'.format(name) cmd = text_var('/nas/bin/server_mount', mover_name) cmd += text_var('rw', rw) cmd += [name, path] return cmd
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
def copy_snap(self, src_name, tgt_name, ignore_migration_check=False, ignore_dedup_check=False): cmd = ['snap', '-copy'] cmd += text_var('-id', src_name) cmd += text_var('-name', tgt_name) if ignore_migration_check: cmd.append('-ignoreMigrationCheck') if ignore_dedup_check: cmd.append('-ignoreDeduplicationCheck') return cmd
def copy_ckpt(snap_name, fs_name, connect_id, session_name=None): if session_name is None: session_name = '{}:{}'.format(fs_name, snap_name) cmd = ['/nas/bin/nas_copy'] cmd += text_var('-name', session_name[0:63]) cmd.append('-source') cmd += text_var('-ckpt', snap_name) cmd.append('-destination') cmd += text_var('-fs', fs_name) cmd += text_var('-interconnect', 'id={}'.format(connect_id)) cmd += ['-overwrite_destination', '-full_copy'] return cmd
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
def add_user(self, name, password, scope=None, role=None): if scope is None: scope = VNXUserScopeEnum.GLOBAL if role is None: role = VNXUserRoleEnum.ADMIN cmd = ['security', '-adduser'] cmd += text_var('-user', name) cmd += text_var('-password', password) cmd += enum_var('-scope', scope, VNXUserScopeEnum) cmd += enum_var('-role', role, VNXUserRoleEnum) cmd.append('-o') return cmd
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
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
def modify_snap(self, name, new_name=None, desc=None, auto_delete=None, rw=None): opt = [] if new_name is not None and name != new_name: opt += text_var('-name', new_name) opt += text_var('-descr', desc) opt += yes_no_var('-allowAutoDelete', auto_delete) opt += yes_no_var('-allowReadWrite', rw) if len(opt) > 0: cmd = ['snap', '-modify', '-id', name] + opt else: cmd = [] return cmd
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
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
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 get_sg(self, name=None, engineering=False): cmd = ['storagegroup'] if engineering: cmd.append('-messner') cmd += '-list -host -iscsiAttributes'.split() cmd += text_var('-gname', name) return cmd
def create_pool(self, name, disks, raid_type=None): cmd = ['storagepool', '-create', '-disks'] cmd += disks cmd += enum_var('-rtype', raid_type, VNXPoolRaidType) cmd += text_var('-name', name) cmd.append('-skiprules') return cmd
def modify_storage_pool(self, name=None, pool_id=None, new_name=None): cmd = ['storagepool', '-modify'] cmd += self._get_id_name_opt(pool_id, name) cmd += text_var('-newName', new_name) cmd.append('-o') return cmd
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
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
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 delete_user(self, name, scope=None): if scope is None: scope = VNXUserScopeEnum.GLOBAL cmd = ['security', '-rmuser'] cmd += text_var('-user', name) cmd += enum_var('-scope', scope, VNXUserScopeEnum) cmd.append('-o') return cmd
def create_cg(self, name, members=None, auto_delete=None): cmd = 'snap -group -create'.split() cmd += text_var('-name', name) cmd += yes_no_var('-allowSnapAutoDelete', auto_delete) if members is not None and len(members) > 0: cmd += ['-res', self._get_cg_member_repr(members)] return cmd
def create_mirror_group_async(self, name, policy=VNXMirrorGroupRecoveryPolicy.AUTO, description=None): cmd = ['mirror', '-async', '-creategroup', '-name', name] cmd += text_var('-description', description) cmd += VNXMirrorViewRecoveryPolicy.get_opt(policy) cmd += ['-o'] return cmd
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
def deny_cifs_share_access(cls, share_name, mover_name, user_name, domain, access=CifsAccessControl.FULL): cmd = cls._share_access_cmd_prefix(mover_name, share_name) access_str = cls._access_str(access, domain, user_name) cmd += text_var('revoke', access_str) return cmd
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
def create_fs(fs_name, source_fs_name, pool_name, is_thin=False): cmd = ['/nas/bin/nas_fs'] cmd += text_var('-name', fs_name) cmd += ['-type', 'uxfs', '-create'] cmd.append('samesize={}'.format(source_fs_name)) cmd.append('pool={}'.format(pool_name)) cmd += ['storage=SINGLE', 'worm=off'] cmd += yes_no_var('-thin', is_thin) cmd += ['-option', 'slice=y'] return cmd
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
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 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 _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
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
def modify_snap(self, name, new_name=None, desc=None, auto_delete=None, allow_rw=None, keep_for=None): opt = [] if new_name is not None and name != new_name: opt += text_var('-name', new_name) opt += text_var('-descr', desc) # -keepFor and -allowAutoDelete cannot co-exist if keep_for: opt += text_var('-keepFor', keep_for) else: opt += yes_no_var('-allowAutoDelete', auto_delete) opt += yes_no_var('-allowReadWrite', allow_rw) if len(opt) > 0: cmd = ['snap', '-modify', '-id', name] + opt else: cmd = [] return cmd
def create_mount_point(self, primary_lun_id=None, primary_lun_name=None, mount_point_name=None, mount_point_id=None, sp_id=None): cmd = 'lun -create -type snap'.split() cmd += self._get_primary_lun_opt(primary_lun_id, primary_lun_name) cmd += self._get_lun_opt(lun_id=mount_point_id, lun_name=mount_point_name) if sp_id: cmd += text_var('-sp', sp_id) return cmd
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
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
def modify_lun(self, lun_id=None, lun_name=None, new_name=None, new_tier=None, dedup=None): cmd = ['lun', '-modify'] cmd += self._get_lun_opt(lun_id, lun_name) cmd += text_var('-newName', new_name) cmd += self._get_tier_opt(new_tier) if dedup is not None: dedup_op = 'on' if dedup else 'off' cmd += ['-deduplication', dedup_op] cmd.append('-o') return cmd
def attach_nfs_interface(if_name, vdm_name=None): cmd = ['/nas/bin/nas_server'] if vdm_name is not None: cmd += text_var('-vdm', vdm_name) cmd += text_var('-attach', if_name) return cmd
def delete_ckpt(ckpt_name): cmd = ['/nas/bin/nas_fs'] cmd += text_var('-delete', ckpt_name) cmd.append('-Force') return cmd
def umount(mover_name, name): cmd = text_var('/nas/bin/server_umount', mover_name) cmd += text_var('-perm', name) return cmd
def _share_access_cmd_prefix(mover_name, share_name): cmd = text_var('/nas/bin/.server_config', mover_name) cmd.append('-v') cmd += text_var('sharesd', share_name) return cmd
def _mirror_view_image_op(op, name, image_id): cmd = ['mirror', '-sync', op] cmd += text_var('-name', name) cmd += text_var('-imageuid', image_id) cmd.append('-o') return cmd
def get_mirror_view(self, name=None): cmd = 'mirror -sync -list'.split() cmd += text_var('-name', name) return cmd