##################################################################################
# Cloudify vSphere built in types and plugins definitions.
##################################################################################

plugins:
  vsphere:
    executor: central_deployment_agent
    package_name: cloudify-vsphere-plugin
    package_version: '2.20.9'

data_types:

  cloudify.datatypes.vsphere.Config:
    properties:
      username:
        type: string
        required: false
      host:
        type: string
        required: false
      password:
        type: string
        required: false
      datacenter_name:
        type: string
        required: false
      auto_placement:
        type: string
        required: false
      resource_pool_name:
        type: string
        required: false
      port:
        type: integer
        required: false
      allow_insecure:
        type: boolean
        required: false
      certificate_path:
        type: string
        required: false
      certificate_data:
        type: string
        required: false

  cloudify.datatypes.vsphere.ServerProperties:
    properties:
      memory:
        type: integer
        required: false
      cpus:
        type: integer
        required: false
      template:
        type: string
        required: false
      name:
        type: string
        required: false
      add_scale_suffix:
        type: boolean
        default: true
      clone_vm:
        type: string
        required: false
      disk_provision_type:
        type: string
        required: false
      disk_size:
        type: integer
        required: false
      cpu_hot_add:
        type: boolean
        default: true
      cpu_hot_remove:
        type: boolean
        default: true
      memory_hot_add:
        type: boolean
        default: true

  cloudify.datatypes.vsphere.NetworkingProperties:
    properties:
      domain:
        type: string
        required: false
      dns_servers:
        required: false
      connect_networks:
        required: false

