direct-io.hg

changeset 7560:f3ebb4d6baab

Added network-attach and network-detach. Fixes bug #300.

Signed-off-by: Ewan Mellor <ewan@xensource.com>
author emellor@leeni.uk.xensource.com
date Sun Oct 30 16:44:47 2005 +0100 (2005-10-30)
parents e0ea9320c351
children e212c0b60fbe
files tools/python/xen/xm/main.py
line diff
     1.1 --- a/tools/python/xen/xm/main.py	Sun Oct 30 16:43:52 2005 +0100
     1.2 +++ b/tools/python/xen/xm/main.py	Sun Oct 30 16:44:47 2005 +0100
     1.3 @@ -112,6 +112,12 @@ xm full list of subcommands:
     1.4                                     where <DevId> may either be the device ID
     1.5                                     or the device name as mounted in the guest.
     1.6      block-list    <DomId>          List virtual block devices for a domain
     1.7 +
     1.8 +    network-attach  <DomID> [script=<script>] [ip=<ip>] [mac=<mac>]
     1.9 +                            [bridge=<bridge>] [backend=<backDomID>]
    1.10 +        Create a new virtual network device 
    1.11 +    network-detach  <DomId> <DevId>  Destroy a domain's virtual network
    1.12 +                                     device, where <DevId> is the device ID.
    1.13      network-limit   <DomId> <Vif> <Credit> <Period>
    1.14          Limit the transmission rate of a virtual network interface
    1.15      network-list    <DomId>        List virtual network interfaces for a domain
    1.16 @@ -588,14 +594,39 @@ def xm_block_attach(args):
    1.17      from xen.xend.XendClient import server
    1.18      server.xend_domain_device_create(dom, vbd)
    1.19  
    1.20 -def xm_block_detach(args):
    1.21 -    arg_check(args,2,"block-detach")
    1.22 +
    1.23 +def xm_network_attach(args):
    1.24 +    n = len(args)
    1.25 +    if n == 0:
    1.26 +        usage("network-attach")
    1.27 +        
    1.28 +    dom = args[0]
    1.29 +    vif = ['vif']
    1.30 +
    1.31 +    for a in args[1:]:
    1.32 +        vif.append(a.split("="))
    1.33 +
    1.34 +    from xen.xend.XendClient import server
    1.35 +    server.xend_domain_device_create(dom, vif)
    1.36 +
    1.37 +
    1.38 +def detach(args, command, deviceClass):
    1.39 +    arg_check(args, 2, command)
    1.40  
    1.41      dom = args[0]
    1.42      dev = args[1]
    1.43  
    1.44      from xen.xend.XendClient import server
    1.45 -    server.xend_domain_device_destroy(dom, 'vbd', dev)
    1.46 +    server.xend_domain_device_destroy(dom, deviceClass, dev)
    1.47 +
    1.48 +
    1.49 +def xm_block_detach(args):
    1.50 +    detach(args, 'block-detach', 'vbd')
    1.51 +
    1.52 +
    1.53 +def xm_network_detach(args):
    1.54 +    detach(args, 'network-detach', 'vif')
    1.55 +
    1.56  
    1.57  def xm_vnet_list(args):
    1.58      from xen.xend.XendClient import server
    1.59 @@ -673,6 +704,8 @@ commands = {
    1.60      "block-detach": xm_block_detach,
    1.61      "block-list": xm_block_list,
    1.62      # network
    1.63 +    "network-attach": xm_network_attach,
    1.64 +    "network-detach": xm_network_detach,
    1.65      "network-limit": xm_network_limit,
    1.66      "network-list": xm_network_list,
    1.67      # vnet