Add pyVmomi stubs (#3921)

This commit is contained in:
Alexandre Yang
2020-05-26 12:04:56 +02:00
committed by GitHub
parent 448c4e1fa7
commit a8834fcd46
9 changed files with 155 additions and 0 deletions

View File

View File

@@ -0,0 +1,67 @@
from datetime import datetime
from enum import Enum
from typing import Any, List
from . import event
from . import fault
from . import view
from ..vmodl.query import PropertyCollector
from .event import EventManager
from .option import OptionManager
from .view import ViewManager
class ManagedObject: ...
class ManagedEntity(ManagedObject):
_moId: str
obj: None
name: str
class ServiceInstanceContent:
setting: OptionManager
propertyCollector: PropertyCollector
rootFolder: Folder
viewManager: ViewManager
perfManager: PerformanceManager
eventManager: EventManager
class ServiceInstance:
content: ServiceInstanceContent
def CurrentTime(self) -> Any: ...
class PerformanceManager:
class MetricId:
def __init__(self, counterId: Any, instance: Any): ...
class PerfCounterInfo:
key: int
groupInfo: Any
nameInfo: Any
rollupType: Any
class QuerySpec:
entity: ManagedEntity
metricId: List[PerformanceManager.MetricId]
intervalId: int
maxSample: int
startTime: datetime
class EntityMetricBase:
value: Any
entity: ManagedEntity
def QueryPerfCounterByLevel(self, collection_level: int) -> List[PerformanceManager.PerfCounterInfo]: ...
def QueryPerf(self, querySpec: List[PerformanceManager.QuerySpec]) -> List[PerformanceManager.EntityMetricBase]: ...
class ClusterComputeResource(ManagedEntity): ...
class ComputeResource(ManagedEntity): ...
class Datacenter(ManagedEntity): ...
class Datastore(ManagedEntity): ...
class Folder(ManagedEntity): ...
class HostSystem(ManagedEntity): ...
class VirtualMachine(ManagedEntity): ...
class VirtualMachinePowerState(Enum):
poweredOff: int
poweredOn: int
suspended: int

14
third_party/2and3/pyVmomi/vim/event.pyi vendored Normal file
View File

@@ -0,0 +1,14 @@
from datetime import datetime
from typing import List
class Event:
createdTime: datetime
class EventFilterSpec:
class ByTime:
def __init__(self, beginTime: datetime): ...
time: EventFilterSpec.ByTime
class EventManager:
latestEvent: Event
def QueryEvents(self, filer: EventFilterSpec) -> List[Event]: ...

View File

@@ -0,0 +1,2 @@
class InvalidName(Exception): ...
class RestrictedByAdministrator(Exception): ...

View File

@@ -0,0 +1,7 @@
from typing import Any, List
class OptionManager:
def QueryOptions(self, name: str) -> List[OptionValue]: ...
class OptionValue:
value: Any

15
third_party/2and3/pyVmomi/vim/view.pyi vendored Normal file
View File

@@ -0,0 +1,15 @@
from typing import List, Type
from pyVmomi.vim import ManagedEntity
class ContainerView:
def Destroy(self) -> None: ...
class ViewManager:
# Doc says the `type` parameter of CreateContainerView is a `List[str]`,
# but in practice it seems to be `List[Type[ManagedEntity]]`
# Source: https://pubs.vmware.com/vi-sdk/visdk250/ReferenceGuide/vim.view.ViewManager.html
@staticmethod
def CreateContainerView(
container: ManagedEntity, type: List[Type[ManagedEntity]], recursive: bool
) -> ContainerView: ...

View File

@@ -0,0 +1,8 @@
from typing import Any
from . import fault
from . import query
class DynamicProperty:
name: str
val: Any

View File

@@ -0,0 +1 @@
class InvalidArgument(Exception): ...

View File

@@ -0,0 +1,41 @@
from typing import Any, List, Optional, Type
from pyVmomi.vim import ManagedEntity
from pyVmomi.vim.view import ContainerView
from pyVmomi.vmodl import DynamicProperty
class PropertyCollector:
class PropertySpec:
type: Type[ManagedEntity]
pathSet: List[str]
class TraversalSpec:
path: str
skip: bool
type: Type[ContainerView]
class RetrieveOptions:
maxObjects: int
class ObjectSpec:
skip: bool
selectSet: List[PropertyCollector.TraversalSpec]
obj: Any
class FilterSpec:
propSet: List[PropertyCollector.PropertySpec]
objectSet: List[PropertyCollector.ObjectSpec]
class ObjectContent:
obj: ManagedEntity
propSet: List[DynamicProperty]
class RetrieveResult:
objects: List[PropertyCollector.ObjectContent]
token: Optional[str]
def RetrievePropertiesEx(
self, specSet: List[PropertyCollector.FilterSpec], options: PropertyCollector.RetrieveOptions
) -> PropertyCollector.RetrieveResult: ...
def ContinueRetrievePropertiesEx(self, token: str) -> PropertyCollector.RetrieveResult: ...