2019-03-21 05:46:49 +00:00
|
|
|
export function ContainerGroupDefaultModel() {
|
2018-05-28 14:40:33 +00:00
|
|
|
this.Location = '';
|
|
|
|
this.OSType = 'Linux';
|
|
|
|
this.Name = '';
|
|
|
|
this.Image = '';
|
|
|
|
this.AllocatePublicIP = true;
|
|
|
|
this.Ports = [
|
|
|
|
{
|
|
|
|
container: 80,
|
|
|
|
host: 80,
|
2020-04-10 21:54:53 +00:00
|
|
|
protocol: 'TCP',
|
|
|
|
},
|
2018-05-28 14:40:33 +00:00
|
|
|
];
|
|
|
|
this.CPU = 1;
|
|
|
|
this.Memory = 1;
|
|
|
|
}
|
|
|
|
|
2019-03-21 05:46:49 +00:00
|
|
|
export function ContainerGroupViewModel(data) {
|
2018-05-28 14:40:33 +00:00
|
|
|
this.Id = data.id;
|
|
|
|
this.Name = data.name;
|
|
|
|
this.Location = data.location;
|
|
|
|
this.IPAddress = data.properties.ipAddress.ip;
|
|
|
|
this.Ports = data.properties.ipAddress.ports;
|
|
|
|
}
|
|
|
|
|
2019-03-21 05:46:49 +00:00
|
|
|
export function CreateContainerGroupRequest(model) {
|
2018-05-28 14:40:33 +00:00
|
|
|
this.location = model.Location;
|
|
|
|
|
|
|
|
var containerPorts = [];
|
|
|
|
var addressPorts = [];
|
|
|
|
for (var i = 0; i < model.Ports.length; i++) {
|
|
|
|
var binding = model.Ports[i];
|
|
|
|
|
|
|
|
containerPorts.push({
|
2020-04-10 21:54:53 +00:00
|
|
|
port: binding.container,
|
2018-05-28 14:40:33 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
addressPorts.push({
|
|
|
|
port: binding.host,
|
2020-04-10 21:54:53 +00:00
|
|
|
protocol: binding.protocol,
|
2018-05-28 14:40:33 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
this.properties = {
|
|
|
|
osType: model.OSType,
|
|
|
|
containers: [
|
|
|
|
{
|
|
|
|
name: model.Name,
|
|
|
|
properties: {
|
|
|
|
image: model.Image,
|
|
|
|
ports: containerPorts,
|
|
|
|
resources: {
|
|
|
|
requests: {
|
|
|
|
cpu: model.CPU,
|
2020-04-10 21:54:53 +00:00
|
|
|
memoryInGB: model.Memory,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2018-05-28 14:40:33 +00:00
|
|
|
],
|
|
|
|
ipAddress: {
|
2020-04-10 21:54:53 +00:00
|
|
|
type: model.AllocatePublicIP ? 'Public' : 'Private',
|
|
|
|
ports: addressPorts,
|
|
|
|
},
|
2018-05-28 14:40:33 +00:00
|
|
|
};
|
|
|
|
}
|