~james-page/ubuntu/saucy/openvswitch/1.12-snapshot

« back to all changes in this revision

Viewing changes to utilities/ovs-vsctl.c

  • Committer: James Page
  • Date: 2013-08-21 10:16:57 UTC
  • mfrom: (1.1.20)
  • Revision ID: james.page@canonical.com-20130821101657-3o0z0qeiv5zkwlzi
New upstream snapshot

Show diffs side-by-side

added added

removed removed

Lines of Context:
128
128
static struct table_style table_style = TABLE_STYLE_DEFAULT;
129
129
 
130
130
/* All supported commands. */
131
 
static const struct vsctl_command_syntax all_commands[];
 
131
static const struct vsctl_command_syntax *get_all_commands(void);
132
132
 
133
133
/* The IDL we're using and the current transaction, if any.
134
134
 * This is for use by vsctl_exit() only, to allow it to clean up.
302
302
    options = xmemdup(global_long_options, sizeof global_long_options);
303
303
    allocated_options = ARRAY_SIZE(global_long_options);
304
304
    n_options = n_global_long_options;
305
 
    for (p = all_commands; p->name; p++) {
 
305
    for (p = get_all_commands(); p->name; p++) {
306
306
        if (p->options[0]) {
307
307
            char *save_ptr = NULL;
308
308
            char *name;
568
568
    if (shash_is_empty(&commands)) {
569
569
        const struct vsctl_command_syntax *p;
570
570
 
571
 
        for (p = all_commands; p->name; p++) {
 
571
        for (p = get_all_commands(); p->name; p++) {
572
572
            shash_add_assert(&commands, p->name, p);
573
573
        }
574
574
    }
1453
1453
    ovsdb_idl_add_column(ctx->idl, &ovsrec_bridge_col_mirrors);
1454
1454
    ovsdb_idl_add_column(ctx->idl, &ovsrec_bridge_col_netflow);
1455
1455
    ovsdb_idl_add_column(ctx->idl, &ovsrec_bridge_col_sflow);
 
1456
    ovsdb_idl_add_column(ctx->idl, &ovsrec_bridge_col_ipfix);
1456
1457
    ovsdb_idl_add_column(ctx->idl, &ovsrec_bridge_col_flood_vlans);
1457
1458
    ovsdb_idl_add_column(ctx->idl, &ovsrec_bridge_col_other_config);
1458
1459
 
1477
1478
    const struct ovsrec_netflow *nf, *next_nf;
1478
1479
    const struct ovsrec_ssl *ssl, *next_ssl;
1479
1480
    const struct ovsrec_sflow *sflow, *next_sflow;
 
1481
    const struct ovsrec_ipfix *ipfix, *next_ipfix;
 
1482
    const struct ovsrec_flow_sample_collector_set *fscset, *next_fscset;
1480
1483
 
1481
1484
    /* Reset the Open_vSwitch table. */
1482
1485
    ovsrec_open_vswitch_set_manager_options(ctx->ovs, NULL, 0);
1490
1493
        ovsrec_bridge_set_mirrors(br, NULL, 0);
1491
1494
        ovsrec_bridge_set_netflow(br, NULL);
1492
1495
        ovsrec_bridge_set_sflow(br, NULL);
 
1496
        ovsrec_bridge_set_ipfix(br, NULL);
1493
1497
        ovsrec_bridge_set_flood_vlans(br, NULL, 0);
1494
1498
 
1495
1499
        /* We only want to save the "hwaddr" key from other_config. */
1539
1543
        ovsrec_sflow_delete(sflow);
1540
1544
    }
1541
1545
 
 
1546
    OVSREC_IPFIX_FOR_EACH_SAFE (ipfix, next_ipfix, idl) {
 
1547
        ovsrec_ipfix_delete(ipfix);
 
1548
    }
 
1549
 
 
1550
    OVSREC_FLOW_SAMPLE_COLLECTOR_SET_FOR_EACH_SAFE (fscset, next_fscset, idl) {
 
1551
        ovsrec_flow_sample_collector_set_delete(fscset);
 
1552
    }
 
1553
 
