Esempio n. 1
0
    def uploadAndUseArchive(self, filename):
        """
		Upload and use an executable archive
		topology actions for rextfv, combined.
		:param str filename: executable archive file
		:return:
		"""
        upload_and_use_rextfv(self.api, self.el_id, filename)
Esempio n. 2
0
	def uploadAndUseArchive(self, filename):
		"""
		Upload and use an executable archive
		topology actions for rextfv, combined.
		:param str filename: executable archive file
		:return:
		"""
		upload_and_use_rextfv(self.api, self.el_id, filename)
Esempio n. 3
0
def run():
    """
	Parses the command-line arguments, opens an API connection and creates access to the available commands of the host.
	It decides based on the options whether to directly execute python code or to execute a file or to grant access to the interactive cli.

	"""
    options = parseArgs()
    url = options.url if options.url else createUrl(
        options.protocol, options.hostname, options.port, options.username,
        options.password)
    api = getConnection(url, options.client_cert)
    locals = getLocals(api)
    locals[
        "upload_and_use_rextfv"] = lambda element_id, filename: upload_and_use_rextfv(
            api, element_id, filename)
    locals[
        "upload_and_use_image"] = lambda element_id, filename: upload_and_use_image(
            api, element_id, filename)
    locals["download_rextfv"] = lambda element_id, filename: download_rextfv(
        api, element_id, filename)
    locals["download_image"] = lambda element_id, filename: download_image(
        api, element_id, filename)
    if options.arguments:
        runSource(locals, "\n".join(options.arguments))
    elif options.file:
        runFile(locals, options.file, options)
    else:
        runInteractive(locals)
Esempio n. 4
0
def run():
	"""
	Parses the command-line arguments, opens an API connection and creates access to the available commands of the host.
	It decides based on the options whether to directly execute python code or to execute a file or to grant access to the interactive cli.

	"""
	options = parseArgs()
	url = options.url if options.url else createUrl(options.protocol, options.hostname, options.port, options.username, options.password)
	api = getConnection(url, options.client_cert)
	locals = getLocals(api)
	locals["upload_and_use_rextfv"] = lambda element_id, filename: upload_and_use_rextfv(api, element_id, filename)
	locals["upload_and_use_image"] = lambda element_id, filename: upload_and_use_image(api, element_id, filename)
	locals["download_rextfv"] = lambda element_id, filename: download_rextfv(api, element_id, filename)
	locals["download_image"] = lambda element_id, filename: download_image(api, element_id, filename)
	if options.arguments:
		runSource(locals, "\n".join(options.arguments))
	elif options.file:
		runFile(locals, options.file, options)
	else:
		runInteractive(locals)
Esempio n. 5
0
    while os.path.exists(os.path.join("/tmp",
                                      "tomato_demo_setup_%d" % randint)):
        randint = random.randint(0, 100000)
    installer_dir = os.path.join("/tmp", "tomato_demo_setup_%d" % randint)
    installer_archive = os.path.join(installer_dir, "install_demo.tar.gz")

    shutil.copytree("archive_content", installer_dir)
    with open(os.path.join(installer_dir, "config.json"), "w+") as f:
        json.dump(config, f)
    with tarfile.open(installer_archive, 'w:gz') as tar:
        tar.add(installer_dir, arcname='.')

    for name, inf in config.iteritems():
        print "Installing software on '%s'" % name
        print "  python"
        upload_and_use_rextfv(api, inf["element_id"], "install_python.tar.gz",
                              True)
        print "  demo software"
        upload_and_use_rextfv(api, inf["element_id"], installer_archive, True)

    shutil.rmtree(installer_dir)

htmlfile = create_html(options, config, top_id)

print ""
print "Configuration complete"
print ""
print "IDs:"
print "  topology:", top_id
for name, info in config.iteritems():
    print "  " + name + ":", info["element_id"]
print ""
Esempio n. 6
0
 def uploadAndUseArchive(self, filename):
     upload_and_use_rextfv(self.api, self.el_id, filename)
Esempio n. 7
0
	def uploadAndUseArchive(self, filename):
		upload_and_use_rextfv(self.api, self.el_id, filename)
Esempio n. 8
0
File: setup.py Progetto: GLab/ToMaTo
	randint = random.randint(0, 100000)
	while os.path.exists(os.path.join("/tmp", "tomato_demo_setup_%d" % randint)):
		randint = random.randint(0, 100000)
	installer_dir = os.path.join("/tmp", "tomato_demo_setup_%d" % randint)
	installer_archive = os.path.join(installer_dir, "install_demo.tar.gz")

	shutil.copytree("archive_content", installer_dir)
	with open(os.path.join(installer_dir, "config.json"), "w+") as f:
		json.dump(config, f)
	with tarfile.open(installer_archive, 'w:gz') as tar:
		tar.add(installer_dir, arcname='.')

	for name, inf in config.iteritems():
		print "Installing software on '%s'" % name
		print "  python"
		upload_and_use_rextfv(api, inf["element_id"], "install_python.tar.gz", True)
		print "  demo software"
		upload_and_use_rextfv(api, inf["element_id"], installer_archive, True)

	shutil.rmtree(installer_dir)

htmlfile = create_html(options, config, top_id)

print ""
print "Configuration complete"
print ""
print "IDs:"
print "  topology:", top_id
for name, info in config.iteritems():
	print "  "+name+":", info["element_id"]
print ""
Esempio n. 9
0
	def _upload_and_use_rextfv(*args, **kwargs):
		return upload_and_use_rextfv(api, *args, **kwargs)