1 from PLC.Method import Method
2 from PLC.Auth import Auth
3 from PLC.Faults import *
4 from PLC.Parameter import *
5 from PLC.Slices import Slice, Slices
6 from PLC.SliceTags import SliceTag, SliceTags
8 class GetSliceFamily(Method):
10 Returns the slice vserver reference image that a given slice
11 should be based on. This depends on the global PLC settings in the
12 PLC_FLAVOUR area, optionnally overridden by any of the 'vref',
13 'arch', 'pldistro', 'fcdistro' tag if set on the slice.
16 roles = ['admin', 'user', 'node']
18 # don't support sliver-specific settings yet
21 Mixed(Slice.fields['slice_id'],
22 Slice.fields['name']),
25 returns = Parameter (str, "the slicefamily this slice should be based upon")
28 ### system slices - at least planetflow - still rely on 'vref'
30 def call(self, auth, slice_id_or_name):
32 arch = self.api.config.PLC_FLAVOUR_SLICE_ARCH
33 pldistro = self.api.config.PLC_FLAVOUR_SLICE_PLDISTRO
34 fcdistro = self.api.config.PLC_FLAVOUR_SLICE_FCDISTRO
37 # Get slice information
38 slices = Slices(self.api, [slice_id_or_name])
40 raise PLCInvalidArgument, "No such slice %r"%slice_id_or_name
42 slice_tags = SliceTags(self.api, slice['slice_tag_ids'])
44 for slice_tag in slice_tags:
45 if slice_tag['tagname'] == 'arch':
46 arch = slice_tag['value']
47 elif slice_tag['tagname'] == 'pldistro':
48 pldistro = slice_tag['value']
49 elif slice_tag['tagname'] == 'fcdistro':
50 fcdistro = slice_tag['value']
51 elif slice_tag['tagname'] == 'vref':
52 vref = slice_tag['value']
54 # omf-control'ed slivers need the omf vserver reference image
55 # we used to issue SetSliceVref (self.api) (auth,slice_id,'omf')
56 # to avoid asking users to set both tags 'omf_control' and 'vref'
57 # however we can't use SetSliceVref here because a node is only allowed
58 # to set a sliver tag, not a slice tag
59 # and this somehow gets called from GetSlivers
60 # anyways it was a bad idea, let's have the UI do that instead
62 # xxx would make sense to check the corresponding vserver rpms are available
63 # in all node-families yum repos (and yumgroups, btw)
65 return "%s-%s-%s"%(vref,fcdistro,arch)
67 return "%s-%s-%s"%(pldistro,fcdistro,arch)