Python cookbook: adding a UNIX host
This topic describes the process of adding a UNIX host using the delphixpy Python API.
Within Delphix, there are both hosts and host environments. A host represents a remote system, but may or may not be a source or target for linking or provisioning. For example, in an Oracle RAC cluster, the cluster environment represents the location of the Oracle installation(s), and while there are hosts within that cluster they are not individually manageable as environments.
Procedure
Create new environment creation parameters and initialize the structure for a UNIX host.
ActionScript
CODEfrom delphixpy.web.vo import HostEnvironmentCreateParameters, UnixHostEnvironment, UnixHostCreateParameters, UnixHost, EnvironmentUser, PasswordCredentialhost_environment_create_parameters_vo = HostEnvironmentCreateParameters()host_environment_create_parameters_vo.host_environment = UnixHostEnvironment()host_environment_create_parameters_vo.host_parameters = UnixHostCreateParameters()host_environment_create_parameters_vo.host_parameters.host = UnixHost()host_environment_create_parameters_vo.primary_user = EnvironmentUser()host_environment_create_parameters_vo.primary_user.credential = PasswordCredential()
Set the host address and port. The name of the environment is derived from the address used, though you can provide a more descriptive name if desired. The address can be a DNS names, IP addresses, or a comma separated list of the above.
ActionScript
CODEhost_environment_create_parameters_vo.host_parameters.host.addresses = ["192.168.1.2"]host_environment_create_parameters_vo.host_parameters.host.port = 22
Set the toolkit path. This is where Delphix will store temporary binaries used while the host is configured as part of Delphix.
ActionScript
CODEhost_environment_create_parameters_vo.host_parameters.host.toolkit_path = "/var/delphix"
Set the username and password to use when connecting over SSH. This user must have the privileges described in the Delphix Administration Guide. To configure a SSH user, change the credential object to
SystemKeyCredential
.ActionScript
CODEhost_environment_create_parameters_vo.primary_user.name = "oracle"host_environment_create_parameters_vo.primary_user.credential.password = "my secret password"
Commit the result. A reference to your new environment will be returned from the create call. The environment discovery process will execute as an asynchronous job. The default behavior is to wait for the result, so progress will be updated until the discovery process is complete or fails.
ActionScript
CODEfrom delphixpy.delphix_server import DelphixServerfrom delphixpy.web import environmentserver = DelphixServer("delphix-address", "delphix-user", "delphix-password", "DOMAIN")new_environment_reference = environment.create(server, host_environment_create_parameters_vo)
Full example
ActionScript
CODEfrom delphixpy.delphix_server import DelphixServerfrom delphixpy.web import environmentfrom delphixpy.web.vo import HostEnvironmentCreateParameters, UnixHostEnvironment, UnixHostCreateParameters, UnixHost, EnvironmentUser, PasswordCredentialhost_environment_create_parameters_vo = HostEnvironmentCreateParameters()host_environment_create_parameters_vo.host_environment = UnixHostEnvironment()host_environment_create_parameters_vo.host_parameters = UnixHostCreateParameters()host_environment_create_parameters_vo.host_parameters.host = UnixHost()host_environment_create_parameters_vo.primary_user = EnvironmentUser()host_environment_create_parameters_vo.primary_user.credential = PasswordCredential()host_environment_create_parameters_vo.host_parameters.host.addresses = ["192.168.1.2"]host_environment_create_parameters_vo.host_parameters.host.port = 22host_environment_create_parameters_vo.host_parameters.host.toolkit_path = "/var/delphix"host_environment_create_parameters_vo.primary_user.name = "oracle"host_environment_create_parameters_vo.primary_user.credential.password = "my secret password"server = DelphixServer("delphix-address", "delphix-user", "delphix-password", "DOMAIN")new_environment_reference = environment.create(server, host_environment_create_parameters_vo)