DataMuseum.dk

Presents historical artifacts from the history of:

Rational R1000/400 Tapes

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about Rational R1000/400 Tapes

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - download
Index: ┃ B D L R T V

⟦a1ef997d1⟧ R1K_ARCHIVE_DATA, TextFile

    Length: 21800 (0x5528)
    Types: R1K_ARCHIVE_DATA, TextFile
    Names: »DATA«

Derivation

└─⟦8ee07855d⟧ Bits:30000545 8mm tape, Rational 1000, DTIA 2_1_6
    └─ ⟦0c25cb74a⟧ »DATA« 
        └─⟦this⟧ 

TextFile

with Debug_Tools;
with Directory_Tools;
with File_Utilities;
with Log;
with Profile;
with Remote_Operations;
with Simple_Status;
procedure Verify_Installation (On_Host  : String;
                               Username : String := "root";
                               Password : String;
                               Response : String := "~---,<VERBOSE>") is

    package Dtn renames Directory_Tools.Naming;
    package Fu  renames File_Utilities;
    package Ro  renames Remote_Operations;
    package Ss  renames Simple_Status;

    procedure Error (Message  : String;
                     Kind     : Profile.Msg_Kind         := Profile.Error_Msg;
                     Response : Profile.Response_Profile := Profile.Get)
        renames Log.Put_Line;
    procedure Note (Message  : String;
                    Kind     : Profile.Msg_Kind         := Profile.Note_Msg;
                    Response : Profile.Response_Profile := Profile.Get)
        renames Log.Put_Line;
    procedure Positive (Message  : String;
                        Kind     : Profile.Msg_Kind := Profile.Positive_Msg;
                        Response : Profile.Response_Profile := Profile.Get)
        renames Log.Put_Line;

    Original_Response : constant Profile.Response_Profile := Profile.Get;

    Context : Ro.Context;
    Status  : Ro.Error_Status;

    Default_Context  : constant Ro.Rational_Pathname :=
       Dtn.Full_Name (Dtn.Default_Context & '$');
    Remote_Test_Area : constant Ro.Remote_Pathname   :=  
       "/tmp/Dtia_Test_Area";

    Local_Object                : constant Ro.Rational_Pathname :=
       Default_Context & ".VERIFY_INSTALLATION'BODY";
    Local_Copy_Of_Remote_Object : constant Ro.Rational_Pathname :=
       Default_Context & ".LOCAL_COPY_OF_REMOTE_OBJECT";

    Remote_Object : constant Ro.Remote_Pathname :=
       Remote_Test_Area & "/install";

    Copied_Object_Simple_Name : constant Ro.Remote_Pathname := "install.copied";

    Copied_Object : constant Ro.Remote_Pathname :=
       Remote_Test_Area & '/' & Copied_Object_Simple_Name;

    Moved_Object : constant Ro.Remote_Pathname :=
       Remote_Test_Area & "/install.moved";

    Remote_Command : constant String := "/bin/ls " & Remote_Test_Area;

    procedure Check (Status : Ro.Error_Status) is
    begin
        if Ss.Error (Status) then
            Log.Put_Condition (Status);
            raise Profile.Error;
        end if;
    end Check;

    procedure Acquire_Connection is
    begin
        Note ("Acquiring connection to host """ &
              On_Host & """ as user """ & Username & '"');
        Ro.Acquire (A_Context => Context,
                    Status    => Status,
                    Machine   => On_Host,
                    User      => Username,
                    Password  => Password,
                    Session   => "");
        Check (Status);
    end Acquire_Connection;

    procedure Create_Test_Area is
        Test_Area_Exists : Boolean;
    begin
        Note ("Checking for test area existence on remote machine");
        Ro.File_Exists (The_File   => Remote_Test_Area,
                        In_Context => Context,
                        Status     => Status,
                        Exists     => Test_Area_Exists);
        Check (Status);
        if Test_Area_Exists then
            Note ("Destroying old test area");
            Ro.Delete_Directory (In_Context => Context,
                                 With_Name  => Remote_Test_Area,
                                 Status     => Status,
                                 Recursive  => True);
            Check (Status);
        end if;
        Note ("Creating new test area " & Remote_Test_Area);
        Ro.Create_Directory (In_Context => Context,  
                             With_Name  => Remote_Test_Area,
                             Status     => Status);
        Check (Status);
    end Create_Test_Area;

    procedure File_Transfer is
    begin
        Note ("Storing " & Local_Object & " into " & Remote_Object);
        Ro.Put (From_File  => Local_Object,
                To_File    => Remote_Object,
                In_Context => Context,
                Status     => Status);
        Check (Status);
        Note ("Retrieving " & Remote_Object &
              " into " & Local_Copy_Of_Remote_Object);
        Ro.Get (From_File  => Remote_Object,
                In_Context => Context,
                To_File    => Local_Copy_Of_Remote_Object,
                Status     => Status);
        Check (Status);
        if Fu.Equal (Local_Object, Local_Copy_Of_Remote_Object) then
            Positive ("File transfer was successful");
        else
            Error ("Errors were detected during file transfer");
            raise Profile.Error;
        end if;
    end File_Transfer;

    procedure Remote_Copy is
        Copied_Object_Exists : Boolean;
    begin
        Note ("Copying " & Remote_Object & " to " & Copied_Object);
        Ro.Copy (From_File  => Remote_Object,
                 To_File    => Copied_Object,
                 In_Context => Context,
                 Status     => Status);
        Check (Status);
        Ro.File_Exists (The_File   => Copied_Object,
                        In_Context => Context,
                        Status     => Status,
                        Exists     => Copied_Object_Exists);
        Check (Status);
        if Copied_Object_Exists then
            Positive ("Remote copy succeeded");
        else
            Error ("Remote copy failed");
            raise Profile.Error;
        end if;
    end Remote_Copy;

    procedure Remote_Move is
        Moved_Object_Exists : Boolean;
    begin
        Note ("Moving " & Remote_Object & " to " & Moved_Object);
        Ro.Move (From_File  => Remote_Object,
                 To_File    => Moved_Object,
                 In_Context => Context,
                 Status     => Status);
        Check (Status);
        Ro.File_Exists (The_File   => Moved_Object,
                        In_Context => Context,
                        Status     => Status,
                        Exists     => Moved_Object_Exists);
        Check (Status);
        if Moved_Object_Exists then
            Positive ("Remote move succeeded");
        else
            Error ("Remote move failed");
            raise Profile.Error;
        end if;
    end Remote_Move;

    procedure Remote_Delete is
        Deleted_Object_Exists : Boolean;
    begin
        Note ("Deleting " & Moved_Object);
        Ro.Delete_File (In_Context => Context,
                        With_Name  => Moved_Object,
                        Status     => Status);
        Check (Status);
        Ro.File_Exists (The_File   => Moved_Object,
                        In_Context => Context,
                        Status     => Status,
                        Exists     => Deleted_Object_Exists);
        Check (Status);
        if Deleted_Object_Exists then
            Error ("Remote delete failed");
            raise Profile.Error;
        else
            Positive ("Remote delete succeeded");
        end if;
    end Remote_Delete;

    procedure Remote_Execution is
        Command_Was_Successful : Boolean := False;
        procedure Process_Output (Text     :        String;
                                  Severity :        Profile.Msg_Kind;
                                  State    : in out Boolean;
                                  Response : in out Ro.Command_Response) is
        begin
            Note ("Verifying command output");
            State := Text = Copied_Object_Simple_Name & Ascii.Lf;
            if not State then
                Error ("Unexpected command output {" &
                       Text & "} during command execution");
            end if;
        end Process_Output;
        procedure Read_Input (State    : in out Boolean;
                              Buffer   : out    String;
                              Last     : out    Natural;
                              Response : in out Ro.Command_Response) is
        begin
            State    := False;
            Buffer   := (others => Ascii.Nul);
            Last     := 0;
            Response := Ro.Abort_Command;
            Error ("Unexpected attempt to read input during command execution");
        end Read_Input;
        procedure Timeout_Handler (State    : in out Boolean;
                                   Response : in out Ro.Command_Response) is
        begin
            State    := False;
            Response := Ro.Abort_Command;
            Error ("Unexpected timeout during command execution");
        end Timeout_Handler;
        procedure Perform_Execution is
           new Ro.Execution_Generic (Execution_State => Boolean,
                                     Process_Output  => Process_Output,
                                     Read_Input      => Read_Input,
                                     Timeout_Handler => Timeout_Handler);
    begin
        Note ("Executing " & Remote_Command);
        Perform_Execution (Command    => Remote_Command,
                           In_Context => Context,
                           State      => Command_Was_Successful,
                           Status     => Status);
        Check (Status);
        if Command_Was_Successful then
            Positive ("Remote command execution succeeded");
        else
            Error ("Remote command execution failed");
            raise Profile.Error;
        end if;
    end Remote_Execution;

    procedure Remote_Cleanup is
    begin
        Note ("Deleting directory " & Remote_Test_Area);
        Ro.Delete_Directory (In_Context => Context,
                             With_Name  => Remote_Test_Area,
                             Status     => Status,
                             Recursive  => True);
        Check (Status);
    end Remote_Cleanup;

    procedure Destroy_Connection is
    begin
        Ro.Destroy (A_Context => Context, Status => Status);
        Check (Status);
    end Destroy_Connection;

