Changeset 39926 for trunk/Nebulous-Server/bin/neb-cabadd
- Timestamp:
- Jan 6, 2017, 11:30:10 AM (10 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
Nebulous-Server/bin/neb-cabadd (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk
-
Property svn:mergeinfo
set to
/branches/czw_branch/20160809 merged eligible
-
Property svn:mergeinfo
set to
-
trunk/Nebulous-Server/bin/neb-cabadd
r26292 r39926 19 19 use Pod::Usage qw( pod2usage ); 20 20 21 my ($db, $dbhost, $dbuser, $dbpass, $cname, $location );21 my ($db, $dbhost, $dbuser, $dbpass, $cname, $location, $site_id, $update, $cab_id); 22 22 23 23 $db = $ENV{'NEB_DB'} unless $db; … … 33 33 'cname|n=s' => \$cname, 34 34 'location|l=s' => \$location, 35 'site_id|s=s' => \$site_id, 36 'cab_id=s' => \$cab_id, 37 'update|u' => \$update, 35 38 ) || pod2usage( 2 ); 36 39 37 40 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV; 38 pod2usage( -msg => "Required options: --db --user --pass --cname ", -exitval => 2 )39 unless $db && $dbuser && $dbpass && $cname ;41 pod2usage( -msg => "Required options: --db --user --pass --cname --site_id", -exitval => 2 ) 42 unless $db && $dbuser && $dbpass && $cname && $site_id; 40 43 41 44 my $dbh = DBI->connect( … … 52 55 my $sql = Nebulous::Server::SQL->new(); 53 56 54 print "Adding cabinet..."; 55 56 my $query = $dbh->prepare( $sql->new_cabinet ); 57 $query->execute( $cname, $location); 58 59 print " OK\n"; 60 57 if (defined($update)) { 58 unless ($cname && $location && $site_id && $cab_id) { 59 pod2usage( -msg => "Required options for update: --db --user --pass --cname --site_id --location --cab_id", -exitval => 2 ); 60 } 61 print "Updating cabinet..."; 62 my $query = $dbh->prepare( $sql->update_cabinet ); 63 # Check query: 64 # UPDATE cabinet SET 65 # location = ?, 66 # name = ?, 67 # site_id = ? 68 # WHERE cab_id = ? 69 70 $query->execute( $location, $cname, $site_id, $cab_id ); 71 72 print "OK\n"; 73 74 } 75 else { 76 print "Adding cabinet..."; 77 78 my $query = $dbh->prepare( $sql->new_cabinet ); 79 $query->execute( $cname, $location, $site_id); 80 81 print " OK\n"; 82 } 61 83 __END__ 62 84 … … 69 91 =head1 SYNOPSIS 70 92 71 neb-cabadd --cname <cabinet name> --location <cabinet location> 93 neb-cabadd --cname <cabinet name> --location <cabinet location> --site_id <site_id> 72 94 [--db <database>] [--user <username>] [--pass <password>] [--host <hostname] 73 95 … … 89 111 90 112 Description of the location of the cabinet. 113 114 =item * --site_id <site_id> 115 116 Numerical value of the location's site. Default = 0. 91 117 92 118 =item * --db|-d <database>
Note:
See TracChangeset
for help on using the changeset viewer.
