-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
NOISSUE - Simplify manager to vm provision only (#353)
* new agent structure Signed-off-by: Sammy Oina <[email protected]> * fix lint Signed-off-by: Sammy Oina <[email protected]> * fix tests Signed-off-by: Sammy Oina <[email protected]> * cvm tests fix Signed-off-by: Sammy Oina <[email protected]> * fix test Signed-off-by: Sammy Oina <[email protected]> * manager server, for vm provisioning Signed-off-by: Sammy Oina <[email protected]> * fix lint Signed-off-by: Sammy Oina <[email protected]> * add cli and test Signed-off-by: Sammy Oina <[email protected]> * restore result cli Signed-off-by: Sammy Oina <[email protected]> * fix tests Signed-off-by: Sammy Oina <[email protected]> * fix failing tests Signed-off-by: Sammy Oina <[email protected]> * fix failing test Signed-off-by: Sammy Oina <[email protected]> * refactor: remove context from docker struct and use local context in Run method Signed-off-by: Sammy Oina <[email protected]> * delete: remove unused gRPC API and related server implementation Signed-off-by: Sammy Oina <[email protected]> --------- Signed-off-by: Sammy Oina <[email protected]>
- Loading branch information
Showing
36 changed files
with
653 additions
and
4,560 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
// Copyright (c) Ultraviolet | ||
// SPDX-License-Identifier: Apache-2.0 | ||
package cli | ||
|
||
import ( | ||
"github.com/fatih/color" | ||
"github.com/spf13/cobra" | ||
"github.com/ultravioletrs/cocos/manager" | ||
"google.golang.org/protobuf/types/known/emptypb" | ||
) | ||
|
||
func (c *CLI) NewCreateVMCmd() *cobra.Command { | ||
return &cobra.Command{ | ||
Use: "create-vm", | ||
Short: "Create a new virtual machine", | ||
Example: `create-vm`, | ||
Args: cobra.ExactArgs(0), | ||
Run: func(cmd *cobra.Command, args []string) { | ||
if err := c.InitializeManagerClient(cmd); err == nil { | ||
defer c.Close() | ||
} | ||
|
||
if c.connectErr != nil { | ||
printError(cmd, "Failed to connect to manager: %v ❌ ", c.connectErr) | ||
return | ||
} | ||
|
||
cmd.Println("🔗 Creating a new virtual machine") | ||
|
||
res, err := c.managerClient.CreateVm(cmd.Context(), &emptypb.Empty{}) | ||
if err != nil { | ||
printError(cmd, "Error creating virtual machine: %v ❌ ", err) | ||
return | ||
} | ||
|
||
cmd.Println(color.New(color.FgGreen).Sprintf("✅ Virtual machine created successfully with id %s and port %s", res.SvmId, res.ForwardedPort)) | ||
}, | ||
} | ||
} | ||
|
||
func (c *CLI) NewRemoveVMCmd() *cobra.Command { | ||
return &cobra.Command{ | ||
Use: "remove-vm", | ||
Short: "Remove a virtual machine", | ||
Example: `remove-vm <svm_id>`, | ||
Args: cobra.ExactArgs(1), | ||
Run: func(cmd *cobra.Command, args []string) { | ||
if err := c.InitializeManagerClient(cmd); err == nil { | ||
defer c.Close() | ||
} | ||
|
||
if c.connectErr != nil { | ||
printError(cmd, "Failed to connect to manager: %v ❌ ", c.connectErr) | ||
return | ||
} | ||
|
||
cmd.Println("🔗 Removing virtual machine") | ||
|
||
_, err := c.managerClient.RemoveVm(cmd.Context(), &manager.RemoveReq{SvmId: args[0]}) | ||
if err != nil { | ||
printError(cmd, "Error removing virtual machine: %v ❌ ", err) | ||
return | ||
} | ||
|
||
cmd.Println(color.New(color.FgGreen).Sprintf("✅ Virtual machine removed successfully")) | ||
}, | ||
} | ||
} |
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
Oops, something went wrong.