3 from PLC.Method import Method
4 from PLC.Auth import Auth
5 from PLC.Faults import *
6 from PLC.Parameter import *
7 from PLC.Slices import Slice, Slices
9 from PLC.Accessors.Accessors_standard import * # import slice accessors
11 class GetSliceFamily(Method):
13 Returns the slice vserver reference image that a given slice
14 should be based on. This depends on the global PLC settings in the
15 PLC_FLAVOUR area, optionnally overridden by any of the 'vref',
16 'arch', 'pldistro', 'fcdistro' tag if set on the slice.
19 roles = ['admin', 'user', 'node']
21 # don't support sliver-specific settings yet
24 Mixed(Slice.fields['slice_id'],
25 Slice.fields['name']),
28 returns = Parameter (str, "the slice-family this slice should be based upon")
31 ### system slices - at least planetflow - still rely on 'vref'
33 def call(self, auth, slice_id_or_name):
34 # Get slice information
35 slices = Slices(self.api, [slice_id_or_name])
37 raise PLCInvalidArgument, "No such slice %r"%slice_id_or_name
39 slice_id = slice['slice_id']
41 # the vref tag, if set, wins
42 vref = GetSliceVref (self.api).call(auth,slice_id)
45 arch = GetSliceArch (self.api).call(auth,slice_id)
46 if not arch: arch = self.api.config.PLC_FLAVOUR_SLICE_ARCH
48 pldistro = GetSlicePldistro (self.api).call(auth, slice_id)
49 if not pldistro: pldistro = self.api.config.PLC_FLAVOUR_SLICE_PLDISTRO
51 fcdistro = GetSliceFcdistro (self.api).call(auth, slice_id)
52 if not fcdistro: fcdistro = self.api.config.PLC_FLAVOUR_SLICE_FCDISTRO
54 # xxx would make sense to check the corresponding vserver rpms are available
55 # in all node-families yum repos (and yumgroups, btw)
56 return "%s-%s-%s"%(pldistro,fcdistro,arch)