diff options
author | mxiong <mxiong@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2005-08-01 02:27:27 +0000 |
---|---|---|
committer | mxiong <mxiong@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2005-08-01 02:27:27 +0000 |
commit | 04ed124c002bd48c56a5bb37e5417c8568937123 (patch) | |
tree | 8a028816479bde648375040ba49cc338c517b082 | |
parent | 10bed77c01a2baa581c58bb5cd3618c0bfc7a1d1 (diff) | |
download | ATCD-04ed124c002bd48c56a5bb37e5417c8568937123.tar.gz |
ChangeLogTag: Sun Jul 31 21:26:43 2005 Ming Xiong <mxiong@dre.vanderbilt.edu>
-rw-r--r-- | TAO/CIAO/DAnCE/new_RepositoryManager/RMadmin.cpp | 280 |
1 files changed, 130 insertions, 150 deletions
diff --git a/TAO/CIAO/DAnCE/new_RepositoryManager/RMadmin.cpp b/TAO/CIAO/DAnCE/new_RepositoryManager/RMadmin.cpp index 696bcb42e6d..70fe157fe7e 100644 --- a/TAO/CIAO/DAnCE/new_RepositoryManager/RMadmin.cpp +++ b/TAO/CIAO/DAnCE/new_RepositoryManager/RMadmin.cpp @@ -1,38 +1,33 @@ // $Id$ -/** - * #file RMadmin.cpp - * - * @author Stoyan Paunov <spaunov@isis.vanderbilt.edu> - **/ - -#include "new_RepositoryManagerC.h" +#include "RepositoryManagerC.h" #include "Options.h" -#include "ace/OS_NS_fcntl.h" //for open -#include "ace/OS_NS_unistd.h" //for close -#include "ace/OS_NS_sys_stat.h" //for filesize and fstat and mkdir +//#include "Config_Handlers/pcd.hpp" //for the PackageConfiguration data struct +#include "ace/OS_NS_fcntl.h" //for open +#include "ace/OS_NS_unistd.h" //for close +#include "ace/OS_NS_sys_stat.h" //for filesize and fstat and mkdir #include "Config_Handlers/DnC_Dump.h" #include <iostream> using namespace std; -//IOR file of the Sender +//IOR file of the RM const char * ior = "file://RepositoryManagerDeamon.ior"; ///=============================COUPLE OF HELPER METHORS================================== CORBA::Octet* read_from_disk ( - const char* full_path, - size_t &length - ); + const char* full_path, + size_t &length + ); int write_to_disk ( - const char* full_path, - const CORBA::Octet* buffer, - size_t length - ); + const char* full_path, + const CORBA::Octet* buffer, + size_t length + ); ///======================================================================================== @@ -43,8 +38,8 @@ int ACE_TMAIN (int argc, ACE_TCHAR *argv[]) ACE_TRY_NEW_ENV { // Initialize orb - CORBA::ORB_var orb = CORBA::ORB_init (argc, argv, - ""ACE_ENV_ARG_PARAMETER); + CORBA::ORB_var orb = CORBA::ORB_init (argc, argv, + ""ACE_ENV_ARG_PARAMETER); ACE_TRY_CHECK; @@ -54,94 +49,79 @@ int ACE_TMAIN (int argc, ACE_TCHAR *argv[]) ACE_ENV_ARG_PARAMETER); ACE_TRY_CHECK; - CIAO::new_RepositoryManagerDaemon_var rm = - CIAO::new_RepositoryManagerDaemon::_narrow (obj.in () - ACE_ENV_ARG_PARAMETER); + CIAO::RepositoryManagerDaemon_var rm = + CIAO::RepositoryManagerDaemon::_narrow (obj.in () + ACE_ENV_ARG_PARAMETER); ACE_TRY_CHECK; if (CORBA::is_nil (rm.in ())) { - ACE_ERROR_RETURN ((LM_ERROR, - "Unable to acquire new_RepositoryManagerDaemon's objref\n"), + ACE_ERROR_RETURN ((LM_ERROR, + "Unable to acquire RepositoryManagerDaemon's objref\n"), -1); } - Options* options = Options::instance (); - options->parse_args (argc, argv); - - if (options->shutdown_) - { - rm->shutdown (); - } - else if (options->install_) - { - size_t length = 0; - CORBA::Octet* buffer = read_from_disk (options->local_path_.c_str (), length); - - Deployment::Package* the_package = new Deployment::Package ( - length, //max of the sequence - length, //length of the sequence - buffer, //data to be stored within the sequence - true //take ownership of the data - ); - - try - { - rm->installPackage (options->package_.c_str (), *the_package, false); - } - catch (CORBA::Exception &) - { - cout << "\nPackage is already in the repository!\n"; - } - - cout << "\nReassuring that the package in the repository ..." << endl; - try - { - Deployment::Package_var package_back = rm->findPackageByName (options->package_.c_str ()); - cout << "The package was found!" << endl; - cout << "Its size is " << package_back->length () << endl; - } - catch (CORBA::Exception &) - { - cout << "\nNo such package!" << endl; - } - } - else if (options->delete_) - { - try - { - rm->deletePackage (options->package_.c_str ()); - cout << options->package_.c_str () << " deleted" << endl; - } - catch (CORBA::Exception &) - { - cout << "\nNo such package!" << endl; - } - - } - else if (options->plan_) - { - - Deployment::DeploymentPlan_var plan = rm->retrievePlan (options->package_.c_str ()); - - Deployment::DnC_Dump::dump (plan); - } - else if (options->artifact_ != "") - { - try - { - Deployment::Implementation_var impl = rm->findImplementationByName (options->artifact_.c_str (), - options->package_.c_str()); - write_to_disk (impl->name, impl->the_implementation.get_buffer (),impl->the_implementation.length ()); - } - catch (CORBA::Exception &) - { - cout << "\nNo such implementation artifact in that package!" << endl; - } - - } - + Options* options = Options::instance (); + options->parse_args (argc, argv); + + if (options->shutdown_) + { + rm->shutdown (); + } + else if (options->install_) + { + try + { + rm->installPackage (options->name_.c_str (), options->path_.c_str ()); + } + catch (CORBA::Exception &ex) + { + cout << "\nPackage is already in the repository!\n"; + return 0; + } + + cout << "\nReassuring that the package in the repository ..." << endl; + try + { + Deployment::PackageConfiguration_var pc = rm->findPackageByName (options->name_.c_str ()); + cout << "The package was found!" << endl; + cout << "Label: " << pc->label << endl; + cout << "UUID: " << pc->UUID << endl; + } + catch (CORBA::Exception &ex) + { + cout << "\nError! Package not found!" << endl; + } + } + else if (options->delete_) + { + try + { + rm->deletePackage (options->name_.c_str ()); + cout << options->name_.c_str () << " deleted" << endl; + } + catch (CORBA::Exception &ex) + { + cout << "\nNo such package!" << endl; + } + + } + else if (options->find_) + { + if (options->name_ != "") + { + Deployment::PackageConfiguration_var pc = rm->findPackageByName (options->name_.c_str ()); + cout << "The package was found!" << endl; + Deployment::DnC_Dump::dump (pc); + } + else + { + Deployment::PackageConfiguration_var pc = rm->findPackageByUUID (options->uuid_.c_str ()); + cout << "The package was found!" << endl; + Deployment::DnC_Dump::dump (pc); + } + } orb->destroy (ACE_ENV_SINGLE_ARG_PARAMETER); ACE_TRY_CHECK; @@ -149,7 +129,7 @@ int ACE_TMAIN (int argc, ACE_TCHAR *argv[]) ACE_CATCHANY { ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, - "Unknown exception \n"); + "Unknown exception \n"); return -1; } ACE_ENDTRY; @@ -160,68 +140,68 @@ int ACE_TMAIN (int argc, ACE_TCHAR *argv[]) CORBA::Octet* read_from_disk ( - const char* full_path, - size_t &length - ) + const char* full_path, + size_t &length + ) { - //open the file + //open the file - ACE_HANDLE handle = ACE_OS::open (full_path, O_RDONLY); - if (handle == ACE_INVALID_HANDLE) - ACE_ERROR_RETURN ((LM_ERROR, - ACE_TEXT ("%p\n"), - ACE_TEXT ("[RM::read_from_disk] file open error")), - 0); + ACE_HANDLE handle = ACE_OS::open (full_path, O_RDONLY); + if (handle == ACE_INVALID_HANDLE) + ACE_ERROR_RETURN ((LM_ERROR, + ACE_TEXT ("%p\n"), + ACE_TEXT ("[RM::read_from_disk] file open error")), + 0); - ACE_stat file_info; + ACE_stat file_info; - ACE_OS::fstat (handle, &file_info); + ACE_OS::fstat (handle, &file_info); - CORBA::Octet* buffer = new CORBA::Octet[file_info.st_size]; + CORBA::Octet* buffer = new CORBA::Octet[file_info.st_size]; - if (buffer == 0) - return 0; + if (buffer == 0) + return 0; - //read the contents of the file into the buffer - if (ACE_OS::read_n (handle, buffer, file_info.st_size) == -1) - ACE_ERROR_RETURN ((LM_ERROR, - ACE_TEXT ("%p\n"), - ACE_TEXT ("[RM::write_to_disk] file write error")), - 0); + //read the contents of the file into the buffer + if (ACE_OS::read_n (handle, buffer, file_info.st_size) == -1) + ACE_ERROR_RETURN ((LM_ERROR, + ACE_TEXT ("%p\n"), + ACE_TEXT ("[RM::write_to_disk] file write error")), + 0); - // Close the file handle - ACE_OS::close (handle); + // Close the file handle + ACE_OS::close (handle); - length = file_info.st_size; - return buffer; + length = file_info.st_size; + return buffer; } int write_to_disk ( - const char* full_path, - const CORBA::Octet* buffer, - size_t length - ) + const char* full_path, + const CORBA::Octet* buffer, + size_t length + ) { - - // Open a file handle to the local filesystem - ACE_HANDLE handle = ACE_OS::open (full_path, O_CREAT | O_TRUNC | O_WRONLY); - if (handle == ACE_INVALID_HANDLE) - ACE_ERROR_RETURN ((LM_ERROR, - ACE_TEXT ("%p\n"), - ACE_TEXT ("[RM::write_to_disk] file creation error")), - -1); - - //write the data to the file - if (ACE_OS::write (handle, buffer, length) == -1) - ACE_ERROR_RETURN ((LM_ERROR, - ACE_TEXT ("%p\n"), - ACE_TEXT ("[RM::write_to_disk] file write error")), - -1); - - // Close the file handle - ACE_OS::close (handle); - - return 1; + + // Open a file handle to the local filesystem + ACE_HANDLE handle = ACE_OS::open (full_path, O_CREAT | O_TRUNC | O_WRONLY); + if (handle == ACE_INVALID_HANDLE) + ACE_ERROR_RETURN ((LM_ERROR, + ACE_TEXT ("%p\n"), + ACE_TEXT ("[RM::write_to_disk] file creation error")), + -1); + + //write the data to the file + if (ACE_OS::write (handle, buffer, length) == -1) + ACE_ERROR_RETURN ((LM_ERROR, + ACE_TEXT ("%p\n"), + ACE_TEXT ("[RM::write_to_disk] file write error")), + -1); + + // Close the file handle + ACE_OS::close (handle); + + return 1; } |