X-Git-Url: http://git.onelab.eu/?p=plcapi.git;a=blobdiff_plain;f=trunk%2FPLC%2FMethods%2FDeleteNetworkType.py;fp=trunk%2FPLC%2FMethods%2FDeleteNetworkType.py;h=a02f6e0c876572a58b9cd470776f0be52a0f38bb;hp=0000000000000000000000000000000000000000;hb=5a4c1b1278ffa01e630fde47f7c54888ed20a576;hpb=cee5ab52df1c9f38b6eaff2dd354cb22f59028c7 diff --git a/trunk/PLC/Methods/DeleteNetworkType.py b/trunk/PLC/Methods/DeleteNetworkType.py new file mode 100644 index 0000000..a02f6e0 --- /dev/null +++ b/trunk/PLC/Methods/DeleteNetworkType.py @@ -0,0 +1,35 @@ +from PLC.Faults import * +from PLC.Method import Method +from PLC.Parameter import Parameter, Mixed +from PLC.NetworkTypes import NetworkType, NetworkTypes +from PLC.Auth import Auth + +class DeleteNetworkType(Method): + """ + Deletes a network type. + + WARNING: This will cause the deletion of all network interfaces + that use this type. + + Returns 1 if successful, faults otherwise. + """ + + roles = ['admin'] + + accepts = [ + Auth(), + NetworkType.fields['type'] + ] + + returns = Parameter(int, '1 if successful') + + + def call(self, auth, name): + network_types = NetworkTypes(self.api, [name]) + if not network_types: + raise PLCInvalidArgument, "No such network type" + network_type = network_types[0] + + network_type.delete() + + return 1