def action(ip=('i', default_ip)): """ Installs a new database configuration for the appliance. """ # create all tables db.create_all() if not Appliance.get(): # initialize the appliance object appliance = Appliance() appliance.initialize(ip) # sync flavors from pool (openstack sync comes later when we have a user) flavors = Flavors().sync() # configure output configure_blurb()
def action(ip=('i', default_ip)): """ Restores the appliance to factory default settings. """ try: if ip == default_ip: print "Please enter the appliance's IP address." print "Usage: ./manage.py reset -i x.x.x.x" return action # double check they want to do this if query_yes_no("Are you sure you want to reset the appliance?"): # initialize database path = os.path.dirname(os.path.abspath(__file__)) os.system('sqlite3 "%s/utterio.db" < "%s/schema.sql"' % (path, path)) # initialize the appliance object appliance = Appliance() appliance.initialize(ip) # sync with pool database images = Images() iresponse = images.sync(appliance) flavors = Flavors() fresponse = flavors.sync(appliance) if iresponse['response'] != "success": print iresponse['result'] elif fresponse['response'] != "success": print iresponse['result'] else: print "The database has been cleared and a new API token has been generated." configure_blurb() except ValueError as ex: print ex
def action(ip=('i', default_ip)): """ Installs a new database configuration for the appliance. """ # run database reset script - use current path to run file path = os.path.dirname(os.path.abspath(__file__)) # initialize database os.system('sqlite3 "%s/utterio.db" < "%s/schema.sql"' % (path, path)) # initialize the appliance object appliance = Appliance() appliance.initialize(ip) # sync to remote database images = Images() response = images.sync(appliance) flavors = Flavors() response = flavors.sync(appliance) # configure output configure_blurb()
def action(ip=('i', default_ip)): """ Restores the appliance to factory default settings. """ try: if ip == default_ip: print "Please enter the appliance's IP address." print "Usage: ./manage.py reset -i x.x.x.x" return action # double check they want to do this if query_yes_no("Are you sure you want to reset the appliance?"): # initialize database path = os.path.dirname(os.path.abspath(__file__)) os.system('cp "%s/utterio.db" "%s/utterio_backup.db"' % (path, path)) # delete, then create all tables db.drop_all() db.create_all() # initialize the appliance object appliance = Appliance() appliance.initialize(ip) # sync with pool database flavors = Flavors().sync() if flavors['response'] != "success": print flavors['result'] else: print "The database has been cleared and a new API token has been generated." configure_blurb() except ValueError as ex: print ex