~nchohan/+junk/mytools

« back to all changes in this revision

Viewing changes to bin/appscale-reset-pwd

  • Committer: root
  • Date: 2010-11-03 07:43:57 UTC
  • Revision ID: root@appscale-image0-20101103074357-xea7ja3sor3x93oc
init

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/ruby -w
 
2
# Programmer: Chris Bunch
 
3
 
 
4
$VERBOSE = nil
 
5
 
 
6
require 'soap/rpc/driver'
 
7
require 'yaml'
 
8
 
 
9
$:.unshift File.join(File.dirname(__FILE__), "..", "lib")
 
10
require 'app_controller_client'
 
11
require 'common_functions'
 
12
require 'encryption_helper'
 
13
require 'user_app_client'
 
14
 
 
15
USAGE = <<END_OF_USAGE
 
16
#{AS_VERSION}
 
17
 
 
18
Usage: appscale-reset-pwd [OPTIONS]
 
19
 
 
20
Examples:
 
21
  appscale-reset-pwd --keyname foo
 
22
  
 
23
Flags:
 
24
  --keyname: The name of the SSH key to use for Eucalyptus. Two AppScale instances can be run concurrently in one cloud if they have unique names, and they can conflict if they have the same name.
 
25
END_OF_USAGE
 
26
 
 
27
ALL_FLAGS = ["help", "usage", "h", "keyname", "version"]
 
28
 
 
29
require 'parse_args'
 
30
 
 
31
keyname = KEYNAME
 
32
secret = CommonFunctions.get_secret_key(keyname)
 
33
 
 
34
head_node_ip = CommonFunctions.get_load_balancer_ip(keyname)
 
35
abort("We are not able to reset your password right now, as AppScale is not currently running.") if head_node_ip == ""
 
36
 
 
37
user = CommonFunctions.get_email
 
38
pass = CommonFunctions.get_password
 
39
puts "\n"
 
40
encrypted_pass = CommonFunctions.encrypt_password(user, pass)
 
41
 
 
42
acc = AppControllerClient.new(head_node_ip, secret)
 
43
userappserver_ip = acc.get_userappserver_ip
 
44
 
 
45
uac = UserAppClient.new(userappserver_ip, secret)
 
46
uac.change_password(user, encrypted_pass)