node_types:

  cloudify.vsphere.nodes.Server:
    derived_from: cloudify.nodes.vsphere.Server

  cloudify.nodes.vsphere.Server:
    derived_from: cloudify.nodes.Compute
    properties:
      use_external_resource:
        type: boolean
        default: false
      allowed_hosts:
        required: false
      allowed_clusters:
        required: false
      allowed_datastores:
        required: false
      server:
        type: cloudify.datatypes.vsphere.ServerProperties
      networking:
        type: cloudify.datatypes.vsphere.NetworkingProperties
      custom_attributes:
        required: false
      cdrom_image:
        default: false
      extra_config:
        default: {}
      wait_ip:
        default: false
      vm_folder:
        default: false
      connection_config:
        type: cloudify.datatypes.vsphere.Config
      force_stop:
        default: false
      force_delete:
        default: false
      enable_start_vm:
        default: true
      postpone_delete_networks:
        default: false
      minimal_vm_version:
        default: 13
      boot_order:
        type: list
        required: false
      disk_keys:
        type: list
        required: false
      ethernet_keys:
        type: list
        required: false
    interfaces:
      cloudify.interfaces.lifecycle:
        create:
          implementation: vsphere.vsphere_server_plugin.server.create
          inputs:
            max_wait_time: &id001
              type: integer
              default: 300
        start:
          implementation: vsphere.vsphere_server_plugin.server.start
          inputs:
            max_wait_time: *id001
        poststart:
          implementation: vsphere.vsphere_server_plugin.server.poststart
          inputs: {}
        stop:
          implementation: vsphere.vsphere_server_plugin.server.stop
          inputs:
            max_wait_time: *id001
        shutdown_guest:
          implementation: vsphere.vsphere_server_plugin.server.shutdown_guest
          inputs:
            max_wait_time: *id001
        delete:
          implementation: vsphere.vsphere_server_plugin.server.delete
          inputs:
            max_wait_time: *id001
        check_drift:
          implementation: vsphere.vsphere_server_plugin.server.check_drift
          inputs: {}
        update:
          implementation: vsphere.vsphere_server_plugin.server.update
          inputs: {}
      cloudify.interfaces.freeze:
        suspend:
          implementation: vsphere.vsphere_server_plugin.server.freeze_suspend
          inputs:
            max_wait_time: *id001
        resume:
          implementation: vsphere.vsphere_server_plugin.server.freeze_resume
          inputs:
            max_wait_time: *id001
      cloudify.interfaces.snapshot:
        create:
          implementation: vsphere.vsphere_server_plugin.server.snapshot_create
          inputs:
            max_wait_time: *id001
        apply:
          implementation: vsphere.vsphere_server_plugin.server.snapshot_apply
          inputs:
            max_wait_time: *id001
        delete:
          implementation: vsphere.vsphere_server_plugin.server.snapshot_delete
          inputs:
            max_wait_time: *id001
      cloudify.interfaces.host:
        get_state:
          implementation: vsphere.vsphere_server_plugin.server.get_state
          inputs:
            max_wait_time: *id001
            minimum_wait_time:
              type: integer
              default: 0
      cloudify.interfaces.modify:
        resize:
          implementation: vsphere.vsphere_server_plugin.server.resize_server
          inputs:
            max_wait_time: *id001
            hot_add:
              default: true
      cloudify.interfaces.power:
        'on':
          implementation: vsphere.vsphere_server_plugin.power.power_on
          inputs:
            max_wait_time: *id001
        'off':
          implementation: vsphere.vsphere_server_plugin.power.power_off
          inputs:
            max_wait_time: *id001
        reset:
          implementation: vsphere.vsphere_server_plugin.power.reset
          inputs:
            max_wait_time: *id001
        reboot:
          implementation: vsphere.vsphere_server_plugin.power.reboot
          inputs:
            max_wait_time: *id001
        shut_down:
          implementation: vsphere.vsphere_server_plugin.power.shut_down
          inputs:
            max_wait_time: *id001

  cloudify.vsphere.nodes.WindowsServer:
    derived_from: cloudify.nodes.vsphere.WindowsServer

  cloudify.nodes.vsphere.WindowsServer:
    derived_from: cloudify.vsphere.nodes.Server
    properties:
      windows_password:
        type: string
        required: false
      windows_timezone:
        type: integer
        default: 90
      windows_organization:
        type: string
        default: Organization
      custom_sysprep:
        type: string
        required: false
      os_family:
        default: windows
      agent_config:
        type: cloudify.datatypes.AgentConfig
        default:
          port: 5985

  cloudify.vsphere.nodes.Network:
    derived_from: cloudify.nodes.vsphere.Network

  cloudify.nodes.vsphere.Network:
    derived_from: cloudify.nodes.Network
    properties:
      use_external_resource:
        type: boolean
        default: false
      network: {}
      connection_config:
        default: {}
        type: cloudify.datatypes.vsphere.Config
    interfaces:
      cloudify.interfaces.lifecycle:
        create:
          implementation: vsphere.vsphere_network_plugin.network.create
          inputs: {}
        delete:
          implementation: vsphere.vsphere_network_plugin.network.delete
          inputs: {}

  cloudify.vsphere.nodes.Storage:
    derived_from: cloudify.nodes.vsphere.Storage

  cloudify.nodes.vsphere.Storage:
    derived_from: cloudify.nodes.Volume
    properties:
      use_external_resource:
        type: boolean
        default: false
      storage:
        default: {}
      connection_config:
        default: {}
        type: cloudify.datatypes.vsphere.Config
    interfaces:
      cloudify.interfaces.lifecycle:
        create:
          implementation: vsphere.vsphere_storage_plugin.storage.create
          inputs:
            max_wait_time: *id001
            storage:
              default: { get_property: [SELF, storage ]}
        delete:
          implementation: vsphere.vsphere_storage_plugin.storage.delete
          inputs:
            max_wait_time: *id001
        check_drift:
          implementation: vsphere.vsphere_storage_plugin.storage.check_drift
          inputs: {}
        update:
          implementation: vsphere.vsphere_storage_plugin.storage.update
          inputs: {}
      cloudify.interfaces.modify:
        resize:
          implementation: vsphere.vsphere_storage_plugin.storage.resize
          inputs:
            max_wait_time: *id001
            storage:
              default: { get_property: [SELF, storage] }

  cloudify.vsphere.nodes.IPPool:
    derived_from: cloudify.nodes.vsphere.IPPool

  cloudify.nodes.vsphere.IPPool:
    derived_from: cloudify.nodes.Subnet
    properties:
      datacenter_name:
        type: string
        required: false
      ippool: {}
      connection_config:
        default: {}
        type: cloudify.datatypes.vsphere.Config
    interfaces:
      cloudify.interfaces.lifecycle:
        create:
          implementation: vsphere.vsphere_network_plugin.ippool.create
          inputs: {}
        poststart:
          implementation: vsphere.vsphere_network_plugin.ippool.poststart
          inputs: {}
        delete:
          implementation: vsphere.vsphere_network_plugin.ippool.delete
          inputs: {}
        check_drift:
          implementation: vsphere.vsphere_network_plugin.ippool.check_drift
          inputs: {}

  cloudify.vsphere.nodes.CloudInitISO:
    derived_from: cloudify.nodes.vsphere.CloudInitISO

  cloudify.nodes.vsphere.CloudInitISO:
    derived_from: cloudify.nodes.Volume
    properties:
      datacenter_name:
        type: string
        required: false
      allowed_datastores:
        required: false
      allowed_datastore_ids:
        required: false
      volume_prefix:
        default: cloudinit
      vol_ident:
        default: cidata
      sys_ident:
        default: ''
      files:
        default: {}
      raw_files:
        default: {}
      files_raw:
        default: { get_property: [SELF, raw_files] }
      connection_config:
        default: {}
        type: cloudify.datatypes.vsphere.Config
    interfaces:
      cloudify.interfaces.lifecycle:
        create:
          implementation: vsphere.vsphere_storage_plugin.cidata.create
          inputs: {}
        delete:
          implementation: vsphere.vsphere_storage_plugin.cidata.delete
          inputs: {}

  cloudify.vsphere.nodes.Datacenter:
    derived_from: cloudify.nodes.vsphere.Datacenter

  cloudify.nodes.vsphere.Datacenter:
    derived_from: cloudify.nodes.Root
    properties:
      name: {}
      use_external_resource:
        type: boolean
        default: true
      connection_config:
        default: {}
        type: cloudify.datatypes.vsphere.Config
    interfaces:
      cloudify.interfaces.lifecycle:
        create:
          implementation: vsphere.cloudify_vsphere.datacenter.create
          inputs: {}
        delete:
          implementation: vsphere.cloudify_vsphere.datacenter.delete
          inputs: {}

  cloudify.vsphere.nodes.Datastore:
    derived_from: cloudify.nodes.vsphere.Datastore

  cloudify.nodes.vsphere.Datastore:
    derived_from: cloudify.nodes.Root
    properties:
      name: {}
      use_external_resource:
        type: boolean
        default: true
      connection_config:
        default: {}
        type: cloudify.datatypes.vsphere.Config
    interfaces:
      cloudify.interfaces.lifecycle:
        create:
          implementation: vsphere.cloudify_vsphere.datastore.create
          inputs: {}
        delete:
          implementation: vsphere.cloudify_vsphere.datastore.delete
          inputs: {}

  cloudify.vsphere.nodes.Cluster:
    derived_from: cloudify.nodes.vsphere.Cluster

  cloudify.nodes.vsphere.Cluster:
    derived_from: cloudify.nodes.Root
    properties:
      name: {}
      use_external_resource:
        type: boolean
        default: true
      connection_config:
        default: {}
        type: cloudify.datatypes.vsphere.Config
    interfaces:
      cloudify.interfaces.lifecycle:
        create:
          implementation: vsphere.cloudify_vsphere.cluster.create
          inputs: {}
        delete:
          implementation: vsphere.cloudify_vsphere.cluster.delete
          inputs: {}

  cloudify.vsphere.nodes.ResourcePool:
    derived_from: cloudify.nodes.vsphere.ResourcePool

  cloudify.nodes.vsphere.ResourcePool:
    derived_from: cloudify.nodes.Root
    properties:
      name: {}
      use_external_resource:
        type: boolean
        default: false
      host_name:
        default: ''
      cluster_name:
        default: ''
      pool_spec:
        default: {}
      connection_config:
        default: {}
        type: cloudify.datatypes.vsphere.Config
    interfaces:
      cloudify.interfaces.lifecycle:
        create:
          implementation: vsphere.cloudify_vsphere.resource_pool.create
          inputs: {}
        poststart:
          implementation: vsphere.cloudify_vsphere.resource_pool.poststart
          inputs: {}
        delete:
          implementation: vsphere.cloudify_vsphere.resource_pool.delete
          inputs: {}
        check_drift:
          implementation: vsphere.cloudify_vsphere.resource_pool.check_drift
          inputs: {}
      cloudify.interfaces.operations:
        update:
          implementation: vsphere.cloudify_vsphere.resource_pool.update_resource_pool
          inputs: {}

  cloudify.vsphere.nodes.VMFolder:
    derived_from: cloudify.nodes.vsphere.VMFolder

  cloudify.nodes.vsphere.VMFolder:
    derived_from: cloudify.nodes.Root
    properties:
      name: {}
      use_external_resource:
        type: boolean
        default: true
      connection_config:
        default: {}
        type: cloudify.datatypes.vsphere.Config
    interfaces:
      cloudify.interfaces.lifecycle:
        create:
          implementation: vsphere.cloudify_vsphere.vm_folder.create
          inputs: {}
        delete:
          implementation: vsphere.cloudify_vsphere.vm_folder.delete
          inputs: {}

  cloudify.vsphere.nodes.Host:
    derived_from: cloudify.nodes.vsphere.Host

  cloudify.nodes.vsphere.Host:
    derived_from: cloudify.nodes.Root
    properties:
      name: {}
      use_external_resource:
        type: boolean
        default: true
      connection_config:
        default: {}
        type: cloudify.datatypes.vsphere.Config
    interfaces:
      cloudify.interfaces.lifecycle:
        create:
          implementation: vsphere.cloudify_vsphere.hypervisor_host.create
          inputs: {}
        delete:
          implementation: vsphere.cloudify_vsphere.hypervisor_host.delete
          inputs: {}

  cloudify.vsphere.nodes.ContentLibraryDeployment:
    derived_from: cloudify.nodes.vsphere.ContentLibraryDeployment

  cloudify.nodes.vsphere.ContentLibraryDeployment:
    derived_from: cloudify.nodes.Root
    properties:
      library_name:
        default: ''
      template_name:
        default: ''
      target:
        default: {}
      deployment_spec:
        default: {}
      connection_config:
        default: {}
        type: cloudify.datatypes.vsphere.Config
    interfaces:
      cloudify.interfaces.lifecycle:
        create:
          implementation: vsphere.cloudify_vsphere.contentlibrary.deployment.create
          inputs: {}
        delete:
          implementation: vsphere.cloudify_vsphere.contentlibrary.deployment.delete
          inputs: {}

  cloudify.nodes.vsphere.OvfDeployment:
    derived_from: cloudify.nodes.Root
    properties:
      target:
        default: {}
      ovf_name:
        default: ''
      ovf_source:
        default: ''
      datastore_name: {}
      disk_provisioning:
        default: thin
      network_mappings: {}
      memory:
        type: integer
        required: false
      cpus:
        type: integer
        required: false
      disk_size:
        type: integer
        required: false
      cdrom_image:
        type: string
        required: false
      extra_config:
        default: {}
      boot_firmware:
        type: string
        required: false
      boot_order:
        type: list
        required: false
      disk_keys:
        type: list
        required: false
      ethernet_keys:
        type: list
        required: false
      connection_config:
        default: {}
        type: cloudify.datatypes.vsphere.Config
    interfaces:
      cloudify.interfaces.lifecycle:
        create:
          implementation: vsphere.cloudify_vsphere.ovf.create
          inputs: {}
        delete:
          implementation: vsphere.cloudify_vsphere.ovf.delete
          inputs: {}

  cloudify.vsphere.nodes.NIC:
    derived_from: cloudify.nodes.vsphere.NIC

  cloudify.nodes.vsphere.NIC:
    derived_from: cloudify.nodes.Root
    properties:
      name: {}
      switch_distributed:
        default: false
      adapter_type:
        default: Vmxnet3
      start_connected:
        default: true
      allow_guest_control:
        default: true
      network_connected:
        default: true
      wake_on_lan_enabled:
        default: true
      address_type:
        default: assigned
      mac_address:
        default: ''
      network_configuration:
        default: {}
      connection_config:
        type: cloudify.datatypes.vsphere.Config
    interfaces:
      cloudify.interfaces.lifecycle:
        create:
          implementation: vsphere.cloudify_vsphere.devices.create_controller
          inputs:
            name:
              default: { get_attribute: [SELF, name] }
            switch_distributed:
              default: { get_attribute: [SELF, switch_distributed] }
            adapter_type:
              default: { get_attribute: [SELF, adapter_type] }
            start_connected:
              default: { get_attribute: [SELF, start_connected] }
            allow_guest_control:
              default: { get_attribute: [SELF, allow_guest_control] }
            network_connected:
              default: { get_attribute: [SELF, network_connected] }
            wake_on_lan_enabled:
              default: { get_attribute: [SELF, wake_on_lan_enabled] }
            address_type:
              default: { get_attribute: [SELF, address_type] }
            mac_address:
              default: { get_attribute: [SELF, mac_address] }
            network_configuration:
              default: { get_attribute: [SELF, network_configuration] }
        delete:
          implementation: vsphere.cloudify_vsphere.devices.delete_controller

  cloudify.vsphere.nodes.SCSIController:
    derived_from: cloudify.nodes.vsphere.SCSIController

  cloudify.nodes.vsphere.SCSIController:
    derived_from: cloudify.nodes.Root
    properties:
      busNumber:
        default: 0
      label:
        default: SCSIController
      adapterType:
        default: paravirtual
      hotAddRemove:
        default: true
      sharedBus:
        default: noSharing
      scsiCtlrUnitNumber:
        default: -1
      connection_config:
        type: cloudify.datatypes.vsphere.Config
    interfaces:
      cloudify.interfaces.lifecycle:
        create:
          implementation: vsphere.cloudify_vsphere.devices.create_controller
          inputs:
            busNumber:
              default: { get_attribute: [SELF, busNumber] }
            hotAddRemove:
              default: { get_attribute: [SELF, hotAddRemove] }
            sharedBus:
              default: { get_attribute: [SELF, sharedBus] }
            scsiCtlrUnitNumber:
              default: { get_attribute: [SELF, scsiCtlrUnitNumber] }
            adapterType:
              default: { get_attribute: [SELF, adapterType] }
            label:
              default: { get_attribute: [SELF, label] }
        delete:
          implementation: vsphere.cloudify_vsphere.devices.delete_controller

  cloudify.nodes.vsphere.PCIDevice:
    derived_from: cloudify.nodes.Root
    properties:
      device_name:
        type: string
      turn_off_vm:
        default: false
      connection_config:
        type: cloudify.datatypes.vsphere.Config
    interfaces:
      cloudify.interfaces.lifecycle:
        precreate:
          implementation: vsphere.cloudify_vsphere.devices.copy_device_properties
        postdelete:
          implementation: vsphere.cloudify_vsphere.devices.clean_device_properties

  cloudify.nodes.vsphere.USBDevice:
    derived_from: cloudify.nodes.Root
    properties:
      controller_type:
        default: usb3
      device_name:
        type: string
      connection_config:
        type: cloudify.datatypes.vsphere.Config
    interfaces:
      cloudify.interfaces.lifecycle:
        precreate:
          implementation: vsphere.cloudify_vsphere.devices.copy_device_properties
        postdelete:
          implementation: vsphere.cloudify_vsphere.devices.clean_device_properties

  cloudify.nodes.vsphere.SerialPort:
    derived_from: cloudify.nodes.Root
    properties:
      device_name:
        type: string
      turn_off_vm:
        default: false
      connection_config:
        type: cloudify.datatypes.vsphere.Config
    interfaces:
      cloudify.interfaces.lifecycle:
        precreate:
          implementation: vsphere.cloudify_vsphere.devices.copy_device_properties
        postdelete:
          implementation: vsphere.cloudify_vsphere.devices.clean_device_properties


  cloudify.vsphere.nodes.ISO:
    derived_from: cloudify.nodes.vsphere.ISO

  cloudify.nodes.vsphere.ISO:
    derived_from: cloudify.nodes.Volume
    properties:
      datacenter_name:
        type: string
        required: false
      allowed_datastores:
        required: false
      allowed_datastore_ids:
        required: false
      volume_prefix:
        default: cloudinit
      iso_file_path:
        type: string
        required: true
      connection_config:
        default: {}
        type: cloudify.datatypes.vsphere.Config
      use_external_resource:
        default: false
      force_delete:
        default: false
    interfaces:
      cloudify.interfaces.lifecycle:
        create:
          implementation: vsphere.vsphere_storage_plugin.cidata.upload_iso
          inputs: {}
        delete:
          implementation: vsphere.vsphere_storage_plugin.cidata.delete_iso
          inputs: {}

