Author: fapeeler
Date: Wed Mar 28 18:12:26 2012
New Revision: 1306520
URL: http://svn.apache.org/viewvc?rev=1306520&view=rev
Log:
VCL-463
updated to handle changes in server reservations:
- starts with state servermodified
- add/remove users based on changes in the VCL user group through manage groups
Modified:
incubator/vcl/trunk/managementnode/bin/vcld
incubator/vcl/trunk/managementnode/lib/VCL/DataStructure.pm
incubator/vcl/trunk/managementnode/lib/VCL/Module/OS.pm
incubator/vcl/trunk/managementnode/lib/VCL/Module/OS/Linux.pm
incubator/vcl/trunk/managementnode/lib/VCL/inuse.pm
incubator/vcl/trunk/managementnode/lib/VCL/utils.pm
Modified: incubator/vcl/trunk/managementnode/bin/vcld
URL:
http://svn.apache.org/viewvc/incubator/vcl/trunk/managementnode/bin/vcld?rev=1306520&r1=1306519&r2=1306520&view=diff
==============================================================================
--- incubator/vcl/trunk/managementnode/bin/vcld (original)
+++ incubator/vcl/trunk/managementnode/bin/vcld Wed Mar 28 18:12:26 2012
@@ -206,7 +206,7 @@ sub main () {
$ENV{database_select_calls} = {};
# Make sure the request state is valid
- if ($request_state_name !~
/inuse|reserved|deleted|timeout|reclaim|reload|new|tomaintenance|image|imageprep|makeproduction|imageinuse|complete|failed|pending|maintenance|tovmhostinuse|rebootsoft|reboothard|reinstall/)
{
+ if ($request_state_name !~
/inuse|reserved|deleted|timeout|reclaim|reload|new|tomaintenance|image|imageprep|makeproduction|imageinuse|complete|failed|pending|maintenance|tovmhostinuse|rebootsoft|reboothard|reinstall|servermodified/)
{
notify($ERRORS{'WARNING'}, $LOGFILE, "assigned
request in unsupported state: $request_state_name");
next REQUEST;
}
@@ -501,7 +501,7 @@ sub make_new_child {
}
# The imageinuse state is now handled by inuse.pm
- if ($state =~ /^(imageinuse|rebootsoft|reboothard)$/) {
+ if ($state =~ /^(imageinuse|rebootsoft|reboothard|servermodified)$/) {
notify($ERRORS{'DEBUG'}, $LOGFILE, "request will be processed
by inuse.pm");
$state_module = "VCL::inuse";
}
Modified: incubator/vcl/trunk/managementnode/lib/VCL/DataStructure.pm
URL:
http://svn.apache.org/viewvc/incubator/vcl/trunk/managementnode/lib/VCL/DataStructure.pm?rev=1306520&r1=1306519&r2=1306520&view=diff
==============================================================================
--- incubator/vcl/trunk/managementnode/lib/VCL/DataStructure.pm (original)
+++ incubator/vcl/trunk/managementnode/lib/VCL/DataStructure.pm Wed Mar 28
18:12:26 2012
@@ -397,7 +397,7 @@ $SUBROUTINE_MAPPINGS{server_request_fixe
$SUBROUTINE_MAPPINGS{server_request_admingroupid} =
'$self->request_data->{reservation}{RESERVATION_ID}{serverrequest}{admingroupid}';
$SUBROUTINE_MAPPINGS{server_request_logingroupid} =
'$self->request_data->{reservation}{RESERVATION_ID}{serverrequest}{logingroupid}';
$SUBROUTINE_MAPPINGS{server_request_monitored} =
'$self->request_data->{reservation}{RESERVATION_ID}{serverrequest}{monitored}';
-$SUBROUTINE_MAPPINGS{server_ssh_allow_users} =
'$self->request_data->{user}{unityid}';
+$SUBROUTINE_MAPPINGS{server_allow_users} =
'$self->request_data->{user}{unityid}';
$SUBROUTINE_MAPPINGS{imagerevision_comments} =
'$self->request_data->{reservation}{RESERVATION_ID}{imagerevision}{comments}';
$SUBROUTINE_MAPPINGS{imagerevision_date_created} =
'$self->request_data->{reservation}{RESERVATION_ID}{imagerevision}{datecreated}';
Modified: incubator/vcl/trunk/managementnode/lib/VCL/Module/OS.pm
URL:
http://svn.apache.org/viewvc/incubator/vcl/trunk/managementnode/lib/VCL/Module/OS.pm?rev=1306520&r1=1306519&r2=1306520&view=diff
==============================================================================
--- incubator/vcl/trunk/managementnode/lib/VCL/Module/OS.pm (original)
+++ incubator/vcl/trunk/managementnode/lib/VCL/Module/OS.pm Wed Mar 28 18:12:26
2012
@@ -2093,6 +2093,7 @@ sub manage_server_access {
my $server_request_admingroupid =
$self->data->get_server_request_admingroupid();
my $server_request_logingroupid =
$self->data->get_server_request_logingroupid();
my $user_login_id_owner = $self->data->get_user_login_id();
+ my $user_id_owner = $self->data->get_user_id();
# Build list of users.
# If in admin group set admin flag
@@ -2103,7 +2104,7 @@ sub manage_server_access {
my @userlist_admin;
my @userlist_login;
my %user_hash;
- my $ssh_allow_list;
+ my $allow_list;
if ($server_request_admingroupid) {
@userlist_admin =
getusergroupmembers($server_request_admingroupid);
@@ -2112,54 +2113,61 @@ sub manage_server_access {
@userlist_login =
getusergroupmembers($server_request_logingroupid);
}
- notify($ERRORS{'OK'}, 0, " admin list= @userlist_admin");
- notify($ERRORS{'OK'}, 0, " login list= @userlist_login");
-
+ notify($ERRORS{'OK'}, 0, " admin login list= @userlist_admin");
+ notify($ERRORS{'OK'}, 0, " nonadmin login list= @userlist_login");
if (scalar @userlist_admin > 0) {
foreach my $str (@userlist_admin) {
- my ($username,$uid,$vcl_user_id) = split(/:/, $str);
+ my ($username,$uid,$vcl_user_id) = 0;
+ ($username,$uid,$vcl_user_id) = split(/:/, $str);
my ($correct_username, $user_domain) = split /@/,
$username;
- $user_hash{$uid}{"username"} = $correct_username;
- $user_hash{$uid}{"uid"} = $uid;
- $user_hash{$uid}{"vcl_user_id"} = $vcl_user_id;
- $user_hash{$uid}{"rootaccess"} = 1;
- notify($ERRORS{'OK'}, 0, "adding admin $uid for
$username ");
+ $user_hash{$vcl_user_id}{"username"} = $correct_username;
+ $user_hash{$vcl_user_id}{"uid"} = $uid;
+ $user_hash{$vcl_user_id}{"vcl_user_id"} = $vcl_user_id;
+ $user_hash{$vcl_user_id}{"rootaccess"} = 1;
+ notify($ERRORS{'DEBUG'}, 0, "adding admin vcl_user_id=
$vcl_user_id uid= $uid for $username ");
}
}
if (scalar @userlist_login > 0) {
foreach my $str (@userlist_login) {
- notify($ERRORS{'OK'}, 0, "admin str= $str");
- my ($username, $uid,$vcl_user_id) = split(/:/, $str);
+ notify($ERRORS{'OK'}, 0, "nonadmin user str= $str");
+ my ($username, $uid,$vcl_user_id) = 0;
+ ($username, $uid,$vcl_user_id) = split(/:/, $str);
my ($correct_username, $user_domain) = split /@/,
$username;
if (!exists($user_hash{$uid})) {
- $user_hash{$uid}{"username"} =
$correct_username;
- $user_hash{$uid}{"uid"} = $uid;
- $user_hash{$uid}{"vcl_user_id"} = $vcl_user_id;
- $user_hash{$uid}{"rootaccess"} = 2;
- notify($ERRORS{'OK'}, 0, "adding $uid for
$username ");
+ $user_hash{$vcl_user_id}{"username"} =
$correct_username;
+ $user_hash{$vcl_user_id}{"uid"} = $uid;
+ $user_hash{$vcl_user_id}{"vcl_user_id"} =
$vcl_user_id;
+ $user_hash{$vcl_user_id}{"rootaccess"} = 2;
+ notify($ERRORS{'DEBUG'}, 0, "adding
$vcl_user_id for $username ");
}
else {
- notify($ERRORS{'OK'}, 0, "$uid for $username
exists in user_hash, skipping");
+ notify($ERRORS{'OK'}, 0, "$vcl_user_id for
$username exists in user_hash, skipping");
}
}
}
# Collect users in reservationaccounts table
my %res_accounts = get_reservation_accounts($reservation_id);
+ notify($ERRORS{'DEBUG'}, 0, "res_accounts:".
format_data(%res_accounts));
my $not_standalone_list = "";
if(defined($ENV{management_node_info}{NOT_STANDALONE}) &&
$ENV{management_node_info}{NOT_STANDALONE}){
$not_standalone_list =
$ENV{management_node_info}{NOT_STANDALONE};
}
+ #Add users
foreach my $userid (sort keys %user_hash) {
next if (!($userid));
#Skip reservation owner, this account is processed in the new
and reserved states
- next if ($userid eq $user_login_id_owner);
+ notify($ERRORS{'DEBUG'}, 0, "userid= $userid user_id_owner=
$user_id_owner ");
+ if ($userid eq $user_id_owner) {
+ $allow_list .= " $user_hash{$userid}{username}";
+ next;
+ }
my $standalone = 0;
if(!exists($res_accounts{$userid})){
# check affiliation
- notify($ERRORS{'OK'}, 0, "checking affiliation for
$userid");
+ notify($ERRORS{'DEBUG'}, 0, "checking affiliation for
$userid");
my $affiliation_name =
get_user_affiliation($user_hash{$userid}{vcl_user_id});
if(defined($affiliation_name)) {
@@ -2176,34 +2184,55 @@ sub manage_server_access {
$user_hash{$userid}{"passwd"} = 0;
}
- if
(update_reservation_accounts($reservation_id,$user_hash{$userid}{vcl_user_id},$user_hash{$userid}{passwd}))
{
- notify($ERRORS{'OK'}, 0, "Inserted
$reservation_id,$user_hash{$userid}{vcl_user_id},$user_hash{$userid}{passwd}
into reservationsaccounts table");
-
+ if
(update_reservation_accounts($reservation_id,$userid,$user_hash{$userid}{passwd},"add"))
{
+ notify($ERRORS{'OK'}, 0, "Inserted
$reservation_id,$userid,$user_hash{$userid}{passwd} into reservationsaccounts
table");
}
# Create user on the OS
-
if($self->create_user($user_hash{$userid}{username},$user_hash{$userid}{passwd},$userid,$user_hash{$userid}{rootaccess},$standalone))
{
+
if($self->create_user($user_hash{$userid}{username},$user_hash{$userid}{passwd},$user_hash{$userid}{uid},$user_hash{$userid}{rootaccess},$standalone))
{
notify($ERRORS{'OK'}, 0, "Successfully created
user $user_hash{$userid}{username} on $computer_node_name");
}
else {
notify($ERRORS{'WARNING'}, 0, "Failed to create
user on $computer_node_name ");
}
- $ssh_allow_list .= " $user_hash{$userid}{username}";
+ $allow_list .= " $user_hash{$userid}{username}";
-
}
else {
- notify($ERRORS{'WARNING'}, 0, "$userid exists in
reservationaccounts table, assuming it exists on OS");
+ notify($ERRORS{'DEBUG'}, 0, "$userid exists in
reservationaccounts table, assuming it exists on OS");
}
}
- notify($ERRORS{'OK'}, 0, "ssh_allow_list= $ssh_allow_list");
+
+ #Remove anyone listed in reservationaccounts list that is not in
user_hash
+ foreach my $res_userid (sort keys %res_accounts) {
+ notify($ERRORS{'OK'}, 0, "res_userid= $res_userid username=
$res_accounts{$res_userid}{username}");
+ #Skip reservation owner, this account is processed in the new
and reserved states
+ if ($res_userid eq $user_login_id_owner) {
+ $allow_list .= " $res_accounts{$res_userid}{username}";
+ next;
+ }
+ if(!exists($user_hash{$res_userid})) {
+ notify($ERRORS{'OK'}, 0, "username=
$res_accounts{$res_userid}{username} is not listed in reservationsaccounts,
attempting to delete");
+ #Delete from reservationaccounts
+ if
(update_reservation_accounts($reservation_id,$res_accounts{$res_userid}{userid},0,"delete"))
{
+ notify($ERRORS{'OK'}, 0,
"Deleted $reservation_id,$res_accounts{$res_userid}{userid} from
reservationsaccounts table");
+ }
+ #Delete from OS
+
if($self->delete_user($res_accounts{$res_userid}{username},0,0)) {
+ notify($ERRORS{'OK'}, 0,
"Successfully removed user= $res_accounts{$res_userid}{username}");
+ }
+ next;
+ }
+ $allow_list .= " $res_accounts{$res_userid}{username}";
+ }
+ notify($ERRORS{'OK'}, 0, "allow_list= $allow_list");
- $self->data->set_server_ssh_allow_users($ssh_allow_list);
+ $self->data->set_server_allow_users($allow_list);
- if ( $self->can("update_server_access") ) {
- if ( $self->update_server_access($ssh_allow_list) ) {
+ if ($self->can("update_server_access") ) {
+ if ( $self->update_server_access($allow_list) ) {
notify($ERRORS{'OK'}, 0, "updated remote access list");
}
}
Modified: incubator/vcl/trunk/managementnode/lib/VCL/Module/OS/Linux.pm
URL:
http://svn.apache.org/viewvc/incubator/vcl/trunk/managementnode/lib/VCL/Module/OS/Linux.pm?rev=1306520&r1=1306519&r2=1306520&view=diff
==============================================================================
--- incubator/vcl/trunk/managementnode/lib/VCL/Module/OS/Linux.pm (original)
+++ incubator/vcl/trunk/managementnode/lib/VCL/Module/OS/Linux.pm Wed Mar 28
18:12:26 2012
@@ -140,43 +140,14 @@ sub pre_capture {
if(!$self->clean_iptables()) {
return;
}
-
- # Try to clear /tmp
- if ($self->execute("/usr/sbin/tmpwatch -f 0 /tmp; /bin/cp /dev/null
/var/log/wtmp")) {
- notify($ERRORS{'DEBUG'}, 0, "cleared /tmp on
$computer_node_name");
- }
-
- # Clear SSH idenity keys from /root/.ssh
- if (!$self->clear_private_keys()) {
- notify($ERRORS{'WARNING'}, 0, "unable to clear known identity keys");
- }
-
- #Fetch exclude_list
- my @exclude_list = $self->get_exclude_list();
-
- if (@exclude_list ) {
- notify($ERRORS{'DEBUG'}, 0, "skipping files listed in
exclude_list\n" . join("\n", @exclude_list));
- }
-
- #Remove files
- if(!(grep( /70-persistent-net.rules/ , @exclude_list ) ) ){
-
if(!$self->delete_file("/etc/udev/rules.d/70-persistent-net.rules")){
- notify($ERRORS{'WARNING'}, 0, "unable to remove
/etc/udev/rules.d/70-persistent-net.rules");
- }
- }
-
- if(!(grep( /\/var\/log\/secure/ , @exclude_list ) ) ){
- if(!$self->delete_file("/var/log/secure")){
- notify($ERRORS{'WARNING'}, 0, "unable to remove
/var/log/secure");
- }
- }
- if(!(grep( /\/var\/log\/messages/ , @exclude_list ) ) ){
- if(!$self->delete_file("/var/log/messages")){
- notify($ERRORS{'WARNING'}, 0, "unable to remove
/var/log/secure");
- }
+ if(!$self->clean_known_files()) {
+ notify($ERRORS{'WARNING'}, 0, "unable to clean known files");
}
+ #Fetch exclude_list
+ my @exclude_list = $self->get_exclude_list();
+
# Write /etc/rc.local script
if(!(grep( /rc.local/ , @exclude_list ) ) ){
if (!$self->generate_rc_local()){
@@ -835,6 +806,13 @@ sub delete_user {
notify($ERRORS{'WARNING'}, 0, "image identity keys could not be
determined");
return 0;
}
+
+ if ($self->user_logged_in($user_login_id)) {
+ notify($ERRORS{'OK'}, 0, "user $user_login_id is logged in,
logging of user");
+ if($self->logoff_user($user_login_id)) {
+
+ }
+ }
# Use userdel to delete the user
# Do not use userdel -r, it will affect HPC user storage for HPC
installs
my $user_delete_command = "/usr/sbin/userdel $user_login_id";
@@ -962,7 +940,7 @@ sub grant_access {
notify($ERRORS{'OK'}, 0, "server_request_id= $server_request_id");
if ( $server_request_id ) {
- my $server_allow_user_list =
$self->data->get_server_ssh_allow_users();
+ my $server_allow_user_list =
$self->data->get_server_allow_users();
notify($ERRORS{'OK'}, 0, "server_allow_user_list=
$server_allow_user_list");
if ( $server_allow_user_list ) {
@@ -2998,6 +2976,7 @@ sub create_user {
if (!$username) {
$username = $self->data->get_user_login_id();
+ notify($ERRORS{'OK'}, 0, "username not
provided, pulling from datastructure");
}
if (!$password) {
$password = $self->data->get_reservation_password();
@@ -3007,10 +2986,12 @@ sub create_user {
}
if (!$user_uid) {
$user_uid = $self->data->get_user_uid();
+ notify($ERRORS{'OK'}, 0, "user_uid not provided, pulling from
datastructure");
}
if (!$user_standalone) {
$user_standalone = $self->data->get_user_standalone();
+ notify($ERRORS{'OK'}, 0, "user_standalone not provided, pulling
from datastructure");
}
#adminoverride, if 0 use value from database for $imagemeta_rootaccess
@@ -3110,23 +3091,29 @@ sub update_server_access {
if ( !$server_allow_user_list ) {
- my $server_allow_user_list =
$self->data->get_server_ssh_allow_users();
+ my $server_allow_user_list =
$self->data->get_server_allow_users();
}
notify($ERRORS{'OK'}, 0, "server_allow_user_list=
$server_allow_user_list");
if ( $server_allow_user_list ) {
- my $cmd = "echo \"AllowUsers $server_allow_user_list\" >>
/etc/ssh/external_sshd_config";
+ my $cmd = "sed -i -e \"/^AllowUsers */d\"
/etc/ssh/external_sshd_config; echo \"AllowUsers $server_allow_user_list\" >>
/etc/ssh/external_sshd_config";
if (run_ssh_command($computer_node_name, $identity, $cmd,
"root")) {
notify($ERRORS{'DEBUG'}, 0, "added AllowUsers
$server_allow_user_list to external_sshd_config");
}
else {
notify($ERRORS{'CRITICAL'}, 0, "failed to add AllowUsers
$server_allow_user_list to external_sshd_config");
}
-
- if ($self->execute("/etc/init.d/ext_sshd stop;
sleep 2; /etc/init.d/ext_sshd start")) {
- notify($ERRORS{'DEBUG'}, 0, "restarted
ext_sshd");
+
+ if(!$self->stop_service("ext_sshd")) {
+
}
+ if(!$self->start_service("ext_sshd")) {
+ notify($ERRORS{'WARNING'}, 0, "failed
to start ext_sshd");
+ return 0;
+ }
+
+ notify($ERRORS{'DEBUG'}, 0, "restarted
ext_sshd");
}
return 1;
@@ -3308,7 +3295,7 @@ sub start_service {
$command = "systemctl start
$service_name" . ".service";
}
else {
- $command = "/sbin/service $service_name
start";
+ $command = "service $service_name start";
}
my ($status, $output) = run_ssh_command($computer_node_name,
$management_node_keys, $command, '', '', 1);
@@ -3366,7 +3353,7 @@ sub stop_service {
$command = "systemctl stop $service_name" . ".service";
}
else {
- $command = "/sbin/service $service_name stop";
+ $command = "service $service_name stop";
}
my ($status, $output) = run_ssh_command($computer_node_name,
$management_node_keys, $command, '', '', 1);
@@ -4510,6 +4497,63 @@ sub user_logged_in {
}
+#/////////////////////////////////////////////////////////////////////////////
+
+=head2 clean_known_files
+
+ Parameters :
+ Returns : 1
+ Description : Removes or overwrites known files that are not excluded.
+
+=cut
+
+sub clean_known_files {
+ my $self = shift;
+ if (ref($self) !~ /linux/i) {
+ notify($ERRORS{'CRITICAL'}, 0, "subroutine was called as a function, it
must be called as a class method");
+ return;
+ }
+
+ my $computer_node_name = $self->data->get_computer_node_name();
+
+ # Try to clear /tmp
+ if ($self->execute("/usr/sbin/tmpwatch -f 0 /tmp; /bin/cp /dev/null
/var/log/wtmp")) {
+ notify($ERRORS{'DEBUG'}, 0, "cleared /tmp on $computer_node_name");
+ }
+
+ # Clear SSH idenity keys from /root/.ssh
+ if (!$self->clear_private_keys()) {
+ notify($ERRORS{'WARNING'}, 0, "unable to clear known identity keys");
+ }
+
+ #Fetch exclude_list
+ my @exclude_list = $self->get_exclude_list();
+
+ if (@exclude_list ) {
+ notify($ERRORS{'DEBUG'}, 0, "skipping files listed in exclude_list\n" .
join("\n", @exclude_list));
+ }
+
+ #Remove files
+ if(!(grep( /70-persistent-net.rules/ , @exclude_list ) ) ){
+ if(!$self->delete_file("/etc/udev/rules.d/70-persistent-net.rules")){
+ notify($ERRORS{'WARNING'}, 0, "unable to remove
/etc/udev/rules.d/70-persistent-net.rules");
+ }
+ }
+
+ if(!(grep( /\/var\/log\/secure/ , @exclude_list ) ) ){
+ if(!$self->delete_file("/var/log/secure")){
+ notify($ERRORS{'WARNING'}, 0, "unable to remove /var/log/secure");
+ }
+ }
+
+ if(!(grep( /\/var\/log\/messages/ , @exclude_list ) ) ){
+ if(!$self->delete_file("/var/log/messages")){
+ notify($ERRORS{'WARNING'}, 0, "unable to remove /var/log/secure");
+ }
+ }
+
+ return 1;
+}
##/////////////////////////////////////////////////////////////////////////////
1;
Modified: incubator/vcl/trunk/managementnode/lib/VCL/inuse.pm
URL:
http://svn.apache.org/viewvc/incubator/vcl/trunk/managementnode/lib/VCL/inuse.pm?rev=1306520&r1=1306519&r2=1306520&view=diff
==============================================================================
--- incubator/vcl/trunk/managementnode/lib/VCL/inuse.pm (original)
+++ incubator/vcl/trunk/managementnode/lib/VCL/inuse.pm Wed Mar 28 18:12:26 2012
@@ -159,6 +159,32 @@ sub process {
}
}
+ #Server modified
+ if($request_state_name =~ /servermodified/) {
+ notify($ERRORS{'OK'}, 0, "this is a 'servermodified' request");
+
+ #FIXME - a cmd queue is needed to tell vcld what to do
+ #for now we assume a user has been added/removed from a user
group
+ #
+
+ if (!$self->os->manage_server_access()) {
+ notify($ERRORS{'WARNING'}, 0, "Failed to update server
access");
+ }
+
+
+ # Put this request back into the inuse state
+ if (update_request_state($request_id, "inuse", "inuse")) {
+ notify($ERRORS{'OK'}, 0, "request state set back to
inuse");
+ }
+ else {
+ notify($ERRORS{'WARNING'}, 0, "unable to set request state back to
inuse");
+ }
+
+ notify($ERRORS{'OK'}, 0, "exiting");
+ exit;
+
+ }
+
# Set the user connection timeout limit in minutes
my $connect_timeout_limit = 15;
Modified: incubator/vcl/trunk/managementnode/lib/VCL/utils.pm
URL:
http://svn.apache.org/viewvc/incubator/vcl/trunk/managementnode/lib/VCL/utils.pm?rev=1306520&r1=1306519&r2=1306520&view=diff
==============================================================================
--- incubator/vcl/trunk/managementnode/lib/VCL/utils.pm (original)
+++ incubator/vcl/trunk/managementnode/lib/VCL/utils.pm Wed Mar 28 18:12:26 2012
@@ -2220,7 +2220,8 @@ sub get_reservation_accounts {
SELECT DISTINCT
reservationaccounts.userid AS reservationaccounts_userid,
reservationaccounts.password AS reservationaccounts_password,
- affiliation.name AS affiliation_name
+ affiliation.name AS affiliation_name,
+ user.unityid AS user_name
FROM
reservationaccounts,
affiliation,
@@ -2247,6 +2248,7 @@ sub get_reservation_accounts {
$user_info{$userid}{"userid"} = $userid;
$user_info{$userid}{"password"} =
$reservation_acct{reservationaccounts_password};
$user_info{$userid}{"affiliation"} =
$reservation_acct{affiliation_name};
+ $user_info{$userid}{"username"} =
$reservation_acct{user_name};
}
return %user_info;
@@ -2261,6 +2263,12 @@ sub update_reservation_accounts {
my $resid = shift;
my $userid = shift;
my $password = shift;
+ my $mode = shift;
+
+ if(!$mode) {
+ notify($ERRORS{'WARNING'}, 0, "mode argument was not specified,
either add or delete");
+ return;
+ }
if ( !$resid ) {
notify($ERRORS{'WARNING'}, 0, "resid argument was not
specified");
@@ -2275,32 +2283,47 @@ sub update_reservation_accounts {
if ( !$password ) {
$password = '';
}
-
- my $insert_statement = "
- INSERT INTO
- reservationaccounts
- (
- reservationid,
- userid,
- password
- )
- VALUES
- (
- '$resid',
- '$userid',
- '$password'
- )
- ";
- notify($ERRORS{'OK'}, 0, "$insert_statement");
+ my $statement;
+
+ #ADD
+ if($mode =~ /add/i) {
+ $statement = "
+ INSERT INTO
+ reservationaccounts
+ (
+ reservationid,
+ userid,
+ password
+ )
+ VALUES
+ (
+ '$resid',
+ '$userid',
+ '$password'
+ )
+ ";
+ }
+ elsif( $mode =~ /delete/i ) {
+ $statement = "
+ DELETE
+ reservationaccounts
+ FROM
+ reservationaccounts
+ WHERE
+ reservationid = '$resid' AND
+ userid = '$userid'
+ "
+
+ }
- if( database_execute($insert_statement) ) {
- notify($ERRORS{'OK'}, 0, "inserted new reservationaccount info
$resid $userid");
+ if(database_execute($statement) ) {
+ #notify($ERRORS{'OK'}, 0, "executed $statement $resid $userid");
return 1;
}
else {
+ notify($ERRORS{'OK'}, 0, "failed to to execute statement=
$statement");
return 0;
- notify($ERRORS{'OK'}, 0, "failed to insert new
reservationaccount info $resid $userid");
}
}
@@ -3121,6 +3144,9 @@ sub getusergroupmembers {
for (@selected_rows) {
my %hash = %{$_};
+ if(!defined($hash{uid})){
+ $hash{uid} = 0;
+ }
push(@retarray, "$hash{unityid}:$hash{uid}:$hash{id}");
}
@@ -3128,6 +3154,8 @@ sub getusergroupmembers {
} ## end sub getusergroupmembers
+
+
#/////////////////////////////////////////////////////////////////////////////
=head2 get_user_group_member_info
@@ -4049,7 +4077,12 @@ sub database_execute {
my $sql_insertid = $statement_handle->{'mysql_insertid'};
$statement_handle->finish;
$dbh->disconnect if !defined $ENV{dbh};
- return $sql_insertid;
+ if($sql_insertid) {
+ return $sql_insertid;
+ }
+ else {
+ return 1;
+ }
}
else {
$statement_handle->finish;