APIPythonOpen-Source Solutions

 View Only
Expand all | Collapse all

Add SQL server (windows) source and target through delphixpy or delphix API

  • 1.  Add SQL server (windows) source and target through delphixpy or delphix API

    Posted 09-25-2016 03:08:00 PM
    Hey,

    Is there a way to configure the SQL target and source servers on the Delphix engine through delphixpy or delphix API?

    Thanks
    #DemoEnvironment
    #Masking


  • 2.  RE: Add SQL server (windows) source and target through delphixpy or delphix API
    Best Answer

    Posted 09-25-2016 11:46:00 PM
    Absolutely! But first, you need at least one Windows machine with the Delphix Connector installed. https://docs.delphix.com/display/DOCS50/Adding+a+SQL+Server+Standalone+Target+Environment

    Next, run the addhostcmd on the Windows machine that will add the Windows machine as a staging server to Delphix.

    If you have additional Windows environments to add, you can add the Windows environments to the Delphix engine via that API, specifying the Windows Staging server above as you Staging Server/Connector Environment.

    I'll will dig out a working example I have tomorrow when I go into my office. 


  • 3.  RE: Add SQL server (windows) source and target through delphixpy or delphix API

    Posted 09-26-2016 07:46:00 AM
    Hey Adam,
    Thanks for your reply. 

    I have one SQL server machine which will be served as the staging (lets call it T1) , and another target machine which will serve as proxy and target machine (lets call it T2).  
    Another SQL server machine is the source (lets call it S).

    I configure S and T1 manually and I need to configure T2 into the Delphix engine automatically using the delphixpy. I need this machine to handle the end user DB which will be provisioned from VDB which is created in T1. I'm not sure which module is the one that handles configuration of second target machine which will handle the end user DB provisioned from the VDB on staging. 

    BTW , if T2 provisioned data from VDB in T1 , I still need to install delphix connector on T2?

    Thanks!
    Luiza


  • 4.  RE: Add SQL server (windows) source and target through delphixpy or delphix API

    Posted 09-26-2016 11:49:00 AM
    Ok, great! I love scenarios! I have a lot to catch up on this morning, since it is Monday. I will try to build out a mockup of your scenario and post back here today. 


  • 5.  RE: Add SQL server (windows) source and target through delphixpy or delphix API

    Posted 09-27-2016 11:44:00 AM
    Thank you..


  • 6.  RE: Add SQL server (windows) source and target through delphixpy or delphix API

    Posted 09-27-2016 11:45:00 AM
    Just as an update. I am spinning up my Windows stuff this morning, as we speak. I will mix this in with my other work and try my best to have something to share by the end of today. 


  • 7.  RE: Add SQL server (windows) source and target through delphixpy or delphix API

    Posted 09-27-2016 12:05:00 PM
    I hate leaving you hanging, so in the interim; the way I do it for our internal automation is I install the connector on all of our Windows images. I then use winrm or python to execute the addhostcmd to add the server to the the Delphix engine. If you are looking for something for a lab, then this will do for you. If you are looking for something like a production-style roll out, then I hope to have an example of that for you later today.







  • 8.  RE: Add SQL server (windows) source and target through delphixpy or delphix API

    Posted 09-27-2016 02:24:00 PM
    Thanks. Yes I need something for production. 
    I also can't find documentation about the dlphixpy to see which objects and modules I can use there. 




  • 9.  RE: Add SQL server (windows) source and target through delphixpy or delphix API

    Posted 09-27-2016 02:36:00 PM
    The delphixpy module leverages all the objects in the API. You can see the full object model of the API on your Delphix Engine:  http://<ENGINE IP>/api. You can use this document to convert from API/CLI to python: https://docs.delphix.com/display/DOCS50/CLI+to+Python+Transition

    Actually, I have a helpful blog with video on how to easily map what you do in the GUI to the python bindings here: 
    https://www.delphix.com/blog/data-virtualization/delphixpy-delphix-python-module-part-2">https://www.delphix.com/blog/data-virtualization/delphixpy-delphix-python-module-part-2">https://www.delphix.com/blog/data-virtualization/delphixpy-delphix-python-module-part-2


  • 10.  RE: Add SQL server (windows) source and target through delphixpy or delphix API

    Posted 09-30-2016 05:54:00 PM
    Luiza, here is the api transaction log of me adding a windows source to my DE via the CLI. I talk about how to generate this type of information in https://www.delphix.com/blog/data-virtualization/delphixpy-delphix-python-module-part-2 , as this is how I use it all the time. In the below information, "proxy" is the host reference id of the "Connector Environment" you see in the GUI.

    === POST /resources/json/delphix/environment ===

    {

        "type": "HostEnvironmentCreateParameters",

        "primaryUser": {

            "type": "EnvironmentUser",

            "name": "delphix\\delphix_admin",

            "credential": {

                "type": "PasswordCredential",

                "password": "delphix"

            }

        },

        "hostEnvironment": {

            "type": "WindowsHostEnvironment",

            "name": "WINDOWSSOURCE",

            "proxy": "WINDOWS_HOST-6"

        },

        "hostParameters": {

            "type": "WindowsHostCreateParameters",

            "host": {

                "type": "WindowsHost",

                "address": "WINDOWSSOURCE"

            }

        }

    }

    I then converted that to python that looks like this:
    Begin Code
    +++++
    #!/usr/bin/env python
    #Adam Bowen Sept 2016
    VERSION="v.0.0.001"
    #just a quick and dirty example of adding a windows source

    from delphixpy.delphix_engine import DelphixEngine
    from delphixpy.web import environment
    from delphixpy.web.vo import HostEnvironmentCreateParameters, EnvironmentUser, PasswordCredential, \
    WindowsHostEnvironment, WindowsHostCreateParameters, WindowsHost

    engine_address = "192.168.2.37"
    engine_username = "delphix_admin"
    engine_password = "landshark"

    def serversess(f_engine_address, f_engine_username, f_engine_password):
        """
        Function to setup the session with the Delphix Engine
        """
        server_session= DelphixEngine(f_engine_address, f_engine_username, f_engine_password, "DOMAIN")
        return server_session

    server = serversess(engine_address, engine_username, engine_password)

    envCreateParams = HostEnvironmentCreateParameters()


    envCreateParams.primary_user = EnvironmentUser()
    envCreateParams.primary_user.name = "delphix\delphix_admin"
    envCreateParams.primary_user.credential = PasswordCredential()
    envCreateParams.primary_user.credential.password = "delphix"
    envCreateParams.host_environment = WindowsHostEnvironment()
    envCreateParams.host_environment.name = "WINDOWSSOURCE"
    envCreateParams.host_environment.proxy = "WINDOWS_HOST-6" #This is the Host ID of the Windows Server that houses the connector
    envCreateParams.host_parameters = WindowsHostCreateParameters()
    envCreateParams.host_parameters.host = WindowsHost()
    envCreateParams.host_parameters.host.address = "WINDOWSSOURCE"

    environment.create(server, envCreateParams)
    +++++++++++
    End code



  • 11.  RE: Add SQL server (windows) source and target through delphixpy or delphix API

    Posted 10-05-2016 09:17:00 AM
    thanks!


  • 12.  RE: Add SQL server (windows) source and target through delphixpy or delphix API

    Posted 10-05-2016 11:39:00 AM
    No problem. Glad I could help. Sorry it took so long!