6. YaPI::DHCPD

This package is the public YaST2 API to configure the ISC DHCP server

6.1. List of Global Functions

6.2. Functions

6.2.1. $status StopDhcpService ($config);

Immediatelly stops the DHCP service. Returns nonzero if operation succeeded, zero if operation failed.

Example 78. 

  my $status = StopDhcpService ({});
  if ($status == 0)
  {
    print "Stopping DHCP server failed";
  }
  else
  {
    print "Stopping DHCP server succeeded";
  }

6.2.2. $status StartDhcpService ($config);

Immediatelly starts the DHCP service. Returns nonzero if operation succeeded, zero if operation failed.

Example 79. 

  my $status = StartDhcpService ({});
  if ($status == 0)
  {
    print "Starting DHCP server failed";
  }
  else
  {
    print "Starting DHCP server succeeded";
  }

6.2.3. $status GetDhcpServiceStatus ($config);

Check if DHCP service is running. Returns nonzero if service is running, zero otherwise.

Example 80. 

  my $status = GetDhcpServiceStatus ({});
  if ($status == 0)
  {
    print "DHCP server is not running";
  }
  else
  {
    print "DHCP server is running";
  }

6.2.4. $ret = AddDeclaration ($config, $type, $id, $parent_type, $parent_id);

Add a new empty DHCP declaration. $type is one of subnet, host, group, pool, shared-network. $id is identification of the declaration (eg. host name for the host, $address netmask $netmask for subnet declaration. $parent_type and $parent_id specify the declaration within that the new declaration shall be created.

Example 81. 

  my $type = "host";
  my $id = "client";
  my $ret = AddDeclaration ({}, $type, $id, "", "");
  

6.2.5. $ret = DeleteDeclaration ($config, $type, $id);

Deletes specified declaration including its whole subtree.

Example 82. 

  my $type = "host";
  my $id = "client";
  my $ret = DeleteDeclaration ({}, $type, $id);

6.2.6. $parent = GetDeclarationParent ($config, $type, $id);

Returns the parent of specified declaration. It is returned as a hash with keys "type" and "id".

Example 83. 

  my $type = "host";
  my $id = "client";
  my $parent = GetDeclarationParent ({}, $type, $id);
  if (! defined ($parent))
  {
    print "Specified declaration not found"
  }
  else
  {
    my $par_type =  $parent->{"type"};
    my $par_id = $parent->{"id"};
    print "Parent type: $par_type";
    print "Parent id: $par_id;
  }

6.2.7. $ret = SetDeclarationParent ($config, $type, $id, $new_parent_type, $new_parent_id);

Sets specified parent to the specified declaration (moves it in the tree). The declaration is moved with its complete subtree.

Example 84. 

  my $type = "host";
  my $id = "client";
  my $ret = SetDeclarationParent ({}, $type, $id, "", "");

6.2.8. $children = GetChildrenOfDeclaration ($config, $type, $id);

Get all children of a declaration.

Example 85. 

  my $children = GetChildrenOfDeclaration ({}, "subnet", "192.168.0.0 netmask 255.255.255.0");
  if (! defined ($children))
  {
    print "Specified declaration not found";
  }
  else
  {
    foreach my $child (@{$children}) {
      my $type = $child->{"type"};
      my $id = $child->{"id"};
      print "Have child $type $id";
    }
  }

6.2.9. $options = GetDeclarationOptions ($config, $type, $id);

Get all options of the specified declaration.

Example 86. 

  my $options = GetDeclarationOptions ({}, "subnet", "192.168.0.0 netmask 255.255.255.0");
  if (! defined ($options))
  {
    print "Specified declaration not found";
  }
  else
  {
    foreach my $option (@{$options}) {
      my $key = $option->{"key"};
      my $value = $option->{"value"};
      print "Have option $key with value $value";
    }
  }

6.2.10. $ret = SetDeclarationOptions ({}, $config, $type, $id, $options);

Sets all options of specified declaration. The options argument has the same structure as return value of the GetDeclarationOptions function.

Example 87. 

  my $options = [
    {
      "key" => "domain-name-servers",
      "value" => "ns1.internal.example.org ns2.internal.example.org",
    },
    {
      "key" => "domain-name",
      "value" => "\"internal.example.org\"",
    },
  ]
  $success = SetDeclarationOptions ("host", "client", $options);

6.2.11. $directives = GetDeclarationDirectives ($config, $type, $id);

Get all directives of the specified declaration.

Example 88. 

  my $directives = GetDeclarationDirectives ({}, "subnet", "192.168.0.0 netmask 255.255.255.0");
  if (! defined ($directives))
  {
    print "Specified declaration not found";
  }
  else
  {
    foreach my $directive (@{$directives}) {
      my $key = $option->{"key"};
      my $value = $option->{"value"};
      print "Have directive $key with value $value";
    }
  }

6.2.12. $ret = SetDeclarationDirectives ($config, $type, $id, $directives);

Sets all directives of specified declaration. The directives argument has the same structure as return value of the GetDeclarationDirectives function.

Example 89. 

  my $directives = [
    {
      "key" => "default-lease-time",
      "value" => "600",
    },
    {
      "key" => "max-lease-time",
      "value" => "7200",
    },
  ]
  $success = SetDeclarationDirectives ({}, "host", "client", $directives);

6.2.13. $exists = ExistsDeclaration ($config, $type, $id);

Checks if specified declaration exists.

Example 90. 

  my $exists = ExistsDeclaration ({}, "host", "client");
  if ($exists)
  {
    print "Host found";
  }
  else
  {
    print "Host not found";
  }