mirror of
https://github.com/xcat2/confluent.git
synced 2026-09-29 00:31:09 +00:00
Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 20457bbe37 | |||
| 206a79a976 | |||
| 99f9e852da | |||
| 6ab176218e | |||
| 5ccfa36da6 | |||
| 5b1e144d32 | |||
| 4722c3ec92 |
@@ -90,6 +90,13 @@ class NodeHandler(bmchandler.NodeHandler):
|
||||
smmip = smmip[-1][0]
|
||||
if smmip and ':' in smmip:
|
||||
raise exc.NotImplementedException('IPv6 not supported')
|
||||
wc.request('POST', '/data', 'get=hostname')
|
||||
rsp = wc.getresponse()
|
||||
rspdata = fromstring(util.stringify(rsp.read()))
|
||||
currip = rspdata.find('netConfig').find('ifConfigEntries').find(
|
||||
'ifConfig').find('v4IPAddr').text
|
||||
if currip == smmip:
|
||||
return
|
||||
netconfig = netutil.get_nic_config(cfg, nodename, ip=smmip)
|
||||
netmask = netutil.cidr_to_mask(netconfig['prefix'])
|
||||
setdata = 'set=ifIndex:0,v4DHCPEnabled:0,v4IPAddr:{0},v4NetMask:{1}'.format(smmip, netmask)
|
||||
|
||||
@@ -250,6 +250,8 @@ class NodeRange(object):
|
||||
return nodes
|
||||
if ':' in element: # : range for less ambiguity
|
||||
return self.expandrange(element, ':')
|
||||
elif '..' in element:
|
||||
return self.expandrange(element, '..')
|
||||
elif '-' in element:
|
||||
return self.expandrange(element, '-')
|
||||
elif '+' in element:
|
||||
|
||||
@@ -1035,6 +1035,8 @@ class IpmiHandler(object):
|
||||
return self._create_storage(storelem)
|
||||
|
||||
def _delete_storage(self, storelem):
|
||||
if len(storelem) < 2:
|
||||
storelem.append('')
|
||||
if len(storelem) < 2 or storelem[0] != 'volumes':
|
||||
raise exc.InvalidArgumentException('Must target a specific volume')
|
||||
volname = storelem[-1]
|
||||
|
||||
@@ -894,6 +894,8 @@ class IpmiHandler(object):
|
||||
return self._create_storage(storelem)
|
||||
|
||||
def _delete_storage(self, storelem):
|
||||
if len(storelem) < 2:
|
||||
storelem.append('')
|
||||
if len(storelem) < 2 or storelem[0] != 'volumes':
|
||||
raise exc.InvalidArgumentException('Must target a specific volume')
|
||||
volname = storelem[-1]
|
||||
|
||||
@@ -99,8 +99,10 @@ class SshShell(conapi.Console):
|
||||
def recvdata(self):
|
||||
while self.connected:
|
||||
pendingdata = self.shell.recv(8192)
|
||||
if pendingdata == '':
|
||||
self.datacallback(conapi.ConsoleEvent.Disconnect)
|
||||
if not pendingdata:
|
||||
self.ssh.close()
|
||||
if self.datacallback:
|
||||
self.datacallback(conapi.ConsoleEvent.Disconnect)
|
||||
return
|
||||
self.datacallback(pendingdata)
|
||||
|
||||
@@ -110,7 +112,7 @@ class SshShell(conapi.Console):
|
||||
# that would rather not use the nodename as anything but an opaque
|
||||
# identifier
|
||||
self.datacallback = callback
|
||||
if self.username is not '':
|
||||
if self.username is not b'':
|
||||
self.logon()
|
||||
else:
|
||||
self.inputmode = 0
|
||||
@@ -126,12 +128,14 @@ class SshShell(conapi.Console):
|
||||
password=self.password, allow_agent=False,
|
||||
look_for_keys=False)
|
||||
except paramiko.AuthenticationException:
|
||||
self.ssh.close()
|
||||
self.inputmode = 0
|
||||
self.username = b''
|
||||
self.password = b''
|
||||
self.datacallback('\r\nlogin as: ')
|
||||
return
|
||||
except paramiko.ssh_exception.NoValidConnectionsError as e:
|
||||
self.ssh.close()
|
||||
self.datacallback(str(e))
|
||||
self.inputmode = 0
|
||||
self.username = b''
|
||||
@@ -139,6 +143,7 @@ class SshShell(conapi.Console):
|
||||
self.datacallback('\r\nlogin as: ')
|
||||
return
|
||||
except cexc.PubkeyInvalid as pi:
|
||||
self.ssh.close()
|
||||
self.keyaction = ''
|
||||
self.candidatefprint = pi.fingerprint
|
||||
self.datacallback(pi.message)
|
||||
@@ -148,6 +153,7 @@ class SshShell(conapi.Console):
|
||||
self.datacallback('\r\nEnter "disconnect" or "accept": ')
|
||||
return
|
||||
except paramiko.SSHException as pi:
|
||||
self.ssh.close()
|
||||
self.inputmode = -2
|
||||
warn = str(pi)
|
||||
if warnhostkey:
|
||||
@@ -169,11 +175,11 @@ class SshShell(conapi.Console):
|
||||
self.datacallback(conapi.ConsoleEvent.Disconnect)
|
||||
return
|
||||
elif self.inputmode == -1:
|
||||
while len(data) and data[0] == b'\x7f' and len(self.keyaction):
|
||||
while len(data) and data[0:1] == b'\x7f' and len(self.keyaction):
|
||||
self.datacallback('\b \b') # erase previously echoed value
|
||||
self.keyaction = self.keyaction[:-1]
|
||||
data = data[1:]
|
||||
while len(data) and data[0] == b'\x7f':
|
||||
while len(data) and data[0:1] == b'\x7f':
|
||||
data = data[1:]
|
||||
while b'\x7f' in data:
|
||||
delidx = data.index(b'\x7f')
|
||||
@@ -195,11 +201,11 @@ class SshShell(conapi.Console):
|
||||
elif len(data) > 0:
|
||||
self.datacallback(data)
|
||||
elif self.inputmode == 0:
|
||||
while len(data) and data[0] == b'\x7f' and len(self.username):
|
||||
while len(data) and data[0:1] == b'\x7f' and len(self.username):
|
||||
self.datacallback('\b \b') # erase previously echoed value
|
||||
self.username = self.username[:-1]
|
||||
data = data[1:]
|
||||
while len(data) and data[0] == b'\x7f':
|
||||
while len(data) and data[0:1] == b'\x7f':
|
||||
data = data[1:]
|
||||
while b'\x7f' in data:
|
||||
delidx = data.index(b'\x7f')
|
||||
@@ -216,7 +222,7 @@ class SshShell(conapi.Console):
|
||||
# echo back typed data
|
||||
self.datacallback(data)
|
||||
elif self.inputmode == 1:
|
||||
while len(data) > 0 and data[0] == b'\x7f':
|
||||
while len(data) > 0 and data[0:1] == b'\x7f':
|
||||
self.password = self.password[:-1]
|
||||
data = data[1:]
|
||||
while b'\x7f' in data:
|
||||
@@ -237,4 +243,4 @@ class SshShell(conapi.Console):
|
||||
|
||||
def create(nodes, element, configmanager, inputdata):
|
||||
if len(nodes) == 1:
|
||||
return SshShell(nodes[0], configmanager)
|
||||
return SshShell(nodes[0], configmanager)
|
||||
|
||||
@@ -111,6 +111,8 @@ class ShellSession(consoleserver.ConsoleSession):
|
||||
|
||||
def destroy(self):
|
||||
try:
|
||||
activesessions[(self.configmanager.tenant, self.node,
|
||||
self.username)][self.sessionid].close()
|
||||
del activesessions[(self.configmanager.tenant, self.node,
|
||||
self.username)][self.sessionid]
|
||||
except KeyError:
|
||||
|
||||
@@ -472,11 +472,14 @@ class SockApi(object):
|
||||
|
||||
def watch_for_cert(self):
|
||||
libc = ctypes.CDLL(ctypes.util.find_library('c'))
|
||||
watcher = libc.inotify_init()
|
||||
watcher = libc.inotify_init1(os.O_NONBLOCK)
|
||||
if libc.inotify_add_watch(watcher, b'/etc/confluent/', 0x100) > -1:
|
||||
while True:
|
||||
select.select((watcher,), (), (), 86400)
|
||||
os.read(watcher, 1024)
|
||||
try:
|
||||
os.read(watcher, 1024)
|
||||
except Exception:
|
||||
pass
|
||||
if self.should_run_remoteapi():
|
||||
os.close(watcher)
|
||||
self.start_remoteapi()
|
||||
|
||||
Reference in New Issue
Block a user