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

feat(dedicated): add slaac option to vrack ipv6 block #11663

Merged
merged 3 commits into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ export const STATUS = {
delivered: 'delivered',
};

export const SLAAC_VALUES = {
enabled: true,
disabled: false,
};

export const VRACK_DASHBOARD_TRACKING_PREFIX = 'vrack::dashboard';
export const VRACK_ACTIONS_SUFFIX = 'action';

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
export const SLAAC_GUIDES_LINK = {
DE:
'https://help.ovhcloud.com/csm/de-dedicated-servers-configure-an-ipv6-in-a-vrack?id=kb_article_view&sysparm_article=KB0062832',
ASIA:
'https://help.ovhcloud.com/csm/asia-dedicated-servers-configure-an-ipv6-in-a-vrack?id=kb_article_view&sysparm_article=KB0062833',
AU:
'https://help.ovhcloud.com/csm/en-au-dedicated-servers-configure-an-ipv6-in-a-vrack?id=kb_article_view&sysparm_article=KB0062836',
CA:
'https://help.ovhcloud.com/csm/en-ca-dedicated-servers-configure-an-ipv6-in-a-vrack?id=kb_article_view&sysparm_article=KB0062827',
GB:
'https://help.ovhcloud.com/csm/en-gb-dedicated-servers-configure-an-ipv6-in-a-vrack?id=kb_article_view&sysparm_article=KB0062828',
IE:
'https://help.ovhcloud.com/csm/en-ie-dedicated-servers-configure-an-ipv6-in-a-vrack?id=kb_article_view&sysparm_article=KB0062826',
SG:
'https://help.ovhcloud.com/csm/en-sg-dedicated-servers-configure-an-ipv6-in-a-vrack?id=kb_article_view&sysparm_article=KB0062829',
EN:
'https://help.ovhcloud.com/csm/en-dedicated-servers-configure-an-ipv6-in-a-vrack?id=kb_article_view&sysparm_article=KB0062838',
ES:
'https://help.ovhcloud.com/csm/es-es-dedicated-servers-configure-an-ipv6-in-a-vrack?id=kb_article_view&sysparm_article=KB0062830',
WS:
'https://help.ovhcloud.com/csm/es-dedicated-servers-configure-an-ipv6-in-a-vrack?id=kb_article_view&sysparm_article=KB0062835',
QC:
'https://help.ovhcloud.com/csm/fr-ca-dedicated-servers-configure-an-ipv6-in-a-vrack?id=kb_article_view&sysparm_article=KB0062834',
FR:
'https://help.ovhcloud.com/csm/fr-dedicated-servers-configure-an-ipv6-in-a-vrack?id=kb_article_view&sysparm_article=KB0062825',
IT:
'https://help.ovhcloud.com/csm/it-dedicated-servers-configure-an-ipv6-in-a-vrack?id=kb_article_view&sysparm_article=KB0062839',
PL:
'https://help.ovhcloud.com/csm/pl-dedicated-servers-configure-an-ipv6-in-a-vrack?id=kb_article_view&sysparm_article=KB0062837',
PT:
'https://help.ovhcloud.com/csm/pt-dedicated-servers-configure-an-ipv6-in-a-vrack?id=kb_article_view&sysparm_article=KB0062831',
DEFAULT:
'https://help.ovhcloud.com/csm/en-ie-dedicated-servers-configure-an-ipv6-in-a-vrack?id=kb_article_view&sysparm_article=KB0062826',
};

export const SLAAC_LABEL = 'SLAAC';
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { POLLING_INTERVAL } from '../../dashboard/vrack.constant';
import { POLLING_INTERVAL, SLAAC_VALUES } from '../../dashboard/vrack.constant';
import { SLAAC_LABEL, SLAAC_GUIDES_LINK } from './ipv6.constant';

