Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update How to deploy a machine with mycelium network script #3310

Merged
merged 4 commits into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 32 additions & 13 deletions packages/grid_client/scripts/single_vm_mycelium.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
import { MachinesModel } from "../src";
import { generateRandomHexSeed, GridClient, MachinesDeleteModel, MachinesModel } from "../src";
import { config, getClient } from "./client_loader";
import { log } from "./utils";

async function deploy(client, vms) {
async function deploy(client: GridClient, vms: MachinesModel) {
const res = await client.machines.deploy(vms);
log("================= Deploying VM =================");
log(res);
log("================= Deploying VM =================");
}

async function getDeployment(client, vms) {
const res = await client.machines.getObj(vms);
async function getDeployment(client: GridClient, name: string) {
const res = await client.machines.getObj(name);
log("================= Getting deployment information =================");
log(res);
log("================= Getting deployment information =================");
}

async function cancel(client, vms) {
const res = await client.machines.delete(vms);
async function cancel(client: GridClient, options: MachinesDeleteModel) {
const res = await client.machines.delete(options);
log("================= Canceling the deployment =================");
log(res);
log("================= Canceling the deployment =================");
Expand All @@ -32,12 +32,18 @@ async function main() {
network: {
name: "hellotest",
ip_range: "10.249.0.0/16",
// myceliumSeeds: [
// {
// nodeId: 168,
// seed: "050d109829d8492d48bfb33b711056080571c69e46bfde6b4294c4c5bf468a76", //(HexSeed of length 32)
// },
// ],
myceliumSeeds: [
{
nodeId: 168,
/**
* ### Mycelium Network Seed:
* - The `seed` is an optional field used to provide a specific seed for the Mycelium network.
* - If not provided, the `GridClient` will generate a seed automatically when the `mycelium` flag is enabled.
* - **Use Case:** If you need the new machine to have the same IP address as a previously deleted machine, you can reuse the old seed by setting the `myceliumSeed` field.
*/
seed: generateRandomHexSeed(32),
},
],
},
machines: [
{
Expand All @@ -53,8 +59,21 @@ async function main() {
public_ip: false,
public_ip6: false,
planetary: true,
/**
* ### Mycelium Flag Behavior:
* - When the `mycelium` flag is enabled, there’s no need to manually provide the `myceliumSeed` flag.
* - The `GridClient` will automatically generate the necessary seed for you.
* - **However**, if you have **an existing seed** from a previously deleted machine and wish to deploy a new machine that retains the same IP address,
* - **you can simply pass in the old seed during deployment instead of calling the `generateRandomHexSeed()` function**.
*/
mycelium: true,
// myceliumSeed: "1e1404279b3d", //(HexSeed of length 6)
/**
* ### Mycelium Seed:
* - The `myceliumSeed` is an optional field used to provide a specific seed for the Mycelium network.
* - If not provided, the `GridClient` will generate a seed automatically when the `mycelium` flag is enabled.
* - **Use Case:** If you need the new machine to have the same IP address as a previously deleted machine, you can reuse the old seed by setting the `myceliumSeed` field.
*/
myceliumSeed: generateRandomHexSeed(6), // (HexSeed of length 6)
cpu: 1,
memory: 1024 * 2,
rootfs_size: 0,
Expand Down
19 changes: 19 additions & 0 deletions packages/grid_client/src/modules/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,12 @@ class NetworkModel {
}

class MyceliumNetworkModel {
/**
* ### Mycelium Network Seed:
* - The `seed` is an optional field used to provide a specific seed for the Mycelium network.
* - If not provided, the `GridClient` will generate a seed automatically when the `mycelium` flag is enabled.
* - **Use Case:** If you need the new machine to have the same IP address as a previously deleted machine, you can reuse the old seed by setting the `myceliumSeed` field.
*/
@Expose() @IsString() @Length(32) seed?: string;
@Expose() @IsInt() @Min(1) nodeId: number;
}
Expand All @@ -110,7 +116,20 @@ class MachineModel {
@Expose() @IsBoolean() public_ip: boolean;
@Expose() @IsOptional() @IsBoolean() public_ip6?: boolean;
@Expose() @IsBoolean() planetary: boolean;
/**
* ### Mycelium Flag Behavior:
* - When the `mycelium` flag is enabled, there’s no need to manually provide the `myceliumSeed` flag.
* - The `GridClient` will automatically generate the necessary seed for you.
* - **However**, if you have **an existing seed** from a previously deleted machine and wish to deploy a new machine that retains the same IP address,
* - **you can simply pass in the old seed during deployment instead of calling the `generateRandomHexSeed()` function**.
*/
@Expose() @IsBoolean() mycelium: boolean;
/**
* ### Mycelium Seed:
* - The `myceliumSeed` is an optional field used to provide a specific seed for the Mycelium network.
* - If not provided, the `GridClient` will generate a seed automatically when the `mycelium` flag is enabled.
* - **Use Case:** If you need the new machine to have the same IP address as a previously deleted machine, you can reuse the old seed by setting the `myceliumSeed` field.
*/
@Expose() @IsOptional() @IsString() @Length(6) myceliumSeed?: string;
@Expose() @IsInt() @Min(1) cpu: number;
@Expose() @Min(256) memory: number; // in MB
Expand Down
Loading