APIPythonOpen-Source Solutions

  • 1.  Provisioning a VDB via the API and adding a post script to it

    Posted 09-29-2016 10:26:00 AM
    Hi
    Is it possible to provision a DB via the API
    /resources/json/delphix/database/provision
    and also set up the new VDB to have a post script automatically?

    What I'm trying to do is get all developer created VDBs to be done via the API and each one automatically has a post script that runs against their newly created DB.  I don't want this to be optional to the devs, all the VDBs must run this script on creation/refresh.
    We have created a powershell module which provisions the VDBs via the API and I'm not sure if we can add post script at provision time.

    Our code is something like this 

    private dynamic ProvisionDatabase()        {
                var targetEnvironment = new Environment(this.Session).GetEnvironment(this.TargetServerName);
                var targetRepository = new Repository(this.Session).GetRepository(targetEnvironment.reference.Value);
                var snapshot = new Snapshot(this.Session);

                this.Log.Info(targetRepository.reference.Value);

                dynamic json = new ExpandoObject();
                json.type = "MSSqlProvisionParameters";

                json.container = new ExpandoObject();
                json.container.type = "MSSqlDatabaseContainer";
                json.container.name = this.TargetVirtualSourceName;
                json.container.group = this.TargetGroup;

                json.source = new ExpandoObject();
                json.source.type = "MSSqlVirtualSource";

                json.sourceConfig = new ExpandoObject();
                json.sourceConfig.type = "MSSqlSIConfig";
                json.sourceConfig.repository = targetRepository.reference.Value;
                json.sourceConfig.databaseName = this.TargetPhysicalDatabaseName;
                json.sourceConfig.instance = new ExpandoObject();
                json.sourceConfig.instance.type = "MSSqlInstanceConfig";
                json.sourceConfig.instance.host = targetEnvironment.host;

                json.timeflowPointParameters = new ExpandoObject();
                json.timeflowPointParameters.type = "TimeflowPointSemantic";
                json.timeflowPointParameters.container = this.DatabaseResult.reference.Value;
                json.timeflowPointParameters.location = "LATEST_SNAPSHOT";
                

                var result = this.DoPost(json, "/resources/json/delphix/database/provision");
                this.Log.Debug(result);
                return result;
            }


  • 2.  RE: Provisioning a VDB via the API and adding a post script to it
    Best Answer

    Posted 09-29-2016 10:36:00 AM
    Hi Mark,

    Yep, the hooks are defined in the MSSqlVirtualSource object (as type String), such as:

    json.source.postScript

    described in the API docs under <SERVER>/api/#MSSqlVirtualSource

    Hope that helps,

    Regards,

    Scott.


  • 3.  RE: Provisioning a VDB via the API and adding a post script to it

    Posted 09-29-2016 10:46:00 AM
    ah thanks Scott...much appreciated