export default class VrackAssignedIpCtrl {
/* @ngInject */
Expand All @@ -9,6 +10,7 @@ export default class VrackAssignedIpCtrl {
vrackAssignedIpv6Service,
$translate,
OvhApiVrack,
coreConfig,
) {
this.$q = $q;
this.vrackAssignedIpv6Service = vrackAssignedIpv6Service;
Expand All @@ -18,10 +20,40 @@ export default class VrackAssignedIpCtrl {
this.$timeout = $timeout;
this.loading = false;
this.subnets = [];
this.user = coreConfig.getUser();
this.slaacGuidesLink =
SLAAC_GUIDES_LINK[this.user.ovhSubsidiary] || SLAAC_GUIDES_LINK.DEFAULT;
this.label = { SLAAC: SLAAC_LABEL };
}

$onInit() {
this.refreshData();
this.vrackAssignedIpv6Service
.fetchAllBridgedSubrange(this.serviceName, this.ip.niceName)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should bridgedSubranges be instead in the resolve of the routing file?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nop because this component is not loaded at the init of the page doing like this allow to make the call only when we open the ipv6 detail

.then(({ data }) => {
this.$q
.all(
data.map((bridgedSubrange) => {
return this.vrackAssignedIpv6Service
.getBridgedSubrange(
this.serviceName,
this.ip.niceName,
bridgedSubrange,
)
.then((res) => {
return {
...res.data,
model: SLAAC_VALUES[res.data.slaac],
loading: false,
};
});
}),
)
.then((bridges) => {
this.bridgedSubranges = bridges;
});
});

this.loadSubnet();
}

openAddSubnetModal() {
Expand All @@ -44,7 +76,10 @@ export default class VrackAssignedIpCtrl {
nexthop,
})
.then(({ data }) => {
this.watingTask(data.id);
this.loader = true;
this.watingTask(data.id, () => {
this.loadSubnet();
});
})
.catch((err) => {
this.CucCloudMessage.error(
Expand All @@ -61,6 +96,34 @@ export default class VrackAssignedIpCtrl {
};
}

toggleSubrange(bridgedSubrange) {
const bridged = bridgedSubrange;
bridged.loading = true;
const targetValue = !bridged.model;
this.CucCloudMessage.flushMessages('vrack');
this.vrackAssignedIpv6Service
.updateBridgedSubrange(
this.serviceName,
this.ip.niceName,
bridged.bridgedSubrange,
targetValue,
)
.then(({ data }) => {
this.watingTask(data.id, () => {
bridged.model = targetValue;
bridged.loading = false;
});
})
.catch((err) => {
this.CucCloudMessage.error(
[
this.$translate.instant('vrack_error'),
err?.data?.message || err.message || '',
].join(' '),
);
});
}

openDeleteSubnetModal(subnet) {
this.deleteSubnetModalContext = {
isOpenModal: true,
Expand All @@ -70,7 +133,10 @@ export default class VrackAssignedIpCtrl {
this.vrackAssignedIpv6Service
.deleteIpVrackSubnet(this.serviceName, this.ip.niceName, subnet)
.then(({ data }) => {
this.watingTask(data.id);
this.loader = true;
this.watingTask(data.id, () => {
this.loadSubnet();
});
})
.catch((err) => {
this.CucCloudMessage.error(
Expand All @@ -87,29 +153,28 @@ export default class VrackAssignedIpCtrl {
};
}

refreshData() {
loadSubnet() {
this.vrackAssignedIpv6Service
.getIpVrackSubnet(this.serviceName, this.ip.niceName)
.then(({ data }) => {
this.loader = false;
this.subnets = data;
});
}

watingTask(taskId) {
this.loader = true;
watingTask(taskId, callback) {
this.OvhApiVrack.v6()
.task({
serviceName: this.serviceName,
taskId,
})
.$promise.then(() => {
this.$timeout(() => {
this.watingTask(taskId);
this.watingTask(taskId, callback);
}, POLLING_INTERVAL);
})
.catch(() => {
this.loader = false;
this.refreshData();
if (callback) callback();
});
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div class="vrack__assigned-ip">
<div class="vrack__assigned-ip__sub-item">
<div class="vrack__assigned-ipv6">
<div class="vrack__assigned-ipv6__sub-item">
<button
class="oui-button oui-button_secondary oui-button_icon-left"
ng-click="$ctrl.openAddSubnetModal()"
Expand All @@ -8,14 +8,62 @@
<span data-translate="vrack__assigned-ipv6_add_subnet"></span>
</button>
</div>
<!-- subridg -->
<li
class="vrack__assigned-ipv6__subrange"
data-ng-repeat="bridged in $ctrl.bridgedSubranges track by $index"
>
<span
class="vrack__assigned-ipv6__subrange__title"
data-ng-bind="::bridged.bridgedSubrange"
></span>
<span>
{{:: $ctrl.label.SLAAC }}
<oui-switch
data-ng-hide="bridged.loading"
model="bridged.model"
on-change="$ctrl.toggleSubrange(bridged)"
>
</oui-switch>
<oui-spinner data-size="s" data-ng-show="bridged.loading">
</oui-spinner>
</span>
<button
type="button"
class="oui-popover-button"
data-oui-popover="{{:: 'vrack__assigned-ipv6__subrange_slaac_help' | translate }}"
data-oui-popover-placement="right"
data-oui-popover-scope="$ctrl"
data-oui-popover-template="vrack__assigned-ipv6__subrange_slaac_help.html"
></button>
<script
type="text/ng-template"
id="vrack__assigned-ipv6__subrange_slaac_help.html"
>
<p
data-translate="vrack__assigned-ipv6__subrange_slaac_help"
></p>
<a
class="oui-link_icon"
aria-hidden="true"
data-ng-href="{{$ctrl.slaacGuidesLink}}"
target="_blank"
>
<span class="oui-icon oui-icon-book ml-0" aria-hidden="true"></span>
<span
data-translate="vrack__assigned-ipv6__subrange_slaac_help_tooltip_link"
></span>
</a>
</script>
</li>
<ul
class="vrack__assigned-ip__sub-item"
class="vrack__assigned-ipv6__sub-item"
data-ng-repeat="subnet in $ctrl.subnets track by $index"
>
<!-- subnet -->
<li class="vrack__assigned-ip__subnet">
<li class="vrack__assigned-ipv6__subnet">
<span
class="vrack__assigned-ip__subnet__title"
class="vrack__assigned-ipv6__subnet__title"
data-translate="vrack__assigned-ipv6_subnet_via"
data-translate-values="{ ipblock: $ctrl.ip.niceName, ip: subnet }"
></span>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
@import '../../dashboard/vrack-mapper.less';

.vrack {
&__assigned-ip {
&__assigned-ipv6 {
&__sub-item {
display: flex;
justify-content: end;
flex-flow: wrap;
}

&__subnet {
&__subnet,
&__subrange {
list-style: none;
padding: 0.625rem 0.9375rem;
border-width: 1px;
Expand All @@ -22,6 +23,7 @@
user-select: none;
cursor: default;
box-shadow: @vrack-service-box-shadow_selected;
overflow: hidden;

&__title {
text-overflow: ellipsis;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,33 @@ export default class VrackAssignedIpService {
);
}

fetchAllBridgedSubrange(serviceName, ipBlock) {
return this.$http.get(
`/vrack/${encodeURIComponent(serviceName)}/ipv6/${encodeURIComponent(
ipBlock,
)}/bridgedSubrange`,
);
}

getBridgedSubrange(serviceName, ipBlock, bridgedSubrange) {
return this.$http.get(
`/vrack/${encodeURIComponent(serviceName)}/ipv6/${encodeURIComponent(
ipBlock,
)}/bridgedSubrange/${encodeURIComponent(bridgedSubrange)}`,
);
}

updateBridgedSubrange(serviceName, ipBlock, bridgedSubrange, status) {
return this.$http.put(
`/vrack/${encodeURIComponent(serviceName)}/ipv6/${encodeURIComponent(
ipBlock,
)}/bridgedSubrange/${encodeURIComponent(bridgedSubrange)}`,
{
slaac: status ? 'enabled' : 'disabled',
},
);
}

deleteIpVrackSubnet(serviceName, ipBlock, routedSubrange) {
return this.$http.delete(
`/vrack/${encodeURIComponent(serviceName)}/ipv6/${encodeURIComponent(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"vrack__assigned-ipv6_add_subnet": "Ajouter un sous réseau",
"vrack__assigned-ipv6__subrang_slaac_help": "L'activation de SLAAC facilite l'adressage IPv6, mais évitez de l'utiliser avec plusieurs région utilisés par vRack",
"vrack__assigned-ipv6__subrang_slaac_help_tooltip_link": "Plus de détails",
"vrack__assigned-ipv6__subrange_slaac_help": "L'activation de SLAAC facilite l'adressage IPv6, mais évitez de l'utiliser avec plusieurs région utilisés par vRack",
"vrack__assigned-ipv6__subrange_slaac_help_tooltip_link": "Plus de détails",
"vrack__assigned-ipv6__subnet_add_title": "Ajouter un sous-réseau",
"vrack__assigned-ipv6__subnet_add_description": "Vous allez ajouter un nouveau sous-réseau routé /64 à votre vRack. Veuillez spécifier le préfixe (qui ne doit pas chevaucher un autre préfixe existant) ainsi que l'adresse next-hop qui doit faire partie du premier sous-réseau /64 (bridged) de votre bloc IPv6 additionnel.",
"vrack__assigned-ipv6__subnet_add_subnet": "IPv6 subnet en format CIDR",
Expand Down
Loading