Using Custom Scripts Stored in the Software Library

This section describes how to use the custom scripts available in the Software Library to customize your deployment procedure. In particular, this section covers the following:

Using Custom Scripts with Input Parameters

To use the custom scripts as a part of the Provision Fusion Middleware procedure, you must ensure that you have stored these scripts on the Software Library as a directive.

To store custom scripts with input parameters on the Software Library, follow these steps:

  1. In Cloud Control, from Enterprise menu, select Provisioning and Patching, then click Software Library.
  2. Create a folder called Directive.
  3. On the Software Library page, from the Actions menu, select Create Entity, then click Directives.
  4. On the Describe page, provide a unique name for the parent folder. For example, My Custom Script With Parameters. Click Next.
  5. On the Configure page, in the Command Line Arguments section, click Add.
  6. In the Add Command Line Argument dialog box, enter the property name INPUT_FILE, then click OK. Verify that the Command Line contains the value: "${INPUT_FILE}"
  7. On the Select Files page, select Upload Files. In the Specify Destination section, select an upload location. In the Specify Source section, select the scripts to be uploaded. Ensure the directly executable file is in the Main File menu.

    For example, myscript.pl is the main executable file, and listMyServers.py is another file that is uploaded. Following are example scripts that you can refer:

    Contents of the Perl script: myscript.pl

    #!/usr/local/bin/perl
     
    print "**********************\n";
    print "*     This is a      *\n";
    print "*    test script     *\n";
    print "**********************\n";
     
    my $inputFile = $ARGV[0];
    my %properties;
    open (FILE, "<$inputFile") or die "can't open $inputFile for reading: $!";
    print "Input properties:\n";
    while (<FILE>)
    {
      chomp;
      my ($key, $val) = split /=/;
      $properties{$key} = $val;
      print "\t$key=$val\n";
    }
    close FILE;
     
    my $mwHome = $properties{MIDDLEWARE_HOME};
    my $protocol = $properties{ADMIN_PROTOCOL};
    my $host =$properties{ADMIN_SERVER_LISTEN_ADDRESS};
    my $port = $properties{ADMIN_SERVER_LISTEN_PORT};
    my $cmd = $mwHome."/wlserver_10.3/common/bin/wlst.sh listMyServers.py $protocol $host $port";
     
    print "\nExecuting:\n\t$cmd\n";
    print "\nOutput is:\n\n";
     
    system($cmd);
     
    exit 0;
    

    Contents of the Python script: listMyServers.py

    #!/usr/bin/python
     
    protocol = sys.argv[1];
    host = sys.argv[2];
    port = sys.argv[3];
    username = 'weblogic';
    password = 'XXXXXXXX';
     
    connectUrl = protocol + '://' + host + ':' + port;
     
    connect(username, password, connectUrl);
    cd('/Servers');
    ls();
    disconnect();
    exit();
    

    Click Next.

  8. On the Review page, review the details, and click Save and Upload.

Using Custom Scripts Without Inputs Parameters

To use the custom scripts as a part of the Provision Fusion Middleware procedure, you must ensure that you have stored these scripts on the Software Library as a directive.

To store custom scripts without input parameters on the Software Library, follow these steps:

  1. In Cloud Control, from Enterprise menu, select Provisioning and Patching, then click Software Library.
  2. Create a folder called Directive.
  3. On the Software Library page, from the Actions menu, select Create Entity, then click Directives.
  4. On the Describe page, provide a unique name for the parent folder. For example, My Custom Script Without Parameters. Click Next.
  5. On the Configure page, in the Command Line Arguments section, click Next.
  6. On the Select Files page, select Upload Files. In the Specify Destination section, select an upload location. In the Specify Source section, select the scripts to be uploaded. Ensure the directly executable file is in the Main File menu.

    For example, myscript1.pl is the main executable file, and listMyServers.py is another file that is uploaded. Following are example scripts that you can refer:

    Contents of the Perl script: myscript1.pl

    #!/usr/local/bin/perl
     
    print "**********************\n";
    print "*     This is a      *\n";
    print "*    test script     *\n";
    print "**********************\n";
     
    my $mwHome = "/scratch/bbanthia/soa/middleware";
    my $protocol = "t3";
    my $host = "slc01mpj.us.example.com";
    my $port = "7001";
    my $cmd = $mwHome."/wlserver_10.3/common/bin/wlst.sh listMyServers.py $protocol $host $port";
     
    print "Executing:\n\t$cmd\n";
    print "\nOutput is:\n\n";
     
    system($cmd);
     
    exit 0;
    

    Contents of the Python script: listMyServers.py

    #!/usr/bin/python
     
    protocol = sys.argv[1];
    host = sys.argv[2];
    port = sys.argv[3];
    username = 'weblogic';
    password = 'XXXXXXXX';
     
    connectUrl = protocol + '://' + host + ':' + port;
     
    connect(username, password, connectUrl);
    cd('/Servers');
    ls();
    disconnect();
    exit();
    

    Click Next.

  7. On the Review page, review the details, and click Save and Upload.