Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
6bd5c23
Added sspi mechanism support and __pillar__ and config merging to sal…
Sep 21, 2017
3369a3d
Added the EsxiProxySchema JSON schema
Sep 21, 2017
434d88b
Added salt.modules.esxi.get_details that returns the proxy details
Sep 21, 2017
5c79512
Added salt.modules.vsphere._get_esxi_proxy_details
Sep 21, 2017
ffbab2c
Added esxi proxy support and retrieval of esxi reference in salt.modu…
Sep 25, 2017
230c17e
Added salt.utils.vsan.get_vsan_disk_management_system
Sep 23, 2017
67afc2f
Added salt.utils.vsan.get_host_vsan_system
Sep 23, 2017
6a31c43
Added salt.utils.vsan.create_diskgroup
Sep 23, 2017
d637b07
Added salt.utils.vsan.add_capacity_to_diskgroup
Sep 25, 2017
d8a2724
Added salt.utils.vsan.remove_capacity_from_diskgroup
Sep 25, 2017
a8406fb
Added salt.utils.vsan.remove_diskgroup
Sep 23, 2017
273afc1
Added salt.exceptions.VMwareObjectNotFoundError
Sep 25, 2017
4d6eb41
Added salt.utils.vmware._get_partition_info
Sep 25, 2017
cd4d296
Added salt.utils.vmware._get_new_computed_partition_spec
Sep 25, 2017
8e1eb19
Added salt.utils.vmware.create_vmfs_datastore
Sep 25, 2017
9831a5d
Added salt.utils.vmware.get_host_datastore_system
Sep 25, 2017
a34cf12
Added salt.utils.vmware.remove_datastore
Sep 25, 2017
783a75a
Improved logic to filter hosts based on parent in salt.utils.vmware.g…
Sep 24, 2017
27cd7cf
Added salt.utils.vmware._get_scsi_address_to_lun_key_map
Sep 24, 2017
cc21f38
Added salt.utils.vmware.get_all_luns
Sep 24, 2017
5a8cc2f
Added salt.utils.vmware.get_scsi_address_to_lun_map
Sep 24, 2017
8b7af00
Added salt.utils.vmware.get_disks
Sep 24, 2017
200159d
Added salt.utils.vmware.get_disk_partition_info
Sep 24, 2017
c386612
Added salt.utils.vmware.erase_disk_partitions
Sep 24, 2017
3d03836
Added salt.utils.get_diskgroups
Sep 24, 2017
13e8bad
Added salt.utils._check_disks_in_diskgroup
Sep 24, 2017
beb2b61
Added salt.utils.vmware.get_host_cache
Sep 24, 2017
f84c55b
Added salt.utils.vmware.configure_host_cache
Sep 24, 2017
6ad97b0
Change debug logs to trace logs in salt.utils.vmware.get_datastores
Sep 24, 2017
0186045
Change debug logs to trace logs in salt.utils.vmware.rename_datastore
Sep 24, 2017
e989010
Added salt.modules.list_hosts_via_proxy
Sep 24, 2017
4230224
Added salt.modules.vsphere.list_disks
Sep 24, 2017
5d89f7b
Added salt.modules.vsphere.erase_disk_partitions
Sep 24, 2017
f76115f
Added salt.modules.vsphere.list_disk_partitions
Sep 24, 2017
23fbb26
Added salt.modules.vsphere.list_diskgroups
Sep 24, 2017
40589ad
Added DiskGroupsDiskIdSchema JSON schema and DiskGroupDiskIdItem comp…
Sep 25, 2017
7532c28
Added salt.modules.vsphere.create_diskgroup
Sep 25, 2017
41d3846
Added salt.modules.vsphere.add_capacity_to_diskgroup
Sep 25, 2017
7904726
Added salt.modules.vsphere.remove_capacity_from_diskgroup
Sep 25, 2017
b3909ee
Added salt.modules.vsphere.remove_diskgroup
Sep 25, 2017
8bd7993
Added SimpleHostCacheSchema JSON schema
Sep 25, 2017
8538884
Added salt.modules.vsphere.get_host_cache
Sep 25, 2017
ea63774
Added salt.modules.vsphere.configure_host_cache
Sep 25, 2017
55e5a6e
Added DiskGroupsDiskScsiAddressSchema JSON schema
Sep 25, 2017
23e2fd3
Added VmfsDatastoreSchema and HostCacheSchema JSON schemas used in ho…
Sep 25, 2017
8e58f72
Added salt.modules.vsphere.create_vmfs_datastore
Sep 25, 2017
29b59a6
Comment fix in salt.modules.vsphere.rename_datastore
Sep 25, 2017
fa6460d
Added salt.modules.vsphere.remove_datastore
Sep 26, 2017
7d70a01
Moved pyVmomi/python incompatibility check from __virtual__ to pyVmom…
Sep 25, 2017
152ce0b
Added salt.states.esxi additional imports and pyVmomi/python compatib…
Sep 25, 2017
1423d9d
Added diskgroups_configured state that configures VSAN diskgroups on …
Sep 25, 2017
c1d36f5
Added host_cache_configured state that configures the host cache on E…
Sep 25, 2017
ac3a3bd
Added VMwareObjectExistsError exception
Sep 26, 2017
951d43e
pylint
Sep 26, 2017
2e2b01e
Fix logic to list hosts
Sep 26, 2017
adfa462
Fixed tests for salt.utils.vmware.get_hosts
Sep 26, 2017
90a174c
more pylint
Sep 27, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
219 changes: 219 additions & 0 deletions salt/config/schemas/esxi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,219 @@
# -*- coding: utf-8 -*-
'''
:codeauthor: :email:`Alexandru Bleotu ([email protected])`


salt.config.schemas.esxi
~~~~~~~~~~~~~~~~~~~~~~~~

ESXi host configuration schemas
'''

