~ibmcharmers/charms/trusty/layer-ibm-mobilefirst-server/devel

« back to all changes in this revision

Viewing changes to reactive/ibm-db2.sh

  • Committer: Suchitra Venugopal
  • Date: 2016-06-23 08:25:19 UTC
  • Revision ID: suchvenu@in.ibm.com-20160623082519-yqng7hxat0jvouai
Minor changes after changing the states in db2 Interface

Show diffs side-by-side

added added

removed removed

Lines of Context:
329
329
                        while [ $free_port == 0 ]
330
330
                        do
331
331
                                is_free=`netstat -lnp | grep $new_port | cut -d":" -f2 | cut -d" " -f1`
 
332
                                juju-log "Suchitra free port - $is_free"
 
333
                                juju-log "New port is $new_port"
332
334
                                if [ "$is_free" != "$new_port" ]; then
333
335
                                        free_port=1
334
336
                                else
550
552
        services=$(relation_call --state=db.connected services) || true
551
553
        for service in $services; do
552
554
                juju-log "IBM DB2: Resetting states for the service $service"
553
 
                relation_call --state=db.connected reset_states $service
 
555
                #relation_call --state=db.connected reset_states $service
554
556
                relation_call --state=db.connected dismiss_sshconfigured $service || true
 
557
                relation_call --state=db.connected reset_states $service || true
555
558
        done
556
559
 
557
560
        remove_state 'ibm-db2.uninstalled'
679
682
                key=$(relation_call --state=db.connected get_sshkeys $service) || true
680
683
                juju-log "IBM DB2: Received the ssh key $key from the service $service"
681
684
 
682
 
                if [ -z "$key" ]; then
 
685
                if [ "$key" == "None" ]; then
683
686
                        juju-log "IBM DB2: No data sent yet"
684
687
                        continue
685
688
                fi
708
711
                        echo "$key" > $AUTH_KEY_FILE
709
712
                        echo "$service:$key" > $TEMP_KEY_FILE
710
713
                fi
 
714
                relation_call --state=db.connected set_sshconfigured $service || true
 
715
                juju-log "IBM DB2: Completed updating the authorized key"
711
716
                set -e
712
717
        done
713
 
        juju-log "IBM DB2: Completed updating the authorized key"
714
 
        relation_call --state=db.connected set_sshconfigured $service || true
 
718
        #juju-log "IBM DB2: Completed updating the authorized key"
 
719
        #relation_call --state=db.connected set_sshconfigured $service || true
715
720
}
716
721
 
717
 
@when 'db.connected'
 
722
@when 'db.ready'
718
723
@when 'ibm-db2.installed'
719
724
@when 'db.sshconfigured'
720
725
function create_consumer_dbs(){
721
726
        DB2_INSTALL_PATH=/opt/ibm/db2/V10.5
722
727
        services=$(relation_call --state=db.connected services)
723
728
        for service in $services; do
 
729
 
 
730
                key=$(relation_call --state=db.connected get_sshkeys $service) || true
 
731
                juju-log "IBM DB2: In create_consumer_dbs function, Received the ssh key $key from the service $service"
 
732
 
 
733
                if [ "$key" == "None" ]; then
 
734
                        juju-log "IBM DB2: No data sent yet"
 
735
                        continue
 
736
                fi
 
737
 
 
738
                
724
739
                #Create the user for the remote unit connected
725
740
                juju-log "IBM DB2: Creating the users for the consumer $service"
726
741
                create_user $service
731
746
 
732
747
                get_cfgusername $service
733
748
                service_name=`su - $cfgusername -c 'db2 get dbm cfg|grep -i svce|cut -d"=" -f2'`
734
 
                db2_port=`grep $service_name /etc/services | cut -d"/" -f1 | cut -f2`
 
749
                db2_port=`grep $service_name /etc/services | cut -d"/" -f1 | grep "db2c_$cfgusername" | cut -f2`
735
750
                db2_path="/opt/ibm/db2"
736
751
                hostname=`unit-get private-address`
737
752
                dbusername=$cfgusername
768
783
                fi
769
784
                #Remove the ssh key entry from ssh keys file
770
785
                remove_sshkeys $service
 
786
                #relation_call --state=db.departed dismiss $service || true
 
787
                #relation_call --state=db.departed reset_states $service || true 
 
788
                relation_call --state=db.departed dismiss_sshconfigured $service || true
771
789
                relation_call --state=db.departed dismiss $service || true
772
 
                relation_call --state=db.departed dismiss_sshconfigured $service || true
773
790
        done
774
791
}
775
792