forj 0.0.35 → 0.0.36

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b1995afd2ab24967e07aef8b4451acbff58dd367
4
- data.tar.gz: 662ce3b7da524bf101ba45a3526ca1c04d1a336f
3
+ metadata.gz: 56a2084ebba0322d7ddd4c282f4920d0200a7f80
4
+ data.tar.gz: 10f942c5e93c5efb94c62b51447cee6dc7c057ce
5
5
  SHA512:
6
- metadata.gz: bb8659a39b98f5aed5a0e26337428e8a96667d8f2c35482855e24b0db706492020a6d03564ded3d635d9f096a52b01e25f2d1a685bb4e824c5a93111ab464350
7
- data.tar.gz: 60918b32d461c2ad7b5e43dda24172a036d6c22c6fef392d0ec4ce5092652d6e16bb250abc98ea038f9e8b581a0361b2112905487d43bd3c2d9784b0c455fe11
6
+ metadata.gz: de3ed0c44cf1d360e823d2ccff9ac391b08d16d5944c01e49c96175e4035e1493ca9c967a3dfc15b29e4eb6a9c316431846e5787eda884c241894f38fb8d42c3
7
+ data.tar.gz: 938f9c93e3eaa1b86d917e66f89e8dd93902bd4a414347fb77074d08e4e176f51be87df7863a7f6d09a21662156e4250b70947197c9db4b08b716ad4ff18eefa
data/README.md CHANGED
@@ -4,24 +4,23 @@ Forj cli
4
4
 
5
5
  Installation
6
6
  ------------
7
- ### For ruby 2.0
8
7
 
9
- **Fedora/CentOS/Redhat rpm like package system**
8
+ ###Fedora/CentOS/Redhat rpm like package system
9
+
10
+ **For ruby 2.0**
10
11
 
11
12
  $ sudo yum install ruby-devel libxml2-devel libxslt-devel python-yaml gcc git -y
12
13
  $ sudo gem install forj
13
14
 
14
- **Ubuntu/Debian deb like package system (not tested)**
15
+ ###Ubuntu/Debian deb like package system
15
16
 
16
- $ sudo apt-get install ruby-dev build-essential libopenssl-ruby1.9.1 libssl-dev zlib1g-dev git -y
17
- $ sudo gem install forj
18
-
19
- ### For ruby 1.9
17
+ **For ruby 1.9**
20
18
 
21
- $ sudo apt-get install ruby-dev build-essential libopenssl-ruby1.9.1 libssl-dev zlib1g-dev git -y
19
+ $ sudo apt-get install ruby-dev build-essential libopenssl-ruby1.9.1 libssl-dev zlib1g-dev libxml2-dev libxslt-dev git -y
22
20
  $ sudo gem install forj
23
21
 
24
- ### For ruby 1.8
22
+
23
+ **For ruby 1.8**
25
24
 
26
25
  $ sudo apt-get install ruby1.8-dev ruby1.8 ri1.8 rdoc1.8 irb1.8 -y
27
26
  $ sudo apt-get install libreadline-ruby1.8 libruby1.8 libopenssl-ruby -y
data/bin/forj CHANGED
@@ -23,16 +23,16 @@ require 'ansi'
23
23
  $APP_PATH = File.dirname(__FILE__)
24
24
  $LIB_PATH = File.expand_path(File.join(File.dirname($APP_PATH),'lib'))
25
25
 
26
- $FORJ_DATA_PATH= File.expand_path('~/.forj')
27
26
  $LOAD_PATH << './lib'
28
27
 
29
- require_relative '../lib/boot.rb'
28
+ require 'boot.rb'
29
+ require 'down.rb'
30
+ require 'setup.rb'
31
+ require 'ssh.rb'
32
+
30
33
  include Boot
31
- require_relative '../lib/down.rb'
32
34
  include Down
33
- require_relative '../lib/setup.rb'
34
35
  include Setup
35
- require_relative '../lib/ssh.rb'
36
36
  include Ssh
37
37
 
