Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1026 bootstrap fail #1032

Merged
merged 5 commits into from
Nov 30, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions src/rockstor/scripts/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,24 +33,33 @@


def main():
aw = APIWrapper()
device_scan()

try:
device_scan()
except Exception, e:
print ('BTRFS device scan failed due to an exception. This indicates '
'a serious problem. Aborting. Exception: %s' % e.__str__())
sys.exit(1)
print('BTRFS device scan complete')

num_attempts = 0
while True:
try:
aw = APIWrapper()
aw.api_call('network')
aw.api_call('commands/bootstrap', calltype='post')
break
except requests.exceptions.ConnectionError, e:
except Exception, e:
#Retry on every exception, primarily because of django-oauth related
#code behaving unpredictably while setting tokens. Retrying is a
#decent workaround for now(11302015).
if (num_attempts > 15):
print('Max attempts(15) reached. Connection errors persist. '
'Failed to bootstrap. Error: %s' % e.__str__())
sys.exit(1)
print('Connection error while bootstrapping. This could be because '
print('Exception occured while bootstrapping. This could be because '
'rockstor.service is still starting up. will wait 2 seconds '
'and try again.')
'and try again. Exception: %s' % e.__str__())
time.sleep(2)
num_attempts += 1
print('Bootstrapping complete')
Expand Down
6 changes: 3 additions & 3 deletions src/rockstor/storageadmin/views/disk_smart.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def get(self, *args, **kwargs):
@transaction.atomic
def _info(disk):
attributes = extended_info(disk.name)
capabilities = capabilities(disk.name)
cap = capabilities(disk.name)
e_summary, e_lines = error_logs(disk.name)
smartid = info(disk.name)
test_d, log_lines = test_logs(disk.name)
Expand All @@ -80,8 +80,8 @@ def _info(disk):
atype=t[6], updated=t[7], failed=t[8],
raw_value=t[9])
sa.save()
for c in capabilities:
t = capabilities[c]
for c in cap:
t = cap[c]
SMARTCapability(info=si, name=c, flag=t[0], capabilities=t[1]).save()
for enum in sorted(e_summary.keys(), reverse=True):
l = e_summary[enum]
Expand Down
20 changes: 10 additions & 10 deletions src/rockstor/storageadmin/views/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,18 @@ class NetworkMixin(object):

@staticmethod
def _update_ni_obj(nio, values):
nio.dname = values.get('dname', None)
nio.mac = values.get('mac', None)
nio.dname = values.get('dname', nio.dname)
nio.mac = values.get('mac', nio.mac)
nio.method = values.get('method', 'manual')
nio.autoconnect = values.get('autoconnect', 'no')
nio.netmask = values.get('netmask', None)
nio.ipaddr = values.get('ipaddr', None)
nio.gateway = values.get('gateway', None)
nio.dns_servers = values.get('dns_servers', None)
nio.ctype = values.get('ctype', None)
nio.dtype = values.get('dtype', None)
nio.dspeed = values.get('dspeed', None)
nio.state = values.get('state', None)
nio.netmask = values.get('netmask', nio.netmask)
nio.ipaddr = values.get('ipaddr', nio.ipaddr)
nio.gateway = values.get('gateway', nio.gateway)
nio.dns_servers = values.get('dns_servers', nio.dns_servers)
nio.ctype = values.get('ctype', nio.ctype)
nio.dtype = values.get('dtype', nio.dtype)
nio.dspeed = values.get('dspeed', nio.dspeed)
nio.state = values.get('state', nio.state)
return nio

@staticmethod
Expand Down
27 changes: 17 additions & 10 deletions src/rockstor/system/osi.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,16 @@ def inplace_replace(of, nf, regex, nl):

def run_command(cmd, shell=False, stdout=subprocess.PIPE,
stderr=subprocess.PIPE, throw=True, log=False):
p = subprocess.Popen(cmd, shell=shell, stdout=stdout, stderr=stderr)
out, err = p.communicate()
out = out.split('\n')
err = err.split('\n')
rc = p.returncode
try:
p = subprocess.Popen(cmd, shell=shell, stdout=stdout, stderr=stderr)
out, err = p.communicate()
out = out.split('\n')
err = err.split('\n')
rc = p.returncode
except Exception, e:
msg = ('Exception while running command(%s): %s' % (cmd, e.__str__()))
raise Exception(msg)

if (rc != 0):
if (log):
e_msg = ('non-zero code(%d) returned by command: %s. output: %s error:'
Expand Down Expand Up @@ -216,17 +221,18 @@ def config_network_device(name, dtype='ethernet', method='auto', ipaddr=None,
add_cmd = [NMCLI, 'c', 'add', 'type', dtype, 'con-name', name, 'ifname', name]
if (method == 'manual'):
add_cmd.extend(['ip4', '%s/%s' % (ipaddr, netmask)])
if (gateway is not None):
if (gateway is not None and len(gateway.strip()) > 0):
add_cmd.extend(['gw4', gateway])
run_command(add_cmd)
#3. modify with extra options like dns servers
if (method == 'manual'):
mod_cmd = [NMCLI, 'c', 'mod', name, ]
if (dns_servers is not None):
if (dns_servers is not None and len(dns_servers.strip()) > 0):
mod_cmd.extend(['ipv4.dns', dns_servers])
if (autoconnect == 'no'):
mod_cmd.extend(['connection.autoconnect', 'no'])
run_command(mod_cmd)
if (len(mod_cmd) > 4):
run_command(mod_cmd)
#wait for the interface to be activated
num_attempts = 0
while True:
Expand All @@ -237,7 +243,7 @@ def config_network_device(name, dtype='ethernet', method='auto', ipaddr=None,
else:
break
if (num_attempts > 30):
msg = ('Waited more than %s seconds for connection(%s) state to '
msg = ('Waited %s seconds for connection(%s) state to '
'be activated but it has not. Giving up. current state: %s'
% (num_attempts, name, state))
raise Exception(msg)
Expand Down Expand Up @@ -327,7 +333,8 @@ def get_net_config(all=False, name=None):
dname = o[i].strip().split(':')[1]
config[dname] = {'dname': dname,
'mac': o[i+2].strip().split('GENERAL.HWADDR:')[1],
'name': o[i+5].strip().split('GENERAL.CONNECTION:')[1],}
'name': o[i+5].strip().split('GENERAL.CONNECTION:')[1],
'dtype': 'ethernet', }
for device in config:
config[device].update(net_config_helper(config[device]['name']))
if (config[device]['name'] == '--'):
Expand Down