mirror of
https://github.com/linuxkit/linuxkit.git
synced 2025-07-20 17:49:10 +00:00
Merge pull request #1508 from rneugeba/meta
Allow passing LogicalIDs into hyperkit instances
This commit is contained in:
commit
466f59189a
@ -2,7 +2,13 @@
|
|||||||
"ID": "cattle",
|
"ID": "cattle",
|
||||||
"Properties": {
|
"Properties": {
|
||||||
"Allocation": {
|
"Allocation": {
|
||||||
"Size": 5
|
"LogicalIDs": [
|
||||||
|
"192.168.65.200",
|
||||||
|
"192.168.65.201",
|
||||||
|
"192.168.65.202",
|
||||||
|
"192.168.65.203",
|
||||||
|
"192.168.65.204"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"Instance": {
|
"Instance": {
|
||||||
"Plugin": "instance-hyperkit",
|
"Plugin": "instance-hyperkit",
|
||||||
@ -10,7 +16,7 @@
|
|||||||
"Moby": "etcd",
|
"Moby": "etcd",
|
||||||
"Disk" : 0,
|
"Disk" : 0,
|
||||||
"CPUs" : 1,
|
"CPUs" : 1,
|
||||||
"Memory" : 512
|
"Memory" : 512,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"Flavor": {
|
"Flavor": {
|
||||||
|
@ -68,6 +68,13 @@ func (p hyperkitPlugin) Provision(spec instance.Spec) (*instance.ID, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
id := instance.ID(path.Base(instanceDir))
|
id := instance.ID(path.Base(instanceDir))
|
||||||
|
log.Infof("[%s] New instance", id)
|
||||||
|
|
||||||
|
logicalID := string(id)
|
||||||
|
if spec.LogicalID != nil {
|
||||||
|
logicalID = string(*spec.LogicalID)
|
||||||
|
}
|
||||||
|
log.Infof("[%s] LogicalID: %s", id, logicalID)
|
||||||
|
|
||||||
// Start a HyperKit instance
|
// Start a HyperKit instance
|
||||||
h, err := hyperkit.New(p.HyperKit, instanceDir, p.VPNKitSock, "")
|
h, err := hyperkit.New(p.HyperKit, instanceDir, p.VPNKitSock, "")
|
||||||
@ -81,17 +88,25 @@ func (p hyperkitPlugin) Provision(spec instance.Spec) (*instance.ID, error) {
|
|||||||
h.DiskSize = int(properties["Disk"].(float64))
|
h.DiskSize = int(properties["Disk"].(float64))
|
||||||
h.UserData = spec.Init
|
h.UserData = spec.Init
|
||||||
h.Console = hyperkit.ConsoleFile
|
h.Console = hyperkit.ConsoleFile
|
||||||
|
log.Infof("[%s] Booting: %s/%s", id, h.Kernel, h.Initrd)
|
||||||
|
log.Infof("[%s] %d CPUs, %dMB Memory, %dMB Disk", id, h.CPUs, h.Memory, h.DiskSize)
|
||||||
|
|
||||||
err = h.Start("console=ttyS0")
|
err = h.Start("console=ttyS0")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
log.Info("Started new VM: ", id)
|
log.Infof("[%s] Started", id)
|
||||||
|
|
||||||
|
if err := ioutil.WriteFile(path.Join(instanceDir, "logical.id"), []byte(logicalID), 0644); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
tagData, err := types.AnyValue(spec.Tags)
|
tagData, err := types.AnyValue(spec.Tags)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log.Debugf("[%s] tags: %s", id, tagData)
|
||||||
if err := ioutil.WriteFile(path.Join(instanceDir, "tags"), tagData.Bytes(), 0644); err != nil {
|
if err := ioutil.WriteFile(path.Join(instanceDir, "tags"), tagData.Bytes(), 0644); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -206,7 +221,14 @@ func (p hyperkitPlugin) DescribeInstances(tags map[string]string, properties boo
|
|||||||
p.Destroy(id)
|
p.Destroy(id)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
lid := instance.LogicalID(h.Pid)
|
|
||||||
|
lidData, err := ioutil.ReadFile(path.Join(instanceDir, "logical.id"))
|
||||||
|
if err != nil {
|
||||||
|
log.Warningln("Could not get logical ID. Id: ", id)
|
||||||
|
p.Destroy(id)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
lid := instance.LogicalID(lidData)
|
||||||
logicalID = &lid
|
logicalID = &lid
|
||||||
|
|
||||||
descriptions = append(descriptions, instance.Description{
|
descriptions = append(descriptions, instance.Description{
|
||||||
|
Loading…
Reference in New Issue
Block a user