38
38
  require 'forj-config.rb' # Load class ForjConfig
@@ -44,6 +44,9 @@ require 'connection.rb' # Load class ForjConnection
44
44
 
45
45
  include Logging
46
46
 
47
+ # Initialize forj paths
48
+ ensure_forj_dirs_exists()
49
+
47
50
  # Initialize global Log object
48
51
  $FORJ_LOGGER=ForjLog.new()
49
52
 
@@ -102,8 +105,8 @@ The list of predefined values can be retrieved with forj show defaults
102
105
 
103
106
  method_option :account_name, :aliases => '-a', :desc => 'Set the forj account name to use. By default, it takes the provider name.'
104
107
  method_option :infra, :aliases => '-i', :desc => 'Defines your Infra directory to use while booting. You can also set FORJ_INFRA_DIR.'
105
- method_option :key_name, :aliases => '-k', :desc => 'Import a key pair.'
106
- method_option :key_path, :aliases => '-p', :desc => 'Public key data'
108
+ method_option :key_name, :aliases => '-k', :desc => "Keypair name to use."
109
+ method_option :key_path, :aliases => '-p', :desc => "Private or Public key file. forj will determine if you provide a public key or a private, if respectively the extension '.pub' exist or not."
107
110
 
108
111
  method_option :boothook, :aliases => '-H', :desc => 'By default, boothook file used is build/bin/build-tools/boothook.sh. Use this option to set another one.'
109
112
  method_option :build, :aliases => '-B', :desc => 'Replace the default build.sh'
@@ -124,7 +127,18 @@ The list of predefined values can be retrieved with forj show defaults
124
127
  oConfig.set('account_name', options[:account_name])
125
128
  oConfig.set('infra_repo', options[:infra])
126
129
  oConfig.set('keypair_name', options[:key_name])
127
- oConfig.set('keypair_path', options[:key_path])
130
+ if options[:key_path]
131
+ mFound = options[:key_path].match(/^(.*)(\.pub)?$/)
132
+ if mFound
133
+ key_path = File.expand_path(mFound[1])
134
+ if mFound[2] and not File.exists?(File.expand_path(mFound[1]+mFound[2]))
135
+ Logging.fatal(1, "'%s' is not a valid keypair files. At least the public key (.pub) is have to exist.")
136
+ end
137
+ oConfig.set('keypair_path', key_path)
138
+ else
139
+ Logging.fatal(1, "'%s' is not a valid keypair files. At least the public key (.pub) is have to exist.")
140
+ end
141
+ end
128
142
 
129
143
  # TODO: Be able to support the default provider from config.yaml
130
144
  oConfig.set('provider', cloud_provider)
data/lib/boot.rb CHANGED
@@ -42,16 +42,16 @@ module Boot
42
42
 
43
43
  # Check options and set data
44
44
  cloud_provider=oConfig.get('provider')
45
- raise 'No provider specified.' if not cloud_provider
45
+ Logging.fatal(1, 'No provider specified.') if not cloud_provider
46
46
 
47
47
  if cloud_provider != 'hpcloud'
48
- raise "forj setup support only hpcloud. '%s' is currently not supported." % cloud_provider
48
+ Logging.fatal(1, "forj setup support only hpcloud. '%s' is currently not supported." % cloud_provider)
49
49
  end
50
50
 
51
51
  oConfig.setDefault('account_name', cloud_provider)
52
52
 
53
53
  initial_msg = 'booting %s on %s (~/.forj/forj.log)' % [blueprint , cloud_provider]
54
- Logging.message(initial_msg)
54
+ Logging.high_level_msg(initial_msg) #################
55
55
 
56
56
  # Initialize defaults
57
57
  maestro_url = oConfig.get('maestro_url')
@@ -73,6 +73,7 @@ module Boot
73
73
 
74
74
  # Step Maestro Clone
75
75
  if not maestro_repo
76
+ Logging.high_level_msg('cloning maestro repo ...' ) #################
76
77
  Logging.info('cloning maestro repo from \'%s\'...' % maestro_url)
