Fix PEP8 issues
Change-Id: I6cfebccba269c21e752307966093cfb216b81c2c
This commit is contained in:
parent
cf0635f306
commit
ae3df717de
10
createDB.py
10
createDB.py
|
@ -1,5 +1,9 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
"""
|
||||
Create the MoltenIron user in mysql and grant it access.
|
||||
"""
|
||||
|
||||
# Copyright (c) 2016 IBM Corporation.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
|
@ -15,16 +19,20 @@
|
|||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# pylint: disable-msg=C0103
|
||||
|
||||
import os
|
||||
import sys
|
||||
import yaml
|
||||
|
||||
|
||||
def SQL(query):
|
||||
print(os.popen("mysql -u root -p --execute=\"" + query + "\"").read())
|
||||
"""Perform a mysql command"""
|
||||
print os.popen("mysql -u root -p --execute=\"" + query + "\"").read()
|
||||
|
||||
|
||||
def main():
|
||||
"""The main routine"""
|
||||
path = sys.argv[0]
|
||||
dirs = path.split("/")
|
||||
newPath = "/".join(dirs[:-1]) + "/"
|
||||
|
|
|
@ -1,5 +1,10 @@
|
|||
#! /usr/bin/env python
|
||||
|
||||
"""
|
||||
This is the MoltenIron Command Line client that speaks to
|
||||
a MoltenIron server.
|
||||
"""
|
||||
|
||||
# Copyright (c) 2016 IBM Corporation.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
|
@ -15,21 +20,26 @@
|
|||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# pylint: disable-msg=C0103
|
||||
# pylint: disable=redefined-outer-name
|
||||
|
||||
import argparse
|
||||
import httplib
|
||||
import json
|
||||
import sys
|
||||
import os
|
||||
import yaml
|
||||
import argparse
|
||||
|
||||
DEBUG = False
|
||||
|
||||
|
||||
# Create a decorator pattern that maintains a registry
|
||||
def makeRegistrar():
|
||||
"""Decorator that keeps track of tagged functions."""
|
||||
registry = {}
|
||||
|
||||
def registrar(func):
|
||||
"""Store the function pointer."""
|
||||
registry[func.__name__] = func
|
||||
# normally a decorator returns a wrapped function,
|
||||
# but here we return func unmodified, after registering it
|
||||
|
@ -42,6 +52,7 @@ command = makeRegistrar()
|
|||
|
||||
|
||||
class MoltenIron(object):
|
||||
"""This is the MoltenIron client object."""
|
||||
|
||||
def __init__(self):
|
||||
self.conf = None
|
||||
|
@ -51,15 +62,17 @@ class MoltenIron(object):
|
|||
self.response_str = None
|
||||
self.response_json = None
|
||||
|
||||
def setup_conf(self, conf):
|
||||
""" """
|
||||
self.conf = conf
|
||||
def setup_conf(self, _conf):
|
||||
"""Sets the class variable to what is passed in. """
|
||||
self.conf = _conf
|
||||
|
||||
def setup_argv(self, argv):
|
||||
self.argv = argv
|
||||
def setup_argv(self, _argv):
|
||||
"""Sets the class variable to what is passed in. """
|
||||
self.argv = _argv
|
||||
|
||||
def setup_parser(self, parser):
|
||||
self.parser = parser
|
||||
def setup_parser(self, _parser):
|
||||
"""Sets the class variable to what is passed in. """
|
||||
self.parser = _parser
|
||||
|
||||
def _setup_response(self):
|
||||
""" """
|
||||
|
@ -291,7 +304,7 @@ class MoltenIron(object):
|
|||
if __name__ == "__main__":
|
||||
mi = MoltenIron()
|
||||
|
||||
parser = argparse.ArgumentParser(description="Molteniron command line tool")
|
||||
parser = argparse.ArgumentParser(description="Molteniron CLI tool")
|
||||
parser.add_argument("-c",
|
||||
"--conf-dir",
|
||||
action="store",
|
||||
|
@ -326,12 +339,12 @@ if __name__ == "__main__":
|
|||
mi.setup_argv(args)
|
||||
mi.setup_parser(parser)
|
||||
|
||||
print(mi.get_response())
|
||||
print mi.get_response()
|
||||
|
||||
try:
|
||||
rc = mi.get_response_map()['status']
|
||||
except KeyError:
|
||||
print("Error: Server returned: %s" % (mi.get_response_map(),))
|
||||
print "Error: Server returned: %s" % (mi.get_response_map(),)
|
||||
rc = 444
|
||||
|
||||
if rc == 200:
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
"""
|
||||
This is a helper program for the MoltenIron server.
|
||||
"""
|
||||
|
||||
# Copyright (c) 2016 IBM Corporation.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
|
@ -15,6 +19,9 @@
|
|||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# pylint: disable-msg=C0103
|
||||
# pylint: disable=redefined-outer-name
|
||||
|
||||
import argparse
|
||||
import sys
|
||||
import os
|
||||
|
@ -27,16 +34,22 @@ PID = "/var/run/moltenirond.pid"
|
|||
YAML_CONF = "/usr/local/etc/molteniron/conf.yaml"
|
||||
ERROR_LOGFILE = "/tmp/MoltenIron-error-logfile"
|
||||
|
||||
|
||||
class MoltenIronPIDNotFound(RuntimeError):
|
||||
"""os.path.isfile() error: The PID file does not exist"""
|
||||
|
||||
|
||||
class MoltenIronKillError(RuntimeError):
|
||||
"""os.kill() error"""
|
||||
|
||||
|
||||
class MoltenIronReadLinesError(RuntimeError):
|
||||
"""fobj.readlines() error"""
|
||||
|
||||
|
||||
def get_moltenirond_pid():
|
||||
"""Return the PID of the MoltenIron server process."""
|
||||
|
||||
if not os.path.isfile(PID):
|
||||
raise MoltenIronPIDNotFound("isfile error %s" % (PID, ))
|
||||
|
||||
|
@ -55,17 +68,24 @@ def get_moltenirond_pid():
|
|||
except Exception as e:
|
||||
raise MoltenIronReadLinesError("readlines error: %s" % (e, ))
|
||||
|
||||
|
||||
def moltenirond_main():
|
||||
"""This is the main routine for the MoltenIron server."""
|
||||
|
||||
with open(YAML_CONF, "r") as fobj:
|
||||
conf = yaml.load(fobj)
|
||||
|
||||
moltenirond.listener(conf)
|
||||
|
||||
|
||||
def log_error(s):
|
||||
"""Log an error to stderr and to a file."""
|
||||
|
||||
with open(ERROR_LOGFILE, "a+") as fobj:
|
||||
fobj.writelines(s + "\n")
|
||||
print >> sys.stderr, s
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
parser = argparse.ArgumentParser(description="Molteniron daemon helper")
|
||||
|
@ -121,16 +141,22 @@ if __name__ == "__main__":
|
|||
pid = get_moltenirond_pid()
|
||||
except MoltenIronPIDNotFound:
|
||||
pid = -1
|
||||
|
||||
if pid > 0:
|
||||
log_error("Error: The daemon is already running")
|
||||
sys.exit(1)
|
||||
|
||||
daemon = Daemonize(app="moltenirond",
|
||||
pid=PID,
|
||||
action=moltenirond_main)
|
||||
|
||||
daemon.start()
|
||||
elif args.command[0].upper().lower() == "stop":
|
||||
try:
|
||||
pid = get_moltenirond_pid()
|
||||
except MoltenIronPIDNotFound:
|
||||
pid = -1
|
||||
|
||||
if pid > 0:
|
||||
os.remove(PID)
|
||||
os.kill(pid, signal.SIGTERM)
|
||||
|
@ -138,10 +164,6 @@ if __name__ == "__main__":
|
|||
log_error("Error: The daemon doesn't exist?")
|
||||
log_error("Error: pid = %d" % (pid, ))
|
||||
sys.exit(1)
|
||||
except Exception as e:
|
||||
log_error("Error: The daemon doesn't exist?")
|
||||
log_error("Error: %s" % (e, ))
|
||||
sys.exit(1)
|
||||
else:
|
||||
msg = "Error: Unknown command: %s" % (args.command[0], )
|
||||
log_error(msg)
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
"""
|
||||
This is the MoltenIron server.
|
||||
"""
|
||||
|
||||
# Copyright (c) 2016 IBM Corporation.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
|
@ -15,6 +19,14 @@
|
|||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# flake8 disabling E242
|
||||
# https://pep8.readthedocs.io/en/latest/intro.html
|
||||
# https://gitlab.com/pycqa/flake8/issues/63
|
||||
# Gah!
|
||||
|
||||
# pylint: disable-msg=C0103
|
||||
# pylint: disable=redefined-outer-name
|
||||
|
||||
from BaseHTTPServer import HTTPServer, BaseHTTPRequestHandler
|
||||
import calendar
|
||||
from datetime import datetime
|
||||
|
@ -46,7 +58,9 @@ metadata = MetaData()
|
|||
|
||||
|
||||
class JSON_encoder_with_DateTime(json.JSONEncoder):
|
||||
"""Special class to allow json to encode datetime objects"""
|
||||
def default(self, o):
|
||||
"""Override default"""
|
||||
if isinstance(o, datetime):
|
||||
return o.isoformat()
|
||||
|
||||
|
@ -59,29 +73,36 @@ class JSON_encoder_with_DateTime(json.JSONEncoder):
|
|||
# http://stackoverflow.com/questions/1713038/super-fails-with-error-typeerror-
|
||||
# argument-1-must-be-type-not-classobj
|
||||
class OBaseHTTPRequestHandler(BaseHTTPRequestHandler, object):
|
||||
"""Converts BaseHTTPRequestHandler into a new-style class"""
|
||||
pass
|
||||
|
||||
|
||||
# We need to pass in conf into MoltenIronHandler, so make a class factory
|
||||
# to do that
|
||||
# NOTE: URL is over two lines :(
|
||||
# http://stackoverflow.com/questions/21631799/how-can-i-pass-parameters-to-a-
|
||||
# requesthandler
|
||||
def MakeMoltenIronHandlerWithConf(conf):
|
||||
"""Allows passing in conf to MoltenIronHandler,"""
|
||||
class MoltenIronHandler(OBaseHTTPRequestHandler):
|
||||
"""HTTP handler class"""
|
||||
def __init__(self, *args, **kwargs):
|
||||
# Note this *needs* to be done before call to super's class!
|
||||
self.conf = conf
|
||||
self.data_string = None
|
||||
super(OBaseHTTPRequestHandler, self).__init__(*args, **kwargs)
|
||||
|
||||
def do_POST(self):
|
||||
"""HTTP POST support"""
|
||||
CL = 'Content-Length'
|
||||
self.data_string = self.rfile.read(int(self.headers[CL]))
|
||||
response = self.parse(self.data_string)
|
||||
self.send_reply(response)
|
||||
|
||||
def send_reply(self, response):
|
||||
"""Sends the HTTP reply"""
|
||||
if DEBUG:
|
||||
print("send_reply: response = %s" % (response,))
|
||||
print "send_reply: response = %s" % (response,)
|
||||
# get the status code off the response json and send it
|
||||
status_code = response['status']
|
||||
self.send_response(status_code)
|
||||
|
@ -121,7 +142,7 @@ def MakeMoltenIronHandlerWithConf(conf):
|
|||
response = {'status': 400, 'message': str(e)}
|
||||
|
||||
if DEBUG:
|
||||
print("parse: response = %s" % (response,))
|
||||
print "parse: response = %s" % (response,)
|
||||
|
||||
return response
|
||||
|
||||
|
@ -129,6 +150,7 @@ def MakeMoltenIronHandlerWithConf(conf):
|
|||
|
||||
|
||||
class Nodes(declarative_base()):
|
||||
"""Nodes database class"""
|
||||
|
||||
__tablename__ = 'Nodes'
|
||||
|
||||
|
@ -182,6 +204,7 @@ class Nodes(declarative_base()):
|
|||
timestamp)
|
||||
|
||||
def map(self):
|
||||
"""Returns a map of the database row contents"""
|
||||
return {key: value for key, value
|
||||
in self.__dict__.items()
|
||||
if not key.startswith('_') and not callable(key)}
|
||||
|
@ -216,6 +239,7 @@ timestamp='%s'/>"""
|
|||
|
||||
|
||||
class IPs(declarative_base()):
|
||||
"""IPs database class"""
|
||||
|
||||
__tablename__ = 'IPs'
|
||||
|
||||
|
@ -310,6 +334,7 @@ class DataBase():
|
|||
self.setup_status()
|
||||
|
||||
def create_engine(self):
|
||||
"""Create the sqlalchemy database engine"""
|
||||
engine = None
|
||||
|
||||
if self.db_type == TYPE_MYSQL:
|
||||
|
@ -333,11 +358,12 @@ class DataBase():
|
|||
return engine
|
||||
|
||||
def close(self):
|
||||
"""Close the sqlalchemy database engine"""
|
||||
if DEBUG:
|
||||
print("close: Calling engine.dispose()")
|
||||
print "close: Calling engine.dispose()"
|
||||
self.engine.dispose()
|
||||
if DEBUG:
|
||||
print("close: Finished")
|
||||
print "close: Finished"
|
||||
|
||||
def get_session(self):
|
||||
"""Get a SQL academy session from the pool """
|
||||
|
@ -376,12 +402,13 @@ class DataBase():
|
|||
yield conn
|
||||
except Exception as e:
|
||||
if DEBUG:
|
||||
print("Exception caught in connection_scope: %s" % (e,))
|
||||
print "Exception caught in connection_scope: %s" % (e,)
|
||||
raise
|
||||
finally:
|
||||
conn.close()
|
||||
|
||||
def delete_db(self):
|
||||
"""Delete the sqlalchemy database"""
|
||||
# Instead of:
|
||||
# IPs.__table__.drop(self.engine, checkfirst=True)
|
||||
# Nodes.__table__.drop(self.engine, checkfirst=True)
|
||||
|
@ -390,16 +417,18 @@ class DataBase():
|
|||
return {'status': 200}
|
||||
|
||||
def create_metadata(self):
|
||||
"""Create the sqlalchemy database metadata"""
|
||||
# Instead of:
|
||||
# Nodes.__table__.create(self.engine, checkfirst=True)
|
||||
# IPs.__table__.create(self.engine, checkfirst=True)
|
||||
if DEBUG:
|
||||
print("create_metadata: Calling metadata.create_all")
|
||||
print "create_metadata: Calling metadata.create_all"
|
||||
metadata.create_all(self.engine, checkfirst=True)
|
||||
if DEBUG:
|
||||
print("create_metadata: Finished")
|
||||
print "create_metadata: Finished"
|
||||
|
||||
def to_timestamp(self, ts):
|
||||
"""Convert from a database time stamp to a Python time stamp"""
|
||||
timestamp = None
|
||||
if self.db_type == TYPE_MYSQL:
|
||||
timestamp = time.strftime("%Y-%m-%d %H:%M:%S", ts)
|
||||
|
@ -409,6 +438,7 @@ class DataBase():
|
|||
return timestamp
|
||||
|
||||
def from_timestamp(self, timestamp):
|
||||
"""Convert from a Python time stamp to a database time stamp"""
|
||||
ts = None
|
||||
if self.db_type == TYPE_MYSQL:
|
||||
ts = time.strptime(timestamp, "%Y-%m-%d %H:%M:%S")
|
||||
|
@ -427,7 +457,7 @@ class DataBase():
|
|||
count = session.query(Nodes).filter_by(status="ready").count()
|
||||
|
||||
# If we don't have enough nodes return an error
|
||||
if (count < how_many):
|
||||
if count < how_many:
|
||||
fmt = "Not enough available nodes found."
|
||||
fmt += " Found %d, requested %d"
|
||||
return {'status': 404,
|
||||
|
@ -435,22 +465,23 @@ class DataBase():
|
|||
|
||||
nodes_allocated = {}
|
||||
|
||||
for i in range(how_many):
|
||||
for _ in range(how_many):
|
||||
first_ready = session.query(Nodes)
|
||||
first_ready = first_ready.filter_by(status="ready")
|
||||
first_ready = first_ready.first()
|
||||
|
||||
id = first_ready.id
|
||||
node_id = first_ready.id
|
||||
# We have everything we need from node
|
||||
|
||||
log(self.conf,
|
||||
"allocating node id: %d for %s" % (id, owner_name, ))
|
||||
"allocating node id: %d for %s" % (node_id,
|
||||
owner_name, ))
|
||||
|
||||
timestamp = self.to_timestamp(time.gmtime())
|
||||
|
||||
# Update the node to the in use state
|
||||
stmt = update(Nodes)
|
||||
stmt = stmt.where(Nodes.id == id)
|
||||
stmt = stmt.where(Nodes.id == node_id)
|
||||
stmt = stmt.values(status="dirty",
|
||||
provisioned=owner_name,
|
||||
timestamp=timestamp)
|
||||
|
@ -460,7 +491,8 @@ class DataBase():
|
|||
session.close()
|
||||
session = self.get_session()
|
||||
|
||||
first_ready = session.query(Nodes).filter_by(id=id).one()
|
||||
first_ready = session.query(Nodes).filter_by(id=node_id)
|
||||
first_ready = first_ready.one()
|
||||
|
||||
first_ready_node = first_ready.map()
|
||||
|
||||
|
@ -474,19 +506,19 @@ class DataBase():
|
|||
= ','.join(allocation_pool)
|
||||
|
||||
# Add the node to the nodes dict
|
||||
nodes_allocated['node_%d' % (id, )] = first_ready_node
|
||||
nodes_allocated['node_%d' % (node_id, )] = first_ready_node
|
||||
|
||||
except Exception as e:
|
||||
|
||||
if DEBUG:
|
||||
print("Exception caught in deallocateBM: %s" % (e,))
|
||||
print "Exception caught in deallocateBM: %s" % (e,)
|
||||
|
||||
# Don't send the exception object as it is not json serializable!
|
||||
return {'status': 400, 'message': str(e)}
|
||||
|
||||
return {'status': 200, 'nodes': nodes_allocated}
|
||||
|
||||
def deallocateBM(self, id):
|
||||
def deallocateBM(self, node_id):
|
||||
"""Given the ID of a node (or the IPMI IP), de-allocate that node.
|
||||
|
||||
This changes the node status of that node from "used" to "ready."
|
||||
|
@ -498,11 +530,13 @@ class DataBase():
|
|||
|
||||
query = session.query(Nodes.id, Nodes.ipmi_ip, Nodes.name)
|
||||
|
||||
if (type(id) == str or type(id) == unicode) and ("." in id):
|
||||
if (isinstance(node_id, str) or
|
||||
isinstance(node_id, unicode)) \
|
||||
and ("." in node_id):
|
||||
# If an ipmi_ip was passed
|
||||
query = query.filter_by(ipmi_ip=id)
|
||||
query = query.filter_by(ipmi_ip=node_id)
|
||||
else:
|
||||
query = query.filter_by(id=id)
|
||||
query = query.filter_by(id=node_id)
|
||||
|
||||
node = query.one()
|
||||
|
||||
|
@ -520,7 +554,7 @@ class DataBase():
|
|||
except Exception as e:
|
||||
|
||||
if DEBUG:
|
||||
print("Exception caught in deallocateBM: %s" % (e,))
|
||||
print "Exception caught in deallocateBM: %s" % (e,)
|
||||
|
||||
# Don't send the exception object as it is not json serializable!
|
||||
return {'status': 400, 'message': str(e)}
|
||||
|
@ -544,7 +578,7 @@ class DataBase():
|
|||
self.deallocateBM(node.id)
|
||||
except Exception as e:
|
||||
if DEBUG:
|
||||
print("Exception caught in deallocateOwner: %s" % (e,))
|
||||
print "Exception caught in deallocateOwner: %s" % (e,)
|
||||
message = "Failed to deallocate node with ID %d" % (node.id,)
|
||||
return {'status': 400, 'message': message}
|
||||
|
||||
|
@ -568,7 +602,7 @@ class DataBase():
|
|||
|
||||
try:
|
||||
if DEBUG:
|
||||
print("addBMNode: node = %s" % (node, ))
|
||||
print "addBMNode: node = %s" % (node, )
|
||||
|
||||
with self.session_scope() as session, \
|
||||
self.connection_scope() as conn:
|
||||
|
@ -604,15 +638,15 @@ class DataBase():
|
|||
if 'timestamp' in node:
|
||||
timestamp_str = node['timestamp']
|
||||
if DEBUG:
|
||||
print("timestamp_str = %s" % (timestamp_str, ))
|
||||
print "timestamp_str = %s" % (timestamp_str, )
|
||||
if len(timestamp_str) != 0 and timestamp_str != "-1":
|
||||
ts = time.gmtime(float(timestamp_str))
|
||||
timestamp = self.to_timestamp(ts)
|
||||
if DEBUG:
|
||||
print("timestamp = %s" % (timestamp, ))
|
||||
print "timestamp = %s" % (timestamp, )
|
||||
stmt = stmt.values(timestamp=timestamp)
|
||||
if DEBUG:
|
||||
print(stmt.compile().params)
|
||||
print stmt.compile().params
|
||||
|
||||
conn.execute(stmt)
|
||||
|
||||
|
@ -633,14 +667,14 @@ class DataBase():
|
|||
stmt = stmt.values(node_id=new_node.id, ip=ip)
|
||||
|
||||
if DEBUG:
|
||||
print(stmt.compile().params)
|
||||
print stmt.compile().params
|
||||
|
||||
conn.execute(stmt)
|
||||
|
||||
except Exception as e:
|
||||
|
||||
if DEBUG:
|
||||
print("Exception caught in addBMNode: %s" % (e,))
|
||||
print "Exception caught in addBMNode: %s" % (e,)
|
||||
|
||||
# Don't send the exception object as it is not json serializable!
|
||||
return {'status': 400, 'message': str(e)}
|
||||
|
@ -685,7 +719,7 @@ class DataBase():
|
|||
except Exception as e:
|
||||
|
||||
if DEBUG:
|
||||
print("Exception caught in removeBMNode: %s" % (e,))
|
||||
print "Exception caught in removeBMNode: %s" % (e,)
|
||||
|
||||
# Don't send the exception object as it is not json serializable!
|
||||
return {'status': 400, 'message': str(e)}
|
||||
|
@ -701,7 +735,7 @@ class DataBase():
|
|||
"""
|
||||
|
||||
if DEBUG:
|
||||
print("cull: maxSeconds = %s" % (maxSeconds, ))
|
||||
print "cull: maxSeconds = %s" % (maxSeconds, )
|
||||
|
||||
nodes_culled = {}
|
||||
|
||||
|
@ -711,12 +745,12 @@ class DataBase():
|
|||
nodes = session.query(Nodes)
|
||||
|
||||
if DEBUG:
|
||||
print("There are %d nodes" % (nodes.count(), ))
|
||||
print "There are %d nodes" % (nodes.count(), )
|
||||
|
||||
for node in nodes:
|
||||
|
||||
if DEBUG:
|
||||
print(node)
|
||||
print node
|
||||
|
||||
if node.timestamp in ('', '-1', None):
|
||||
continue
|
||||
|
@ -741,7 +775,7 @@ class DataBase():
|
|||
log(self.conf, logstring)
|
||||
|
||||
if DEBUG:
|
||||
print(logstring)
|
||||
print logstring
|
||||
|
||||
self.deallocateBM(node.id)
|
||||
|
||||
|
@ -751,7 +785,7 @@ class DataBase():
|
|||
except Exception as e:
|
||||
|
||||
if DEBUG:
|
||||
print("Exception caught in cull: %s" % (e,))
|
||||
print "Exception caught in cull: %s" % (e,)
|
||||
|
||||
# Don't send the exception object as it is not json serializable!
|
||||
return {'status': 400, 'message': str(e)}
|
||||
|
@ -787,7 +821,7 @@ class DataBase():
|
|||
except Exception as e:
|
||||
|
||||
if DEBUG:
|
||||
print("Exception caught in doClean: %s" % (e,))
|
||||
print "Exception caught in doClean: %s" % (e,)
|
||||
|
||||
# Don't send the exception object as it is not json serializable!
|
||||
return {'status': 400, 'message': str(e)}
|
||||
|
@ -815,7 +849,7 @@ class DataBase():
|
|||
except Exception as e:
|
||||
|
||||
if DEBUG:
|
||||
print("Exception caught in get_ips: %s" % (e,))
|
||||
print "Exception caught in get_ips: %s" % (e,)
|
||||
|
||||
# Don't send the exception object as it is not json serializable!
|
||||
return {'status': 400, 'message': str(e)}
|
||||
|
@ -855,14 +889,14 @@ class DataBase():
|
|||
except Exception as e:
|
||||
|
||||
if DEBUG:
|
||||
print("Exception caught in get_field: %s" % (e,))
|
||||
print "Exception caught in get_field: %s" % (e,)
|
||||
|
||||
# Don't send the exception object as it is not json serializable!
|
||||
return {'status': 400, 'message': str(e)}
|
||||
|
||||
return {'status': 200, 'result': results}
|
||||
|
||||
def set_field(self, id, key, value):
|
||||
def set_field(self, node_id, key, value):
|
||||
"""Given an identifying id, set specified key to the passed value. """
|
||||
|
||||
if not hasattr(Nodes, key):
|
||||
|
@ -874,19 +908,19 @@ class DataBase():
|
|||
self.connection_scope() as conn:
|
||||
|
||||
query = session.query(Nodes)
|
||||
nodes = query.filter_by(id=id)
|
||||
nodes = query.filter_by(id=node_id)
|
||||
|
||||
if nodes.count() == 0:
|
||||
return {'status': 404,
|
||||
'message': 'Node with id of %s does not exist!'
|
||||
% id}
|
||||
% node_id}
|
||||
|
||||
nodes.one()
|
||||
|
||||
kv = {key: value}
|
||||
|
||||
stmt = update(Nodes)
|
||||
stmt = stmt.where(Nodes.id == id)
|
||||
stmt = stmt.where(Nodes.id == node_id)
|
||||
stmt = stmt.values(**kv)
|
||||
|
||||
conn.execute(stmt)
|
||||
|
@ -894,7 +928,7 @@ class DataBase():
|
|||
except Exception as e:
|
||||
|
||||
if DEBUG:
|
||||
print("Exception caught in set_field: %s" % (e,))
|
||||
print "Exception caught in set_field: %s" % (e,)
|
||||
|
||||
# Don't send the exception object as it is not json serializable!
|
||||
return {'status': 400, 'message': str(e)}
|
||||
|
@ -991,7 +1025,7 @@ class DataBase():
|
|||
except Exception as e:
|
||||
|
||||
if DEBUG:
|
||||
print("Exception caught in status: %s" % (e,))
|
||||
print "Exception caught in status: %s" % (e,)
|
||||
|
||||
# Don't send the exception object as it is not json serializable!
|
||||
return {'status': 400, 'message': str(e)}
|
||||
|
@ -1000,10 +1034,11 @@ class DataBase():
|
|||
|
||||
|
||||
def listener(conf):
|
||||
"""HTTP listener"""
|
||||
mi_addr = str(conf['serverIP'])
|
||||
mi_port = int(conf['mi_port'])
|
||||
handler_class = MakeMoltenIronHandlerWithConf(conf)
|
||||
print('Listening... to %s:%d' % (mi_addr, mi_port,))
|
||||
print 'Listening... to %s:%d' % (mi_addr, mi_port,)
|
||||
moltenirond = HTTPServer((mi_addr, mi_port), handler_class)
|
||||
moltenirond.serve_forever()
|
||||
|
||||
|
@ -1041,27 +1076,15 @@ def log(conf, message):
|
|||
logdir = conf["logdir"]
|
||||
now = datetime.today()
|
||||
|
||||
fname = ( "molteniron-"
|
||||
+ str(now.day)
|
||||
+ "-"
|
||||
+ str(now.month)
|
||||
+ "-"
|
||||
+ str(now.year)
|
||||
+ ".log"
|
||||
)
|
||||
fname = "molteniron-%d-%d-%d.log" % (now.day,
|
||||
now.month,
|
||||
now.year, )
|
||||
|
||||
timestamp = ( "{0:0>2}".format(str(now.hour))
|
||||
+ ":"
|
||||
+ "{0:0>2}".format(str(now.minute))
|
||||
+ ":"
|
||||
+ "{0:0>2}".format(str(now.second))
|
||||
)
|
||||
timestamp = "{0:0>2}".format(str(now.hour))
|
||||
timestamp += ":{0:0>2}".format(str(now.minute))
|
||||
timestamp += ":{0:0>2}".format(str(now.second))
|
||||
|
||||
message = ( timestamp
|
||||
+ " "
|
||||
+ message
|
||||
+ "\n"
|
||||
)
|
||||
message = timestamp + " " + message + "\n"
|
||||
|
||||
# check if logdir exists, if not create it
|
||||
if not os.path.isdir(logdir):
|
||||
|
|
7
setup.py
7
setup.py
|
@ -1,5 +1,9 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
"""
|
||||
Install the molteniron python package.
|
||||
"""
|
||||
|
||||
# Copyright (c) 2016 IBM Corporation.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
|
@ -23,5 +27,4 @@ setup(name="molteniron",
|
|||
url="https://github.com/openstack/third-party-ci-tools",
|
||||
py_modules=["molteniron/__init__", "molteniron/moltenirond"],
|
||||
scripts=["molteniron/moltenirond-helper", "molteniron/molteniron"],
|
||||
data_files=[("etc/molteniron/", ["conf.yaml"])]
|
||||
)
|
||||
data_files=[("etc/molteniron/", ["conf.yaml"])])
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
"""
|
||||
Tests the addBMNode MoltenIron command.
|
||||
"""
|
||||
|
||||
# Copyright (c) 2016 IBM Corporation.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
|
@ -15,6 +19,8 @@
|
|||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# pylint: disable-msg=C0103
|
||||
|
||||
import sys
|
||||
import os
|
||||
import yaml
|
||||
|
@ -22,7 +28,7 @@ import argparse
|
|||
from molteniron import moltenirond
|
||||
|
||||
if __name__ == "__main__":
|
||||
parser = argparse.ArgumentParser(description="Molteniron command line tool")
|
||||
parser = argparse.ArgumentParser(description="Molteniron CLI tool")
|
||||
parser.add_argument("-c",
|
||||
"--conf-dir",
|
||||
action="store",
|
||||
|
@ -52,9 +58,9 @@ if __name__ == "__main__":
|
|||
"ipmi_password": "2f024600fc5ef6f7",
|
||||
"port_hwaddr": "97: c3:b0: 47:0c:0d",
|
||||
"cpu_arch": "ppc64el",
|
||||
"cpus": 20L,
|
||||
"ram_mb": 51000L,
|
||||
"disk_gb": 500L,
|
||||
"cpus": 20,
|
||||
"ram_mb": 51000,
|
||||
"disk_gb": 500,
|
||||
"status": "ready",
|
||||
"provisioned": "",
|
||||
"timestamp": "",
|
||||
|
@ -67,9 +73,9 @@ if __name__ == "__main__":
|
|||
"ipmi_password": "6cf0957c985b2deb",
|
||||
"port_hwaddr": "2d: 9e:3c:83:8a: be",
|
||||
"cpu_arch": "ppc64el",
|
||||
"cpus": 20L,
|
||||
"ram_mb": 51000L,
|
||||
"disk_gb": 500L,
|
||||
"cpus": 20,
|
||||
"ram_mb": 51000,
|
||||
"disk_gb": 500,
|
||||
"status": "ready",
|
||||
"provisioned": "",
|
||||
"timestamp": "",
|
||||
|
@ -82,9 +88,9 @@ if __name__ == "__main__":
|
|||
"ipmi_password": "cc777c10196db585",
|
||||
"port_hwaddr": "47: b0:dc:d5: 82:d9",
|
||||
"cpu_arch": "ppc64el",
|
||||
"cpus": 20L,
|
||||
"ram_mb": 51000L,
|
||||
"disk_gb": 500L,
|
||||
"cpus": 20,
|
||||
"ram_mb": 51000,
|
||||
"disk_gb": 500,
|
||||
"status": "used",
|
||||
"provisioned": "7a72eccd-3153-4d08-9848-c6d3b1f18f9f",
|
||||
"timestamp": "1460489832",
|
||||
|
@ -97,9 +103,9 @@ if __name__ == "__main__":
|
|||
"ipmi_password": "a700a2d789075276",
|
||||
"port_hwaddr": "44: 94:1a: c7:8a:9f",
|
||||
"cpu_arch": "ppc64el",
|
||||
"cpus": 20L,
|
||||
"ram_mb": 51000L,
|
||||
"disk_gb": 500L,
|
||||
"cpus": 20,
|
||||
"ram_mb": 51000,
|
||||
"disk_gb": 500,
|
||||
"status": "used",
|
||||
"provisioned": "6b8823ef-3e14-4811-98b9-32e27397540d",
|
||||
"timestamp": "1460491566",
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
"""
|
||||
Tests the MoltenIron allocateBM command.
|
||||
"""
|
||||
|
||||
# Copyright (c) 2016 IBM Corporation.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
|
@ -15,13 +19,17 @@
|
|||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# pylint: disable-msg=C0103
|
||||
|
||||
import sys
|
||||
import os
|
||||
import yaml
|
||||
import argparse
|
||||
from molteniron import moltenirond
|
||||
|
||||
|
||||
def compare_provisioned_nodes(lhs, rhs):
|
||||
"""Specially compares lhs against rhs."""
|
||||
lhs = lhs.copy()
|
||||
rhs = rhs.copy()
|
||||
rhs['provisioned'] = 'hamzy'
|
||||
|
@ -32,8 +40,9 @@ def compare_provisioned_nodes(lhs, rhs):
|
|||
del lhs['id']
|
||||
assert lhs == rhs
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
parser = argparse.ArgumentParser(description="Molteniron command line tool")
|
||||
parser = argparse.ArgumentParser(description="Molteniron CLI tool")
|
||||
parser.add_argument("-c",
|
||||
"--conf-dir",
|
||||
action="store",
|
||||
|
@ -63,9 +72,9 @@ if __name__ == "__main__":
|
|||
"ipmi_password": "e05cc5f061426e34",
|
||||
"port_hwaddr": "f8: de: 29:33:a4:ed",
|
||||
"cpu_arch": "ppc64el",
|
||||
"cpus": 20L,
|
||||
"ram_mb": 51000L,
|
||||
"disk_gb": 500L,
|
||||
"cpus": 20,
|
||||
"ram_mb": 51000,
|
||||
"disk_gb": 500,
|
||||
"status": "ready",
|
||||
"provisioned": "",
|
||||
"timestamp": "",
|
||||
|
@ -78,9 +87,9 @@ if __name__ == "__main__":
|
|||
"ipmi_password": "0614d63b6635ea3d",
|
||||
"port_hwaddr": "4c: c5:da: 28:2c:2d",
|
||||
"cpu_arch": "ppc64el",
|
||||
"cpus": 20L,
|
||||
"ram_mb": 51000L,
|
||||
"disk_gb": 500L,
|
||||
"cpus": 20,
|
||||
"ram_mb": 51000,
|
||||
"disk_gb": 500,
|
||||
"status": "ready",
|
||||
"provisioned": "",
|
||||
"timestamp": "",
|
||||
|
@ -93,9 +102,9 @@ if __name__ == "__main__":
|
|||
"ipmi_password": "928b056134e4d770",
|
||||
"port_hwaddr": "53: 76: c6:09:50:64",
|
||||
"cpu_arch": "ppc64el",
|
||||
"cpus": 20L,
|
||||
"ram_mb": 51000L,
|
||||
"disk_gb": 500L,
|
||||
"cpus": 20,
|
||||
"ram_mb": 51000,
|
||||
"disk_gb": 500,
|
||||
"status": "used",
|
||||
"provisioned": "7a72eccd-3153-4d08-9848-c6d3b1f18f9f",
|
||||
"timestamp": "1460489832",
|
||||
|
@ -108,9 +117,9 @@ if __name__ == "__main__":
|
|||
"ipmi_password": "33f448a4fc176492",
|
||||
"port_hwaddr": "85: e0: 73:e9:fc:ca",
|
||||
"cpu_arch": "ppc64el",
|
||||
"cpus": 20L,
|
||||
"ram_mb": 51000L,
|
||||
"disk_gb": 500L,
|
||||
"cpus": 20,
|
||||
"ram_mb": 51000,
|
||||
"disk_gb": 500,
|
||||
"status": "used",
|
||||
"provisioned": "6b8823ef-3e14-4811-98b9-32e27397540d",
|
||||
"timestamp": "1460491566",
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
"""
|
||||
Tests the MoltenIron cull command.
|
||||
"""
|
||||
|
||||
# Copyright (c) 2016 IBM Corporation.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
|
@ -15,6 +19,8 @@
|
|||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# pylint: disable-msg=C0103
|
||||
|
||||
import sys
|
||||
import os
|
||||
import yaml
|
||||
|
@ -22,7 +28,9 @@ import argparse
|
|||
import time
|
||||
from molteniron import moltenirond
|
||||
|
||||
|
||||
def compare_culled_nodes(lhs, rhs):
|
||||
"""Specially compares lhs against rhs."""
|
||||
lhs = lhs.copy()
|
||||
rhs = rhs.copy()
|
||||
del rhs['allocation_pool']
|
||||
|
@ -33,7 +41,7 @@ def compare_culled_nodes(lhs, rhs):
|
|||
assert lhs == rhs
|
||||
|
||||
if __name__ == "__main__":
|
||||
parser = argparse.ArgumentParser(description="Molteniron command line tool")
|
||||
parser = argparse.ArgumentParser(description="Molteniron CLI tool")
|
||||
parser.add_argument("-c",
|
||||
"--conf-dir",
|
||||
action="store",
|
||||
|
@ -63,9 +71,9 @@ if __name__ == "__main__":
|
|||
"ipmi_password": "34118fd3509621ba",
|
||||
"port_hwaddr": "ff: 2c: e1:cc:8e:7c",
|
||||
"cpu_arch": "ppc64el",
|
||||
"cpus": 20L,
|
||||
"ram_mb": 51000L,
|
||||
"disk_gb": 500L,
|
||||
"cpus": 20,
|
||||
"ram_mb": 51000,
|
||||
"disk_gb": 500,
|
||||
"status": "ready",
|
||||
"provisioned": "",
|
||||
"timestamp": "",
|
||||
|
@ -78,9 +86,9 @@ if __name__ == "__main__":
|
|||
"ipmi_password": "fa2125690a95b43c",
|
||||
"port_hwaddr": "f6: 58:13:02:64:59",
|
||||
"cpu_arch": "ppc64el",
|
||||
"cpus": 20L,
|
||||
"ram_mb": 51000L,
|
||||
"disk_gb": 500L,
|
||||
"cpus": 20,
|
||||
"ram_mb": 51000,
|
||||
"disk_gb": 500,
|
||||
"status": "ready",
|
||||
"provisioned": "",
|
||||
"timestamp": "-1",
|
||||
|
@ -93,9 +101,9 @@ if __name__ == "__main__":
|
|||
"ipmi_password": "3aee014d56425a6c",
|
||||
"port_hwaddr": "6e: d4:a5:ae: 13:55",
|
||||
"cpu_arch": "ppc64el",
|
||||
"cpus": 20L,
|
||||
"ram_mb": 51000L,
|
||||
"disk_gb": 500L,
|
||||
"cpus": 20,
|
||||
"ram_mb": 51000,
|
||||
"disk_gb": 500,
|
||||
"status": "used",
|
||||
"provisioned": "7a72eccd-3153-4d08-9848-c6d3b1f18f9f",
|
||||
# NOTE: time() can return fractional values. Ex: 1460560140.47
|
||||
|
@ -109,9 +117,9 @@ if __name__ == "__main__":
|
|||
"ipmi_password": "254dd9fb34ddcac7",
|
||||
"port_hwaddr": "a0: c9: 22:23:22:9d",
|
||||
"cpu_arch": "ppc64el",
|
||||
"cpus": 20L,
|
||||
"ram_mb": 51000L,
|
||||
"disk_gb": 500L,
|
||||
"cpus": 20,
|
||||
"ram_mb": 51000,
|
||||
"disk_gb": 500,
|
||||
"status": "used",
|
||||
"provisioned": "6b8823ef-3e14-4811-98b9-32e27397540d",
|
||||
"timestamp": str(time.time() - 2000.0),
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
"""
|
||||
Tests the MoltenIron deallocateBM command.
|
||||
"""
|
||||
|
||||
# Copyright (c) 2016 IBM Corporation.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
|
@ -15,13 +19,17 @@
|
|||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# pylint: disable-msg=C0103
|
||||
|
||||
import sys
|
||||
import os
|
||||
import yaml
|
||||
import argparse
|
||||
from molteniron import moltenirond
|
||||
|
||||
|
||||
def compare_provisioned_nodes(lhs, rhs):
|
||||
"""Specially compares lhs against rhs."""
|
||||
lhs = lhs.copy()
|
||||
rhs = rhs.copy()
|
||||
rhs['provisioned'] = 'hamzy'
|
||||
|
@ -33,7 +41,7 @@ def compare_provisioned_nodes(lhs, rhs):
|
|||
assert lhs == rhs
|
||||
|
||||
if __name__ == "__main__":
|
||||
parser = argparse.ArgumentParser(description="Molteniron command line tool")
|
||||
parser = argparse.ArgumentParser(description="Molteniron CLI tool")
|
||||
parser.add_argument("-c",
|
||||
"--conf-dir",
|
||||
action="store",
|
||||
|
@ -63,9 +71,9 @@ if __name__ == "__main__":
|
|||
"ipmi_password": "16f6954d347c4de2",
|
||||
"port_hwaddr": "28: 5a: e7:e3:fe:75",
|
||||
"cpu_arch": "ppc64el",
|
||||
"cpus": 20L,
|
||||
"ram_mb": 51000L,
|
||||
"disk_gb": 500L,
|
||||
"cpus": 20,
|
||||
"ram_mb": 51000,
|
||||
"disk_gb": 500,
|
||||
"status": "ready",
|
||||
"provisioned": "",
|
||||
"timestamp": "",
|
||||
|
@ -78,9 +86,9 @@ if __name__ == "__main__":
|
|||
"ipmi_password": "3a23241cfa516699",
|
||||
"port_hwaddr": "7d: 0a: e5:b9:41:9b",
|
||||
"cpu_arch": "ppc64el",
|
||||
"cpus": 20L,
|
||||
"ram_mb": 51000L,
|
||||
"disk_gb": 500L,
|
||||
"cpus": 20,
|
||||
"ram_mb": 51000,
|
||||
"disk_gb": 500,
|
||||
"status": "ready",
|
||||
"provisioned": "",
|
||||
"timestamp": "",
|
||||
|
@ -93,9 +101,9 @@ if __name__ == "__main__":
|
|||
"ipmi_password": "4f7e47c57f27ec55",
|
||||
"port_hwaddr": "5a: e8: 11:e9:11:a2",
|
||||
"cpu_arch": "ppc64el",
|
||||
"cpus": 20L,
|
||||
"ram_mb": 51000L,
|
||||
"disk_gb": 500L,
|
||||
"cpus": 20,
|
||||
"ram_mb": 51000,
|
||||
"disk_gb": 500,
|
||||
"status": "used",
|
||||
"provisioned": "7a72eccd-3153-4d08-9848-c6d3b1f18f9f",
|
||||
"timestamp": "1460489832",
|
||||
|
@ -108,9 +116,9 @@ if __name__ == "__main__":
|
|||
"ipmi_password": "aeff165ded2c2f9f",
|
||||
"port_hwaddr": "4d: 18:82: dc:2c:d6",
|
||||
"cpu_arch": "ppc64el",
|
||||
"cpus": 20L,
|
||||
"ram_mb": 51000L,
|
||||
"disk_gb": 500L,
|
||||
"cpus": 20,
|
||||
"ram_mb": 51000,
|
||||
"disk_gb": 500,
|
||||
"status": "used",
|
||||
"provisioned": "6b8823ef-3e14-4811-98b9-32e27397540d",
|
||||
"timestamp": "1460491566",
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
"""
|
||||
Tests the MoltenIron deallocateOwner command.
|
||||
"""
|
||||
|
||||
# Copyright (c) 2016 IBM Corporation.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
|
@ -15,13 +19,17 @@
|
|||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# pylint: disable-msg=C0103
|
||||
|
||||
import sys
|
||||
import os
|
||||
import yaml
|
||||
import argparse
|
||||
from molteniron import moltenirond
|
||||
|
||||
|
||||
def compare_provisioned_nodes(lhs, rhs):
|
||||
"""Specially compares lhs against rhs."""
|
||||
lhs = lhs.copy()
|
||||
rhs = rhs.copy()
|
||||
rhs['provisioned'] = 'hamzy'
|
||||
|
@ -33,7 +41,7 @@ def compare_provisioned_nodes(lhs, rhs):
|
|||
assert lhs == rhs
|
||||
|
||||
if __name__ == "__main__":
|
||||
parser = argparse.ArgumentParser(description="Molteniron command line tool")
|
||||
parser = argparse.ArgumentParser(description="Molteniron CLI tool")
|
||||
parser.add_argument("-c",
|
||||
"--conf-dir",
|
||||
action="store",
|
||||
|
@ -63,9 +71,9 @@ if __name__ == "__main__":
|
|||
"ipmi_password": "f367d07be07d6358",
|
||||
"port_hwaddr": "6d: 9a:78: f3:ed:3a",
|
||||
"cpu_arch": "ppc64el",
|
||||
"cpus": 20L,
|
||||
"ram_mb": 51000L,
|
||||
"disk_gb": 500L,
|
||||
"cpus": 20,
|
||||
"ram_mb": 51000,
|
||||
"disk_gb": 500,
|
||||
"status": "ready",
|
||||
"provisioned": "",
|
||||
"timestamp": "",
|
||||
|
@ -78,9 +86,9 @@ if __name__ == "__main__":
|
|||
"ipmi_password": "1c6a27307f8fe79d",
|
||||
"port_hwaddr": "16: 23: e8:07:b4:a9",
|
||||
"cpu_arch": "ppc64el",
|
||||
"cpus": 20L,
|
||||
"ram_mb": 51000L,
|
||||
"disk_gb": 500L,
|
||||
"cpus": 20,
|
||||
"ram_mb": 51000,
|
||||
"disk_gb": 500,
|
||||
"status": "ready",
|
||||
"provisioned": "",
|
||||
"timestamp": "",
|
||||
|
@ -93,9 +101,9 @@ if __name__ == "__main__":
|
|||
"ipmi_password": "1766d597a024dd8d",
|
||||
"port_hwaddr": "12: 33:9f:04:07:9b",
|
||||
"cpu_arch": "ppc64el",
|
||||
"cpus": 20L,
|
||||
"ram_mb": 51000L,
|
||||
"disk_gb": 500L,
|
||||
"cpus": 20,
|
||||
"ram_mb": 51000,
|
||||
"disk_gb": 500,
|
||||
"status": "used",
|
||||
"provisioned": "7a72eccd-3153-4d08-9848-c6d3b1f18f9f",
|
||||
"timestamp": "1460489832",
|
||||
|
@ -108,9 +116,9 @@ if __name__ == "__main__":
|
|||
"ipmi_password": "7c55be8b4ef42869",
|
||||
"port_hwaddr": "c2: 31: e9:8a:75:96",
|
||||
"cpu_arch": "ppc64el",
|
||||
"cpus": 20L,
|
||||
"ram_mb": 51000L,
|
||||
"disk_gb": 500L,
|
||||
"cpus": 20,
|
||||
"ram_mb": 51000,
|
||||
"disk_gb": 500,
|
||||
"status": "used",
|
||||
"provisioned": "6b8823ef-3e14-4811-98b9-32e27397540d",
|
||||
"timestamp": "1460491566",
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
"""
|
||||
Tests the MoltenIron doClean command.
|
||||
"""
|
||||
|
||||
# Copyright (c) 2016 IBM Corporation.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
|
@ -15,6 +19,8 @@
|
|||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# pylint: disable-msg=C0103
|
||||
|
||||
import sys
|
||||
import os
|
||||
import yaml
|
||||
|
@ -22,7 +28,7 @@ import argparse
|
|||
from molteniron import moltenirond
|
||||
|
||||
if __name__ == "__main__":
|
||||
parser = argparse.ArgumentParser(description="Molteniron command line tool")
|
||||
parser = argparse.ArgumentParser(description="Molteniron CLI tool")
|
||||
parser.add_argument("-c",
|
||||
"--conf-dir",
|
||||
action="store",
|
||||
|
@ -52,9 +58,9 @@ if __name__ == "__main__":
|
|||
"ipmi_password": "e23af1e52896cf02",
|
||||
"port_hwaddr": "5d: 7e:05: dd:fe:65",
|
||||
"cpu_arch": "ppc64el",
|
||||
"cpus": 20L,
|
||||
"ram_mb": 51000L,
|
||||
"disk_gb": 500L,
|
||||
"cpus": 20,
|
||||
"ram_mb": 51000,
|
||||
"disk_gb": 500,
|
||||
"status": "ready",
|
||||
"provisioned": "",
|
||||
"timestamp": "",
|
||||
|
@ -67,9 +73,9 @@ if __name__ == "__main__":
|
|||
"ipmi_password": "57212373db56c76a",
|
||||
"port_hwaddr": "7e: 41:89: e1:28:03",
|
||||
"cpu_arch": "ppc64el",
|
||||
"cpus": 20L,
|
||||
"ram_mb": 51000L,
|
||||
"disk_gb": 500L,
|
||||
"cpus": 20,
|
||||
"ram_mb": 51000,
|
||||
"disk_gb": 500,
|
||||
"status": "ready",
|
||||
"provisioned": "",
|
||||
"timestamp": "",
|
||||
|
@ -82,9 +88,9 @@ if __name__ == "__main__":
|
|||
"ipmi_password": "c2f4b0bfa31fe9de",
|
||||
"port_hwaddr": "4f: a7: 48:59:6a:a7",
|
||||
"cpu_arch": "ppc64el",
|
||||
"cpus": 20L,
|
||||
"ram_mb": 51000L,
|
||||
"disk_gb": 500L,
|
||||
"cpus": 20,
|
||||
"ram_mb": 51000,
|
||||
"disk_gb": 500,
|
||||
"status": "used",
|
||||
"provisioned": "7a72eccd-3153-4d08-9848-c6d3b1f18f9f",
|
||||
"timestamp": "1460489832",
|
||||
|
@ -97,9 +103,9 @@ if __name__ == "__main__":
|
|||
"ipmi_password": "f99d122fc129c1dd",
|
||||
"port_hwaddr": "a2: 0d: bc:ca:c5:a5",
|
||||
"cpu_arch": "ppc64el",
|
||||
"cpus": 20L,
|
||||
"ram_mb": 51000L,
|
||||
"disk_gb": 500L,
|
||||
"cpus": 20,
|
||||
"ram_mb": 51000,
|
||||
"disk_gb": 500,
|
||||
"status": "used",
|
||||
"provisioned": "6b8823ef-3e14-4811-98b9-32e27397540d",
|
||||
"timestamp": "1460491566",
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
"""
|
||||
Tests the MoltenIron get_field command.
|
||||
"""
|
||||
|
||||
# Copyright (c) 2016 IBM Corporation.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
|
@ -15,6 +19,8 @@
|
|||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# pylint: disable-msg=C0103
|
||||
|
||||
import sys
|
||||
import os
|
||||
import yaml
|
||||
|
@ -22,7 +28,7 @@ import argparse
|
|||
from molteniron import moltenirond
|
||||
|
||||
if __name__ == "__main__":
|
||||
parser = argparse.ArgumentParser(description="Molteniron command line tool")
|
||||
parser = argparse.ArgumentParser(description="Molteniron CLI tool")
|
||||
parser.add_argument("-c",
|
||||
"--conf-dir",
|
||||
action="store",
|
||||
|
@ -52,9 +58,9 @@ if __name__ == "__main__":
|
|||
"ipmi_password": "7db1486ac9ea6533",
|
||||
"port_hwaddr": "ca: 2c: ab:88:47:b0",
|
||||
"cpu_arch": "ppc64el",
|
||||
"cpus": 20L,
|
||||
"ram_mb": 51000L,
|
||||
"disk_gb": 500L,
|
||||
"cpus": 20,
|
||||
"ram_mb": 51000,
|
||||
"disk_gb": 500,
|
||||
"status": "ready",
|
||||
"provisioned": "hamzy",
|
||||
"timestamp": "",
|
||||
|
@ -67,9 +73,9 @@ if __name__ == "__main__":
|
|||
"ipmi_password": "c3f8e3f3407e880b",
|
||||
"port_hwaddr": "90: 24:5c: d5:0e:b3",
|
||||
"cpu_arch": "ppc64el",
|
||||
"cpus": 20L,
|
||||
"ram_mb": 51000L,
|
||||
"disk_gb": 500L,
|
||||
"cpus": 20,
|
||||
"ram_mb": 51000,
|
||||
"disk_gb": 500,
|
||||
"status": "ready",
|
||||
"provisioned": "mjturek",
|
||||
"timestamp": "",
|
||||
|
@ -82,9 +88,9 @@ if __name__ == "__main__":
|
|||
"ipmi_password": "1bcbf739c7108291",
|
||||
"port_hwaddr": "9c: 6b:1b:31: a5:2d",
|
||||
"cpu_arch": "ppc64el",
|
||||
"cpus": 20L,
|
||||
"ram_mb": 51000L,
|
||||
"disk_gb": 500L,
|
||||
"cpus": 20,
|
||||
"ram_mb": 51000,
|
||||
"disk_gb": 500,
|
||||
"status": "used",
|
||||
"provisioned": "7a72eccd-3153-4d08-9848-c6d3b1f18f9f",
|
||||
"timestamp": "1460489832",
|
||||
|
@ -97,9 +103,9 @@ if __name__ == "__main__":
|
|||
"cpu_arch": "ppc64el",
|
||||
"ipmi_password": "0c200c858ac46280",
|
||||
"port_hwaddr": "64: 49:12: c6:3f:bd",
|
||||
"cpus": 20L,
|
||||
"ram_mb": 51000L,
|
||||
"disk_gb": 500L,
|
||||
"cpus": 20,
|
||||
"ram_mb": 51000,
|
||||
"disk_gb": 500,
|
||||
"status": "used",
|
||||
"provisioned": "mjturek",
|
||||
"timestamp": "1460491566",
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
"""
|
||||
Tests the MoltenIron get_ips command.
|
||||
"""
|
||||
|
||||
# Copyright (c) 2016 IBM Corporation.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
|
@ -15,6 +19,8 @@
|
|||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# pylint: disable-msg=C0103
|
||||
|
||||
import sys
|
||||
import os
|
||||
import yaml
|
||||
|
@ -22,7 +28,7 @@ import argparse
|
|||
from molteniron import moltenirond
|
||||
|
||||
if __name__ == "__main__":
|
||||
parser = argparse.ArgumentParser(description="Molteniron command line tool")
|
||||
parser = argparse.ArgumentParser(description="Molteniron CLI tool")
|
||||
parser.add_argument("-c",
|
||||
"--conf-dir",
|
||||
action="store",
|
||||
|
@ -52,9 +58,9 @@ if __name__ == "__main__":
|
|||
"ipmi_password": "1aa328d7767653ad",
|
||||
"port_hwaddr": "17: e7:f1:ab:a5: 9f",
|
||||
"cpu_arch": "ppc64el",
|
||||
"cpus": 20L,
|
||||
"ram_mb": 51000L,
|
||||
"disk_gb": 500L,
|
||||
"cpus": 20,
|
||||
"ram_mb": 51000,
|
||||
"disk_gb": 500,
|
||||
"status": "ready",
|
||||
"provisioned": "hamzy",
|
||||
"timestamp": "",
|
||||
|
@ -67,9 +73,9 @@ if __name__ == "__main__":
|
|||
"ipmi_password": "84b9d9ceb866f612",
|
||||
"port_hwaddr": "0b: f1: 9c:9d:a6:eb",
|
||||
"cpu_arch": "ppc64el",
|
||||
"cpus": 20L,
|
||||
"ram_mb": 51000L,
|
||||
"disk_gb": 500L,
|
||||
"cpus": 20,
|
||||
"ram_mb": 51000,
|
||||
"disk_gb": 500,
|
||||
"status": "ready",
|
||||
"provisioned": "mjturek",
|
||||
"timestamp": "",
|
||||
|
@ -82,9 +88,9 @@ if __name__ == "__main__":
|
|||
"ipmi_password": "ba60285a1fd69800",
|
||||
"port_hwaddr": "da: e0: 86:2a:80:9c",
|
||||
"cpu_arch": "ppc64el",
|
||||
"cpus": 20L,
|
||||
"ram_mb": 51000L,
|
||||
"disk_gb": 500L,
|
||||
"cpus": 20,
|
||||
"ram_mb": 51000,
|
||||
"disk_gb": 500,
|
||||
"status": "used",
|
||||
"provisioned": "7a72eccd-3153-4d08-9848-c6d3b1f18f9f",
|
||||
"timestamp": "1460489832",
|
||||
|
@ -97,9 +103,9 @@ if __name__ == "__main__":
|
|||
"cpu_arch": "ppc64el",
|
||||
"ipmi_password": "7810c66057ef4f2d",
|
||||
"port_hwaddr": "d6: bc:ca: 83:95:e7",
|
||||
"cpus": 20L,
|
||||
"ram_mb": 51000L,
|
||||
"disk_gb": 500L,
|
||||
"cpus": 20,
|
||||
"ram_mb": 51000,
|
||||
"disk_gb": 500,
|
||||
"status": "used",
|
||||
"provisioned": "mjturek",
|
||||
"timestamp": "1460491566",
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
"""
|
||||
Tests the MoltenIron removeBMNode command.
|
||||
"""
|
||||
|
||||
# Copyright (c) 2016 IBM Corporation.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
|
@ -15,6 +19,8 @@
|
|||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# pylint: disable-msg=C0103
|
||||
|
||||
import sys
|
||||
import os
|
||||
import yaml
|
||||
|
@ -22,7 +28,7 @@ import argparse
|
|||
from molteniron import moltenirond
|
||||
|
||||
if __name__ == "__main__":
|
||||
parser = argparse.ArgumentParser(description="Molteniron command line tool")
|
||||
parser = argparse.ArgumentParser(description="Molteniron CLI tool")
|
||||
parser.add_argument("-c",
|
||||
"--conf-dir",
|
||||
action="store",
|
||||
|
@ -52,9 +58,9 @@ if __name__ == "__main__":
|
|||
"ipmi_password": "2703f5fee17f2073",
|
||||
"port_hwaddr": "b1: 71: dd:02:9e:20",
|
||||
"cpu_arch": "ppc64el",
|
||||
"cpus": 20L,
|
||||
"ram_mb": 51000L,
|
||||
"disk_gb": 500L,
|
||||
"cpus": 20,
|
||||
"ram_mb": 51000,
|
||||
"disk_gb": 500,
|
||||
"status": "ready",
|
||||
"provisioned": "",
|
||||
"timestamp": "",
|
||||
|
@ -67,9 +73,9 @@ if __name__ == "__main__":
|
|||
"ipmi_password": "c3f06ff4b798a4ea",
|
||||
"port_hwaddr": "88: 6e:9e: fa:65:d8",
|
||||
"cpu_arch": "ppc64el",
|
||||
"cpus": 20L,
|
||||
"ram_mb": 51000L,
|
||||
"disk_gb": 500L,
|
||||
"cpus": 20,
|
||||
"ram_mb": 51000,
|
||||
"disk_gb": 500,
|
||||
"status": "ready",
|
||||
"provisioned": "",
|
||||
"timestamp": "",
|
||||
|
@ -82,9 +88,9 @@ if __name__ == "__main__":
|
|||
"ipmi_password": "2885d1af50781461",
|
||||
"port_hwaddr": "a2: a2: 64:79:6b:69",
|
||||
"cpu_arch": "ppc64el",
|
||||
"cpus": 20L,
|
||||
"ram_mb": 51000L,
|
||||
"disk_gb": 500L,
|
||||
"cpus": 20,
|
||||
"ram_mb": 51000,
|
||||
"disk_gb": 500,
|
||||
"status": "used",
|
||||
"provisioned": "7a72eccd-3153-4d08-9848-c6d3b1f18f9f",
|
||||
"timestamp": "1460489832",
|
||||
|
@ -97,9 +103,9 @@ if __name__ == "__main__":
|
|||
"ipmi_password": "3e374dc88ca43b4f",
|
||||
"port_hwaddr": "50: 4a:56:3c: e9:0f",
|
||||
"cpu_arch": "ppc64el",
|
||||
"cpus": 20L,
|
||||
"ram_mb": 51000L,
|
||||
"disk_gb": 500L,
|
||||
"cpus": 20,
|
||||
"ram_mb": 51000,
|
||||
"disk_gb": 500,
|
||||
"status": "used",
|
||||
"provisioned": "6b8823ef-3e14-4811-98b9-32e27397540d",
|
||||
"timestamp": "1460491566",
|
||||
|
|
13
tox.ini
13
tox.ini
|
@ -83,9 +83,8 @@ commands = mkdir -p testenv/var/run/
|
|||
stop
|
||||
|
||||
[testenv:pep8]
|
||||
#@TODO - too many failures
|
||||
# pass pep8 in a later patch
|
||||
#commands = flake8
|
||||
deps = flake8
|
||||
commands = flake8
|
||||
|
||||
[testenv:venv]
|
||||
#@TODO - a separate patch
|
||||
|
@ -99,6 +98,8 @@ commands = python setup.py build_sphinx
|
|||
# E712 is ignored on purpose, since it is normal to use 'column == true'
|
||||
# in sqlalchemy.
|
||||
# The rest of the ignores are TODOs
|
||||
|
||||
ignore = E712
|
||||
exclude = .venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg,build,tools
|
||||
ignore = E712,E901
|
||||
exclude = .venv,.git,.tox,dist,doc,*lib/python*,*egg,build,testenv/*,devenv/*
|
||||
# F821 undefined name 'unicode'
|
||||
# if (type(id) == str or type(id) == unicode) and ("." in id):
|
||||
builtins = unicode
|
||||
|
|
Loading…
Reference in New Issue