Skip to content

Commit

Permalink
feat(dedicated.vrack): add occ as new eligibility service in vrack
Browse files Browse the repository at this point in the history
ref: MANAGER-15301

Signed-off-by: Sachin Ramesh <[email protected]>
  • Loading branch information
sachinrameshn committed Nov 6, 2024
1 parent 5cc6d50 commit 1da8338
Show file tree
Hide file tree
Showing 6 changed files with 123 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"vrack_menu_add": "Créer un vRack",
"vrack_menu_project_num": "Vrack {{num}}",
"vrack_service_type_dedicatedserver": "Serveur dédié",
"vrack_service_type_ovhcloudconnect": "OVH Cloud connect",
"vrack_service_type_dedicatedcloud": "Hosted Private Cloud",
"vrack_service_type_managedbaremetal": "Managed Bare Metal",
"vrack_service_type_dedicatedconnect": "Dedicated connect",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export const FEATURE_NAMES = {
legacyVrack: 'vrack',
managedBareMetal: 'managed-bare-metal',
managedBareMetalDatacenter: 'managed-bare-metal',
ovhCloudConnect: 'cloud-connect',
};

export const POLLING_INTERVAL = 500;
Expand Down Expand Up @@ -64,6 +65,7 @@ export const TYPE_SERVICE = {
ip: 'ip',
legacyVrack: 'legacyVrack',
ipv6: 'ipv6',
ovhCloudConnect: 'ovhCloudConnect',
};

export const SERVICES = [
Expand Down
67 changes: 62 additions & 5 deletions packages/manager/modules/vrack/src/dashboard/vrack.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -536,8 +536,19 @@ export default class VrackMoveDialogCtrl {
this.updateLegacyVrackServiceInfo();
}
break;
case TYPE_SERVICE.ovhCloudConnect:
// Update ovhcloudconnect
if (
!this.data.eligibleServices?.ovhCloudConnect?.length !==
services.ovhCloudConnect.length
) {
this.data.eligibleServices.ovhCloudConnect =
services.ovhCloudConnect;
// Update ovhcloudconnect
this.updateOvhCloudConnect();
}
break;
default:
this.updateOvhCloudConnect();
break;
}
}
Expand All @@ -555,9 +566,22 @@ export default class VrackMoveDialogCtrl {
}

updateOvhCloudConnect() {
if (this.data.eligibleServices?.ovhCloudConnect?.length > 0) {
this.data.eligibleServices.ovhCloudConnect = [];
}
return this.$q
.all(
this.data.eligibleServices.ovhCloudConnect.map((serviceId) => {
return this.vrackService
.getOvhCloudConnectServer(serviceId)
.then(({ data }) => {
const occ = VrackMoveDialogCtrl.getOvhCloudConnectServerNiceName(
data,
);
return occ;
});
}),
)
.then((ovhCloudConnect) => {
this.data.eligibleServices.ovhCloudConnect = ovhCloudConnect;
});
}

getEligibleServices() {
Expand Down Expand Up @@ -613,8 +637,12 @@ export default class VrackMoveDialogCtrl {
this.updateIpLoadbalancingServiceInfo();
}
break;
case TYPE_SERVICE.ovhCloudConnect:
if (this.data.eligibleServices?.ovhCloudConnect?.length > 0) {
this.updateOvhCloudConnect();
}
break;
default:
this.updateOvhCloudConnect();
break;
}
}
Expand Down Expand Up @@ -1164,6 +1192,12 @@ export default class VrackMoveDialogCtrl {
},
).$promise;
break;
case 'ovhCloudConnect':
task = this.vrackService.associateOvhCloudConnectToVrack(
this.serviceName,
service.id,
);
break;
default:
break;
}
Expand Down Expand Up @@ -1305,6 +1339,12 @@ export default class VrackMoveDialogCtrl {
ipLoadbalancing: service.id,
}).$promise;
break;
case 'ovhCloudConnect':
task = this.vrackService.dissociateOvhCloudConnectFromVrack(
this.serviceName,
service.id,
);
break;
default:
break;
}
Expand Down Expand Up @@ -1395,6 +1435,16 @@ export default class VrackMoveDialogCtrl {
return formattedService;
}

static getOvhCloudConnectServerNiceName(service) {
const formattedService = {
...service,
id: service.uuid,
niceName: service.uuid,
trueServiceType: 'ovhCloudConnect',
};
return formattedService;
}

