Skip to content

Commit 24434be

Browse files
committed
Revert "Merge pull request #2084 from shapeblue/passwd-speedup"
This reverts commit 48f413a, reversing changes made to 5f35c15.
1 parent dab9795 commit 24434be

5 files changed

Lines changed: 68 additions & 91 deletions

File tree

systemvm/patches/debian/config/opt/cloud/bin/configure.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,36 @@
4545
from cs.CsStaticRoutes import CsStaticRoutes
4646

4747

48+
class CsPassword(CsDataBag):
49+
50+
TOKEN_FILE="/tmp/passwdsrvrtoken"
51+
52+
def process(self):
53+
for item in self.dbag:
54+
if item == "id":
55+
continue
56+
self.__update(item, self.dbag[item])
57+
58+
def __update(self, vm_ip, password):
59+
token = ""
60+
try:
61+
tokenFile = open(self.TOKEN_FILE)
62+
token = tokenFile.read()
63+
except IOError:
64+
logging.debug("File %s does not exist" % self.TOKEN_FILE)
65+
66+
ips_cmd = "ip addr show | grep inet | awk '{print $2}'"
67+
ips = CsHelper.execute(ips_cmd)
68+
for ip in ips:
69+
server_ip = ip.split('/')[0]
70+
proc = CsProcess(['/opt/cloud/bin/passwd_server_ip.py', server_ip])
71+
if proc.find():
72+
update_command = 'curl --header "DomU_Request: save_password" "http://{SERVER_IP}:8080/" -F "ip={VM_IP}" -F "password={PASSWORD}" ' \
73+
'-F "token={TOKEN}" >/dev/null 2>/dev/null &'.format(SERVER_IP=server_ip, VM_IP=vm_ip, PASSWORD=password, TOKEN=token)
74+
result = CsHelper.execute(update_command)
75+
logging.debug("Update password server result ==> %s" % result)
76+
77+
4878
class CsAcl(CsDataBag):
4979
"""
5080
Deal with Network acls

systemvm/patches/debian/config/opt/cloud/bin/cs/CsVmPassword.py

Lines changed: 0 additions & 61 deletions
This file was deleted.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
from pprint import pprint
19+
from netaddr import *
20+
21+
22+
def merge(dbag, data):
23+
"""
24+
Track vm passwords
25+
"""
26+
dbag[data['ip_address']] = data['password']
27+
return dbag

systemvm/patches/debian/config/opt/cloud/bin/merge.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import cs_ip
2424
import cs_guestnetwork
2525
import cs_cmdline
26+
import cs_vmp
2627
import cs_network_acl
2728
import cs_firewallrules
2829
import cs_loadbalancer
@@ -35,6 +36,8 @@
3536
import cs_vpnusers
3637
import cs_staticroutes
3738

39+
from pprint import pprint
40+
3841

3942
class DataBag:
4043

@@ -103,6 +106,8 @@ def process(self):
103106
dbag = self.processGuestNetwork(self.db.getDataBag())
104107
elif self.qFile.type == 'cmdline':
105108
dbag = self.processCL(self.db.getDataBag())
109+
elif self.qFile.type == 'vmpassword':
110+
dbag = self.processVMpassword(self.db.getDataBag())
106111
elif self.qFile.type == 'networkacl':
107112
dbag = self.process_network_acl(self.db.getDataBag())
108113
elif self.qFile.type == 'firewallrules':
@@ -184,6 +189,9 @@ def process_monitorservice(self, dbag):
184189
def process_staticroutes(self, dbag):
185190
return cs_staticroutes.merge(dbag, self.qFile.data)
186191

192+
def processVMpassword(self, dbag):
193+
return cs_vmp.merge(dbag, self.qFile.data)
194+
187195
def processForwardingRules(self, dbag):
188196
# to be used by both staticnat and portforwarding
189197
return cs_forwardingrules.merge(dbag, self.qFile.data)
@@ -268,21 +276,13 @@ class QueueFile:
268276
fileName = ''
269277
configCache = "/var/cache/cloud"
270278
keep = True
271-
do_merge = True
272279
data = {}
273280

274-
def update_databag(self):
275-
if self.do_merge:
276-
logging.info("Merging because do_merge is %s" % self.do_merge)
277-
updateDataBag(self)
278-
else:
279-
logging.info("Not merging because do_merge is %s" % self.do_merge)
280-
281281
def load(self, data):
282282
if data is not None:
283283
self.data = data
284284
self.type = self.data["type"]
285-
self.update_databag()
285+
proc = updateDataBag(self)
286286
return
287287
fn = self.configCache + '/' + self.fileName
288288
try:
@@ -297,7 +297,7 @@ def load(self, data):
297297
self.__moveFile(fn, self.configCache + "/processed")
298298
else:
299299
os.remove(fn)
300-
self.update_databag()
300+
proc = updateDataBag(self)
301301

302302
def setFile(self, name):
303303
self.fileName = name

systemvm/patches/debian/config/opt/cloud/bin/update_config.py

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
import os.path
2626
import configure
2727
import json
28-
from cs.CsVmPassword import *
2928

3029
logging.basicConfig(filename='/var/log/cloud.log', level=logging.INFO, format='%(asctime)s %(filename)s %(funcName)s:%(lineno)d %(message)s')
3130

@@ -46,31 +45,17 @@ def finish_config():
4645
sys.exit(returncode)
4746

4847

49-
def process(do_merge=True):
48+
def process_file():
5049
print "[INFO] Processing JSON file %s" % sys.argv[1]
5150
qf = QueueFile()
5251
qf.setFile(sys.argv[1])
53-
qf.do_merge = do_merge
5452
qf.load(None)
55-
return qf
56-
57-
58-
def process_file():
59-
print "[INFO] process_file"
60-
qf = process()
6153
# These can be safely deferred, dramatically speeding up loading times
6254
if not (os.environ.get('DEFER_CONFIG', False) and sys.argv[1] in ('vm_dhcp_entry.json', 'vm_metadata.json')):
6355
# Converge
6456
finish_config()
6557

6658

67-
def process_vmpasswd():
68-
print "[INFO] process_vmpassword"
69-
qf = process(False)
70-
print "[INFO] Sending password to password server"
71-
CsPassword(qf.getData())
72-
73-
7459
def is_guestnet_configured(guestnet_dict, keys):
7560

7661
existing_keys = []
@@ -152,10 +137,6 @@ def is_guestnet_configured(guestnet_dict, keys):
152137
else:
153138
print "[INFO] update_config.py :: No GuestNetwork configured yet. Configuring first one now."
154139
process_file()
155-
# Bypass saving passwords and running full config/convergence, just feed passwd to passwd server and stop
156-
elif sys.argv[1].startswith("vm_password.json"):
157-
print "[INFO] update_config.py :: Processing incoming vm_passwd file => %s" % sys.argv[1]
158-
process_vmpasswd()
159140
else:
160141
print "[INFO] update_config.py :: Processing incoming file => %s" % sys.argv[1]
161142
process_file()

0 commit comments

Comments
 (0)