Skip to content

Commit

Permalink
Merge pull request #28 from valaparthvi/config
Browse files Browse the repository at this point in the history
[RFR]Add show config option to miqbox
  • Loading branch information
digitronik authored Jun 4, 2020
2 parents 41a1d85 + 584bda3 commit e4d3f07
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 20 deletions.
64 changes: 45 additions & 19 deletions miqbox/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,28 +88,54 @@ def repositories(self):


@click.command(help="Configure MiqBox")
def config():
"""Configure MiqBox"""
@click.option("-s", "--show", is_flag=True, help="Show miqbox configuration")
def config(show):
"""Configure MiqBox and see configuration"""

conf = Configuration()
cfg = conf.data

cfg["libvirt"]["driver"] = click.prompt("Hypervisor drivers url", default=conf.libvirt.driver)
cfg["libvirt"]["storage_pool"]["name"] = click.prompt(
"Storage Pool Name", default=conf.libvirt.pool_name
)
cfg["libvirt"]["storage_pool"]["path"] = click.prompt(
"Storage Pool Path", default=conf.libvirt.pool_path
)
cfg["images"] = click.prompt("Local Image Location", default=conf.image_path)
cfg["repositories"]["upstream"]["url"] = click.prompt(
"Upstream Repository", default=conf.repositories.get("upstream").url
)

if click.confirm("Do you want to set downstream repository?"):
cfg["repositories"]["downstream"]["url"] = click.prompt(
"Downstream Repository", default=conf.repositories.get("downstream").url
if show:
click.echo(
"Appliance:"
f'\n\tUsername: {cfg["appliance"]["username"]}'
f'\n\tPassword: {cfg["appliance"]["password"]}'
)
click.echo(f'Image storage location: {cfg["images"]}')
click.echo(
f'Libvirt:\n\tDriver location: {cfg["libvirt"]["driver"]}\n\tStorage pool:'
f'\n\t\tName: {cfg["libvirt"]["storage_pool"]["name"]}'
f'\n\t\tPath: {cfg["libvirt"]["storage_pool"]["path"]}'
)

click.echo(f'Downstream repository URL: {cfg["repositories"]["downstream"]["url"]}')
click.echo("Downstream versions available:")
for version in cfg["repositories"]["downstream"]["versions"]:
click.echo(f"\t{version}")

click.echo(f'Upstream repository URL: {cfg["repositories"]["upstream"]["url"]}')
click.echo("Upstream versions available:")
for version in cfg["repositories"]["upstream"]["versions"]:
click.echo(f"\t{version.capitalize()}")
else:
cfg["libvirt"]["driver"] = click.prompt(
"Hypervisor drivers url", default=conf.libvirt.driver
)
cfg["libvirt"]["storage_pool"]["name"] = click.prompt(
"Storage Pool Name", default=conf.libvirt.pool_name
)
cfg["libvirt"]["storage_pool"]["path"] = click.prompt(
"Storage Pool Path", default=conf.libvirt.pool_path
)
cfg["images"] = click.prompt("Local Image Location", default=conf.image_path)
cfg["repositories"]["upstream"]["url"] = click.prompt(
"Upstream Repository", default=conf.repositories.get("upstream").url
)

if click.confirm("Do you want to set downstream repository?"):
cfg["repositories"]["downstream"]["url"] = click.prompt(
"Downstream Repository", default=conf.repositories.get("downstream").url
)

conf.write(cfg=cfg)
click.echo(click.style("Configuration saved successfully...", fg="green"))
conf.write(cfg=cfg)
click.echo(click.style("Configuration saved successfully...", fg="green"))
3 changes: 2 additions & 1 deletion miqbox/miqbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,8 @@ def create(image, cpu, memory, db_size, count, configure=False):
click.echo(click.style(f"{name}: {hostname}".center(columns), bold=True))
click.echo(
click.style(
"Note: If Web-UI not respond; Check EVM Server process".center(columns), bold=True,
"Note: If the Web-UI does not respond; Check EVM Server process".center(columns),
bold=True,
)
)
click.echo("=" * columns)

0 comments on commit e4d3f07

Please sign in to comment.