<s> """<STR_LIT>""" <EOL> from backend . decorators import required_roles , load , return_object , return_list , log , return_task <EOL> from backend . serializers . serializers import FullSerializer <EOL> from ovs . dal . hybrids . pmachine import PMachine <EOL> from ovs . dal . lists . pmachinelist import PMachineList <EOL> from ovs . lib . mgmtcenter import MgmtCenterController <EOL> from rest_framework import status <EOL> from rest_framework import viewsets <EOL> from rest_framework . decorators import action <EOL> from rest_framework . decorators import link <EOL> from rest_framework . permissions import IsAuthenticated <EOL> from rest_framework . response import Response <EOL> class PMachineViewSet ( viewsets . ViewSet ) : <EOL> """<STR_LIT>""" <EOL> permission_classes = ( IsAuthenticated , ) <EOL> prefix = r'<STR_LIT>' <EOL> base_name = '<STR_LIT>' <EOL> @ log ( ) <EOL> @ required_roles ( [ '<STR_LIT>' ] ) <EOL> @ return_list ( PMachine ) <EOL> @ load ( ) <EOL> def list ( self ) : <EOL> """<STR_LIT>""" <EOL> return PMachineList . get_pmachines ( ) <EOL> @ log ( ) <EOL> @ required_roles ( [ '<STR_LIT>' ] ) <EOL> @ return_object ( PMachine ) <EOL> @ load ( PMachine ) <EOL> def retrieve ( self , pmachine ) : <EOL> """<STR_LIT>""" <EOL> return pmachine <EOL> @ log ( ) <EOL> @ required_roles ( [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> @ load ( PMachine ) <EOL> def partial_update ( self , contents , pmachine , request ) : <EOL> """<STR_LIT>""" <EOL> contents = None if contents is None else contents . split ( '<STR_LIT:U+002C>' ) <EOL> serializer = FullSerializer ( PMachine , contents = contents , instance = pmachine , data = request . DATA ) <EOL> if serializer . is_valid ( ) : <EOL> serializer . save ( ) <EOL> return Response ( serializer . data , status = status . HTTP_202_ACCEPTED ) <EOL> else : <EOL> return Response ( serializer . errors , status = status . HTTP_400_BAD_REQUEST ) <EOL> @ action ( ) <EOL> @ log ( ) <EOL> @ required_roles ( [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> @ return_task ( ) <EOL> @ load ( PMachine ) <EOL> def configure_host ( self , pmachine , mgmtcenter_guid , update_link = True ) : <EOL> """<STR_LIT>""" <EOL> return MgmtCenterController . configure_host . s ( pmachine . guid , mgmtcenter_guid , update_link ) . apply_async ( <EOL> routing_key = '<STR_LIT>' . format ( pmachine . storagerouters [ <NUM_LIT:0> ] . machine_id ) <EOL> ) <EOL> @ action ( ) <EOL> @ log ( ) <EOL> @ required_roles ( [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> @ return_task ( ) <EOL> @ load ( PMachine ) <EOL> def unconfigure_host ( self , pmachine , mgmtcenter_guid , update_link = True ) : <EOL> """<STR_LIT>""" <EOL> return MgmtCenterController . unconfigure_host . s ( pmachine . guid , mgmtcenter_guid , update_link ) . apply_async ( <EOL> routing_key = '<STR_LIT>' . format ( pmachine . storagerouters [ <NUM_LIT:0> ] . machine_id ) <EOL> ) <EOL> @ link ( ) <EOL> @ log ( ) <EOL> @ required_roles ( [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> @ return_task ( ) <EOL> @ load ( PMachine ) <EOL> def is_host_configured ( self , pmachine ) : <EOL> """<STR_LIT>""" <EOL> return MgmtCenterController . is_host_configured . s ( pmachine . guid ) . apply_async ( <EOL> routing_key = '<STR_LIT>' . format ( pmachine . storagerouters [ <NUM_LIT:0> ] . machine_id ) <EOL> ) <EOL> @ action ( ) <EOL> @ log ( ) <EOL> @ required_roles ( [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> @ return_task ( ) <EOL> @ load ( PMachine ) <EOL> def configure_vpool_for_host ( self , pmachine , vpool_guid ) : <EOL> """<STR_LIT>""" <EOL> return MgmtCenterController . configure_vpool_for_host . s ( pmachine . guid , vpool_guid ) . apply_async ( <EOL> routing_key = '<STR_LIT>' . format ( pmachine . storagerouters [ <NUM_LIT:0> ] . machine_id ) <EOL> ) <EOL> @ action ( ) <EOL> @ log ( ) <EOL> @ required_roles ( [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> @ return_task ( ) <EOL> @ load ( PMachine ) <EOL> def unconfigure_vpool_for_host ( self , pmachine , vpool_guid ) : <EOL> """<STR_LIT>""" <EOL> return MgmtCenterController . unconfigure_vpool_for_host . s ( pmachine . guid , vpool_guid ) . apply_async ( <EOL> routing_key = '<STR_LIT>' . format ( pmachine . storagerouters [ <NUM_LIT:0> ] . machine_id ) <EOL> ) <EOL> @ link ( ) <EOL> @ log ( ) <EOL> @ required_roles ( [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> @ return_task ( ) <EOL> @ load ( PMachine ) <EOL> def is_host_configured_for_vpool ( self , pmachine , vpool_guid ) : <EOL> """<STR_LIT>""" <EOL> return MgmtCenterController . is_host_configured_for_vpool . s ( pmachine . guid , vpool_guid ) . apply_async ( <EOL> routing_key = '<STR_LIT>' . format ( pmachine . storagerouters [ <NUM_LIT:0> ] . machine_id ) <EOL> ) </s>
