X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=xenserver%2Fopt_xensource_libexec_interface-reconfigure;h=27195ad93e69c60f3f59316edcf0de53cd77711f;hb=057fed2b5cfe81bf3ab328a9514a1caf0dfa4f55;hp=e77e85b1d5cd236125fb2ae009d216f022b6d352;hpb=5de7052b9b5fe58628057984ddc99e9cf8a66596;p=openvswitch diff --git a/xenserver/opt_xensource_libexec_interface-reconfigure b/xenserver/opt_xensource_libexec_interface-reconfigure index e77e85b1..27195ad9 100755 --- a/xenserver/opt_xensource_libexec_interface-reconfigure +++ b/xenserver/opt_xensource_libexec_interface-reconfigure @@ -5,22 +5,26 @@ # """Usage: - %(command-name)s --session --pif [up|down|rewrite] - %(command-name)s --force [up|down|rewrite ] + %(command-name)s up + %(command-name)s down + %(command-name)s [] rewrite + %(command-name)s --force up + %(command-name)s --force down + %(command-name)s --force rewrite --device= %(command-name)s --force all down - where, - = --device= --mode=dhcp - = --device= --mode=static --ip= --netmask= [--gateway=] + where is one of: + --session --pif + --pif-uuid + and is one of: + --mode=dhcp + --mode=static --ip= --netmask= [--gateway=] Options: --session A session reference to use to access the xapi DB - --pif A PIF reference. - --force-interface An interface name. Mutually exclusive with --session/--pif. - - Either both --session and --pif or just --pif-uuid. - - is either "up" or "down" or "rewrite" + --pif A PIF reference within the session. + --pif-uuid The UUID of a PIF. + --force An interface name. """ # @@ -28,7 +32,6 @@ # # --output-directory= Write configuration to . Also disables actually # raising/lowering the interfaces -# --pif-uuid A PIF UUID, use instead of --session/--pif. # # # @@ -38,24 +41,6 @@ # 3. A network may have an associated bridge, allowing vifs to be attached # 4. A network may be bridgeless (there's no point having a bridge over a storage pif) -# XXX: --force-interface=all down - -# XXX: --force-interface rewrite - -# XXX: Sometimes this leaves "orphaned" datapaths, e.g. a datapath whose -# only port is the local port. Should delete those. - -# XXX: This can leave crud in ovs-vswitchd.conf in this scenario: -# - Create bond in XenCenter. -# - Create VLAN on bond in XenCenter. -# - Attempt to delete bond in XenCenter (this will fail because there -# is a VLAN on the bond, although the error may not be reported -# until the next step) -# - Delete VLAN in XenCenter. -# - Delete bond in XenCenter. -# At this point there will still be some configuration data for the bond -# or the VLAN in ovs-vswitchd.conf. - import XenAPI import os, sys, getopt, time, signal import syslog @@ -718,10 +703,7 @@ def log_pif_action(action, pif): rec['ip_configuration_mode'] = pifrec['ip_configuration_mode'] rec['action'] = action rec['interface-name'] = interface_name(pif) - if action == "rewrite": - rec['message'] = "Rewrite PIF %(uuid)s configuration" % rec - else: - rec['message'] = "Bring %(action)s PIF %(uuid)s" % rec + rec['message'] = "Bring %(action)s PIF %(uuid)s" % rec log("%(message)s: %(interface-name)s configured as %(ip_configuration_mode)s" % rec) def get_bond_masters_of_pif(pif): @@ -1048,7 +1030,7 @@ def configure_physdev(pif): run_ethtool(device, oc) def modify_config(commands): - run_command(['/root/vswitch/bin/ovs-cfg-mod', '-vANY:console:emer', + run_command(['/usr/bin/ovs-cfg-mod', '-vANY:console:emer', '-F', '/etc/ovs-vswitchd.conf'] + commands + ['-c']) run_command(['/sbin/service', 'vswitch', 'reload']) @@ -1208,7 +1190,7 @@ def action_up(pif): # - The networks corresponding to any VLANs attached to the # datapath's PIF. network_uuids = [] - for nwpif in db.get_pifs_by_device({'device': pifrec['device']}): + for nwpif in db.get_pifs_by_device(pifrec['device']): net = db.get_pif_record(nwpif)['network'] network_uuids += [db.get_network_record(net)['uuid']] @@ -1481,35 +1463,37 @@ def main(argv=None): if pif_uuid: pif = db.get_pif_by_uuid(pif_uuid) - - if not pif: - raise Usage("No PIF given") - if force_management: - # pif is going to be the management pif - management_pif = pif + if action == "rewrite" and not pif: + pass else: - # pif is not going to be the management pif. - # Search DB cache for pif on same host with management=true - pifrec = db.get_pif_record(pif) - management_pif = db.get_management_pif() + if not pif: + raise Usage("No PIF given") + + if force_management: + # pif is going to be the management pif + management_pif = pif + else: + # pif is not going to be the management pif. + # Search DB cache for pif on same host with management=true + pifrec = db.get_pif_record(pif) + management_pif = db.get_management_pif() - log_pif_action(action, pif) + log_pif_action(action, pif) - if not check_allowed(pif): - return 0 + if not check_allowed(pif): + return 0 - if action == "up": - action_up(pif) - elif action == "down": - action_down(pif) - elif action == "rewrite": - action_rewrite(pif) - else: - raise Usage("Unknown action %s" % action) + if action == "up": + action_up(pif) + elif action == "down": + action_down(pif) + elif action == "rewrite": + action_rewrite(pif) + else: + raise Usage("Unknown action %s" % action) # Save cache. - pifrec = db.get_pif_record(pif) db.save(dbcache_file) except Usage, err: