Docsity

WGU D522 Task 1 Performance Assessment | Python Network Automation, Device Inventory,, Exams of Nursing

Toggle sidebar
bg1
1 | P a g e
WGU D522 Task 1 Performance
Assessment | Python Network
Automation, Device Inventory,
Connectivity & DNS Compromise
Audit | Complete 2026 With Complete
Updated Solutions
WGU D522 Task 1 Performance Assessment complete
study guide for 2026. Covers Python network
automation, device inventory validation, connectivity
testing with timeouts, and DNS compromise audit
against approved baselines. Includes CSV parsing,
subprocess execution, Paramiko SSH, resolvectl parsing,
error handling, logging, GitLab workflow, and evidence
documentation. Ideal for Task 1 PA preparation. Not a
substitute for official WGU materials.
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35
pf36
pf37
pf38
pf39
pf3a
pf3b
pf3c
pf3d
pf3e
pf3f
pf40
pf41
pf42
pf43
pf44
pf45
pf46
pf47
pf48
pf49
pf4a
pf4b
pf4c
pf4d
pf4e
pf4f
pf50
pf51
pf52
pf53
pf54
pf55
pf56
pf57
pf58
pf59
pf5a
pf5b
pf5c
pf5d
pf5e
pf5f
pf60

Partial preview of the text

Download WGU D522 Task 1 Performance Assessment | Python Network Automation, Device Inventory, and more Exams Nursing in PDF only on Docsity!

WGU D522 Task 1 Performance

Assessment | Python Network

Automation, Device Inventory,

Connectivity & DNS Compromise

Audit | Complete 2026 With Complete

Updated Solutions

WGU D522 Task 1 Performance Assessment complete

study guide for 2026. Covers Python network

automation, device inventory validation, connectivity

testing with timeouts, and DNS compromise audit

against approved baselines. Includes CSV parsing,

subprocess execution, Paramiko SSH, resolvectl parsing,

error handling, logging, GitLab workflow, and evidence

documentation. Ideal for Task 1 PA preparation. Not a

substitute for official WGU materials.

Q1. What is the primary purpose of a device inventory in network automation? A. To physically label network devices B. To maintain a structured record of network assets and their attributes C. To replace network monitoring tools D. To encrypt device configurations Answer: B Rationale: A device inventory serves as a centralized, structured record containing device names, IP addresses, ports, credentials, and other attributes needed for automation workflows. It does not replace monitoring tools, encrypt configurations, or involve physical labeling. Accurate inventory data is foundational because every subsequent automation task—connectivity checks, configuration audits, DNS validation—depends on knowing which devices exist and how to reach them. Q2. Which Python module is best suited for reading a CSV device inventory file? A. json B. csv C. xml.etree D. pickle Answer: B Rationale: The csv module is purpose-built for reading and writing commaseparated value files, which is the standard format for device inventory lists in network automation. It provides DictReader and DictWriter classes that map rows to dictionaries, simplifying field access. The json module handles JSON, xml.etree handles XML, and pickle handles Python object serialization— none of these are designed for CSV parsing. Q3. In Python's csv.DictReader, what does each row become? A. A tuple of values B. A list of strings C. A dictionary keyed by column headers

incompatible type is passed to an operation. Catching ValueError allows the script to report a clear, row-specific validation error. Q6. What is the risk of not validating inventory records before using them? A. The script will run faster than expected B. Invalid records can cause runtime exceptions that halt the audit C. The CSV file will be deleted D. DNS servers will change automatically Answer: B Rationale: If malformed records—such as non-numeric ports, empty hostnames, or missing fields—are passed directly into connection functions, the script will raise unhandled exceptions and terminate. Validating each record up front lets the script skip or flag bad entries while continuing the audit for valid devices. Validation does not affect speed positively, delete files, or alter DNS configuration. Q7. Which data structure is most appropriate for storing a collection of device dictionaries? A. A single string B. A list of dictionaries C. A set of integers D. A tuple of booleans Answer: B Rationale: A list of dictionaries is the natural Python structure for a collection of records where each record has named fields. Lists preserve order and allow iteration, while dictionaries provide key-based access to each device's attributes. Strings, sets of integers, and tuples of booleans cannot represent multi-field records. Q8. What does the newline="" argument accomplish when opening a CSV file?

A. It removes all newlines from the file B. It prevents newline translation issues on different platforms C. It converts the file to binary mode D. It appends a newline to every row Answer: B Rationale: The csv module documentation recommends opening files with newline="" so that newline handling is delegated to the csv reader rather than the underlying platform. Without it, embedded newlines within quoted fields can be misinterpreted on Windows, producing broken rows. It does not remove newlines, switch to binary mode, or append anything. Q9. What does encoding="utf-8" specify when opening a CSV file? A. The file is compressed B. The character encoding used to decode the file's bytes C. The file is encrypted D. The delimiter is a comma Answer: B Rationale: The encoding parameter tells Python how to decode the raw bytes of the file into text. UTF-8 is the most common encoding and handles international characters. It has nothing to do with compression, encryption, or delimiters. Specifying it explicitly avoids platform-dependent defaults that can cause UnicodeDecodeError. Q10. Which method correctly counts the rows read from a DictReader? A. reader.count() B. len(reader) C. Iterate and increment a counter D. reader.size() Answer: C

Q13. What does SSHClient.set_missing_host_key_policy(AutoAddPolicy()) do in Paramiko? A. Encrypts the session B. Automatically adds unknown host keys without prompting C. Disables authentication D. Sets the SSH port to 22 Answer: B Rationale: By default Paramiko raises an exception when connecting to a host whose key is not in known_hosts. AutoAddPolicy automatically accepts and stores unknown host keys, which is convenient in lab environments but weakens security in production. It does not encrypt the session, disable authentication, or set ports. Q14. Why is AutoAddPolicy considered a security risk in production? A. It slows down connections B. It accepts any host key, enabling man-in-the-middle attacks C. It requires a password D. It blocks port 22 Answer: B Rationale: AutoAddPolicy trusts any presented host key, so an attacker performing a man-in-the-middle attack can impersonate the target device and capture credentials or commands. In production, administrators should prepopulate known_hosts or use RejectPolicy with a managed key database. AutoAddPolicy does not affect speed, require passwords, or block ports. Q15. What does client.exec_command() return in Paramiko? A. A single string of output B. A tuple of stdin, stdout, stderr file-like objects C. A boolean success flag D. An integer exit code

Answer: B Rationale: exec_command returns a 3-tuple of (stdin, stdout, stderr), each being a file-like object. The caller reads stdout with .read() or iterates lines, and can read stderr separately for diagnostics. The exit code is obtained from the channel via recv_exit_status(), not returned directly by exec_command. Q16. How do you obtain the exit status of a remote command in Paramiko? A. stdout.read() B. channel.recv_exit_status() C. client.get_exit_code() D. stderr.read() Answer: B Rationale: After exec_command, the underlying channel object is accessible via the stdout (or stdin) object's .channel attribute, and recv_exit_status() blocks until the remote command completes and returns its exit code. stdout.read() and stderr.read() return output text, and get_exit_code() is not a Paramiko method. Q17. What does the timeout parameter in Paramiko's connect() control? A. The time to wait for DNS resolution only B. The TCP connection timeout in seconds C. The maximum session duration D. The time between keepalive packets Answer: B Rationale: The timeout parameter sets the TCP socket connection timeout—how long Paramiko waits for the underlying socket to connect before raising an exception. Session duration is not limited by this parameter, DNS resolution is part of the connection attempt, and keepalives are configured via set_keepalive() on the transport.

