ref 2979. Generar instrucciones de deploy imagen actualizado.
parent
fe75009481
commit
2a225b9539
|
|
@ -217,6 +217,17 @@ export class DeployImageComponent implements OnInit {
|
|||
this.filteredPartitions = fullClientData.partitions;
|
||||
this.selectedRepository = fullClientData.repository ?? null;
|
||||
|
||||
if (this.selectedRepository?.uuid) {
|
||||
this.http.get(`${this.baseUrl}/image-repositories/${this.selectedRepository.uuid}`).subscribe(
|
||||
(repository: any) => {
|
||||
this.selectedRepository = repository;
|
||||
},
|
||||
(error) => {
|
||||
console.error(this.translate.instant('errorLoadingRepositories1'), error);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
if (fullClientData.partitions) {
|
||||
this.filteredPartitions = fullClientData.partitions.filter((partition: any) => {
|
||||
return partition.partitionNumber !== 0;
|
||||
|
|
@ -586,9 +597,102 @@ export class DeployImageComponent implements OnInit {
|
|||
});
|
||||
}
|
||||
|
||||
|
||||
generateOgInstructions() {
|
||||
this.showInstructions = true;
|
||||
this.ogInstructions = `og-deploy-image --image ${this.selectedImage.name} --partition ${this.selectedPartition?.partitionNumber || 1} --method ${this.selectedMethod}`;
|
||||
this.ogInstructions = this.imageType === 'git'
|
||||
? this.buildGitOgInstructions()
|
||||
: this.buildMonolithicOgInstructions();
|
||||
}
|
||||
|
||||
private getTargetClients(): any[] {
|
||||
if (this.selectedClients.length) {
|
||||
return this.selectedClients;
|
||||
}
|
||||
return this.selectedModelClient ? [this.selectedModelClient] : [];
|
||||
}
|
||||
|
||||
|
||||
private getProto(method: string | null): string {
|
||||
switch (method) {
|
||||
case 'uftp-direct':
|
||||
case 'udpcast-direct':
|
||||
return 'MULTICAST-DIRECT';
|
||||
case 'multicast':
|
||||
case 'uftp':
|
||||
case 'udpcast':
|
||||
return 'MULTICAST';
|
||||
case 'unicast-direct':
|
||||
return 'UNICAST-DIRECT';
|
||||
case 'unicast':
|
||||
return 'UNICAST';
|
||||
case 'p2p':
|
||||
return 'TORRENT';
|
||||
default:
|
||||
return (method || '').toUpperCase();
|
||||
}
|
||||
}
|
||||
|
||||
private getProtoOpt(method: string | null): string {
|
||||
if (method === 'udpcast' || method === 'uftp' || method === 'udpcast-direct') {
|
||||
const mcastMode = `${this.mcastMode}-duplex`;
|
||||
const mcastSpeed = `${this.mcastSpeed}M`;
|
||||
return `${this.mcastPort}:${mcastMode}:${this.mcastIp}:${mcastSpeed}:${this.mcastMaxClients}:${this.mcastMaxTime}`;
|
||||
}
|
||||
if (method === 'p2p') {
|
||||
return `${this.p2pMode}:${this.p2pTime}`;
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
private buildMonolithicOgInstructions(): string {
|
||||
const method = this.selectedMethod;
|
||||
const proto = this.getProto(method);
|
||||
const protoOpt = this.getProtoOpt(method);
|
||||
|
||||
const disk = String(this.selectedPartition?.diskNumber || 1);
|
||||
const par = String(this.selectedPartition?.partitionNumber || 1);
|
||||
const imgname = this.selectedImage?.name || '<image>';
|
||||
const repo = this.selectedRepository?.ip || '<repository-ip>';
|
||||
|
||||
const effectiveDeployMode = this.isDirectMethod() ? 'deploy' : this.deployMode;
|
||||
const isCache = effectiveDeployMode === 'update-cache';
|
||||
|
||||
const restaurarArgs = [disk, par, imgname, repo, proto, protoOpt].filter(a => a !== '').join(' ');
|
||||
const scriptName = isCache ? 'ActualizarCache' : 'RestaurarImagen';
|
||||
|
||||
const innerCommand = isCache
|
||||
? ['updateCache', repo, `/${imgname}.img`, proto, protoOpt].filter(a => a !== '').join(' ')
|
||||
: ['deployImage', repo, imgname, disk, par, proto, protoOpt].filter(a => a !== '').join(' ');
|
||||
|
||||
const clients = this.getTargetClients();
|
||||
const targets = clients.length ? clients : [{ name: '<cliente>', ip: '<client-ip>' }];
|
||||
|
||||
return targets.map(client =>
|
||||
`# Cliente ${client.name || client.ip} (${client.ip || '<client-ip>'})\n` +
|
||||
`${scriptName} ${restaurarArgs}\n` +
|
||||
` ↳ ${innerCommand}`
|
||||
).join('\n\n');
|
||||
}
|
||||
|
||||
private buildGitOgInstructions(): string {
|
||||
const disk = String(this.selectedPartition?.diskNumber || 1);
|
||||
const par = String(this.selectedPartition?.partitionNumber || 1);
|
||||
const repo = this.selectedRepository?.ip || '<repository-ip>';
|
||||
const imageName = this.selectedGitRepository || '<repository-name>';
|
||||
const branch = this.selectedBranch || '<branch>';
|
||||
const commit = this.selectedCommit?.hexsha || '<commit>';
|
||||
|
||||
const command =
|
||||
`RestaurarImagenGit --disk ${disk} --partition ${par} --repository ${repo} ` +
|
||||
`--image-name ${imageName} --branch ${branch} --commit ${commit}`;
|
||||
|
||||
const clients = this.getTargetClients();
|
||||
const targets = clients.length ? clients : [{ name: '<cliente>', ip: '<client-ip>' }];
|
||||
|
||||
return targets.map(client =>
|
||||
`# Cliente ${client.name || client.ip} (${client.ip || '<client-ip>'})\n${command}`
|
||||
).join('\n\n');
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue