Software Development Kit (SDK) and API Discussions

OCUM API

lil_baby_james
4,965 Views

Im trying to use the Manageability SDK to make a simple call to OCUM 7.1 to get the names of clusters, but I can't seem to figure out how. When I put num-records in the get_string method, it says I have 2 which accurately reflects the number of clusters. How do I pull something simple like the name?

 

 

 

s = NaServer(filer, 7, 1)
s.set_server_type("OCUM")
s.set_admin_user(user, password)
s.set_transport_type("HTTPS")
output = s.invoke("cluster-iter")

 

if(output.results_errno() != 0):
     r = output.results_reason()
     print("Failed: \n" + str(r))

 

else :
     r = output.child_get_string("records")
     print (r)

1 ACCEPTED SOLUTION

lil_baby_james
4,910 Views

Answered my own question while playing with it some more. Had to go further down the tree with children_get() and child_get() methods.

 

def getClusters(self):
  returnValue = []
  iterator = self.interface.invoke("cluster-iter")
  if(iterator.results_errno() != 0):
   message = iterator.results_reason()
   print("Failed: \n" + str(message))
  else :
   clusters = iterator.child_get("records").children_get()
   for i in clusters:
    returnValue.append(i.child_get_string("cluster-name"))
  return returnValue

View solution in original post

4 REPLIES 4

lil_baby_james
4,911 Views

Answered my own question while playing with it some more. Had to go further down the tree with children_get() and child_get() methods.

 

def getClusters(self):
  returnValue = []
  iterator = self.interface.invoke("cluster-iter")
  if(iterator.results_errno() != 0):
   message = iterator.results_reason()
   print("Failed: \n" + str(message))
  else :
   clusters = iterator.child_get("records").children_get()
   for i in clusters:
    returnValue.append(i.child_get_string("cluster-name"))
  return returnValue

2006FatBoy
4,792 Views

I have a similar problem, except using the Perl SDK rather than PS and invoking the DLL directly.  Whenver I try to connect to OCUM 7.2 OVA using the code below, I get a the very  helpful generic error shown.  If I use PowerShell and the DataManagement.dll, works fine.  But I'd really rather use Perl for this particular application so I'm trying to figure out what's up here.  I'm not having much luck so any insight would be greatly appreciated.

 

#!/usr/bin/perl

use strict;
use NaServer;
use Data::Dumper;
#use WFAUtil;

BEGIN {$ENV{PERL_LWP_SSL_VERIFY_HOSTNAME} = 0;}

my $TRUE = 1;
my $FALSE = 0;

my $IS_DATASOURCE = $TRUE;

my $ocum_handle;

my $ocum_host = '10.0.0.118';
my $ocum_user = 'admin';
my $ocum_pw = '********';

$ocum_handle = new NaServer($ocum_host,1,0);
$ocum_handle->set_server_type('OCUM');
$ocum_handle->set_transport_type('HTTPS');
$ocum_handle->set_port(443);
$ocum_handle->set_style('LOGIN');
$ocum_handle->set_admin_user($ocum_user, $ocum_pw);

my $result;

eval {
$result = $ocum_handle->system_about();

};

print $@ if $@;

 

Server returned HTTP Error:   (13001)

yaron
4,784 Views

While I don't know the answer to your specific question, I can show you another way of getting that information using Perl.

 

For this solution to work, make sure that:

1. You install the DBD package (DBI package for managing MySQL)

2. You create a database user on the OCUM server with "Report Schema" role

 

Hopefully this code works for you as well.

 

use REST::Client;
use JSON;
use MIME::Base64;
use DBI;

$ENV{PERL_LWP_SSL_VERIFY_HOSTNAME}=0;
 
my $ocum_username = 'dbadmin';
my $ocum_password = 'Netapp1!';
my $ocum_server = 'ocum.demo.netapp.com';
 
# Extract Cluster names from OCUM database
my $sql_query = "SELECT
                                cluster.name AS 'Cluster'
                             FROM
                                cluster";
my $dsn = "DBI:mysql:ocum_report:" . $ocum_server;
my %attr = ( PrintError=>0, # turn off error reporting via warn()
                    RaiseError=>1 # report error via die()
                   );
my $dbh = DBI->connect($dsn,$ocum_username,$ocum_password,\%attr);
my $sth = $dbh->prepare($sql_query);
$sth->execute();
while(my @row = $sth->fetchrow_array()){
      my $cluster_name = $row[0];
}
$sth->finish();
$dbh->disconnect();

2006FatBoy
4,777 Views

I had considered that but was really trying to stay away from going directly to the database.  I may reconsider that method but I  had hoped to use the normal Perl SDK functions which are so much nicer, but it looks like at this point I can't do that no matter which option I pick.

Public