relationships:

  cloudify.vsphere.port_connected_to_network:
    derived_from: cloudify.relationships.vsphere.port_connected_to_network

  cloudify.relationships.vsphere.port_connected_to_network:
    derived_from: cloudify.relationships.connected_to

  cloudify.vsphere.port_connected_to_server:
    derived_from: cloudify.relationships.vsphere.port_connected_to_server

  cloudify.relationships.vsphere.port_connected_to_server:
    derived_from: cloudify.relationships.connected_to

  cloudify.vsphere.storage_connected_to_server:
    derived_from: cloudify.relationships.vsphere.storage_connected_to_server

  cloudify.relationships.vsphere.storage_connected_to_server:
    derived_from: cloudify.relationships.connected_to

  cloudify.vsphere.nic_connected_to_server:
    derived_from: cloudify.relationships.vsphere.nic_connected_to_server

  cloudify.relationships.vsphere.nic_connected_to_server:
    derived_from: cloudify.relationships.contained_in
    source_interfaces:
      cloudify.interfaces.relationship_lifecycle:
        preconfigure:
          implementation: vsphere.cloudify_vsphere.devices.attach_ethernet_card
        unlink:
          implementation: vsphere.cloudify_vsphere.devices.detach_controller

  cloudify.vsphere.controller_connected_to_vm:
    derived_from: cloudify.relationships.vsphere.controller_connected_to_vm

  cloudify.relationships.vsphere.controller_connected_to_vm:
    derived_from: cloudify.relationships.contained_in
    source_interfaces:
      cloudify.interfaces.relationship_lifecycle:
        preconfigure:
          implementation: vsphere.cloudify_vsphere.devices.attach_scsi_controller
        unlink:
          implementation: vsphere.cloudify_vsphere.devices.detach_controller

  cloudify.relationships.vsphere.nic_connected_to_network:
    derived_from: cloudify.relationships.contained_in

  cloudify.relationships.vsphere.server_connected_to_nic:
    derived_from: cloudify.relationships.contained_in
    source_interfaces:
      cloudify.interfaces.relationship_lifecycle:
        establish:
          implementation: vsphere.cloudify_vsphere.devices.attach_server_to_ethernet_card
        unlink:
          implementation: vsphere.cloudify_vsphere.devices.detach_server_from_controller

  cloudify.relationships.vsphere.ippool_connected_to_network:
    derived_from: cloudify.relationships.depends_on

  cloudify.relationships.vsphere.resource_pool_contained_in:
    derived_from: cloudify.relationships.contained_in

  cloudify.relationships.vsphere.usb_connected_to_server:
    derived_from: cloudify.relationships.contained_in
    source_interfaces:
      cloudify.interfaces.relationship_lifecycle:
        establish:
          implementation: vsphere.cloudify_vsphere.devices.attach_usb_device
        unlink:
          implementation: vsphere.cloudify_vsphere.devices.detach_usb_device

  cloudify.relationships.vsphere.serial_connected_to_server:
    derived_from: cloudify.relationships.contained_in
    source_interfaces:
      cloudify.interfaces.relationship_lifecycle:
        establish:
          implementation: vsphere.cloudify_vsphere.devices.attach_serial_port
        unlink:
          implementation: vsphere.cloudify_vsphere.devices.detach_serial_port

  cloudify.relationships.vsphere.pci_connected_to_server:
    derived_from: cloudify.relationships.contained_in
    source_interfaces:
      cloudify.interfaces.relationship_lifecycle:
        establish:
          implementation: vsphere.cloudify_vsphere.devices.attach_pci_device
        unlink:
          implementation: vsphere.cloudify_vsphere.devices.detach_pci_device
