def __init__(self, ip=None, username=None, password=None, scope=0, sec_file=None, timeout=None, heartbeat_interval=None, naviseccli=None): """ initialize a `VNXSystem` instance The `VNXSystem` instance act as a entry point for all VNX resources. :param ip: ip of one block sp :param username: username for block system :param password: password for the specified block user :param scope: scope of the specified block user :param sec_file: security file used by naviseccli :param timeout: naviseccli command timeout :param heartbeat_interval: heartbeat interval used to check the alive of sp. Set to 0 if heart beat is not required. :param naviseccli: binary location of naviseccli in your host. :return: vnx system instance """ super(VNXSystem, self).__init__() self._cli = CliClient(ip, username, password, scope, sec_file, timeout, heartbeat_interval=heartbeat_interval, naviseccli=naviseccli) self._ndu_list = VNXNduList(self._cli) self._ndu_list.with_no_poll() if heartbeat_interval: daemon(self._update_nodes_ip)
def __init__(self, ip=None, username=None, password=None, scope=0, sec_file=None, timeout=None, heartbeat_interval=None, naviseccli=None, file_username=None, file_password=None): """ initialize a `VNXSystem` instance The `VNXSystem` instance act as a entry point for all VNX resources. :param ip: ip of one block sp :param username: username for block system :param password: password for the specified block user :param scope: scope of the specified block user :param sec_file: security file used by naviseccli :param timeout: naviseccli command timeout :param heartbeat_interval: heartbeat interval used to check the alive of sp. Set to 0 if heart beat is not required. :param naviseccli: binary location of naviseccli in your host. :param file_username: username for control station login, default to username :param file_password: password for control station login, default to password :return: vnx system instance """ super(VNXSystem, self).__init__() self._ip = ip self._username = username self._password = password self._scope = scope self._sec_file = sec_file self._timeout = timeout self._hb_interval = heartbeat_interval self._naviseccli = naviseccli self._file_username = file_username self._file_password = file_password self._cli = self._init_block_cli() if heartbeat_interval: daemon(self.update_nodes_ip)
def execute(cls, cmd, timeout=None): if timeout is None: timeout = cls.MAX_TIMEOUT # closure cannot modify value, use list to work around process = [None] output = [None] def run(): start = time.time() cls._log_command(cmd) p = Popen(cmd, bufsize=-1, stdout=PIPE, stderr=PIPE) process[0] = p out = p.stdout.read() cls._log_output(cmd, out, start) if isinstance(out, bytes): out = out.decode("utf-8") out = out.strip() output[0] = out return out thread = daemon(run) thread.join(timeout) if thread.is_alive() and process[0] is not None: log.warn('terminate timeout command: {}'.format(cmd)) process[0].terminate() thread.join() return output[0]
def migrate(self, tgt, rate=VNXMigrationRate.HIGH, on_complete=None, on_error=None): tgt_id = self.get_id(tgt) src_id = self.get_id(self) out = self._cli.migrate_lun(src_id, tgt_id, rate, poll=self.poll) ex.raise_if_err(out, default=ex.VNXMigrationError) if on_complete or on_error: ret = daemon(self._wait_for_migration_done, on_complete, on_error) else: ret = None return ret
def __init__(self, username=None, password=None, scope=0, sec_file=None, interval=60, timeout=30, naviseccli=None): super(NodeHeartBeat, self).__init__(username, password, scope, sec_file=sec_file, timeout=timeout, naviseccli=naviseccli) self._node_map = _NodeInfoMap() self._interval = interval self._heartbeat_thread = None if interval > 0: self._heartbeat_thread = daemon(self._run) self.command_count = 0
def __init__(self, username=None, password=None, scope=0, sec_file=None, interval=60, timeout=30, naviseccli=None): super(NodeHeartBeat, self).__init__(username, password, scope, sec_file=sec_file, timeout=timeout, naviseccli=naviseccli) self._node_map = NodeInfoMap() self._interval = interval self._heartbeat_thread = None if interval > 0: self._heartbeat_thread = daemon(self._run) self.command_count = 0
def _ping_node(self, node): def do(): self._ping_sp(node.ip) if VNXSPEnum.is_sp(node.name) and not node.working: daemon(do)
def interval(self, value): self._interval = value if self._heartbeat_thread is None: # there is no loop check self._heartbeat_thread = daemon(self._run)
def __setstate__(self, state): vars(self).update(state) if self.interval > 0: self._heartbeat_thread = daemon(self._run)