Gandi Wiki


Questions

Host methods

host_list

Signature

array host_list(string session, string domain)

Description

Returns the array of glue records for the specified domain.

Parameters

  • string session: the session id (returned by login)
  • string domain: the domain to retrieve the glue records

Returns

The XML-RPC response will contain an array of hosts (string) or a fault describing the problem. Possible faults are described in section Error Codes Format.

Sample code

  • Sample code (python)
import pprint
try:
    hosts  = proxy.host_list(session, "example.org")
    print "hosts:"
    pprint.pprint(hosts)
except xmlrpclib.Fault, e:
    print "could not retrieve the list of host because: %s" % e.faultString
  • Sample code (php)
$domain = new xmlrpcval("example,org");
$msg  = new xmlrpcmsg("host_list", array($session, $domain));
$reply  = $proxy->send($msg);
if ($reply->faultCode()) {
    printf("could not retrieve the list of hosts because: %s\n", $reply->faultString());
}
else {
    $val  = php_xmlrpc_decode($reply->value());
    print_r($val);
}
  • Sample code (perl)
my $reply  = $proxy->call("host_list", $session, "example.org");
my $hosts  = $reply->result();
unless (defined $hosts) {
    print "could not retrieve the list of hosts because: " . $reply->faultstring . "\n";
}
else {
    print Dumper($hosts);
}



host_info

Signature

array host_info(string session, string fqdn)

Description

Retrieve the IP addresses linked to this hostname.

Parameters

  • string session: the session id (returned by login)
  • string fqdn: the FQDN of the hostname.

Returns

The XML-RPC response will contain the IP addresses (array) associated with the specified hostname or a fault describing the problem. Possible faults are described in section Error Codes Format.

Sample code

  • Sample code (python)
import pprint
host  = "host.example.net"
 
try:
    info  = proxy.host_info(session, host)
    pprint.pprint(info)
except xmlrpclib.Fault, e:
    print "could not get information for hostname '%s': %s" % (host, e.faultString)
  • Sample code (php)
$host  = "host.example.net";
$msg  = new xmlrpcmsg("host_info", array($session, new xmlrpcval($host)));
$reply  = $proxy->send($msg);
if ($reply->faultCode()) {
    printf("could not get information for hostname '%s' because: %s\n", $host, $reply->faultString());
}
else {
    $val  = php_xmlrpc_decode($reply->value());
    print_r($val);
}
  • Sample code (perl)
my $host  = "host.example.net";
my $reply  = $proxy->call("host_info", $session, $host);
my $info  = $reply->result();
unless (defined $opid) {
    printf "could not get information for hostname '%s' because: %s\n", $host, $reply->faultstring;
}
else {
    print Dumper($info);
}



host_create

Signature

int host_create(string session, string host, array ip)

Description

Create a glue record with the specified IP addresses.

Limitations

Only the first IP of the array is used.

Parameters

  • string session: the session id (returned by login)
  • string host: the glue record to create
  • array ip: the IP addresses (string) of this glue record.

Returns

The XML-RPC response will contain this operation attributed ID (int) or a fault describing the problem. Possible faults are described in section Error Codes Format.

Sample code

  • Sample code (python)
host  = "ns1.example.org"
ip_list  = ["1.2.3.4", "1.2.3.5"]
 
try:
    opid  = proxy.host_create(session, host, ip_list)
    print "creation of host '%s' is Gandi operation #%d" % (host, opid)
except xmlrpclib.Fault, e:
    print "could not create host '%s' because: %s" % (host, e.faultString)
  • Sample code (php)
$host  = "ns1.example.org";
$ip_list  = php_xmlrpc_encode(array("1.2.3.4", "1.2.3.5"));
$msg  = new xmlrpcmsg("host_create", array($session, new xmlrpcval($host),
    $ip_list));
$reply  = $proxy->send($msg);
if ($reply->faultCode()) {
    printf("could not create host '%s' because: %s\n", $host, $reply->faultString());
}
else {
    $val  = $reply->value();
    $val  = $val->scalarval();
    printf("creation of host '%s' is Gandi operation #%d\n", $host, $val);
}
  • Sample code (perl)
my $host  = "ns1.example.org";
my $ip_list  = ["1.2.3.4", "1.2.3.5"]
 
my $reply  = $proxy->call("host_create", $session, $host, $ip_list);
 
my $opid  = $reply->result();
unless (defined $opid) {
    printf "could not create host '%s' because: %s\n", $host, $reply->faultstring;
}
else {
    printf "creation of host '%s' is Gandi operation #%d\n", $host, $opid;
}



host_delete

Signature

int host_delete(string session, string host)

Description

Delete a host.

Parameters

  • string session: the session id (returned by login)
  • string host: the host to delete

Returns

The XML-RPC response will contain this operation attributed ID (int) or a fault describing the problem. Possible faults are described in section Error Codes Format.

Sample code

  • Sample code (python)
host  = "ns1.example.com"
try:
    opid  = proxy.host_delete(session, host)
    print "deletion of '%s' is Gandi operation #%d" % (host, opid)
except xmlrpclib.Fault, e:
    print "could not delete host '%s' because: %s" % (host, e.faultString)
  • Sample code (php)
$host  = "example.com";
$msg  = new xmlrpcmsg("host_delete", array($session, new xmlrpcval($host)));
$reply  = $proxy->send($msg);
if ($reply->faultCode()) {
    printf("could not delete host '%s' because: %s\n", $host, $reply->faultString());
}
else {
    $val  = $reply->value();
    $val  = $val->scalarval();
    printf("deletion of host '%s' is Gandi operation #%d\n", $host, $val);
}
  • Sample code (perl)
my $host  = "example.com";
my $reply  = $proxy->call("host_delete", $session, $host);
my $opid  = $reply->result();
unless (defined $opid) {
    printf "could not delete host '%s' because: %s\n", $host, $reply->faultstring;
}
else {
    printf "deletion of host '%s' is Gandi operation #%d\n", $host, $opid;
}



Questions

Flux RSS des questions correspondant à ce filtre (Aide)

Dernière modification: le 17/02/2009 à 13:15 par Pierrick P. (Gandi)