Infoblox::DHCP::OptionSpace - DHCP OptionSpace object.


NAME

Infoblox::DHCP::OptionSpace - DHCP OptionSpace object.


DESCRIPTION

An Option Space defines a namespace in which vendor options can be defined. To define a specific vendor option space, add an option space to DHCP.


CONSTRUCTOR

 my $option_space = Infoblox::DHCP::OptionSpace->new(
       name             => $string,                            #Required
       comment          => $string,                            #Optional, default is undefined
 );


SESSION METHODS

This section describes all the methods in Infoblox::Session module that can be applied to a DHCP OptionSpace object.

Infoblox::Session->add( )

Use this method to add a DHCP OptionSpace object to the Infoblox appliance. See Infoblox::Session->add() for parameters and return values.

Example
 #Construct a DHCP OptionSpace object
 my $option_space = Infoblox::DHCP::OptionSpace->new(
       name => "infospace",
       comment => "some comment"
 );
 #Submit for addition
 my $response = $session->add($option_space)

Infoblox::Session->get( )

Use this method to retrieve all the matching objects from the Infoblox appliance. See Infoblox::Session->get() for parameters and return values.

Key References
 Apply the following attributes to get a specific DHCP OptionSpace object:
  name     - Required. Option space name in string format.
  comment  - Optional. Option space comment.
Example
 #Get DHCP OptionSpace object through the session
 my @retrieved_objs = $session->get(
     object => "Infoblox::DHCP::OptionSpace",
     name   => "infospace",
 );

Infoblox::Session->modify( )

Use this method to modify a DHCP OptionSpace object in the Infoblox appliance. See Infoblox::Session->modify() for parameters and return values.

Example
 #Use method to modify the name.
 $option_space->name("info_space");
 #Submit modification
 my $response = $session->modify( $option_space );

Infoblox::Session->remove( )

Use this method to remove a DHCP OptionSpace object from the Infoblox appliance. See Infoblox::Session->remove() for parameters and return values.

To remove a specific object, first use get() to retrieve the specific DHCP OptionSpace object, and then submit this object for removal.

Example
 #Get DHCP OptionSpace object through the session
 my @retrieved_objs = $session->get(
     object => "Infoblox::DHCP::OptionSpace",
     name   => "info_space",
 );
 #Find the desired object from the retrieved list.
 my $desired_option_space = $retrieved_objs[0];
 #Submit for removal
 my $response = $session->remove( $desired_option_space );

Infoblox::Session->search( )

Use this method to retrieve all the matching objects from the Infoblox appliance. See Infoblox::Session->search() for parameters and return values.

Key References
 Apply the following attributes to get a specific DHCP OptionSpace object:
  name     - Optional. Option space name in string format (regular expression).
  comment  - Optional. Option space comment (regular expression).
Example
 #Get DHCP OptionSpace object through the session
 my @retrieved_objs = $session->search(
     object => "Infoblox::DHCP::OptionSpace",
     comment => ".*comm.*"
 );


METHODS

This section describes all the methods that can used to set and retrieve the attribute values of a DHCP OptionSpace object.

name( )

Use this method to set or retrieve name of option space object.

Include the specified parameter to set the attribute value. Omit the parameter to retrieve the attribute value.

Parameter

Desired name in string format with a maximum of 256 bytes.

Returns

If parameter is specified, the method returns true when the modification succeeds, and returns false when the operation fails.

If parameter is not specified, the method returns the attribute value.

Example
 #Get name
 my $name = $option_space->name();
 #Modify name
 $option_space->name("info_space");

comment( )

Use this method to set or retrieve a comment about the option space object.

Include the specified parameter to set the attribute value. Omit the parameter to retrieve the attribute value.

Parameter

Desired comment in string format with a maximum of 256 bytes.

Returns

If the parameter is specified, the method returns true when the modification succeeds, and returns false when the operation fails.

If the parameter is not specified, the method returns the attribute value.

Example
 #Get comment
 my $comment = $option_space->comment();
 #Modify comment
 $option_space->comment("my comment");

space_type

Use this method to retrieve the type of this option space.

Parameter

None.

Returns

The method returns the attribute value, which can be either 'predefined_dhcp' or 'vendor_space'.

Example
 #Get space_type
 my $space_type = $option_space->space_type();


SAMPLE CODE

The following sample code demonstrates the different functions that can be applied to an OptionSpace object, such as get, add, modify and remove. In addition, the sample includes error handling for the operations.

#Preparation prior to a DHCP OptionSpace object insertion

 #PROGRAM STARTS: Include all the modules that will be used
 use strict;
 use Infoblox;
 #Create a session to the Infoblox appliance
 my $session = Infoblox::Session->new(
                master   => "192.168.1.2", #appliance host ip
                username => "admin",       #appliance user login
                password => "infoblox"     #appliance password
 );
 unless ($session) {
        die("Construct session failed: ",
                Infoblox::status_code() . ":" . Infoblox::status_detail());
 }
 print "Session created successfully\n";

#Create an OptionSpace object

 my $option_space = Infoblox::DHCP::OptionSpace->new (
        "name" => "infospace"
 );
 unless($option_space) {
      die("Construct option_space filter failed: ",
            Infoblox::status_code() . ":" . Infoblox::status_detail());
 }
 print "OptionSpace object created successfully\n";
 #Verify if the DHCP OptionSpace exists in the Infoblox appliance
 my $object = $session->get(
        object => "Infoblox::DHCP::OptionSpace",
        name   => "infospace"
 );
 unless ($object) {
    print "option space does not exist on server, safe to add the option_space\n";
    $session->add($option_space)
       or die("Add option space failed: ",
              $session->status_code() . ":" . $session->status_detail());
 }
 print "DHCP OptionSpace added successfully\n";

#Get and Modify an OptionSpace object

 #Get OptionSpace object through the session
 my @retrieved_objs = $session->get(
     object => "Infoblox::DHCP::OptionSpace",
     name   => "infospace"
 );
 my $object = $retrieved_objs[0];
 unless ($object) {
     die("Get OptionSpace object failed: ",
         $session->status_code() . ":" . $session->status_detail());
 }
 print "Get OptionSpace object found at least 1 matching entry\n";
 #Modify name of the obtained OptionSpace object
 $object->name("info_space");
 #Apply the changes
 $session->modify($object)
     or die("Modify OptionSpace object failed: ",
            $session->status_code() . ":" . $session->status_detail());
 print "OptionSpace object modified successfully \n";

#Remove an OptionSpace object

 #Get OptionSpace object through the session
 my @retrieved_objs = $session->get(
     object => "Infoblox::DHCP::OptionSpace",
     name   => "info_space"
 );
 my $object = $retrieved_objs[0];
 unless ($object) {
     die("Get OptionSpace object failed: ",
         $session->status_code() . ":" . $session->status_detail());
 }
 print "Get OptionSpace object found at least 1 matching entry\n";
 #Submit the object for removal
 $session->remove($object)
     or die("Remove OptionSpace object failed: ",
         $session->status_code() . ":" . $session->status_detail());
 print "OptionSpace object removed successfully \n";
 ####PROGRAM ENDS####


AUTHOR

Infoblox Inc. http://www.infoblox.com/


SEE ALSO

Infoblox::DHCP::OptionDefinition,Infoblox::Session->get(), Infoblox::Session->modify(), Infoblox::Session->remove(), Infoblox::Session


COPYRIGHT

Copyright (c) 2017 Infoblox Inc.