Skip to content

Commit

Permalink
Merge pull request #2738 from threefoldtech/development_filter_by_ipv6
Browse files Browse the repository at this point in the history
  • Loading branch information
zaelgohary authored Jun 9, 2024
2 parents e5c94e2 + c32e50d commit 44f15ae
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/grid_client/src/modules/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,7 @@ class FilterOptions {
@Expose() @IsOptional() @Min(0) sru?: number; // GB
@Expose() @IsOptional() @Min(0) hru?: number; // GB
@Expose() @IsOptional() @IsBoolean() publicIPs?: boolean;
@Expose() @IsOptional() @IsBoolean() hasIPv6?: boolean;
@Expose() @IsOptional() @IsBoolean() accessNodeV4?: boolean;
@Expose() @IsOptional() @IsBoolean() accessNodeV6?: boolean;
@Expose() @IsOptional() @IsBoolean() gateway?: boolean;
Expand Down Expand Up @@ -629,6 +630,7 @@ class FarmFilterOptions {
@Expose() @IsOptional() @Min(0) nodeSRU?: number; // GB
@Expose() @IsOptional() @Min(0) nodeHRU?: number; // GB
@Expose() @IsOptional() @IsBoolean() publicIp?: boolean;
@Expose() @IsOptional() @IsBoolean() nodeHasIPv6?: boolean;
@Expose() @IsOptional() @IsBoolean() certificationType?: CertificationType;
@Expose() @IsOptional() @IsString() farmName?: string;
@Expose() @IsOptional() @IsString() country?: string;
Expand Down
2 changes: 2 additions & 0 deletions packages/grid_client/src/primitives/nodes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,7 @@ class Nodes {
free_ips: options.publicIPs ? 1 : "",
ipv4: options.accessNodeV4,
ipv6: options.accessNodeV6,
has_ipv6: options.hasIPv6,
certification_type: options.certified ? "Certified" : "",
farm_ids: options.farmId ? [options.farmId] : options.farmIds,
farm_name: options.farmName,
Expand Down Expand Up @@ -448,6 +449,7 @@ class Nodes {
country: options.country,
dedicated: options.dedicated,
node_available_for: options.availableFor,
node_has_ipv6: options.nodeHasIPv6,
node_status: "up",
page: options.page,
size: options.size,
Expand Down
3 changes: 3 additions & 0 deletions packages/gridproxy_client/src/builders/farms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export interface FarmsQuery {
certificationType: CertificationType;
dedicated: boolean;
stellarAddress: string;
nodeHasIPv6: boolean;
}

const FARMS_MAPPER: BuilderMapper<FarmsQuery> = {
Expand All @@ -39,6 +40,7 @@ const FARMS_MAPPER: BuilderMapper<FarmsQuery> = {
stellarAddress: "stellar_address",
totalIps: "total_ips",
twinId: "twin_id",
nodeHasIPv6: "node_has_ipv6",
};

const FARMS_VALIDATOR: BuilderValidator<FarmsQuery> = {
Expand All @@ -58,6 +60,7 @@ const FARMS_VALIDATOR: BuilderValidator<FarmsQuery> = {
},
dedicated: assertBoolean,
stellarAddress: assertString,
nodeHasIPv6: assertBoolean,
};

export class FarmsBuilder extends AbstractBuilder<FarmsQuery> {
Expand Down
3 changes: 3 additions & 0 deletions packages/gridproxy_client/src/builders/nodes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ export interface NodesQuery {
sortBy: SortBy;
sortOrder: SortOrder;
numGpu: number;
hasIPv6: boolean;
}

const NODES_MAPPER: BuilderMapper<NodesQuery> = {
Expand Down Expand Up @@ -117,6 +118,7 @@ const NODES_MAPPER: BuilderMapper<NodesQuery> = {
sortBy: "sort_by",
sortOrder: "sort_order",
numGpu: "num_gpu",
hasIPv6: "has_ipv6",
};

const NODES_VALIDATOR: BuilderValidator<NodesQuery> = {
Expand Down Expand Up @@ -174,6 +176,7 @@ const NODES_VALIDATOR: BuilderValidator<NodesQuery> = {
sortBy: assertString,
sortOrder: assertString,
numGpu: assertInt,
hasIPv6: assertBoolean,
};

export class NodesBuilder extends AbstractBuilder<NodesQuery> {
Expand Down
2 changes: 2 additions & 0 deletions packages/playground/src/utils/nodeSelector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ export function normalizeFarmFilters(
publicIp: filters.ipv4 || undefined,
nodeCertified: filters.certified || undefined,
nodeHasGPU: filters.hasGPU || undefined,
nodeHasIPv6: filters.ipv6 || undefined,
};
}

Expand Down Expand Up @@ -195,6 +196,7 @@ export function normalizeNodeFilters(
(filters.solutionDisk ?? 0) + (filters.rootFilesystemSize ?? 0),
) || undefined,
publicIPs: filters.ipv4 || undefined,
hasIPv6: filters.ipv6 || undefined,
hasGPU: filters.hasGPU || undefined,
rentedBy: filters.dedicated ? options.twinId : undefined,
certified: filters.certified || undefined,
Expand Down
6 changes: 6 additions & 0 deletions packages/playground/src/views/nodes.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@
/>
</TfFilter>

<TfFilter query-route="ipv6" v-model="filters.ipv6">
<v-switch color="primary" inset label="IPv6" v-model="filters.ipv6" density="compact" hide-details />
</TfFilter>

<TfFilter class="mt-4" query-route="node-status" v-model="filters.status">
<v-select
:model-value="filters.status || undefined"
Expand Down Expand Up @@ -509,6 +513,7 @@ export default {
dedicated: false,
numGpu: "",
rentable: false,
ipv6: false,
});
const loading = ref<boolean>(true);
Expand Down Expand Up @@ -556,6 +561,7 @@ export default {
numGpu: +filters.value.numGpu || undefined,
rentable: filters.value.rentable && profileManager.profile ? filters.value.rentable : undefined,
availableFor: filters.value.rentable && profileManager.profile ? profileManager.profile.twinId : undefined,
hasIPv6: filters.value.ipv6,
},
{ loadFarm: true },
);
Expand Down

0 comments on commit 44f15ae

Please sign in to comment.