# Import Python libs
from __future__ import absolute_import

# Import Salt libs
from salt.utils.schema import (DefinitionsSchema,
Schema,
ComplexSchemaItem,
ArrayItem,
IntegerItem,
BooleanItem,
StringItem,
OneOfItem)


class VMwareScsiAddressItem(StringItem):
pattern = r'vmhba\d+:C\d+:T\d+:L\d+'


class DiskGroupDiskScsiAddressItem(ComplexSchemaItem):
'''
Schema item of a ESXi host disk group containing disk SCSI addresses
'''

title = 'Diskgroup Disk Scsi Address Item'
description = 'ESXi host diskgroup item containing disk SCSI addresses'

cache_scsi_addr = VMwareScsiAddressItem(
title='Cache Disk Scsi Address',
description='Specifies the SCSI address of the cache disk',
required=True)

capacity_scsi_addrs = ArrayItem(
title='Capacity Scsi Addresses',
description='Array with the SCSI addresses of the capacity disks',
items=VMwareScsiAddressItem(),
min_items=1)


class DiskGroupDiskIdItem(ComplexSchemaItem):
'''
Schema item of a ESXi host disk group containg disk ids
'''

title = 'Diskgroup Disk Id Item'
description = 'ESXi host diskgroup item containing disk ids'

cache_id = StringItem(
title='Cache Disk Id',
description='Specifies the id of the cache disk',
pattern=r'[^\s]+')

capacity_ids = ArrayItem(
title='Capacity Disk Ids',
description='Array with the ids of the capacity disks',
items=StringItem(pattern=r'[^\s]+'),
min_items=1)


class DiskGroupsDiskScsiAddressSchema(DefinitionsSchema):
'''
Schema of ESXi host diskgroups containing disk SCSI addresses
'''

title = 'Diskgroups Disk Scsi Address Schema'
description = 'ESXi host diskgroup schema containing disk SCSI addresses'
diskgroups = ArrayItem(
title='Diskgroups',
description='List of diskgroups in an ESXi host',
min_items=1,
items=DiskGroupDiskScsiAddressItem(),
required=True)
erase_disks = BooleanItem(
title='Erase Diskgroup Disks',
required=True)


class DiskGroupsDiskIdSchema(DefinitionsSchema):
'''
Schema of ESXi host diskgroups containing disk ids
'''

title = 'Diskgroups Disk Id Schema'
description = 'ESXi host diskgroup schema containing disk ids'
diskgroups = ArrayItem(
title='DiskGroups',
description='List of disk groups in an ESXi host',
min_items=1,
items=DiskGroupDiskIdItem(),
required=True)