77
78
  Repositories.clone_repo(maestro_url)
78
79
  maestro_repo=File.expand_path('~/.forj/maestro')
@@ -92,6 +93,7 @@ module Boot
92
93
  # Connect to services
93
94
  oFC=ForjConnection.new(oConfig)
94
95
 
96
+ Logging.high_level_msg('Configuring network...') #################
95
97
  Logging.info('Configuring network \'%s\'' % [oConfig.get('network')])
96
98
  begin
97
99
  network = Network.get_or_create_network(oFC, oConfig.get('network'))
@@ -101,16 +103,17 @@ module Boot
101
103
  Logging.fatal(1, "Network properly configured is required.\n%s\n%s" % [e.message, e.backtrace.join("\n")])
102
104
  end
103
105
 
104
-
106
+ Logging.state('Configuring keypair...') #################
105
107
  Logging.info('Configuring keypair \'%s\'' % [oConfig.get('keypair_name')])
106
- key_name = oConfig.get('keypair_name')
107
- key_path = oConfig.get('keypair_path')
108
- SecurityGroup.upload_existing_key(key_name, key_path)
108
+ SecurityGroup.hpc_import_pubkey(oConfig, oFC.sAccountName)
109
+
110
+ Logging.state('Configuring security group...') #################
109
111
 
110
112
  Logging.info('Configuring Security Group \'%s\'' % [oConfig.get('security_group')])
111
113
  security_group = SecurityGroup.get_or_create_security_group(oFC, oConfig.get('security_group'))
112
114
  ports = oConfig.get('ports')
113
115
 
116
+ Logging.state('Configuring security group ports...') #################
114
117
  ports.each do |port|
115
118
  port = port.to_s if port.class != String
116
119
  if not /^\d+(-\d+)?$/ =~ port
@@ -123,10 +126,11 @@ module Boot
123
126
  end
124
127
  end
125
128
 
129
+ ENV['FORJ_HPC'] = oFC.sAccountName
126
130
  ENV['FORJ_HPC_NET'] = network.name
127
131
  ENV['FORJ_SECURITY_GROUP'] = oConfig.get('security_group')
128
- ENV['FORJ_KEYPAIR'] = key_name
129
- ENV['FORJ_HPC_NOVA_KEYPUB'] = key_path
132
+ ENV['FORJ_KEYPAIR'] = oConfig.get('keypair_name')
133
+ ENV['FORJ_HPC_NOVA_KEYPUB'] = oConfig.get('keypair_path')
130
134
  ENV['FORJ_BASE_IMG'] = oConfig.get('image')
131
135
 
132
136
  # run build.sh to boot maestro
data/lib/connection.rb CHANGED
@@ -30,15 +30,16 @@ class ForjConnection
30
30
 
31
31
  attr_accessor :oCompute
32
32
  attr_accessor :oNetwork
33
+ attr_accessor :sAccountName
33
34
 
34
35
  def initialize(oConfig)
35
36
 
36
- sAccountName = oConfig.get('account_name')
37
+ @sAccountName = oConfig.get('account_name')
37
38
  @provider='HP' # TODO: Support multiple provider. (Generic Provider object required)
38
- sAccountName = oConfig.get('provider') if not sAccountName
39
- sAccountName = 'hpcloud' if not sAccountName
39
+ @sAccountName = oConfig.get('provider') if not @sAccountName
40
+ @sAccountName = 'hpcloud' if not @sAccountName
40
41
 
41
- @credentials = get_credentials(sAccountName)
42
+ @credentials = get_credentials(@sAccountName)
42
43
  oSSLError=SSLErrorMgt.new
43
44
 
44
45
  # Trying to get Compute object
@@ -85,7 +86,7 @@ end
85
86
  def get_credentials(sAccountName)
86
87
  # TODO: Should support forj credentials. not hpcloud credentials.
87
88
 
88
- raise 'Internal Error: Missing sAccountName' if not sAccountName
89
+ Logging.fatal(1, 'Internal Error: Missing sAccountName') if not sAccountName
89
90
 
