mirror of
https://github.com/xcat2/confluent.git
synced 2026-04-13 04:11:31 +00:00
Add mechanism for configurable ikvm response
This allows for more flexible ikvm handling with newer pyghmi.
This commit is contained in:
@@ -434,7 +434,14 @@ def _init_core():
|
||||
'pluginattrs': ['hardwaremanagement.method'],
|
||||
'default': 'ipmi',
|
||||
}),
|
||||
'ikvm': PluginRoute({'handler': 'ikvm'}),
|
||||
'ikvm': PluginRoute({
|
||||
'pluginattrs': ['hardwaremanagement.method'],
|
||||
'default': 'ipmi',
|
||||
}),
|
||||
'ikvm_methods': PluginRoute({
|
||||
'pluginattrs': ['hardwaremanagement.method'],
|
||||
'default': 'ipmi',
|
||||
}),
|
||||
},
|
||||
'description': PluginRoute({
|
||||
'pluginattrs': ['hardwaremanagement.method'],
|
||||
|
||||
@@ -952,7 +952,7 @@ class InputIdentImage(ConfluentInputMessage):
|
||||
|
||||
class InputIkvmParams(ConfluentInputMessage):
|
||||
keyname = 'method'
|
||||
valid_values = ['unix', 'wss']
|
||||
valid_values = ['unix', 'wss', 'url']
|
||||
|
||||
class InputIdentifyMessage(ConfluentInputMessage):
|
||||
valid_values = set([
|
||||
|
||||
@@ -38,6 +38,7 @@ ipmicommand = eventlet.import_patched('pyghmi.ipmi.command')
|
||||
import socket
|
||||
import ssl
|
||||
import traceback
|
||||
import confluent.vinzmanager as vinzmanager
|
||||
|
||||
|
||||
if not hasattr(ssl, 'SSLEOFError'):
|
||||
@@ -175,6 +176,7 @@ def sanitize_invdata(indata):
|
||||
|
||||
class IpmiCommandWrapper(ipmicommand.Command):
|
||||
def __init__(self, node, cfm, **kwargs):
|
||||
self.confluentbmcname = kwargs['bmc']
|
||||
self.cfm = cfm
|
||||
self.node = node
|
||||
self.sensormap = {}
|
||||
@@ -592,6 +594,10 @@ class IpmiHandler(object):
|
||||
self.handle_servicedata_fetch()
|
||||
elif self.element == ['description']:
|
||||
self.handle_description()
|
||||
elif self.element == ['console', 'ikvm_methods']:
|
||||
self.handle_ikvm_methods()
|
||||
elif self.element == ['console', 'ikvm']:
|
||||
self.handle_ikvm()
|
||||
else:
|
||||
raise Exception('Not Implemented')
|
||||
|
||||
@@ -1610,6 +1616,26 @@ class IpmiHandler(object):
|
||||
dsc = self.ipmicmd.get_description()
|
||||
self.output.put(msg.KeyValueData(dsc, self.node))
|
||||
|
||||
def handle_ikvm_methods(self):
|
||||
dsc = self.ipmicmd.get_ikvm_methods()
|
||||
dsc = {'ikvm_methods': dsc}
|
||||
self.output.put(msg.KeyValueData(dsc, self.node))
|
||||
|
||||
def handle_ikvm(self):
|
||||
methods = self.ipmicmd.get_ikvm_methods()
|
||||
if 'openbmc' in methods:
|
||||
url = vinzmanager.get_url(self.node, self.inputdata)
|
||||
self.output.put(msg.ChildCollection(url))
|
||||
return
|
||||
launchdata = self.ipmicmd.get_ikvm_launchdata()
|
||||
if 'url' in launchdata and not launchdata['url'].startswith('https://'):
|
||||
mybmc = self.ipmicmd.confluentbmcname
|
||||
if ':' in mybmc and not '[' in mybmc:
|
||||
mybmc = '[{}]'.format(mybmc)
|
||||
launchdata['url'] = 'https://{}{}'.format(mybmc, launchdata['url'])
|
||||
self.output.put(msg.KeyValueData(launchdata, self.node))
|
||||
|
||||
|
||||
def handle_graphical_console(self):
|
||||
args = self.ipmicmd.get_graphical_console()
|
||||
m = msg.GraphicalConsole(self.node, *args)
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import confluent.vinzmanager as vinzmanager
|
||||
import confluent.exceptions as exc
|
||||
import confluent.firmwaremanager as firmwaremanager
|
||||
import confluent.messages as msg
|
||||
@@ -153,6 +154,7 @@ def sanitize_invdata(indata):
|
||||
|
||||
class IpmiCommandWrapper(ipmicommand.Command):
|
||||
def __init__(self, node, cfm, **kwargs):
|
||||
self.confluentbmcname = kwargs['bmc']
|
||||
#kwargs['pool'] = eventlet.greenpool.GreenPool(4)
|
||||
#Some BMCs at the time of this writing crumble under the weight
|
||||
#of 4 concurrent requests. For now give up on this optimization.
|
||||
@@ -449,6 +451,10 @@ class IpmiHandler(object):
|
||||
self.handle_servicedata_fetch()
|
||||
elif self.element == ['description']:
|
||||
self.handle_description()
|
||||
elif self.element == ['console', 'ikvm_methods']:
|
||||
self.handle_ikvm_methods()
|
||||
elif self.element == ['console', 'ikvm']:
|
||||
self.handle_ikvm()
|
||||
else:
|
||||
raise Exception('Not Implemented')
|
||||
|
||||
@@ -1467,6 +1473,25 @@ class IpmiHandler(object):
|
||||
dsc = self.ipmicmd.get_description()
|
||||
self.output.put(msg.KeyValueData(dsc, self.node))
|
||||
|
||||
def handle_ikvm_methods(self):
|
||||
dsc = self.ipmicmd.get_ikvm_methods()
|
||||
dsc = {'ikvm_methods': dsc}
|
||||
self.output.put(msg.KeyValueData(dsc, self.node))
|
||||
|
||||
def handle_ikvm(self):
|
||||
methods = self.ipmicmd.get_ikvm_methods()
|
||||
if 'openbmc' in methods:
|
||||
url = vinzmanager.get_url(self.node, self.inputdata)
|
||||
self.output.put(msg.ChildCollection(url))
|
||||
return
|
||||
launchdata = self.ipmicmd.get_ikvm_launchdata()
|
||||
if 'url' in launchdata and not launchdata['url'].startswith('https://'):
|
||||
mybmc = self.ipmicmd.confluentbmcname
|
||||
if ':' in mybmc and not '[' in mybmc:
|
||||
mybmc = '[{}]'.format(mybmc)
|
||||
launchdata['url'] = 'https://{}{}'.format(mybmc, launchdata['url'])
|
||||
self.output.put(msg.KeyValueData(launchdata, self.node))
|
||||
|
||||
|
||||
def _str_health(health):
|
||||
if isinstance(health, str):
|
||||
|
||||
Reference in New Issue
Block a user