This repository has been archived by the owner on Apr 20, 2024. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Release: com.io7m.waxmill 0.0.2 Change: Add the vm-kill command
- Loading branch information
Showing
46 changed files
with
671 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
92 changes: 92 additions & 0 deletions
92
...o7m.waxmill.cmdline/src/main/java/com/io7m/waxmill/cmdline/internal/WXMCommandVMKill.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
/* | ||
* Copyright © 2020 Mark Raynsford <code@io7m.com> http://io7m.com | ||
* | ||
* Permission to use, copy, modify, and/or distribute this software for any | ||
* purpose with or without fee is hereby granted, provided that the above | ||
* copyright notice and this permission notice appear in all copies. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY | ||
* SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR | ||
* IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
*/ | ||
|
||
package com.io7m.waxmill.cmdline.internal; | ||
|
||
import com.beust.jcommander.Parameter; | ||
import com.beust.jcommander.Parameters; | ||
import com.io7m.claypot.core.CLPCommandContextType; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import java.nio.file.Path; | ||
import java.util.UUID; | ||
|
||
import static com.io7m.claypot.core.CLPCommandType.Status.SUCCESS; | ||
import static com.io7m.waxmill.machines.WXMDryRun.DRY_RUN; | ||
import static com.io7m.waxmill.machines.WXMDryRun.EXECUTE; | ||
|
||
@Parameters(commandDescription = "Kill a virtual machine.") | ||
public final class WXMCommandVMKill extends WXMAbstractCommandWithConfiguration | ||
{ | ||
private static final Logger LOG = | ||
LoggerFactory.getLogger(WXMCommandVMKill.class); | ||
|
||
@Parameter( | ||
names = "--machine", | ||
description = "The ID of the virtual machine", | ||
required = true, | ||
converter = WXMUUIDConverter.class | ||
) | ||
private UUID id; | ||
|
||
@Parameter( | ||
names = "--dry-run", | ||
description = "Show the commands that would be executed, but do not execute them.", | ||
required = false, | ||
arity = 1 | ||
) | ||
private boolean dryRun; | ||
|
||
/** | ||
* Construct a command. | ||
* | ||
* @param inContext The command context | ||
*/ | ||
|
||
public WXMCommandVMKill( | ||
final CLPCommandContextType inContext) | ||
{ | ||
super(LOG, inContext); | ||
} | ||
|
||
@Override | ||
public String extendedHelp() | ||
{ | ||
return this.messages().format("vmKillHelp"); | ||
} | ||
|
||
@Override | ||
public String name() | ||
{ | ||
return "vm-kill"; | ||
} | ||
|
||
@Override | ||
protected Status executeActualWithConfiguration( | ||
final Path configurationPath) | ||
throws Exception | ||
{ | ||
try (var client = WXMServices.clients().open(configurationPath)) { | ||
final var machine = client.vmFind(this.id); | ||
client.vmKill( | ||
machine, | ||
this.dryRun ? DRY_RUN : EXECUTE | ||
); | ||
} | ||
return SUCCESS; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
...ocumentation/src/main/resources/com/io7m/waxmill/documentation/cmdline-vm-kill-output.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
(Formatted for legibility) | ||
|
||
$ waxmill vm-kill \ | ||
--machine 538a90e4-d50d-4511-8643-ae418279bac4 \ | ||
--dry-run true | ||
|
||
/usr/sbin/bhyvectl \ | ||
--vm=538a90e4-d50d-4511-8643-ae418279bac4 \ | ||
--destroy |
90 changes: 90 additions & 0 deletions
90
...xmill.documentation/src/main/resources/com/io7m/waxmill/documentation/cmdline-vm-kill.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
|
||
<Section xmlns="urn:com.io7m.structural:7:0" | ||
id="2ce6975a-cb78-408e-bf0f-1fa10288f049" | ||
xmlns:xi="http://www.w3.org/2001/XInclude" | ||
title="vm-kill"> | ||
|
||
<Subsection title="Name"> | ||
<Paragraph> | ||
<Term type="command">vm-kill</Term> | ||
- Kill a running virtual machine | ||
</Paragraph> | ||
</Subsection> | ||
|
||
<Subsection title="Description"> | ||
<Paragraph> | ||
The <Term type="command">vm-kill</Term> command kills a running virtual machine. | ||
</Paragraph> | ||
|
||
<FormalItem title="Parameters" | ||
type="parametersTable"> | ||
<Table type="parametersTable"> | ||
<Columns> | ||
<Column>Parameter</Column> | ||
<Column>Type</Column> | ||
<Column>Required</Column> | ||
<Column>Description</Column> | ||
</Columns> | ||
<Row> | ||
<Cell> | ||
<Term type="parameter">--configuration</Term> | ||
</Cell> | ||
<Cell> | ||
<Term type="parameterType">Path</Term> | ||
</Cell> | ||
<Cell> | ||
<Term type="constant">false</Term> | ||
</Cell> | ||
<Cell>The path to the configuration file (environment variable: $WAXMILL_CONFIGURATION_FILE)</Cell> | ||
</Row> | ||
<Row> | ||
<Cell> | ||
<Term type="parameter">--dry-run</Term> | ||
</Cell> | ||
<Cell> | ||
<Term type="parameterType">Boolean</Term> | ||
</Cell> | ||
<Cell> | ||
<Term type="constant">false</Term> | ||
</Cell> | ||
<Cell>Show the commands that would be executed, but do not execute them.</Cell> | ||
</Row> | ||
<Row> | ||
<Cell> | ||
<Term type="parameter">--machine</Term> | ||
</Cell> | ||
<Cell> | ||
<Term type="parameterType">UUID</Term> | ||
</Cell> | ||
<Cell> | ||
<Term type="constant">true</Term> | ||
</Cell> | ||
<Cell>The ID of the virtual machine</Cell> | ||
</Row> | ||
<Row> | ||
<Cell> | ||
<Term type="parameter">--verbose</Term> | ||
</Cell> | ||
<Cell> | ||
<Term type="parameterType">Log Level</Term> | ||
</Cell> | ||
<Cell> | ||
<Term type="constant">false</Term> | ||
</Cell> | ||
<Cell>Set the minimum logging verbosity level.</Cell> | ||
</Row> | ||
</Table> | ||
</FormalItem> | ||
</Subsection> | ||
|
||
<Subsection title="Example"> | ||
<FormalItem title="Example"> | ||
<Verbatim> | ||
<xi:include parse="text" | ||
href="cmdline-vm-kill-output.txt"/> | ||
</Verbatim> | ||
</FormalItem> | ||
</Subsection> | ||
|
||
</Section> |
Oops, something went wrong.