90
91
  creds = File.expand_path('~/.hpcloud/accounts/%s' % [sAccountName])
91
92
  if not File.exists?(creds)
data/lib/defaults.yaml CHANGED
@@ -14,17 +14,28 @@
14
14
 
15
15
  default:
16
16
  maestro_url: https://github.com/forj-oss/maestro.git
17
+
18
+ # Default Infra repository to use. If missing, it will be proposed to be created.
17
19
  infra_repo: ~/.forj/infra
20
+
18
21
  # You can set proto2b in your ~/.forj/config.yaml if you built it from maestro/build. Read the maestro/README.md to create it.
19
22
  image: Ubuntu Precise 12.04.4 LTS Server 64-bit 20140414 (Rescue Image)
23
+
24
+ # Flavor to use for Maestro
20
25
  flavor: standard.xsmall
26
+
27
+ # Ports to open for Maestro, added to the security group
28
+ security_group: forj
21
29
  ports: [22, 80, 443, 3000, 3131, 3132, 3233, 3134, 3135, 4505-4506, 5000, 5666, 8000, 8080-8081, 8083, 8125, 8139-8140, 8773-8776, 9292, 29418, 35357]
22
- keypair_path: ~/.hpcloud/keypairs/nova
23
- keypair_name: nova
30
+
31
+ # Private key file path. Those files (private/public key) will be added to ~/.forj/keypairs/ as respectively 'keypair_name' and 'keypair_name'.pub
32
+ keypair_path: ~/.ssh/forj-id_rsa
33
+ keypair_name: forj
34
+
24
35
  # Network: If network doesn't exist, forj cli will try to create it, and attach it a router.
25
36
  network: forj
26
- security_group: forj
27
- # at this point you have to clone the infra project manually
37
+
38
+ # build.sh internal variables.
28
39
  build_config: box
29
40
  branch: master
30
41
  box_name: maestro
data/lib/forj-config.rb CHANGED
@@ -36,7 +36,7 @@ class ForjDefault
36
36
  # If config doesn't exist, it will be created, empty with 'defaults:' only
37
37
 
38
38
  if not $LIB_PATH
39
- raise 'Internal $LIB_PATH was not set.'
39
+ Logging.fatal(1, 'Internal $LIB_PATH was not set.')
40
40
  end
41
41
 
42
42
  Logging.info ('Reading default configuration...')
@@ -66,7 +66,7 @@ class ForjConfig
66
66
 
67
67
 
68
68
  if not $FORJ_DATA_PATH
69
- raise 'Internal $FORJ_DATA_PATH was not set.'
69
+ Logging.fatal(1, 'Internal $FORJ_DATA_PATH was not set.')
70
70
  end
71
71
 
72
72
  sConfigDefaultName='config.yaml'
@@ -191,5 +191,13 @@ class ForjConfig
191
191
  end
192
192
  @yConfig.merge!(@yLocal) { |key, oldval, newval| key == 'default'? oldval: newval }
193
193
  end
194
+
195
+ def LocalDefaultExist?(key)
196
+ if @yLocal['default'][key]
197
+ true
198
+ else
199
+ false
200
+ end
201
+ end
194
202
 
195
203
  end
data/lib/helpers.rb CHANGED
@@ -15,6 +15,8 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
 
18
+ require 'fileutils'
19
+
18
20
  module Helpers
19
21
  def get_home_path
20
22
  File.expand_path('~')
@@ -25,4 +27,34 @@ module Helpers
25
27
  Dir.mkdir path
26
28
  end
27
29
  end
