class HAConfigItem(ComplexSchemaItem): """ Schema item of ESX cluster high availability """ title = "HA Configuration" description = "ESX cluster HA configuration json schema item" enabled = BooleanItem(title="Enabled", description="Specifies if HA should be enabled") admission_control_enabled = BooleanItem(title="Admission Control Enabled") admission_control_policy = AdmissionControlPolicyItem() default_vm_settings = DefaultVmSettingsItem() hb_ds_candidate_policy = StringItem( title="Heartbeat Datastore Candidate Policy", enum=[ "allFeasibleDs", "allFeasibleDsWithUserPreference", "userSelectedDs" ], ) host_monitoring = StringItem(title="Host Monitoring", choices=["enabled", "disabled"]) options = ArrayItem(min_items=1, items=OptionValueItem()) vm_monitoring = StringItem( title="Vm Monitoring", choices=[ "vmMonitoringDisabled", "vmAndAppMonitoring", "vmMonitoringOnly" ], )
class HAConfigItem(ComplexSchemaItem): ''' Schema item of ESX cluster high availability ''' title = 'HA Configuration' description = 'ESX cluster HA configuration json schema item' enabled = BooleanItem(title='Enabled', description='Specifies if HA should be enabled') admission_control_enabled = BooleanItem(title='Admission Control Enabled') admission_control_policy = AdmissionControlPolicyItem() default_vm_settings = DefaultVmSettingsItem() hb_ds_candidate_policy = StringItem( title='Heartbeat Datastore Candidate Policy', enum=[ 'allFeasibleDs', 'allFeasibleDsWithUserPreference', 'userSelectedDs' ]) host_monitoring = StringItem(title='Host Monitoring', choices=['enabled', 'disabled']) options = ArrayItem(min_items=1, items=OptionValueItem()) vm_monitoring = StringItem(title='Vm Monitoring', choices=[ 'vmMonitoringDisabled', 'vmAndAppMonitoring', 'vmMonitoringOnly' ])
class ESXVirtualMachinePlacementSchemaItem(ComplexSchemaItem): ''' Configuration Schema Item for ESX Virtual Machine Placement ''' title = 'ESX Virtual Machine Placement Information' description = 'ESX virtual machine placement property' required = True cluster = StringItem( title='Virtual Machine Cluster', description= 'Cluster of the virtual machine if it is placed to a cluster') host = StringItem( title='Virtual Machine Host', description= 'Host of the virtual machine if it is placed to a standalone host') resourcepool = StringItem( title='Virtual Machine Resource Pool', description= 'Resource pool of the virtual machine if it is placed to a resource pool' ) folder = StringItem( title='Virtual Machine Folder', description= 'Folder of the virtual machine where it should be deployed, default is the datacenter vmFolder' )
class ESXVirtualMachineCdDriveSchemaItem(ComplexSchemaItem): """ Configuration Schema Item for ESX Virtual Machine CD Drives """ title = "ESX Virtual Machine Serial CD" description = "ESX virtual machine CD/DVD drive properties" adapter = StringItem( title="Virtual Machine CD/DVD Adapter", description="Unique adapter name for virtual machine cd/dvd drive", required=True, ) controller = StringItem(required=True) device_type = StringItem( title="Virtual Machine Device Type", description= "CD/DVD drive of the virtual machine if it is placed to a cluster", required=True, default="client_device", enum=("datastore_iso_file", "client_device"), ) client_device = ESXVirtualMachineCdDriveClientSchemaItem() datastore_iso_file = ESXVirtualMachineCdDriveIsoSchemaItem() connectable = ESXVirtualMachineDeviceConnectionItem()
class ESXClusterEntitySchema(Schema): """Schema of the ESX cluster entity""" title = "ESX Cluster Entity Schema" description = "ESX cluster entity schema" type = StringItem( title="Type", description="Specifies the entity type", required=True, enum=["cluster"], ) datacenter = StringItem( title="Datacenter", description="Specifies the cluster datacenter", required=True, pattern=r"\w+", ) cluster = StringItem( title="Cluster", description="Specifies the cluster name", required=True, pattern=r"\w+", )
class ESXVirtualMachineScsiSchemaItem(ComplexSchemaItem): ''' Configuration Schema Item for ESX Virtual Machine SCSI Controller ''' title = 'ESX Virtual Machine SCSI Controller Configuration' description = 'ESX virtual machine scsi controller properties' required = True adapter = StringItem(title='Virtual Machine SCSI Controller Name', description='Unique SCSI controller name' 'for creation an arbitrary value should be specified', required=True) type = StringItem(title='Virtual Machine SCSI type', description='Type of the SCSI controller', required=True, enum=('lsilogic', 'lsilogic_sas', 'paravirtual', 'buslogic')) bus_sharing = StringItem(title='Virtual Machine SCSI bus sharing', description='Sharing type of the SCSI bus', required=True, enum=('virtual_sharing', 'physical_sharing', 'no_sharing')) bus_number = NumberItem(title='Virtual Machine SCSI bus number', description='Unique bus number of the SCSI device', required=True)
class ESXVirtualMachinePlacementSchemaItem(ComplexSchemaItem): """ Configuration Schema Item for ESX Virtual Machine Placement """ title = "ESX Virtual Machine Placement Information" description = "ESX virtual machine placement property" required = True cluster = StringItem( title="Virtual Machine Cluster", description="Cluster of the virtual machine if it is placed to a cluster", ) host = StringItem( title="Virtual Machine Host", description="Host of the virtual machine if it is placed to a standalone host", ) resourcepool = StringItem( title="Virtual Machine Resource Pool", description="Resource pool of the virtual machine if it is placed to a resource pool", ) folder = StringItem( title="Virtual Machine Folder", description="Folder of the virtual machine where it should be deployed, default is the datacenter vmFolder", )
class ESXVirtualMachineScsiSchemaItem(ComplexSchemaItem): """ Configuration Schema Item for ESX Virtual Machine SCSI Controller """ title = "ESX Virtual Machine SCSI Controller Configuration" description = "ESX virtual machine scsi controller properties" required = True adapter = StringItem( title="Virtual Machine SCSI Controller Name", description="Unique SCSI controller name" "for creation an arbitrary value should be specified", required=True, ) type = StringItem( title="Virtual Machine SCSI type", description="Type of the SCSI controller", required=True, enum=("lsilogic", "lsilogic_sas", "paravirtual", "buslogic"), ) bus_sharing = StringItem( title="Virtual Machine SCSI bus sharing", description="Sharing type of the SCSI bus", required=True, enum=("virtual_sharing", "physical_sharing", "no_sharing"), ) bus_number = NumberItem( title="Virtual Machine SCSI bus number", description="Unique bus number of the SCSI device", required=True, )
class ESXVirtualMachineSerialBackingItem(ComplexSchemaItem): ''' Configuration Schema Item for ESX Virtual Machine Serial Port Backing ''' title = 'ESX Virtual Machine Serial Port Backing' description = 'ESX virtual machine serial port backing' required = True uri = StringItem() direction = StringItem(enum=('client', 'server')) filename = StringItem()
class ESXVirtualMachineSerialBackingItem(ComplexSchemaItem): """ Configuration Schema Item for ESX Virtual Machine Serial Port Backing """ title = "ESX Virtual Machine Serial Port Backing" description = "ESX virtual machine serial port backing" required = True uri = StringItem() direction = StringItem(enum=("client", "server")) filename = StringItem()
class DefaultVmSettingsItem(ComplexSchemaItem): ''' Schema item of the HA default vm settings ''' title = 'Default VM Settings' isolation_response = StringItem( title='Isolation Response', enum=['clusterIsolationResponse', 'none', 'powerOff', 'shutdown']) restart_priority = StringItem( title='Restart Priority', enum=['clusterRestartPriority', 'disabled', 'high', 'low', 'medium'])
class RosterEntryConfig(Schema): ''' Schema definition of a Salt SSH Roster entry ''' title = 'Roster Entry' description = 'Salt SSH roster entry definition' host = StringItem( title='Host', description='The IP address or DNS name of the remote host', # Pretty naive pattern matching pattern= r'^((\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})|([A-Za-z0-9][A-Za-z0-9\.\-]{1,255}))$', min_length=1, required=True) port = PortItem(title='Port', description='The target system\'s ssh port number', default=22) user = StringItem(title='User', description='The user to log in as. Defaults to root', default='root', min_length=1, required=True) passwd = SecretItem(title='Password', description='The password to log in with', min_length=1) priv = StringItem( title='Private Key', description='File path to ssh private key, defaults to salt-ssh.rsa', min_length=1) priv_passwd = SecretItem(title='Private Key passphrase', description='Passphrase for private key file', min_length=1) passwd_or_priv_requirement = AnyOfItem( items=(RequirementsItem(requirements=['passwd']), RequirementsItem(requirements=['priv'])))(flatten=True) sudo = BooleanItem(title='Sudo', description='run command via sudo. Defaults to False', default=False) timeout = IntegerItem( title='Timeout', description=('Number of seconds to wait for response ' 'when establishing an SSH connection')) thin_dir = StringItem( title='Thin Directory', description=('The target system\'s storage directory for Salt ' 'components. Defaults to /tmp/salt-<hash>.')) minion_opts = DictItem(title='Minion Options', description='Dictionary of minion options', properties=MinionConfiguration())
class VCenterEntitySchema(Schema): ''' Entity Schema for a VCenter. ''' title = 'VCenter Entity Schema' description = 'VCenter entity schema' type = StringItem(title='Type', description='Specifies the entity type', required=True, enum=['vcenter']) vcenter = StringItem(title='vCenter', description='Specifies the vcenter hostname', required=True)
class DefaultVmSettingsItem(ComplexSchemaItem): """ Schema item of the HA default vm settings """ title = "Default VM Settings" isolation_response = StringItem( title="Isolation Response", enum=["clusterIsolationResponse", "none", "powerOff", "shutdown"], ) restart_priority = StringItem( title="Restart Priority", enum=["clusterRestartPriority", "disabled", "high", "low", "medium"], )
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 ESXVirtualMachineCdDriveClientSchemaItem(ComplexSchemaItem): ''' Configuration Schema Item for ESX Virtual Machine CD Drive Client ''' title = 'ESX Virtual Machine Serial CD Client' description = 'ESX virtual machine CD/DVD drive client properties' mode = StringItem(required=True, enum=('passthrough', 'atapi'))
class ESXVirtualMachineRemoveSchema(DefinitionsSchema): ''' Remove Schema for ESX Virtual Machines to delete or unregister virtual machines ''' name = StringItem(title='Virtual Machine name', description='Name of the virtual machine', required=True) datacenter = StringItem(title='Virtual Machine Datacenter', description='Datacenter of the virtual machine', required=True) placement = AnyOfItem( required=False, items=[ESXVirtualMachinePlacementSchemaItem(), NullItem()]) power_off = BooleanItem(title='Power off vm', description='Power off vm before delete operation', required=False)
class VCenterEntitySchema(Schema): """ Entity Schema for a VCenter. """ title = "VCenter Entity Schema" description = "VCenter entity schema" type = StringItem( title="Type", description="Specifies the entity type", required=True, enum=["vcenter"], ) vcenter = StringItem(title="vCenter", description="Specifies the vcenter hostname", required=True)
class ESXVirtualMachineCdDriveIsoSchemaItem(ComplexSchemaItem): ''' Configuration Schema Item for ESX Virtual Machine CD Drive ISO ''' title = 'ESX Virtual Machine Serial CD ISO' description = 'ESX virtual machine CD/DVD drive ISO properties' path = StringItem(required=True)
class ESXVirtualMachineInterfaceSchemaItem(ComplexSchemaItem): """ Configuration Schema Item for ESX Virtual Machine Network Interface """ title = "ESX Virtual Machine Network Interface Configuration" description = "ESX Virtual Machine network adapter properties" required = True name = StringItem( title="Virtual Machine Port Group", description= "Specifies the port group name for the virtual machine connection", required=True, ) adapter = StringItem( title="Virtual Machine Network Adapter", description=("Unique name of the network adapter, " "for creation an arbitrary value should be specified"), required=True, ) adapter_type = StringItem( title="Virtual Machine Adapter Type", description="Network adapter type of the virtual machine", required=True, enum=("vmxnet", "vmxnet2", "vmxnet3", "e1000", "e1000e"), default="vmxnet3", ) switch_type = StringItem( title="Virtual Machine Switch Type", description=( "Specifies the type of the virtual switch for the virtual machine" " connection"), required=True, default="standard", enum=("standard", "distributed"), ) mac = StringItem( title="Virtual Machine MAC Address", description="Mac address of the virtual machine", required=False, pattern="^([0-9a-f]{1,2}[:]){5}([0-9a-f]{1,2})$", ) mapping = ESXVirtualMachineNicMapSchemaItem() connectable = ESXVirtualMachineDeviceConnectionItem()
class ESXVirtualMachineCdDriveClientSchemaItem(ComplexSchemaItem): """ Configuration Schema Item for ESX Virtual Machine CD Drive Client """ title = "ESX Virtual Machine Serial CD Client" description = "ESX virtual machine CD/DVD drive client properties" mode = StringItem(required=True, enum=("passthrough", "atapi"))
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 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 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 ESXVirtualMachineSerialSchemaItem(ComplexSchemaItem): ''' Configuration Schema Item for ESX Virtual Machine Serial Port ''' title = 'ESX Virtual Machine Serial Port Configuration' description = 'ESX virtual machine serial port properties' type = StringItem(title='Virtual Machine Serial Port Type', required=True, enum=('network', 'pipe', 'file', 'device')) adapter = StringItem( title='Virtual Machine Serial Port Name', description='Unique adapter name for virtual machine serial port' 'for creation an arbitrary value should be specified', required=True) backing = ESXVirtualMachineSerialBackingItem() connectable = ESXVirtualMachineDeviceConnectionItem() yield_port = BooleanItem(title='Serial Port Yield', description='Serial port yield', default=False)
class EsxclusterProxySchema(Schema): ''' Schema of the esxcluster proxy input ''' title = 'Esxcluster Proxy Schema' description = 'Esxcluster proxy schema' additional_properties = False proxytype = StringItem(required=True, enum=['esxcluster']) vcenter = StringItem(required=True, pattern=r'[^\s]+') datacenter = StringItem(required=True) cluster = StringItem(required=True) mechanism = StringItem(required=True, enum=['userpass', 'sspi']) username = StringItem() passwords = ArrayItem(min_items=1, items=StringItem(), unique_items=True) # TODO Should be changed when anyOf is supported for schemas domain = StringItem() principal = StringItem() protocol = StringItem() port = IntegerItem(minimum=1)
class ESXClusterEntitySchema(Schema): '''Schema of the ESX cluster entity''' title = 'ESX Cluster Entity Schema' description = 'ESX cluster entity schema' type = StringItem(title='Type', description='Specifies the entity type', required=True, enum=['cluster']) datacenter = StringItem(title='Datacenter', description='Specifies the cluster datacenter', required=True, pattern=r'\w+') cluster = StringItem(title='Cluster', description='Specifies the cluster name', required=True, pattern=r'\w+')
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 EsxclusterProxySchema(Schema): """ Schema of the esxcluster proxy input """ title = "Esxcluster Proxy Schema" description = "Esxcluster proxy schema" additional_properties = False proxytype = StringItem(required=True, enum=["esxcluster"]) vcenter = StringItem(required=True, pattern=r"[^\s]+") datacenter = StringItem(required=True) cluster = StringItem(required=True) mechanism = StringItem(required=True, enum=["userpass", "sspi"]) username = StringItem() passwords = ArrayItem(min_items=1, items=StringItem(), unique_items=True) # TODO Should be changed when anyOf is supported for schemas domain = StringItem() principal = StringItem() protocol = StringItem() port = IntegerItem(minimum=1)
class ESXClusterConfigSchema(DefinitionsSchema): ''' Schema of the ESX cluster config ''' title = 'ESX Cluster Configuration Schema' description = 'ESX cluster configuration schema' ha = HAConfigItem() vsan = vSANClusterConfigItem() drs = DRSConfigItem() vm_swap_placement = StringItem(title='VM Swap Placement')