begin

    Profile.Set (Profile.Value (Response));

    Acquire_Connection;
    Create_Test_Area;
    File_Transfer;
    Remote_Copy;
    Remote_Move;
    Remote_Delete;
    Remote_Execution;
    Remote_Cleanup;
    Destroy_Connection;

    Positive ("Verify_Installation has completed successfully");
    Profile.Set (Original_Response);

exception
    when Profile.Error =>
        Error ("Verify_Installation has failed with errors");
        Profile.Set (Original_Response);

    when others =>
        Log.Put_Line ("Verify_Installation failed with" &
                      " an unhandled exception " &
                      Debug_Tools.Get_Exception_Name, Profile.Exception_Msg);
        Error ("Verify_Installation has failed with errors");
        Profile.Set (Original_Response);
end Verify_Installation;procedure Verify_Installation (On_Host  : String;
                               Username : String := "root";
                               Password : String;
                               Response : String := "~---,<VERBOSE>");with Debug_Tools;
with Directory_Tools;
with File_Utilities;
with Log;
with Profile;
with Remote_Operations;
with Simple_Status;
procedure Verify_Installation (On_Host  : String;
                               Username : String := "root";
                               Password : String;
                               Response : String := "~---,<VERBOSE>") is

    package Dtn renames Directory_Tools.Naming;
    package Fu  renames File_Utilities;
    package Ro  renames Remote_Operations;
    package Ss  renames Simple_Status;

    procedure Error (Message  : String;
                     Kind     : Profile.Msg_Kind         := Profile.Error_Msg;
                     Response : Profile.Response_Profile := Profile.Get)
        renames Log.Put_Line;
    procedure Note (Message  : String;
                    Kind     : Profile.Msg_Kind         := Profile.Note_Msg;
                    Response : Profile.Response_Profile := Profile.Get)
        renames Log.Put_Line;
    procedure Positive (Message  : String;
                        Kind     : Profile.Msg_Kind := Profile.Positive_Msg;
                        Response : Profile.Response_Profile := Profile.Get)
        renames Log.Put_Line;

    Original_Response : constant Profile.Response_Profile := Profile.Get;

    Context : Ro.Context;
    Status  : Ro.Error_Status;

    Default_Context  : constant Ro.Rational_Pathname :=
       Dtn.Full_Name (Dtn.Default_Context & '$');
    Remote_Test_Area : constant Ro.Remote_Pathname   :=  
       "/tmp/Dtia_Test_Area";

    Local_Object                : constant Ro.Rational_Pathname :=
       Default_Context & ".VERIFY_INSTALLATION'BODY";
    Local_Copy_Of_Remote_Object : constant Ro.Rational_Pathname :=
       Default_Context & ".LOCAL_COPY_OF_REMOTE_OBJECT";

    Remote_Object : constant Ro.Remote_Pathname :=
       Remote_Test_Area & "/install";

    Copied_Object_Simple_Name : constant Ro.Remote_Pathname := "install.copied";

    Copied_Object : constant Ro.Remote_Pathname :=
       Remote_Test_Area & '/' & Copied_Object_Simple_Name;

    Moved_Object : constant Ro.Remote_Pathname :=
       Remote_Test_Area & "/install.moved";

    Remote_Command : constant String := "/bin/ls " & Remote_Test_Area;

    procedure Check (Status : Ro.Error_Status) is
    begin
        if Ss.Error (Status) then
            Log.Put_Condition (Status);
            raise Profile.Error;
        end if;
    end Check;

    procedure Acquire_Connection is
    begin
        Note ("Acquiring connection to host """ &
              On_Host & """ as user """ & Username & '"');
        Ro.Acquire (A_Context => Context,
                    Status    => Status,
                    Machine   => On_Host,
                    User      => Username,
                    Password  => Password,
                    Session   => "");
        Check (Status);
    end Acquire_Connection;

    procedure Create_Test_Area is
        Test_Area_Exists : Boolean;
    begin
        Note ("Checking for test area existence on remote machine");
        Ro.File_Exists (The_File   => Remote_Test_Area,
                        In_Context => Context,
                        Status     => Status,
                        Exists     => Test_Area_Exists);
        Check (Status);
        if Test_Area_Exists then
            Note ("Destroying old test area");
            Ro.Delete_Directory (In_Context => Context,
                                 With_Name  => Remote_Test_Area,
                                 Status     => Status,
                                 Recursive  => True);
            Check (Status);
        end if;
        Note ("Creating new test area " & Remote_Test_Area);
        Ro.Create_Directory (In_Context => Context,  
                             With_Name  => Remote_Test_Area,
                             Status     => Status);
        Check (Status);
    end Create_Test_Area;

    procedure File_Transfer is
    begin
        Note ("Storing " & Local_Object & " into " & Remote_Object);
        Ro.Put (From_File  => Local_Object,
                To_File    => Remote_Object,
                In_Context => Context,
                Status     => Status);
        Check (Status);
        Note ("Retrieving " & Remote_Object &
              " into " & Local_Copy_Of_Remote_Object);
        Ro.Get (From_File  => Remote_Object,
                In_Context => Context,
                To_File    => Local_Copy_Of_Remote_Object,
                Status     => Status);
        Check (Status);
        if Fu.Equal (Local_Object, Local_Copy_Of_Remote_Object) then
            Positive ("File transfer was successful");
        else
            Error ("Errors were detected during file transfer");
            raise Profile.Error;
        end if;
    end File_Transfer;

    procedure Remote_Copy is
        Copied_Object_Exists : Boolean;
    begin
        Note ("Copying " & Remote_Object & " to " & Copied_Object);
        Ro.Copy (From_File  => Remote_Object,
                 To_File    => Copied_Object,
                 In_Context => Context,
                 Status     => Status);
        Check (Status);
        Ro.File_Exists (The_File   => Copied_Object,
                        In_Context => Context,
                        Status     => Status,
                        Exists     => Copied_Object_Exists);
        Check (Status);
        if Copied_Object_Exists then
            Positive ("Remote copy succeeded");
        else
            Error ("Remote copy failed");
            raise Profile.Error;
        end if;
    end Remote_Copy;

    procedure Remote_Move is
        Moved_Object_Exists : Boolean;
    begin
        Note ("Moving " & Remote_Object & " to " & Moved_Object);
        Ro.Move (From_File  => Remote_Object,
                 To_File    => Moved_Object,
                 In_Context => Context,
                 Status     => Status);
        Check (Status);
        Ro.File_Exists (The_File   => Moved_Object,
                        In_Context => Context,
                        Status     => Status,
                        Exists     => Moved_Object_Exists);
        Check (Status);
        if Moved_Object_Exists then
            Positive ("Remote move succeeded");
        else
            Error ("Remote move failed");
            raise Profile.Error;
        end if;
    end Remote_Move;

    procedure Remote_Delete is
        Deleted_Object_Exists : Boolean;
    begin
        Note ("Deleting " & Moved_Object);
        Ro.Delete_File (In_Context => Context,
                        With_Name  => Moved_Object,
                        Status     => Status);
        Check (Status);
        Ro.File_Exists (The_File   => Moved_Object,
                        In_Context => Context,
                        Status     => Status,
                        Exists     => Deleted_Object_Exists);
        Check (Status);
        if Deleted_Object_Exists then
            Error ("Remote delete failed");
            raise Profile.Error;
        else
            Positive ("Remote delete succeeded");
        end if;
    end Remote_Delete;

    procedure Remote_Execution is
        Command_Was_Successful : Boolean := False;
        procedure Process_Output (Text     :        String;
                                  Severity :        Profile.Msg_Kind;
                                  State    : in out Boolean;
                                  Response : in out Ro.Command_Response) is
        begin
            Note ("Verifying command output");
            State := Text = Copied_Object_Simple_Name & Ascii.Lf;
            if not State then
                Error ("Unexpected command output {" &
                       Text & "} during command execution");
            end if;
        end Process_Output;
        procedure Read_Input (State    : in out Boolean;
                              Buffer   : out    String;
                              Last     : out    Natural;
                              Response : in out Ro.Command_Response) is
        begin
            State    := False;
            Buffer   := (others => Ascii.Nul);
            Last     := 0;
            Response := Ro.Abort_Command;
            Error ("Unexpected attempt to read input during command execution");
        end Read_Input;
        procedure Timeout_Handler (State    : in out Boolean;
                                   Response : in out Ro.Command_Response) is
        begin
            State    := False;
            Response := Ro.Abort_Command;
            Error ("Unexpected timeout during command execution");
        end Timeout_Handler;
        procedure Perform_Execution is
           new Ro.Execution_Generic (Execution_State => Boolean,
                                     Process_Output  => Process_Output,
                                     Read_Input      => Read_Input,
                                     Timeout_Handler => Timeout_Handler);
    begin
        Note ("Executing " & Remote_Command);
        Perform_Execution (Command    => Remote_Command,
                           In_Context => Context,
                           State      => Command_Was_Successful,
                           Status     => Status);
        Check (Status);
        if Command_Was_Successful then
            Positive ("Remote command execution succeeded");
        else
            Error ("Remote command execution failed");
            raise Profile.Error;
        end if;
    end Remote_Execution;

    procedure Remote_Cleanup is
    begin
        Note ("Deleting directory " & Remote_Test_Area);
        Ro.Delete_Directory (In_Context => Context,
                             With_Name  => Remote_Test_Area,
                             Status     => Status,
                             Recursive  => True);
        Check (Status);
    end Remote_Cleanup;

    procedure Destroy_Connection is
    begin
        Ro.Destroy (A_Context => Context, Status => Status);
        Check (Status);
    end Destroy_Connection;

begin

    Profile.Set (Profile.Value (Response));

    Acquire_Connection;
    Create_Test_Area;
    File_Transfer;
    Remote_Copy;
    Remote_Move;
    Remote_Delete;
    Remote_Execution;
    Remote_Cleanup;
    Destroy_Connection;

    Positive ("Verify_Installation has completed successfully");
    Profile.Set (Original_Response);

exception
    when Profile.Error =>
        Error ("Verify_Installation has failed with errors");
        Profile.Set (Original_Response);

    when others =>
        Log.Put_Line ("Verify_Installation failed with" &
                      " an unhandled exception " &
                      Debug_Tools.Get_Exception_Name, Profile.Exception_Msg);
        Error ("Verify_Installation has failed with errors");
        Profile.Set (Original_Response);
end Verify_Installation;

ARCHIVE PAIR

INDEX: ⟦562bba6d9⟧ R1K_ARCHIVE_INDEX
DATA:  ⟦a1ef997d1⟧ R1K_ARCHIVE_DATA, TextFile

OctetView

0x0000…2a21 ⟦b8a484556⟧
0x2a21…2b07 ⟦d24965b85⟧
0x2b07…5528 ⟦b8a484556⟧