-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'development_2.6' into development_2.6_ipv6
- Loading branch information
Showing
71 changed files
with
527 additions
and
413 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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"$schema": "node_modules/lerna/schemas/lerna-schema.json", | ||
"version": "2.5.0-rc2", | ||
"version": "2.5.0-rc3", | ||
"npmClient": "yarn" | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { Decimal } from "decimal.js"; | ||
|
||
const GB = 1024; | ||
|
||
interface RootFSOptions { | ||
/** The machine CPU, should be in cores e.g. 5 cores*/ | ||
CPUCores: number; | ||
/** The machine memory, should be in megabytes e.g. 1024 or 2048 MG*/ | ||
RAMInMegaBytes: number; | ||
} | ||
|
||
/** | ||
* Calculate the root filesystem size (CU - Compute Units) based on provided options. | ||
* | ||
* This function calculates the compute units (CU) required based on the CPU cores and RAM in megabytes. | ||
* If both CPU cores and RAM are provided in the `options` parameter, it calculates CU by multiplying | ||
* the CPU cores with RAM and dividing by 8 * GB, then converting the result to an integer. If the | ||
* calculated CU is zero, it returns 500 / GB; otherwise, it returns 2. | ||
* | ||
* @param {RootFSOptions} [options] - Optional configuration object. | ||
* @param {number} [options.CPUCores] - The number of CPU cores. | ||
* @param {number} [options.RAMInMegaBytes] - The RAM size in megabytes. | ||
* | ||
* @returns {number} - The calculated compute units (CU) based on the provided options. | ||
*/ | ||
function calculateRootFileSystem(options?: RootFSOptions): number { | ||
let cu = 0; | ||
|
||
if (options && options.CPUCores && options.RAMInMegaBytes) { | ||
cu = new Decimal(options.CPUCores) | ||
.mul(options.RAMInMegaBytes) | ||
.divToInt(8 * GB) | ||
.toNumber(); | ||
} | ||
|
||
return cu === 0 ? 500 / GB : 2; | ||
} | ||
|
||
export { calculateRootFileSystem, RootFSOptions }; |
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,91 @@ | ||
import { PublicIPResult, ResultStates } from "../zos"; | ||
|
||
interface NetworkInterface { | ||
/** The network identifier */ | ||
network: string; | ||
/** The IP address of the interface */ | ||
ip: string; | ||
} | ||
|
||
interface ComputeCapacity { | ||
/** Number of CPU cores allocated */ | ||
cpu: number; | ||
/** Amount of memory allocated in MB */ | ||
memory: number; | ||
} | ||
|
||
interface BaseMountData { | ||
/** The name of the mount */ | ||
name: string; | ||
/** The mount point in the filesystem */ | ||
mountPoint: string; | ||
} | ||
|
||
interface ExtendedMountData extends BaseMountData { | ||
/** The size of the mount (optional) */ | ||
size?: number; | ||
/** The state of the mount result (optional) */ | ||
state?: ResultStates; | ||
/** Message providing additional information about the mount result (optional) */ | ||
message?: string; | ||
/** Cache information (optional) */ | ||
cache?: any; | ||
/** Prefix information (optional) */ | ||
prefix?: any; | ||
/** Minimal shards (optional) */ | ||
minimal_shards?: number; | ||
/** Expected shards (optional) */ | ||
expected_shards?: number; | ||
/** QSFS ZDBs name (optional) */ | ||
qsfs_zdbs_name?: string; | ||
/** Metrics endpoint (optional) */ | ||
metricsEndpoint?: string; | ||
} | ||
|
||
// Union type for the mount data | ||
type MountData = BaseMountData | ExtendedMountData; | ||
|
||
export interface ZmachineData { | ||
/** The version of the workload */ | ||
version: number; | ||
/** The contract ID associated with the workload */ | ||
contractId: number; | ||
/** The node ID where the workload is deployed */ | ||
nodeId: string; | ||
/** The name of the workload */ | ||
name: string; | ||
/** The creation timestamp of the workload result */ | ||
created: number; | ||
/** The current state of the workload */ | ||
status: string; | ||
/** Message providing additional information about the workload state */ | ||
message: string; | ||
/** The flist (file list) used by the workload */ | ||
flist: string; | ||
/** The public IP address obtained by the machine */ | ||
publicIP: PublicIPResult; | ||
/** The planetary IP address of the machine */ | ||
planetary: string; | ||
/** The Mycelium IP address of the machine, if applicable */ | ||
myceliumIP: string; | ||
/** List of network interfaces */ | ||
interfaces: NetworkInterface[]; | ||
/** The compute capacity (CPU and memory) allocated to the machine */ | ||
capacity: ComputeCapacity; | ||
/** List of mounts associated with the machine */ | ||
mounts: MountData[]; | ||
/** Environment variables set for the workload */ | ||
env: Record<string, unknown>; | ||
/** The entrypoint command for the workload */ | ||
entrypoint: string; | ||
/** Metadata associated with the workload */ | ||
metadata: string; | ||
/** Description of the workload */ | ||
description: string; | ||
/** Size of the root filesystem */ | ||
rootfs_size: number; | ||
/** Indicates if corex is enabled */ | ||
corex: boolean; | ||
/** The list of the GPUs */ | ||
gpu: string[] | undefined; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { calculateRootFileSystem } from "../../src/helpers/root_fs"; | ||
|
||
describe("Calculate the rootFS size based on the machine specs", () => { | ||
it("should return 2GB when the options are provided", () => { | ||
const options = { CPUCores: 5, RAMInMegaBytes: 2048 }; | ||
const result = calculateRootFileSystem(options); | ||
expect(result).toEqual(2); | ||
}); | ||
|
||
it("should return 0.48828125 when CPU cores and RAM are zero", () => { | ||
const options = { CPUCores: 0, RAMInMegaBytes: 0 }; | ||
const result = calculateRootFileSystem(options); | ||
expect(result).toEqual(0.48828125); | ||
}); | ||
}); |
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.