static getDedicatedServerInterfaceNiceName(service) {
const formattedService = VrackMoveDialogCtrl.getDedicatedServerNiceName(
service.dedicatedServer,
Expand Down Expand Up @@ -1490,6 +1540,13 @@ export default class VrackMoveDialogCtrl {
trueServiceType: 'ip',
};
break;
case 'ovhCloudConnect':
formattedService = {
id: service,
niceName: service,
trueServiceType: 'ovhCloudConnect',
};
break;
case 'cloudProject':
formattedService = VrackMoveDialogCtrl.getCloudProjectNiceName(service);
break;
Expand Down
18 changes: 18 additions & 0 deletions packages/manager/modules/vrack/src/dashboard/vrack.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ export default class Vrack {
return this.$http.get(`/dedicated/server/${serviceName}`);
}

getOvhCloudConnectServer(serviceName) {
return this.$http.get(`/ovhCloudConnect/${serviceName}`);
}

getDedicatedCloud(serviceName) {
return this.$http.get(`/dedicatedCloud/${serviceName}`);
}
Expand All @@ -41,4 +45,18 @@ export default class Vrack {
getIpLoadbalancing(serviceName) {
return this.$http.get(`/ipLoadbalancing/${serviceName}`);
}

associateOvhCloudConnectToVrack(serviceName, ovhCloudConnectId) {
return this.$http
.post(`/vrack/${serviceName}/ovhCloudConnect`, {
ovhCloudConnect: ovhCloudConnectId,
})
.then(({ data }) => data);
}

dissociateOvhCloudConnectFromVrack(serviceName, ovhCloudConnectId) {
return this.$http
.delete(`/vrack/${serviceName}/ovhCloudConnect/${ovhCloudConnectId}`)
.then(({ data }) => data);
}
}
21 changes: 20 additions & 1 deletion packages/manager/modules/vrack/src/partials/available.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ <h2 class="vrack__section-title" data-translate="vrack_your_services"></h2>
'ovh-font ovh-font-ip': serviceType === 'ip',
'ovh-font ovh-font-server': serviceType === 'dedicatedServer' || serviceType === 'dedicatedServerInterface',
'ovh-font ovh-font-network': serviceType === 'dedicatedConnect',
'ovh-font ovh-font-vRack': serviceType === 'legacyVrack'}"
'ovh-font ovh-font-vRack': serviceType === 'legacyVrack',
'oui-icon oui-icon-line-communicating_concept': serviceType === 'ovhCloudConnect'}"
>
</i>
<span data-ng-bind="::$ctrl.getDisplayName(serviceType)"></span>
Expand Down Expand Up @@ -96,6 +97,24 @@ <h2 class="vrack__section-title" data-translate="vrack_your_services"></h2>
</ul>
</li>
</ul>
<ul
class="vrack__service-list"
data-ng-if="serviceType === 'ovhCloudConnect'"
>
<li
class="vrack__service d-flex"
data-ng-repeat="service in services | orderBy: service.niceName track by $index"
data-ng-click="$ctrl.toggleAddService(service.trueServiceType, service.id, service.niceName)"
data-ng-class="{ vrack__service_selected: $ctrl.isSelected(service.trueServiceType, service.id), vrack__service_pending: $ctrl.isPending(service.id) || $ctrl.loaders.adding || $ctrl.loaders.deleting }"
>
<span data-ng-bind="::service.niceName"></span>
<oui-spinner
data-size="s"
data-ng-if="$ctrl.isPending(service.id)"
>
</oui-spinner>
</li>
</ul>
</li>
</ul>
<vrack-select-dialog-modal
Expand Down
21 changes: 20 additions & 1 deletion packages/manager/modules/vrack/src/partials/mapped.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ <h2 class="vrack__section-title" data-translate="vrack_your_vrack"></h2>
'ovh-font ovh-font-ip': serviceType === 'ip',
'ovh-font ovh-font-server': serviceType === 'dedicatedServer' || serviceType === 'dedicatedServerInterface',
'ovh-font ovh-font-network': serviceType === 'dedicatedConnect',
'ovh-font ovh-font-vRack': serviceType === 'legacyVrack'}"
'ovh-font ovh-font-vRack': serviceType === 'legacyVrack',
'oui-icon oui-icon-line-communicating_concept': serviceType === 'ovhCloudConnect'}"
>
</i>
<span data-ng-bind="::$ctrl.getDisplayName(serviceType)"></span>
Expand Down Expand Up @@ -151,6 +152,24 @@ <h2 class="vrack__section-title" data-translate="vrack_your_vrack"></h2>
</ul>
</li>
</ul>
<ul
class="vrack__service-list"
data-ng-if="serviceType === 'ovhCloudConnect'"
>
<li
class="vrack__service vrack__service_selectable d-flex"
data-ng-repeat="service in services | orderBy: service.niceName track by service.id"
data-ng-click="$ctrl.toggleDeleteService(service.trueServiceType, service.id, service.niceName)"
data-ng-class="{ vrack__service_selected: $ctrl.isSelected(service.trueServiceType, service.id), vrack__service_pending: $ctrl.isPending(service.id) || $ctrl.loaders.adding || $ctrl.loaders.deleting }"
>
<span data-ng-bind="::service.niceName"></span>
<oui-spinner
data-size="s"
data-ng-if="$ctrl.isPending(service.id)"
>
</oui-spinner>
</li>
</ul>
</li>
</ul>
<add-ipv6-subnet-modal
Expand Down

0 comments on commit 1da8338

Please sign in to comment.