forj 0.0.40 → 0.0.41
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 +4 -4
- data/README.md +28 -9
- data/bin/forj +263 -59
- data/lib/boot.rb +42 -37
- data/lib/compute.rb +4 -1
- data/lib/connection.rb +1 -1
- data/lib/defaults.yaml +93 -31
- data/lib/down.rb +10 -8
- data/lib/forj-account.rb +84 -20
- data/lib/forj-config.rb +105 -31
- data/lib/network.rb +28 -28
- data/lib/repositories.rb +1 -1
- data/lib/security.rb +8 -8
- data/lib/setup.rb +1 -1
- data/lib/ssh.rb +13 -9
- data/lib/ssh.sh +7 -6
- data/spec/forj-config_spec.rb +43 -29
- metadata +2 -2
data/lib/ssh.sh
CHANGED
@@ -20,8 +20,8 @@ GRE="\e[92m"
|
|
20
20
|
# limitations under the License.
|
21
21
|
|
22
22
|
NOW=$(date +%Y-%m-%d.%H%M%S)
|
23
|
-
logpath=~/.
|
24
|
-
DB
|
23
|
+
logpath=~/.forj/
|
24
|
+
DB=~/.forj/hosts
|
25
25
|
#key_path=~/.ssh/
|
26
26
|
#key_path=~/.hpcloud/keypairs/
|
27
27
|
init_config=~/ssh_init
|
@@ -96,7 +96,7 @@ if [ $1 == '-u' ]; then
|
|
96
96
|
sed -i '/^$/d' $DB
|
97
97
|
echo -e "\n#### Below list are updated" >> $DB
|
98
98
|
|
99
|
-
hpcloud servers | awk -F"\|" '{print $3","$6","$9","$7}' | awk -F, '{print $1$3$4$5}' >> $DB
|
99
|
+
hpcloud servers -a $2 | awk -F"\|" '{print $3","$6","$9","$7}' | awk -F, '{print $1$3$4$5}' >> $DB
|
100
100
|
echo -e "\033[1;32m$DB Updated\033[00m"
|
101
101
|
linenum=$(cat $DB | grep -E -n "#### Below list are updated" | awk -F: '{print $1}')
|
102
102
|
new_serversnum=$(tail -n +$linenum $DB | grep -E " .*\..* " | wc -l)
|
@@ -122,6 +122,7 @@ if [[ $1 =~ ([0-9]{1,3}\.){3}[0-9]{1,3} ]]; then
|
|
122
122
|
else
|
123
123
|
id=$1
|
124
124
|
node=$2
|
125
|
+
key=$3
|
125
126
|
|
126
127
|
if [ "$node" == "" ]; then
|
127
128
|
echo -e "${RED}Error, no server name sent.$RST"
|
@@ -140,7 +141,7 @@ else
|
|
140
141
|
echo -e "${RED}Error, the kit ${GRE}$node${RED} with id ${GRE}$id${RED} was not found.${RST}"
|
141
142
|
exit 1
|
142
143
|
fi
|
143
|
-
key=$(cat $DB | grep -iEw "$ip" | awk '{print $4}' | tr -d ' ')
|
144
|
+
#key=$(cat $DB | grep -iEw "$ip" | awk '{print $4}' | tr -d ' ')
|
144
145
|
message="$node.$id"
|
145
146
|
extended="($ip)"
|
146
147
|
|
@@ -155,7 +156,7 @@ if [ "$node" != "" ]; then
|
|
155
156
|
else
|
156
157
|
logname="$ip"
|
157
158
|
fi
|
158
|
-
key="$key_path$key.pem"
|
159
|
+
#key="$key_path$key.pem"
|
159
160
|
|
160
161
|
echo -e "Connecting to $GRE$message$RST using $BLU$key$RST $extended"
|
161
162
|
|
@@ -181,4 +182,4 @@ if [ "$is_init" == 'true' ]; then
|
|
181
182
|
fi
|
182
183
|
ssh -o StrictHostKeyChecking=no -o ServerAliveInterval=180 -i $key ubuntu@$ip | tee -a $logfile
|
183
184
|
echo -e "$RED══════════════════════════════════════════════════════════════════════════$RST"
|
184
|
-
echo -e "${GRE}Log file: ${RST}$logfile"
|
185
|
+
echo -e "${GRE}Log file: ${RST}$logfile"
|
data/spec/forj-config_spec.rb
CHANGED
@@ -29,6 +29,7 @@ include Logging
|
|
29
29
|
|
30
30
|
$FORJ_LOGGER=ForjLog.new('forj-rspec.log', Logger::FATAL)
|
31
31
|
|
32
|
+
|
32
33
|
describe "class: forj-config," do
|
33
34
|
context "when creating a new instance" do
|
34
35
|
|
@@ -45,13 +46,13 @@ describe "class: forj-config," do
|
|
45
46
|
end
|
46
47
|
|
47
48
|
it 'should be able to create a key/value in local config' do
|
48
|
-
@config.LocalSet(
|
49
|
-
expect(@config.LocalGet(
|
49
|
+
@config.LocalSet(:test1,'value')
|
50
|
+
expect(@config.LocalGet(:test1)).to eq('value')
|
50
51
|
end
|
51
52
|
|
52
53
|
it 'should be able to remove the previously created key/value from local config' do
|
53
|
-
@config.LocalDel(
|
54
|
-
expect(@config.exist?(
|
54
|
+
@config.LocalDel(:test1)
|
55
|
+
expect(@config.exist?(:test1)).to equal(false)
|
55
56
|
end
|
56
57
|
end
|
57
58
|
|
@@ -61,16 +62,16 @@ describe "class: forj-config," do
|
|
61
62
|
end
|
62
63
|
|
63
64
|
after(:all) do
|
64
|
-
@config.LocalDel(
|
65
|
+
@config.LocalDel(:test1)
|
65
66
|
@config.SaveConfig()
|
66
67
|
end
|
67
68
|
|
68
69
|
it 'should save a key/value in local config' do
|
69
|
-
@config.LocalSet(
|
70
|
+
@config.LocalSet(:test1,'value')
|
70
71
|
expect(@config.SaveConfig()).to equal(true)
|
71
72
|
|
72
73
|
oConfig=ForjConfig.new()
|
73
|
-
expect(@config.LocalGet(
|
74
|
+
expect(@config.LocalGet(:test1)).to eq('value')
|
74
75
|
end
|
75
76
|
|
76
77
|
end
|
@@ -81,7 +82,7 @@ describe "class: forj-config," do
|
|
81
82
|
if File.exists?('~/.forj/test.yaml')
|
82
83
|
File.delete(File.expand_path('~/.forj/test.yaml'))
|
83
84
|
end
|
84
|
-
File.open(File.expand_path('~/.forj/test1.yaml'), 'w+') { |file| file.write("default:\n") }
|
85
|
+
File.open(File.expand_path('~/.forj/test1.yaml'), 'w+') { |file| file.write(":default:\n") }
|
85
86
|
@config=ForjConfig.new('test.yaml')
|
86
87
|
@config2=ForjConfig.new('test1.yaml')
|
87
88
|
end
|
@@ -128,59 +129,72 @@ describe "class: forj-config," do
|
|
128
129
|
|
129
130
|
context 'from defaults,' do
|
130
131
|
it 'can get application defaults' do
|
131
|
-
expect(@config.get(
|
132
|
-
expect(@config.getAppDefault(
|
132
|
+
expect(@config.get(:maestro_url).class).to equal(String)
|
133
|
+
expect(@config.getAppDefault(:default, :maestro_url).class).to equal(String)
|
133
134
|
expect(@config.getAppDefault(:description, 'FORJ_HPC').class).to equal(String)
|
134
135
|
|
135
136
|
end
|
136
137
|
it 'can get Local defaults instead of application' do
|
137
|
-
expect(@config.LocalSet(
|
138
|
-
expect(@config.LocalGet(
|
139
|
-
expect(@config.get(
|
138
|
+
expect(@config.LocalSet(:maestro_url,'local')).to equal(true)
|
139
|
+
expect(@config.LocalGet(:maestro_url)).to eq('local')
|
140
|
+
expect(@config.get(:maestro_url)).to eq('local')
|
140
141
|
end
|
141
142
|
|
142
143
|
it 'can get runtime defaults instead of Local/application' do
|
143
|
-
expect(@config.set(
|
144
|
-
expect(@config.get(
|
145
|
-
expect(@config.LocalGet(
|
144
|
+
expect(@config.set(:maestro_url, 'runtime')).to equal(true)
|
145
|
+
expect(@config.get(:maestro_url)).to eq('runtime')
|
146
|
+
expect(@config.LocalGet(:maestro_url)).to eq('local')
|
146
147
|
end
|
147
148
|
|
148
149
|
it 'can get runtime defaults instead of application' do
|
149
|
-
expect(@config.LocalDel(
|
150
|
-
expect(@config.get(
|
151
|
-
expect(@config.LocalGet(
|
150
|
+
expect(@config.LocalDel(:maestro_url)).to equal(true)
|
151
|
+
expect(@config.get(:maestro_url)).to eq('runtime')
|
152
|
+
expect(@config.LocalGet(:maestro_url)).to equal(nil)
|
152
153
|
end
|
153
154
|
|
154
155
|
it 'can get defaults if no key' do
|
155
156
|
expect(@config.set(:test1, nil)).to equal(true)
|
156
157
|
expect(@config.get(:test1, nil, 'default')).to eq('default')
|
157
158
|
expect(@config.get(:test1, nil, nil)).to equal(nil)
|
158
|
-
expect(@config.set(
|
159
|
-
expect(@config.get(
|
159
|
+
expect(@config.set(:maestro_url,nil)).to equal(true)
|
160
|
+
expect(@config.get(:maestro_url)).to eq(@url)
|
160
161
|
end
|
161
162
|
end
|
162
163
|
|
163
164
|
context 'with intermediates,' do
|
164
165
|
before(:all) do
|
165
|
-
@yYAML1={
|
166
|
+
@yYAML1={ :maestro_url => 'url1' }
|
166
167
|
@aArray1=[]
|
167
|
-
@aArray1[0]={
|
168
|
+
@aArray1[0]={ :maestro_url => 'url2' }
|
168
169
|
@aArray1[1]=@yYAML1
|
169
170
|
@aArray2=[]
|
170
171
|
@aArray2[0] = @aArray1[1]
|
171
172
|
@aArray2[1] = @aArray1[0]
|
173
|
+
@aArray3=[]
|
174
|
+
@aArray3[0] = { :hash_1 => { :maestro_url => 'url3' }}
|
175
|
+
@aArray3[1] = { :hash_2 => { :keypair_name => 'nova' }}
|
176
|
+
@aArray4=[]
|
177
|
+
@aArray4[0] = { :hash_1 => { :keypair_name => 'nova' }}
|
178
|
+
@aArray4[1] = { :hash_2 => { :maestro_url => 'url4' }}
|
172
179
|
end
|
173
180
|
|
174
181
|
it 'can get data from one hash' do
|
175
|
-
expect(@config.get(
|
176
|
-
@config.set(
|
177
|
-
expect(@config.get(
|
182
|
+
expect(@config.get(:maestro_url, @yYAML1)).to eq('url1')
|
183
|
+
@config.set(:maestro_url, 'runtime')
|
184
|
+
expect(@config.get(:maestro_url, @yYAML1)).to eq('runtime')
|
178
185
|
end
|
179
186
|
|
180
|
-
it 'can get data from
|
187
|
+
it 'can get data from array of hash' do
|
188
|
+
@config.set(:maestro_url, nil)
|
189
|
+
expect(@config.get(:maestro_url, @aArray1)).to eq('url2')
|
190
|
+
expect(@config.get(:maestro_url, @aArray2)).to eq('url1')
|
191
|
+
end
|
192
|
+
it 'can get data from array of hashes' do
|
181
193
|
@config.set('maestro_url', nil)
|
182
|
-
expect(@config.
|
183
|
-
expect(@config.
|
194
|
+
expect(@config.exist?(:maestro_url, @aArray3)).to eq('hash_1')
|
195
|
+
expect(@config.exist?(:maestro_url, @aArray4)).to eq('hash_2')
|
196
|
+
expect(@config.get(:maestro_url, @aArray3)).to eq('url3')
|
197
|
+
expect(@config.get(:maestro_url, @aArray4)).to eq('url4')
|
184
198
|
end
|
185
199
|
end
|
186
200
|
end
|
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.
|
4
|
+
version: 0.0.41
|
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-09-
|
11
|
+
date: 2014-09-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|