mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
hostman: ovn: do not set external_ids:iface-id for backup
This commit is contained in:
@@ -222,11 +222,12 @@ func (s *SKVMGuestInstance) generateNicScripts(nic jsonutils.JSONObject) error {
|
||||
if dev == nil {
|
||||
return fmt.Errorf("Can't find bridge %s", bridge)
|
||||
}
|
||||
if err := dev.GenerateIfupScripts(s.getNicUpScriptPath(nic), nic); err != nil {
|
||||
isSlave := s.IsSlave()
|
||||
if err := dev.GenerateIfupScripts(s.getNicUpScriptPath(nic), nic, isSlave); err != nil {
|
||||
log.Errorln(err)
|
||||
return err
|
||||
}
|
||||
if err := dev.GenerateIfdownScripts(s.getNicDownScriptPath(nic), nic); err != nil {
|
||||
if err := dev.GenerateIfdownScripts(s.getNicDownScriptPath(nic), nic, isSlave); err != nil {
|
||||
log.Errorln(err)
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -52,12 +52,12 @@ type IBridgeDriver interface {
|
||||
PersistentMac() error
|
||||
DisableDHCPClient() (bool, error)
|
||||
|
||||
GenerateIfupScripts(scriptPath string, nic jsonutils.JSONObject) error
|
||||
GenerateIfdownScripts(scriptPath string, nic jsonutils.JSONObject) error
|
||||
GenerateIfupScripts(scriptPath string, nic jsonutils.JSONObject, isSlave bool) error
|
||||
GenerateIfdownScripts(scriptPath string, nic jsonutils.JSONObject, isSlave bool) error
|
||||
RegisterHostlocalServer(mac, ip string) error
|
||||
|
||||
getUpScripts(nic jsonutils.JSONObject) (string, error)
|
||||
getDownScripts(nic jsonutils.JSONObject) (string, error)
|
||||
getUpScripts(nic jsonutils.JSONObject, isSlave bool) (string, error)
|
||||
getDownScripts(nic jsonutils.JSONObject, isSlave bool) (string, error)
|
||||
}
|
||||
|
||||
type SBaseBridgeDriver struct {
|
||||
@@ -303,8 +303,8 @@ func (d *SBaseBridgeDriver) saveFileExecutable(scriptPath, script string) error
|
||||
return os.Chmod(scriptPath, syscall.S_IRUSR|syscall.S_IWUSR|syscall.S_IXUSR)
|
||||
}
|
||||
|
||||
func (d *SBaseBridgeDriver) generateIfdownScripts(driver IBridgeDriver, scriptPath string, nic jsonutils.JSONObject) error {
|
||||
script, err := driver.getDownScripts(nic)
|
||||
func (d *SBaseBridgeDriver) generateIfdownScripts(driver IBridgeDriver, scriptPath string, nic jsonutils.JSONObject, isSlave bool) error {
|
||||
script, err := driver.getDownScripts(nic, isSlave)
|
||||
if err != nil {
|
||||
log.Errorln(err)
|
||||
return err
|
||||
@@ -312,8 +312,8 @@ func (d *SBaseBridgeDriver) generateIfdownScripts(driver IBridgeDriver, scriptPa
|
||||
return d.saveFileExecutable(scriptPath, script)
|
||||
}
|
||||
|
||||
func (d *SBaseBridgeDriver) generateIfupScripts(driver IBridgeDriver, scriptPath string, nic jsonutils.JSONObject) error {
|
||||
script, err := driver.getUpScripts(nic)
|
||||
func (d *SBaseBridgeDriver) generateIfupScripts(driver IBridgeDriver, scriptPath string, nic jsonutils.JSONObject, isSlave bool) error {
|
||||
script, err := driver.getUpScripts(nic, isSlave)
|
||||
if err != nil {
|
||||
log.Errorln(err)
|
||||
return err
|
||||
|
||||
@@ -83,15 +83,15 @@ func (l *SLinuxBridgeDriver) Interfaces() ([]string, error) {
|
||||
return infs, nil
|
||||
}
|
||||
|
||||
func (l *SLinuxBridgeDriver) GenerateIfdownScripts(scriptPath string, nic jsonutils.JSONObject) error {
|
||||
return l.generateIfdownScripts(l, scriptPath, nic)
|
||||
func (l *SLinuxBridgeDriver) GenerateIfdownScripts(scriptPath string, nic jsonutils.JSONObject, isSlave bool) error {
|
||||
return l.generateIfdownScripts(l, scriptPath, nic, isSlave)
|
||||
}
|
||||
|
||||
func (l *SLinuxBridgeDriver) GenerateIfupScripts(scriptPath string, nic jsonutils.JSONObject) error {
|
||||
return l.generateIfupScripts(l, scriptPath, nic)
|
||||
func (l *SLinuxBridgeDriver) GenerateIfupScripts(scriptPath string, nic jsonutils.JSONObject, isSlave bool) error {
|
||||
return l.generateIfupScripts(l, scriptPath, nic, isSlave)
|
||||
}
|
||||
|
||||
func (l *SLinuxBridgeDriver) getUpScripts(nic jsonutils.JSONObject) (string, error) {
|
||||
func (l *SLinuxBridgeDriver) getUpScripts(nic jsonutils.JSONObject, isSlave bool) (string, error) {
|
||||
s := "#!/bin/bash\n\n"
|
||||
s += fmt.Sprintf("switch='%s'\n", l.bridge)
|
||||
if options.HostOptions.TunnelPaddingBytes > 0 {
|
||||
@@ -103,7 +103,7 @@ func (l *SLinuxBridgeDriver) getUpScripts(nic jsonutils.JSONObject) (string, err
|
||||
return s, nil
|
||||
}
|
||||
|
||||
func (l *SLinuxBridgeDriver) getDownScripts(nic jsonutils.JSONObject) (string, error) {
|
||||
func (l *SLinuxBridgeDriver) getDownScripts(nic jsonutils.JSONObject, isSlave bool) (string, error) {
|
||||
s := "#!/bin/sh\n\n"
|
||||
s += fmt.Sprintf("switch='%s'\n", l.bridge)
|
||||
s += "brctl show ${switch} | grep $1\n"
|
||||
|
||||
@@ -110,15 +110,15 @@ func (d *SOVSBridgeDriver) PersistentMac() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (o *SOVSBridgeDriver) GenerateIfdownScripts(scriptPath string, nic jsonutils.JSONObject) error {
|
||||
return o.generateIfdownScripts(o, scriptPath, nic)
|
||||
func (o *SOVSBridgeDriver) GenerateIfdownScripts(scriptPath string, nic jsonutils.JSONObject, isSlave bool) error {
|
||||
return o.generateIfdownScripts(o, scriptPath, nic, isSlave)
|
||||
}
|
||||
|
||||
func (o *SOVSBridgeDriver) GenerateIfupScripts(scriptPath string, nic jsonutils.JSONObject) error {
|
||||
return o.generateIfupScripts(o, scriptPath, nic)
|
||||
func (o *SOVSBridgeDriver) GenerateIfupScripts(scriptPath string, nic jsonutils.JSONObject, isSlave bool) error {
|
||||
return o.generateIfupScripts(o, scriptPath, nic, isSlave)
|
||||
}
|
||||
|
||||
func (o *SOVSBridgeDriver) getUpScripts(nic jsonutils.JSONObject) (string, error) {
|
||||
func (o *SOVSBridgeDriver) getUpScripts(nic jsonutils.JSONObject, isSlave bool) (string, error) {
|
||||
var (
|
||||
bridge, _ = nic.GetString("bridge")
|
||||
ifname, _ = nic.GetString("ifname")
|
||||
@@ -166,7 +166,9 @@ func (o *SOVSBridgeDriver) getUpScripts(nic jsonutils.JSONObject) (string, error
|
||||
s += "fi\n"
|
||||
s += "ovs-vsctl add-port $SWITCH $IF $TAG\n"
|
||||
if vpcProvider == compute.VPC_PROVIDER_OVN {
|
||||
s += "ovs-vsctl set Interface $IF external_ids:iface-id=iface-$NET_ID-$IF\n"
|
||||
if !isSlave {
|
||||
s += "ovs-vsctl set Interface $IF external_ids:iface-id=iface-$NET_ID-$IF\n"
|
||||
}
|
||||
}
|
||||
s += "PORT=$(ovs-ofctl show $SWITCH | grep -w $IF)\n"
|
||||
s += "PORT=$(echo $PORT | awk 'BEGIN{FS=\"(\"}{print $1}')\n"
|
||||
@@ -186,7 +188,7 @@ func (o *SOVSBridgeDriver) getUpScripts(nic jsonutils.JSONObject) (string, error
|
||||
return s, nil
|
||||
}
|
||||
|
||||
func (o *SOVSBridgeDriver) getDownScripts(nic jsonutils.JSONObject) (string, error) {
|
||||
func (o *SOVSBridgeDriver) getDownScripts(nic jsonutils.JSONObject, isSlave bool) (string, error) {
|
||||
var (
|
||||
bridge, _ = nic.GetString("bridge")
|
||||
ifname, _ = nic.GetString("ifname")
|
||||
|
||||
Reference in New Issue
Block a user