30
+
31
+ def dir_exists?(path)
32
+ if File.exists?(path)
33
+ if not File.directory?(path)
34
+ msg = "'%s' is not a directory. Please fix it." % path
35
+ if $FORJ_LOGGER
36
+ Logging.fatal(1, msg)
37
+ else
38
+ raise msg
39
+ end
40
+ end
41
+ if not File.readable?(path) or not File.writable?(path) or not File.executable?(path)
42
+ msg = "%s is not a valid directory. Check permissions and fix it." % path
43
+ if $FORJ_LOGGER
44
+ Logging.fatal(1, msg)
45
+ else
46
+ raise msg
47
+ end
48
+ end
49
+ return true
50
+ end
51
+ false
52
+ end
53
+
54
+ def ensure_dir_exists(path)
55
+ if not dir_exists?(path)
56
+ FileUtils.mkpath(path) if not File.directory?(path)
57
+ end
58
+ end
59
+
28
60
  end
data/lib/log.rb CHANGED
@@ -61,11 +61,17 @@ module Logging
61
61
  # Class used to create 2 log object, in order to keep track of error in a log file and change log output to OUTPUT on needs (option flags).
62
62
 
63
63
  attr_reader :level
64
-
64
+
65
65
  def initialize(sLogFile = 'forj.log', level = Logger::WARN)
66
- if not $FORJ_DATA_PATH
66
+
67
+ if not $FORJ_DATA_PATH
67
68
  raise "Internal Error: Unable to initialize ForjLog - global FORJ_DATA_PATH not set"
68
69
  end
70
+
71
+ if not Helpers.dir_exists?($FORJ_DATA_PATH)
72
+ raise "Internal Error: Unable to initialize ForjLog - '%s' doesn't exist." % $FORJ_DATA_PATH
73
+ end
74
+
69
75
  @oFileLogger = Logger.new(File.join($FORJ_DATA_PATH, sLogFile), 'weekly')
70
76
  @oFileLogger.level = Logger::DEBUG
71
77
  @oFileLogger.formatter = proc do |severity, datetime, progname, msg|
@@ -160,6 +166,9 @@ module Logging
160
166
  print("%s%s ...\r" % [message, ANSI.clear_line]) if $FORJ_LOGGER.level == Logger::INFO
161
167
  end
162
168
 
163
-
169
+ def high_level_msg(message)
170
+ # Not DEBUG and not INFO. Just printed to the output.
171
+ puts ("%s" % [message]) if $FORJ_LOGGER.level > 1
172
+ end
164
173
 
165
174
  end
data/lib/network.rb CHANGED
@@ -227,7 +227,7 @@ module Network
227
227
 
228
228
  # Router interface to connect to the network
229
229
  def create_router_interface(subnet, router)
230
- raise "Internal Error: subnet/router object not passed." if not subnet or not router
230
+ Logging.fatal(1, "Internal Error: subnet/router object not passed.") if not subnet or not router
231
231
 
232
232
  Logging.debug("Attaching subnet '%s' to router '%s'" % [subnet.name, router.name])
233
233
  begin
data/lib/security.rb CHANGED
@@ -16,11 +16,13 @@
16
16
  # limitations under the License.
17
17
 
18
18
  require 'rubygems'
19
- require 'require_relative'
19
+ require 'highline/import'
20
20
 
21
21
  #
22
22
  # SecurityGroup module
23
23
  #
24
+
25
+ # TODO: Introduce most of HPCloud task in an hpcloud object.
24
26
  module SecurityGroup
25
27
 
26
28
  def get_or_create_security_group(oFC, name)
@@ -135,8 +137,20 @@ module SecurityGroup
135
137
  rule
136
138
  end
137
139
 
138
- def upload_existing_key(key_name, key_path)
139
- command = 'hpcloud keypairs:import %s %s' % [key_name, key_path]
140
+ def hpc_import_pubkey(oConfig, account)
141
+
142
+ key_name = oConfig.get('keypair_name')
143
+ key_path = oConfig.get('keypair_path')
144
+
145
+ Logging.fatal(1, "'keypair_path' undefined. check your config.yaml file.") if not key_path
146
+ Logging.fatal(1, "'keypair_name' undefined. check your config.yaml file.") if not key_name
147
+
148
+ pubkey_path = key_path + '.pub'
149
+ Logging.fatal(1, "keypair '%s' are missing. Please call 'forj setup %s' to create the missing key pair required." % [pubkey_path, account]) if not File.exists?(pubkey_path)
150
+
151
+ Logging.info("Importing your forj keypair '%s' to hpcloud." % pubkey_path)
152
+ command = 'hpcloud keypairs:import %s %s -a %s' % [key_name, pubkey_path, account]
153
+ Logging.debug("Executing command '%s'" % command)
140
154
  Kernel.system(command)
