|
10 | 10 | import logging |
11 | 11 | from typing import Dict, List, Optional, Union |
12 | 12 | from urllib.parse import urlparse |
13 | | -from pyVim.connect import SmartConnect, Disconnect |
14 | | -from pyVmomi import vim, vmodl |
15 | 13 | import ssl |
| 14 | +from pyVim.connect import Disconnect, SmartConnect |
| 15 | +from pyVmomi import vim, vmodl |
| 16 | + |
16 | 17 |
|
17 | 18 | from pydantic import BaseModel, validator, Field |
18 | 19 |
|
@@ -84,6 +85,9 @@ def validate_password(cls, password): |
84 | 85 |
|
85 | 86 |
|
86 | 87 | class Vcenter(Source, InventoryAsyncPlugin): |
| 88 | + """This class is used to dynamically retrieve the inventory |
| 89 | + from Vcenter |
| 90 | + """ |
87 | 91 | def __init__(self, config_data: dict, validate: bool = True) -> None: |
88 | 92 | self._status = 'init' |
89 | 93 | self._server: VcenterServerModel = None |
@@ -208,7 +212,15 @@ async def get_inventory_list(self) -> List: |
208 | 212 | f'Vcenter: Retrieved {len(vms_with_ip)} VMs with IPs') |
209 | 213 | return vms_with_ip |
210 | 214 |
|
211 | | - def parse_inventory(self, inventory_list: list) -> Dict: |
| 215 | + def parse_inventory(self, inventory_list: dict) -> Dict: |
| 216 | + """parse the raw inventory collected from the server and generates |
| 217 | + a new inventory with only the required information. |
| 218 | +
|
| 219 | + Args: |
| 220 | + raw_inventory: raw inventory received from vcenter. |
| 221 | +
|
| 222 | + Returns: A dict containing the inventory. |
| 223 | + """ |
212 | 224 | inventory = {} |
213 | 225 | for name, ip in inventory_list.items(): |
214 | 226 | namespace = self._namespace |
|
0 commit comments