Answer: B Rationale: The re module provides compile(), search(), findall(), and related functions for pattern matching. It is essential for extracting DNS server addresses, interface names, or other structured values from unstructured command output. os handles operating system interfaces, sys handles interpreter state, and math handles numeric operations.

Q21. In the regex r"DNS Servers?:\s([0-9.]+)", what does the? after "Servers" do? A. Makes the preceding character optional B. Makes the preceding s optional, matching both "Server" and "Servers" C. Repeats the group zero or more times D. Escapes the s character Answer: B Rationale: The? quantifier makes the immediately preceding token optional. Here it follows "s", so the pattern matches both "DNS Server:" and "DNS Servers:". It does not repeat the whole group (that would require * or + after a group) and does not escape characters. Q22. What does \s match in a regular expression? A. Zero or more whitespace characters B. One or more digits C. A literal asterisk D. A newline only Answer: A Rationale: \s matches any whitespace character (space, tab, newline), and * means zero or more repetitions. Together, \s matches any amount of whitespace including none, which is useful for tolerating variable spacing after colons in command output. It does not match digits or literals.* Q23. What does the character class [0-9.]+ match? A. One or more characters that are digits or dots B. Exactly one digit C. A single dot D. Any character except digits and dots Answer: A Rationale: [0-9.] defines a character class containing digits 0-9 and the dot. The

Q26. Which Python construct best isolates per-device failures in an audit loop? A. A single try/except around the entire loop B. try/except inside the loop for each device C. No exception handling at all D. A while True loop Answer: B Rationale: Placing try/except inside the loop body ensures that an exception for one device is caught and logged, allowing the loop to proceed to the next device. A single try/except around the whole loop would abort on the first failure, and no handling would crash the script. while True is unrelated to failure isolation. Q27. What is the purpose of logging in an audit script? A. To slow down execution B. To create a timestamped record of actions, results, and errors C. To encrypt output D. To replace print statements entirely Answer: B Rationale: Logging produces a persistent, timestamped record that can be reviewed after the script runs, providing evidence for the assessment and aiding troubleshooting. It does not slow execution meaningfully, encrypt output, or fully replace print—print is still useful for interactive debugging. Q28. Which Python module provides structured logging? A. log B. logging C. print D. syslog Answer: B

Rationale: The standard library logging module provides loggers, handlers, formatters, and levels (DEBUG, INFO, WARNING, ERROR, CRITICAL). syslog is a Unix service, log is not a standard module, and print is a built-in function, not a logging framework. Q29. What does logging.basicConfig(filename="audit.log", level= logging.INFO ) do? A. Prints logs to the console only B. Configures logging to write INFO and above to audit.log C. Deletes audit.log D. Encrypts audit.log Answer: B Rationale: basicConfig with filename directs log records to the specified file, and level= logging.INFO sets the threshold so INFO, WARNING, ERROR, and CRITICAL are recorded while DEBUG is suppressed. It does not delete or encrypt the file, and specifying filename overrides console output unless a StreamHandler is also added. Q30. Why should credentials not be hardcoded in source code? A. It slows the script B. It exposes secrets in version control and to anyone with repo access C. Python cannot read hardcoded strings D. It causes syntax errors Answer: B Rationale: Hardcoded credentials end up in Git history, where they persist even after removal and are visible to anyone with repository access. Best practice is to supply credentials at runtime via environment variables, getpass, or a secrets manager. Hardcoding does not affect speed or cause syntax errors.