141
155
  end
142
156
  end
data/lib/setup.rb CHANGED
@@ -31,13 +31,13 @@ module Setup
31
31
  def setup(sProvider, oConfig, options )
32
32
  begin
33
33
 
34
- raise 'No provider specified.' if not sProvider
34
+ Logging.fatal(1, 'No provider specified.') if not sProvider
35
35
 
36
36
  sAccountName = sProvider # By default, the account name uses the same provider name.
37
37
  sAccountName = options[:account_name] if options[:account_name]
38
38
 
39
39
  if sProvider != 'hpcloud'
40
- raise "forj setup support only hpcloud. '%s' is currently not supported." % sProvider
40
+ Logging.fatal(1, "forj setup support only hpcloud. '%s' is currently not supported." % sProvider)
41
41
  end
42
42
 
43
43
  # TODO: Support of multiple providers thanks to fog.
@@ -50,11 +50,14 @@ module Setup
50
50
  Kernel.system('hpcloud account:copy hp %s' % [sAccountName])
51
51
  end
52
52
 
53
- case Kernel.system('hpcloud account:setup %s' % [sAccountName] )
53
+ Logging.info("Configuring hpcloud account '%s'" % [sAccountName] )
54
+ command = 'hpcloud account:setup %s' % [sAccountName]
55
+ Logging.debug("Executing : '%s'" % command)
56
+ case Kernel.system(command)
54
57
  when false
55
- raise "Unable to setup your hpcloud account"
58
+ Logging.fatal(1, "Unable to setup your hpcloud account")
56
59
  when nil
57
- raise "Unable to execute 'hpcloud' cli. Please check hpcloud installation."
60
+ Logging.fatal(1, "Unable to execute 'hpcloud' cli. Please check hpcloud installation.")
58
61
  end
59
62
 
60
63
  if not oConfig.yConfig['default'].has_key?('account')
@@ -64,6 +67,10 @@ module Setup
64
67
 
65
68
  # Implementation of simple credential encoding for build.sh/maestro
66
69
  save_maestro_creds(sAccountName)
70
+
71
+ # Check/create keypair
72
+ keypair_setup(oConfig)
73
+
67
74
  rescue RuntimeError => e
68
75
  Logging.fatal(1,e.message)
69
76
  rescue => e
@@ -72,7 +79,65 @@ module Setup
72
79
  end
73
80
  end
74
81
 