1542
1554
    vsctl_context_invalidate_cache(ctx);
1543
1555
}
1544
1556
 
1668
1680
{
1669
1681
    struct vsctl_bridge *child, *next_child;
1670
1682
    struct vsctl_port *port, *next_port;
 
1683
    const struct ovsrec_flow_sample_collector_set *fscset, *next_fscset;
1671
1684
 
1672
1685
    HMAP_FOR_EACH_SAFE (child, next_child, children_node, &br->children) {
1673
1686
        del_bridge(ctx, child);
1677
1690
        del_port(ctx, port);
1678
1691
    }
1679
1692
 
 
1693
    OVSREC_FLOW_SAMPLE_COLLECTOR_SET_FOR_EACH_SAFE (fscset, next_fscset,
 
1694
                                                    ctx->idl) {
 
1695
        if (fscset->bridge == br->br_cfg) {
 
1696
            ovsrec_flow_sample_collector_set_delete(fscset);
 
1697
        }
 
1698
    }
 
1699
 
1680
1700
    del_cached_bridge(ctx, br);
1681
1701
}
1682
1702
 
1996
2016
{
1997
2017
    bool must_exist = !shash_find(&ctx->options, "--if-exists");
1998
2018
    bool with_iface = shash_find(&ctx->options, "--with-iface") != NULL;
 
2019
    const char *target = ctx->argv[ctx->argc - 1];
1999
2020
    struct vsctl_port *port;
2000
2021
 
2001
2022
    vsctl_context_populate_cache(ctx);
2002
 
    if (!with_iface) {
2003
 
        port = find_port(ctx, ctx->argv[ctx->argc - 1], must_exist);
 
2023
    if (find_bridge(ctx, target, false)) {
 
2024
        if (must_exist) {
 
2025
            vsctl_fatal("cannot delete port %s because it is the local port "
 
2026
                        "for bridge %s (deleting this port requires deleting "
 
2027
                        "the entire bridge)", target, target);
 
2028
        }
 
2029
        port = NULL;
 
2030
    } else if (!with_iface) {
 
2031
        port = find_port(ctx, target, must_exist);
2004
2032
    } else {
2005
 
        const char *target = ctx->argv[ctx->argc - 1];
2006
2033
        struct vsctl_iface *iface;
2007
2034
 
2008
2035
        port = find_port(ctx, target, false);
2464
2491
static const struct vsctl_table_class tables[] = {
2465
2492
    {&ovsrec_table_bridge,
2466
2493
     {{&ovsrec_table_bridge, &ovsrec_bridge_col_name, NULL},
2467
 
      {NULL, NULL, NULL}}},
 
2494
      {&ovsrec_table_flow_sample_collector_set, NULL,
 
2495
       &ovsrec_flow_sample_collector_set_col_bridge}}},
2468
2496
 
2469
2497
    {&ovsrec_table_controller,
2470
2498
     {{&ovsrec_table_bridge,
2518
2546
     {{&ovsrec_table_flow_table, &ovsrec_flow_table_col_name, NULL},
2519
2547
      {NULL, NULL, NULL}}},
2520
2548
 
 
2549
    {&ovsrec_table_ipfix,
 
2550
     {{&ovsrec_table_bridge,
 
2551
       &ovsrec_bridge_col_name,
 
2552
       &ovsrec_bridge_col_ipfix},
 
2553
      {&ovsrec_table_flow_sample_collector_set, NULL,
 
2554
       &ovsrec_flow_sample_collector_set_col_ipfix}}},
 
2555
 
 
2556
    {&ovsrec_table_flow_sample_collector_set,
 
2557
     {{NULL, NULL, NULL},
 
2558
      {NULL, NULL, NULL}}},
 
2559
 
2521
2560
    {NULL, {{NULL, NULL, NULL}, {NULL, NULL, NULL}}}
2522
2561
};
2523
2562
 
4189
4228
    {NULL, 0, 0, NULL, NULL, NULL, NULL, RO},
4190
4229
};
4191
4230
 
 
4231
static const struct vsctl_command_syntax *get_all_commands(void)
 
4232
{
 
4233
    return all_commands;
 
4234
}