Rationale: CLEAN means the set of DNS servers observed on the device equals the approved set with no extras and no missing entries. No DNS servers configured would be a misconfiguration, unreachable is a separate status, and partial describes a different classification. Q34. What does a PARTIAL classification typically indicate in a DNS audit? A. The device is offline B. Some observed DNS servers are approved and some are not C. All DNS servers match the baseline D. The device has no DNS servers Answer: B Rationale: PARTIAL indicates overlap between observed and approved sets— typically one approved server plus one unapproved server, suggesting an incomplete or gradual compromise or misconfiguration. It differs from COMPROMISED, where none of the observed servers are approved. Q35. What does a COMPROMISED classification indicate? A. The device is unreachable B. None of the observed DNS servers match the approved baseline C. All DNS servers match the baseline D. The device has no DNS configuration Answer: B Rationale: COMPROMISED means every observed DNS server is outside the approved set, strongly suggesting the resolver configuration was altered by an attacker or misapplied policy. This warrants immediate investigation. Unreachable and no configuration are separate statuses. Q36. Why is it important to record the raw command output in addition to the parsed DNS values?

A. It increases file size B. It provides evidence and helps diagnose parsing errors C. It encrypts the results D. It is required by Python Answer: B Rationale: Raw output serves as evidence for the assessment and allows verification that parsing was correct. If the regex misfires or the format changes, the raw output reveals what actually appeared, enabling the parser to be fixed. It is not a Python requirement and does not encrypt anything. Q37. What does the subprocess.run() function do? A. Runs a Python function in a thread B. Executes an external command and waits for it to complete C. Compiles Python source D. Opens a network socket Answer: B Rationale: subprocess.run() launches an external program, waits for it to finish, and returns a CompletedProcess object containing returncode, stdout, and stderr. It does not run Python functions, compile source, or open sockets— though the executed command may itself use sockets. Q38. What does capture_output=True do in subprocess.run()? A. Redirects output to a file B. Captures stdout and stderr into the returned object C. Suppresses all output D. Encrypts output Answer: B Rationale: capture_output=True (equivalent to setting stdout=PIPE and stderr=PIPE) captures the child process's standard output and standard error into the CompletedProcess object's stdout and stderr attributes. It does not redirect to a file, suppress output entirely, or encrypt anything.

Rationale: With check=True, a non-zero exit code raises CalledProcessError, which—if unhandled—terminates the script. In an audit loop, a single ping failure would abort the entire run. Most audit scripts instead inspect returncode manually or catch the exception per device. Q42. Which ping flag limits the number of packets sent on Linux? A. - n B. - c C. - t D. - w Answer: B Rationale: On Linux, ping - c N sends N packets and then exits. - n suppresses DNS resolution, - w sets a deadline in seconds, and - t is a TTL flag on some systems (on Windows - n specifies count). Using - c 1 sends a single packet, which is appropriate for a quick reachability check. Q43. Which ping flag sets a per-packet timeout on Linux? A. - W B. - c C. - i D. - s Answer: A Rationale: On Linux, - W sets the time in seconds to wait for a response to each packet. - c sets packet count, - i sets the interval between packets, and - s sets packet size. Bounded timeouts prevent the audit from hanging on unresponsive hosts. Q44. What is the risk of running ping without a timeout in an audit loop? A. It uses too much CPU

B. The script may hang indefinitely on an unreachable host C. It encrypts packets D. It changes the host's DNS Answer: B Rationale: Without a timeout, ping on some systems can wait a long time for a reply, stalling the entire audit. Bounding the timeout—via the ping flag, subprocess.run's timeout parameter, or both—ensures the script proceeds even when a host is down. Q45. What exception does subprocess.run(timeout=N) raise when the command exceeds N seconds? A. TimeoutError B. subprocess.TimeoutExpired C. socket.timeout D. KeyboardInterrupt Answer: B Rationale: subprocess.run raises subprocess.TimeoutExpired when the timeout elapses, and it kills the child process before raising. TimeoutError is a broader built-in, socket.timeout is socket-specific, and KeyboardInterrupt is userinitiated. Catching TimeoutExpired lets the script mark the device unreachable and continue. Q46. Which module is used for DNS resolution in Python's standard library? A. dns B. socket C. http D. ssl Answer: B Rationale: The socket module provides gethostbyname(), getaddrinfo(), and related functions for resolving hostnames. The dnspython library (imported as