~allenap/maas/xxx-a-thon

« back to all changes in this revision

Viewing changes to src/maasserver/static/js/angular/factories/vlans.js

  • Committer: Gavin Panella
  • Date: 2016-03-22 21:14:34 UTC
  • mfrom: (4657.1.157 maas)
  • Revision ID: gavin.panella@canonical.com-20160322211434-xzuovio86zvzo2js
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
43
43
            return subnets;
44
44
        };
45
45
 
 
46
        VLANsManager.prototype.getName = function(vlan) {
 
47
            var name = vlan.vid;
 
48
            if(vlan.vid === 0) {
 
49
                name = "untagged";
 
50
            } else if(angular.isString(vlan.name) && vlan.name !== "") {
 
51
                name += " (" + vlan.name + ")";
 
52
            }
 
53
            return name;
 
54
        };
 
55
 
 
56
        // Delete the VLAN.
 
57
        VLANsManager.prototype.deleteVLAN = function(vlan) {
 
58
            return RegionConnection.callMethod(
 
59
                "vlan.delete", { "id": vlan.id }, true);
 
60
        };
 
61
 
 
62
        // This is needed for testing: in the normal course of things,
 
63
        // rack_sids is generated entirely by the websocket handler.
 
64
        VLANsManager.prototype.addRackController = function(vlan, rack) {
 
65
            vlan.rack_sids.push(rack.system_id);
 
66
        };
 
67
 
 
68
        // Configure DHCP on the VLAN
 
69
        VLANsManager.prototype.configureDHCP = function(
 
70
            vlan, controllers, extra) {
 
71
            return RegionConnection.callMethod(
 
72
                "vlan.configure_dhcp", {
 
73
                    "id": vlan.id,
 
74
                    "controllers": controllers,
 
75
                    "extra": extra
 
76
                }, true);
 
77
        };
 
78
 
 
79
        // Create a VLAN.
 
80
        VLANsManager.prototype.create = function(vlan) {
 
81
            // We don't add the item to the list because a NOTIFY event will
 
82
            // add the domain to the list. Adding it here will cause angular to
 
83
            // complain because the same object exist in the list.
 
84
            return RegionConnection.callMethod("vlan.create", vlan);
 
85
        };
 
86
 
46
87
        return new VLANsManager();
47
88
    }]);