82
+ def ensure_forj_dirs_exists()
83
+ # Function to create FORJ paths if missing.
84
+
85
+ # Defining Global variables
86
+ $FORJ_DATA_PATH = File.expand_path(File.join('~', '.forj'))
87
+ $FORJ_ACCOUNT_PATH = File.join($FORJ_DATA_PATH, 'account') # Not currently used...
88
+ $FORJ_KEYPAIRS_PATH = File.join($FORJ_DATA_PATH, 'keypairs')
89
+ $FORJ_CREDS_PATH = File.expand_path(File.join('~', '.cache', 'forj'))
90
+
91
+ # TODO: To move to an hpcloud object.
92
+ $HPC_KEYPAIRS = File.expand_path(File.join('~', '.hpcloud', 'keypairs'))
93
+
94
+ Helpers.ensure_dir_exists($FORJ_DATA_PATH)
95
+ Helpers.ensure_dir_exists($FORJ_ACCOUNT_PATH)
96
+ Helpers.ensure_dir_exists($FORJ_KEYPAIRS_PATH)
97
+ Helpers.ensure_dir_exists($FORJ_CREDS_PATH)
98
+ end
99
+
100
+ def keypair_setup(oConfig)
101
+
102
+ key_path = oConfig.get('keypair_path')
103
+
104
+ Logging.info("Configuring forj keypair '%s'" % [key_path] )
105
+
106
+ if not File.exists?(key_path)
107
+ # Need to create a key. ask if we need so.
108
+ real_key_path = File.expand_path(ask("If your ssh keypair doesn't exist, forj will ask ssh-keygen to create one for you.\nPrivate key file path:") do |q|
109
+ q.validate = /\w+/
110
+ q.default = key_path
111
+ end)
112
+ if not File.exists?(real_key_path)
113
+ Helpers.ensure_dir_exists(File.dirname(real_key_path))
114
+ command = 'ssh-keygen -t rsa -f %s' % real_key_path
115
+ Logging.debug("Executing '%s'" % command)
116
+ system(command)
117
+ end
118
+ if not File.exists?(real_key_path)
119
+ Logging.fatal(1, "'%s' not found. Unable to add your keypair to hpcloud. Create it yourself and provide it with -p option. Then retry." % [real_key_path])
120
+ else
121
+ if real_key_path != key_path and not oConfig.LocalDefaultExist?('keypair_path')
122
+ Logging.debug("Saving forj keypair '%s' as default." % [real_key_path] )
123
+ oConfig.LocalSet('keypair_path', real_key_path)
124
+ oConfig.SaveConfig()
125
+ end
126
+ end
127
+ end
128
+ end
129
+
130
+
75
131
  def save_maestro_creds(sAccountName)
132
+ # Check required global data
133
+ if not $FORJ_CREDS_PATH
134
+ Logging.fatal(1, "Internal error: '$FORJ_CREDS_PATH' missing.")
135
+ end
136
+ if not Helpers.dir_exists?($FORJ_CREDS_PATH)
137
+ Logging.fatal(1, "Internal error: '%s' doesn't exist." % $FORJ_CREDS_PATH)
138
+ end
139
+
140
+ Logging.info("Completing hpcloud account '%s' information." % [sAccountName] )
76
141
 
77
142
  # TODO Be able to load the previous username if the g64 file exists.
78
143
  hpcloud_os_user = ask('Enter hpcloud username: ') do |q|
@@ -87,16 +152,12 @@ def save_maestro_creds(sAccountName)
87
152
 
88
153
  add_creds = {:credentials => {:hpcloud_os_user=> hpcloud_os_user, :hpcloud_os_key=> hpcloud_os_key}}
89
154
 
90
- sForjCache=File.expand_path('~/.cache/forj/')
91
- cloud_fog = '%s/%s.g64' % [sForjCache, sAccountName]
92
-
93
-
94
- Helpers.create_directory(sForjCache) if not File.directory?(sForjCache)
155
+ cloud_fog = File.join($FORJ_CREDS_PATH, sAccountName+'.g64')
95
156
 
96
157
  # Security fix: Remove old temp file with clear password.
97
- old_file = '%s/master.forj-13.5' % [sForjCache]
158
+ old_file = '%s/master.forj-13.5' % [$FORJ_CREDS_PATH]
98
159
  File.delete(old_file) if File.exists?(old_file)
99
- old_file = '%s/creds' % [sForjCache]
160
+ old_file = '%s/creds' % [$FORJ_CREDS_PATH]
100
161
  File.delete(old_file) if File.exists?(old_file)
101
162
 
102
163
  hpcloud_creds = File.expand_path('~/.hpcloud/accounts/%s' % [sAccountName])
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: forj
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.35
4
+ version: 0.0.36
5
5
  platform: ruby
6
6
  authors:
7
7
  - forj team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-12 00:00:00.000000000 Z
11
+ date: 2014-08-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -122,7 +122,7 @@ dependencies:
122
122
  - - '>='
123
123
  - !ruby/object:Gem::Version
124
124
  version: 1.4.3
125
- description: forj command line
125
+ description: forj cli - See https://www.forj.io for documentation/information
126
126
  email:
127
127
  - forj@forj.io
128
128
  executables: