1 ### $Id: slices.py 15842 2009-11-22 09:56:13Z anil $
2 ### $URL: https://svn.planet-lab.org/svn/sfa/trunk/sfa/plc/slices.py $
9 from types import StringTypes
10 from sfa.util.misc import *
11 from sfa.util.rspec import *
12 from sfa.util.specdict import *
13 from sfa.util.faults import *
14 from sfa.util.record import GeniRecord
15 from sfa.util.policy import Policy
16 from sfa.util.prefixTree import prefixTree
17 from sfa.util.debug import log
18 from sfa.server.registry import Registries
19 from sfa.util import peers
21 def delete_slice(api, hrn):
22 slicename = hrn_to_pl_slicename(hrn)
23 slices = api.plshell.GetSlices(self.api.plauth, {'name': slicename})
28 # determine if this is a peer slice
29 peer = peers.get_peer(hrn)
31 api.plshell.UnBindObjectFromPeer(api.plauth, 'slice', slice['slice_id'], peer)
32 api.plshell.DeleteSliceFromNodes(api.plauth, slicename, slice['node_ids'])
34 api.plshell.BindObjectToPeer(api.plauth, 'slice', slice['slice_id'], peer, slice['peer_slice_id'])
37 def create_slice(api, hrn, rspec):
38 # XX just import the legacy module and excute that until
39 # we transition the code to this module
40 from sfa.plc.slices import Slices
42 slices.create_slice(hrn, rspec)
44 def start_slice(api, hrn):
45 slicename = hrn_to_pl_slicename(hrn)
46 slices = api.plshell.GetSlices(api.plauth, {'name': slicename}, ['slice_id'])
48 raise RecordNotFound(hrn)
50 attributes = api.plshell.GetSliceTags(api.plauth, {'slice_id': slice_id, 'name': 'enabled'}, ['slice_attribute_id'])
51 attribute_id = attreibutes[0]['slice_attribute_id']
52 api.plshell.UpdateSliceTag(api.plauth, attribute_id, "1" )
56 def stop_slice(api, hrn):
57 slicename = hrn_to_pl_slicename(hrn)
58 slices = api.plshell.GetSlices(api.plauth, {'name': slicename}, ['slice_id'])
60 raise RecordNotFound(hrn)
61 slice_id = slices[0]['slice_id']
62 attributes = api.plshell.GetSliceTags(api.plauth, {'slice_id': slice_id, 'name': 'enabled'}, ['slice_attribute_id'])
63 attribute_id = attributes[0]['slice_attribute_id']
64 api.plshell.UpdateSliceTag(api.plauth, attribute_id, "0")
67 def reset_slice(api, hrn):
68 # XX not implemented at this interface
72 # XX just import the legacy module and excute that until
73 # we transition the code to this module
74 from sfa.plc.slices import Slices