class VmfsDatastoreDiskIdItem(ComplexSchemaItem):
'''
Schema item of a VMFS datastore referencing a backing disk id
'''

title = 'VMFS Datastore Disk Id Item'
description = 'VMFS datastore item referencing a backing disk id'
name = StringItem(
title='Name',
description='Specifies the name of the VMFS datastore',
required=True)
backing_disk_id = StringItem(
title='Backing Disk Id',
description=('Specifies the id of the disk backing the VMFS '
'datastore'),
pattern=r'[^\s]+',
required=True)
vmfs_version = IntegerItem(
title='VMFS Version',
description='VMFS version',
enum=[1, 2, 3, 5])


class VmfsDatastoreDiskScsiAddressItem(ComplexSchemaItem):
'''
Schema item of a VMFS datastore referencing a backing disk SCSI address
'''

title = 'VMFS Datastore Disk Scsi Address Item'
description = 'VMFS datastore item referencing a backing disk SCSI address'
name = StringItem(
title='Name',
description='Specifies the name of the VMFS datastore',
required=True)
backing_disk_scsi_addr = VMwareScsiAddressItem(
title='Backing Disk Scsi Address',
description=('Specifies the SCSI address of the disk backing the VMFS '
'datastore'),
required=True)
vmfs_version = IntegerItem(
title='VMFS Version',
description='VMFS version',
enum=[1, 2, 3, 5])


class VmfsDatastoreSchema(DefinitionsSchema):
'''
Schema of a VMFS datastore
'''

title = 'VMFS Datastore Schema'
description = 'Schema of a VMFS datastore'
datastore = OneOfItem(
items=[VmfsDatastoreDiskScsiAddressItem(),
VmfsDatastoreDiskIdItem()],
required=True)


class HostCacheSchema(DefinitionsSchema):
'''
Schema of ESXi host cache
'''

title = 'Host Cache Schema'
description = 'Schema of the ESXi host cache'
enabled = BooleanItem(
title='Enabled',
required=True)
datastore = VmfsDatastoreDiskScsiAddressItem(required=True)
swap_size = StringItem(
title='Host cache swap size (in GB or %)',
pattern=r'(\d+GiB)|(([0-9]|([1-9][0-9])|100)%)',
required=True)
erase_backing_disk = BooleanItem(
title='Erase Backup Disk',
required=True)


class SimpleHostCacheSchema(Schema):
'''
Simplified Schema of ESXi host cache
'''

title = 'Simple Host Cache Schema'
description = 'Simplified schema of the ESXi host cache'
enabled = BooleanItem(
title='Enabled',
required=True)
datastore_name = StringItem(title='Datastore Name',
required=True)
swap_size_MiB = IntegerItem(title='Host cache swap size in MiB',
minimum=1)


class EsxiProxySchema(Schema):
'''
Schema of the esxi proxy input
'''

title = 'Esxi Proxy Schema'
description = 'Esxi proxy schema'
additional_properties = False
proxytype = StringItem(required=True,
enum=['esxi'])
host = StringItem(pattern=r'[^\s]+') # Used when connecting directly
vcenter = StringItem(pattern=r'[^\s]+') # Used when connecting via a vCenter
esxi_host = StringItem()
username = StringItem()
passwords = ArrayItem(min_items=1,
items=StringItem(),
unique_items=True)
mechanism = StringItem(enum=['userpass', 'sspi'])
# TODO Should be changed when anyOf is supported for schemas
domain = StringItem()
principal = StringItem()
protocol = StringItem()
port = IntegerItem(minimum=1)
12 changes: 12 additions & 0 deletions salt/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,18 @@ class VMwareObjectRetrievalError(VMwareSaltError):
'''


class VMwareObjectExistsError(VMwareSaltError):
'''
Used when a VMware object exists
'''


class VMwareObjectNotFoundError(VMwareSaltError):
'''
Used when a VMware object was not found
'''


class VMwareApiError(VMwareSaltError):
'''
Used when representing a generic VMware API error
Expand Down
4 changes: 4 additions & 0 deletions salt/modules/esxi.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,7 @@ def cmd(command, *args, **kwargs):
proxy_cmd = proxy_prefix + '.ch_config'

return __proxy__[proxy_cmd](command, *args, **kwargs)


def get_details():
return __proxy__['esxi.get_details']()
Loading