From ea935daca0aa0f0c7ed2b93746bd7fda9d02e920 Mon Sep 17 00:00:00 2001 From: jmpfar Date: Sun, 18 Oct 2020 11:29:33 +0000 Subject: [PATCH 1/2] Add service commands to system api group Adding methods that can start and stop services as well as query some general service information. Adding the methods to the still unreleased v1alpha1 Change-Id: I7fc8b15712fe37095ccf246b847042659d963be4 --- client/api/system/v1alpha1/api.pb.go | 527 +++++++++++++++++- client/api/system/v1alpha1/api.proto | 68 +++ .../system/v1alpha1/client_generated.go | 12 + integrationtests/system_test.go | 79 +++ internal/os/system/api.go | 61 ++ internal/server/system/internal/types.go | 60 ++ .../server/system/internal/types_generated.go | 3 + .../internal/v1alpha1/conversion_generated.go | 122 ++++ .../internal/v1alpha1/server_generated.go | 57 ++ internal/server/system/server.go | 43 ++ .../client/api/system/v1alpha1/api.pb.go | 527 +++++++++++++++++- .../client/api/system/v1alpha1/api.proto | 68 +++ .../system/v1alpha1/client_generated.go | 12 + 13 files changed, 1585 insertions(+), 54 deletions(-) diff --git a/client/api/system/v1alpha1/api.pb.go b/client/api/system/v1alpha1/api.pb.go index 6eb3ce7f..e6ba4de1 100644 --- a/client/api/system/v1alpha1/api.pb.go +++ b/client/api/system/v1alpha1/api.pb.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-go. DO NOT EDIT. -// source: src/github.com/kubernetes-csi/csi-proxy/client/api/system/v1alpha1/api.proto +// source: github.com/kubernetes-csi/csi-proxy/client/api/system/v1alpha1/api.proto package v1alpha1 @@ -24,6 +24,85 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package +// https://docs.microsoft.com/en-us/windows/win32/api/winsvc/ns-winsvc-service_status#members +type ServiceStatus int32 + +const ( + ServiceStatus_SERVICE_STATUS_UNKNOWN ServiceStatus = 0 + ServiceStatus_SERVICE_STATUS_STOPPED ServiceStatus = 1 + ServiceStatus_SERVICE_STATUS_START_PENDING ServiceStatus = 2 + ServiceStatus_SERVICE_STATUS_STOP_PENDING ServiceStatus = 3 + ServiceStatus_SERVICE_STATUS_RUNNING ServiceStatus = 4 + ServiceStatus_SERVICE_STATUS_CONTINUE_PENDING ServiceStatus = 5 + ServiceStatus_SERVICE_STATUS_PAUSE_PENDING ServiceStatus = 6 + ServiceStatus_SERVICE_STATUS_PAUSED ServiceStatus = 7 +) + +var ServiceStatus_name = map[int32]string{ + 0: "SERVICE_STATUS_UNKNOWN", + 1: "SERVICE_STATUS_STOPPED", + 2: "SERVICE_STATUS_START_PENDING", + 3: "SERVICE_STATUS_STOP_PENDING", + 4: "SERVICE_STATUS_RUNNING", + 5: "SERVICE_STATUS_CONTINUE_PENDING", + 6: "SERVICE_STATUS_PAUSE_PENDING", + 7: "SERVICE_STATUS_PAUSED", +} + +var ServiceStatus_value = map[string]int32{ + "SERVICE_STATUS_UNKNOWN": 0, + "SERVICE_STATUS_STOPPED": 1, + "SERVICE_STATUS_START_PENDING": 2, + "SERVICE_STATUS_STOP_PENDING": 3, + "SERVICE_STATUS_RUNNING": 4, + "SERVICE_STATUS_CONTINUE_PENDING": 5, + "SERVICE_STATUS_PAUSE_PENDING": 6, + "SERVICE_STATUS_PAUSED": 7, +} + +func (x ServiceStatus) String() string { + return proto.EnumName(ServiceStatus_name, int32(x)) +} + +func (ServiceStatus) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_4066a9d4a9264c6f, []int{0} +} + +// https://docs.microsoft.com/en-us/windows/win32/api/winsvc/nf-winsvc-changeserviceconfiga +type StartType int32 + +const ( + StartType_START_TYPE_BOOT StartType = 0 + StartType_START_TYPE_SYSTEM StartType = 1 + StartType_START_TYPE_AUTOMATIC StartType = 2 + StartType_START_TYPE_MANUAL StartType = 3 + StartType_START_TYPE_DISABLED StartType = 4 +) + +var StartType_name = map[int32]string{ + 0: "START_TYPE_BOOT", + 1: "START_TYPE_SYSTEM", + 2: "START_TYPE_AUTOMATIC", + 3: "START_TYPE_MANUAL", + 4: "START_TYPE_DISABLED", +} + +var StartType_value = map[string]int32{ + "START_TYPE_BOOT": 0, + "START_TYPE_SYSTEM": 1, + "START_TYPE_AUTOMATIC": 2, + "START_TYPE_MANUAL": 3, + "START_TYPE_DISABLED": 4, +} + +func (x StartType) String() string { + return proto.EnumName(StartType_name, int32(x)) +} + +func (StartType) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_4066a9d4a9264c6f, []int{1} +} + type GetBIOSSerialNumberRequest struct { XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` @@ -34,7 +113,7 @@ func (m *GetBIOSSerialNumberRequest) Reset() { *m = GetBIOSSerialNumberR func (m *GetBIOSSerialNumberRequest) String() string { return proto.CompactTextString(m) } func (*GetBIOSSerialNumberRequest) ProtoMessage() {} func (*GetBIOSSerialNumberRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_714d71facb074551, []int{0} + return fileDescriptor_4066a9d4a9264c6f, []int{0} } func (m *GetBIOSSerialNumberRequest) XXX_Unmarshal(b []byte) error { @@ -67,7 +146,7 @@ func (m *GetBIOSSerialNumberResponse) Reset() { *m = GetBIOSSerialNumber func (m *GetBIOSSerialNumberResponse) String() string { return proto.CompactTextString(m) } func (*GetBIOSSerialNumberResponse) ProtoMessage() {} func (*GetBIOSSerialNumberResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_714d71facb074551, []int{1} + return fileDescriptor_4066a9d4a9264c6f, []int{1} } func (m *GetBIOSSerialNumberResponse) XXX_Unmarshal(b []byte) error { @@ -95,40 +174,320 @@ func (m *GetBIOSSerialNumberResponse) GetSerialNumber() string { return "" } +type StartServiceRequest struct { + // Service name (as listed in System\CCS\Services keys) + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *StartServiceRequest) Reset() { *m = StartServiceRequest{} } +func (m *StartServiceRequest) String() string { return proto.CompactTextString(m) } +func (*StartServiceRequest) ProtoMessage() {} +func (*StartServiceRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_4066a9d4a9264c6f, []int{2} +} + +func (m *StartServiceRequest) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_StartServiceRequest.Unmarshal(m, b) +} +func (m *StartServiceRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_StartServiceRequest.Marshal(b, m, deterministic) +} +func (m *StartServiceRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_StartServiceRequest.Merge(m, src) +} +func (m *StartServiceRequest) XXX_Size() int { + return xxx_messageInfo_StartServiceRequest.Size(m) +} +func (m *StartServiceRequest) XXX_DiscardUnknown() { + xxx_messageInfo_StartServiceRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_StartServiceRequest proto.InternalMessageInfo + +func (m *StartServiceRequest) GetName() string { + if m != nil { + return m.Name + } + return "" +} + +type StartServiceResponse struct { + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *StartServiceResponse) Reset() { *m = StartServiceResponse{} } +func (m *StartServiceResponse) String() string { return proto.CompactTextString(m) } +func (*StartServiceResponse) ProtoMessage() {} +func (*StartServiceResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_4066a9d4a9264c6f, []int{3} +} + +func (m *StartServiceResponse) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_StartServiceResponse.Unmarshal(m, b) +} +func (m *StartServiceResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_StartServiceResponse.Marshal(b, m, deterministic) +} +func (m *StartServiceResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_StartServiceResponse.Merge(m, src) +} +func (m *StartServiceResponse) XXX_Size() int { + return xxx_messageInfo_StartServiceResponse.Size(m) +} +func (m *StartServiceResponse) XXX_DiscardUnknown() { + xxx_messageInfo_StartServiceResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_StartServiceResponse proto.InternalMessageInfo + +type StopServiceRequest struct { + // Service name (as listed in System\CCS\Services keys) + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + // Forces stopping of services that has dependant services + Force bool `protobuf:"varint,2,opt,name=force,proto3" json:"force,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *StopServiceRequest) Reset() { *m = StopServiceRequest{} } +func (m *StopServiceRequest) String() string { return proto.CompactTextString(m) } +func (*StopServiceRequest) ProtoMessage() {} +func (*StopServiceRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_4066a9d4a9264c6f, []int{4} +} + +func (m *StopServiceRequest) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_StopServiceRequest.Unmarshal(m, b) +} +func (m *StopServiceRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_StopServiceRequest.Marshal(b, m, deterministic) +} +func (m *StopServiceRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_StopServiceRequest.Merge(m, src) +} +func (m *StopServiceRequest) XXX_Size() int { + return xxx_messageInfo_StopServiceRequest.Size(m) +} +func (m *StopServiceRequest) XXX_DiscardUnknown() { + xxx_messageInfo_StopServiceRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_StopServiceRequest proto.InternalMessageInfo + +func (m *StopServiceRequest) GetName() string { + if m != nil { + return m.Name + } + return "" +} + +func (m *StopServiceRequest) GetForce() bool { + if m != nil { + return m.Force + } + return false +} + +type StopServiceResponse struct { + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *StopServiceResponse) Reset() { *m = StopServiceResponse{} } +func (m *StopServiceResponse) String() string { return proto.CompactTextString(m) } +func (*StopServiceResponse) ProtoMessage() {} +func (*StopServiceResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_4066a9d4a9264c6f, []int{5} +} + +func (m *StopServiceResponse) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_StopServiceResponse.Unmarshal(m, b) +} +func (m *StopServiceResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_StopServiceResponse.Marshal(b, m, deterministic) +} +func (m *StopServiceResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_StopServiceResponse.Merge(m, src) +} +func (m *StopServiceResponse) XXX_Size() int { + return xxx_messageInfo_StopServiceResponse.Size(m) +} +func (m *StopServiceResponse) XXX_DiscardUnknown() { + xxx_messageInfo_StopServiceResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_StopServiceResponse proto.InternalMessageInfo + +type GetServiceRequest struct { + // Service name (as listed in System\CCS\Services keys) + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *GetServiceRequest) Reset() { *m = GetServiceRequest{} } +func (m *GetServiceRequest) String() string { return proto.CompactTextString(m) } +func (*GetServiceRequest) ProtoMessage() {} +func (*GetServiceRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_4066a9d4a9264c6f, []int{6} +} + +func (m *GetServiceRequest) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_GetServiceRequest.Unmarshal(m, b) +} +func (m *GetServiceRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_GetServiceRequest.Marshal(b, m, deterministic) +} +func (m *GetServiceRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_GetServiceRequest.Merge(m, src) +} +func (m *GetServiceRequest) XXX_Size() int { + return xxx_messageInfo_GetServiceRequest.Size(m) +} +func (m *GetServiceRequest) XXX_DiscardUnknown() { + xxx_messageInfo_GetServiceRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_GetServiceRequest proto.InternalMessageInfo + +func (m *GetServiceRequest) GetName() string { + if m != nil { + return m.Name + } + return "" +} + +type GetServiceResponse struct { + // Service display name + DisplayName string `protobuf:"bytes,1,opt,name=display_name,json=displayName,proto3" json:"display_name,omitempty"` + // Service start type + StartType StartType `protobuf:"varint,2,opt,name=start_type,json=startType,proto3,enum=v1alpha1.StartType" json:"start_type,omitempty"` + // Service status + Status ServiceStatus `protobuf:"varint,3,opt,name=status,proto3,enum=v1alpha1.ServiceStatus" json:"status,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *GetServiceResponse) Reset() { *m = GetServiceResponse{} } +func (m *GetServiceResponse) String() string { return proto.CompactTextString(m) } +func (*GetServiceResponse) ProtoMessage() {} +func (*GetServiceResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_4066a9d4a9264c6f, []int{7} +} + +func (m *GetServiceResponse) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_GetServiceResponse.Unmarshal(m, b) +} +func (m *GetServiceResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_GetServiceResponse.Marshal(b, m, deterministic) +} +func (m *GetServiceResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_GetServiceResponse.Merge(m, src) +} +func (m *GetServiceResponse) XXX_Size() int { + return xxx_messageInfo_GetServiceResponse.Size(m) +} +func (m *GetServiceResponse) XXX_DiscardUnknown() { + xxx_messageInfo_GetServiceResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_GetServiceResponse proto.InternalMessageInfo + +func (m *GetServiceResponse) GetDisplayName() string { + if m != nil { + return m.DisplayName + } + return "" +} + +func (m *GetServiceResponse) GetStartType() StartType { + if m != nil { + return m.StartType + } + return StartType_START_TYPE_BOOT +} + +func (m *GetServiceResponse) GetStatus() ServiceStatus { + if m != nil { + return m.Status + } + return ServiceStatus_SERVICE_STATUS_UNKNOWN +} + func init() { + proto.RegisterEnum("v1alpha1.ServiceStatus", ServiceStatus_name, ServiceStatus_value) + proto.RegisterEnum("v1alpha1.StartType", StartType_name, StartType_value) proto.RegisterType((*GetBIOSSerialNumberRequest)(nil), "v1alpha1.GetBIOSSerialNumberRequest") proto.RegisterType((*GetBIOSSerialNumberResponse)(nil), "v1alpha1.GetBIOSSerialNumberResponse") + proto.RegisterType((*StartServiceRequest)(nil), "v1alpha1.StartServiceRequest") + proto.RegisterType((*StartServiceResponse)(nil), "v1alpha1.StartServiceResponse") + proto.RegisterType((*StopServiceRequest)(nil), "v1alpha1.StopServiceRequest") + proto.RegisterType((*StopServiceResponse)(nil), "v1alpha1.StopServiceResponse") + proto.RegisterType((*GetServiceRequest)(nil), "v1alpha1.GetServiceRequest") + proto.RegisterType((*GetServiceResponse)(nil), "v1alpha1.GetServiceResponse") } func init() { - proto.RegisterFile("src/github.com/kubernetes-csi/csi-proxy/client/api/system/v1alpha1/api.proto", fileDescriptor_714d71facb074551) -} - -var fileDescriptor_714d71facb074551 = []byte{ - // 211 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xf2, 0x29, 0x2e, 0x4a, 0xd6, - 0x4f, 0xcf, 0x2c, 0xc9, 0x28, 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0xcf, 0x2e, 0x4d, 0x4a, 0x2d, - 0xca, 0x4b, 0x2d, 0x49, 0x2d, 0xd6, 0x4d, 0x2e, 0xce, 0xd4, 0x4f, 0x2e, 0xce, 0xd4, 0x2d, 0x28, - 0xca, 0xaf, 0xa8, 0xd4, 0x4f, 0xce, 0xc9, 0x4c, 0xcd, 0x2b, 0xd1, 0x4f, 0x2c, 0xc8, 0xd4, 0x2f, - 0xae, 0x2c, 0x2e, 0x49, 0xcd, 0xd5, 0x2f, 0x33, 0x4c, 0xcc, 0x29, 0xc8, 0x48, 0x34, 0x04, 0x89, - 0xe9, 0x15, 0x14, 0xe5, 0x97, 0xe4, 0x0b, 0x71, 0xc0, 0xc4, 0x94, 0x64, 0xb8, 0xa4, 0xdc, 0x53, - 0x4b, 0x9c, 0x3c, 0xfd, 0x83, 0x83, 0x53, 0x8b, 0x32, 0x13, 0x73, 0xfc, 0x4a, 0x73, 0x93, 0x52, - 0x8b, 0x82, 0x52, 0x0b, 0x4b, 0x53, 0x8b, 0x4b, 0x94, 0x9c, 0xb8, 0xa4, 0xb1, 0xca, 0x16, 0x17, - 0xe4, 0xe7, 0x15, 0xa7, 0x0a, 0x29, 0x73, 0xf1, 0x16, 0x83, 0xc5, 0xe3, 0xf3, 0xc0, 0x12, 0x12, - 0x8c, 0x0a, 0x8c, 0x1a, 0x9c, 0x41, 0x3c, 0xc5, 0x48, 0x8a, 0x8d, 0xf2, 0xb8, 0xd8, 0x82, 0xc1, - 0x0e, 0x11, 0x4a, 0xe1, 0x12, 0xc6, 0x62, 0x9a, 0x90, 0x8a, 0x1e, 0xcc, 0x35, 0x7a, 0xb8, 0x9d, - 0x22, 0xa5, 0x4a, 0x40, 0x15, 0xc4, 0x49, 0x4a, 0x0c, 0x4e, 0x0e, 0x51, 0x76, 0x94, 0x85, 0x53, - 0x12, 0x1b, 0x38, 0x90, 0x8c, 0x01, 0x01, 0x00, 0x00, 0xff, 0xff, 0x8b, 0x01, 0xa9, 0x3f, 0x74, - 0x01, 0x00, 0x00, + proto.RegisterFile("github.com/kubernetes-csi/csi-proxy/client/api/system/v1alpha1/api.proto", fileDescriptor_4066a9d4a9264c6f) +} + +var fileDescriptor_4066a9d4a9264c6f = []byte{ + // 589 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x54, 0x5f, 0x6f, 0xd2, 0x50, + 0x1c, 0x5d, 0xd9, 0x86, 0xdb, 0x6f, 0x9b, 0x76, 0x97, 0xfd, 0x41, 0x60, 0x0e, 0x3b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 0x3f, + 0x01, 0x00, 0x00, 0xff, 0xff, 0xbf, 0x78, 0x82, 0xf1, 0x4c, 0x05, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. var _ context.Context -var _ grpc.ClientConn +var _ grpc.ClientConnInterface // This is a compile-time assertion to ensure that this generated file // is compatible with the grpc package it is being compiled against. -const _ = grpc.SupportPackageIsVersion4 +const _ = grpc.SupportPackageIsVersion6 // SystemClient is the client API for System service. // @@ -136,13 +495,19 @@ const _ = grpc.SupportPackageIsVersion4 type SystemClient interface { // GetBIOSSerialNumber returns the device's serial number GetBIOSSerialNumber(ctx context.Context, in *GetBIOSSerialNumberRequest, opts ...grpc.CallOption) (*GetBIOSSerialNumberResponse, error) + // StartService starts a Windows service + StartService(ctx context.Context, in *StartServiceRequest, opts ...grpc.CallOption) (*StartServiceResponse, error) + // StopService stops a Windows service + StopService(ctx context.Context, in *StopServiceRequest, opts ...grpc.CallOption) (*StopServiceResponse, error) + // GetService queries a Windows service state + GetService(ctx context.Context, in *GetServiceRequest, opts ...grpc.CallOption) (*GetServiceResponse, error) } type systemClient struct { - cc *grpc.ClientConn + cc grpc.ClientConnInterface } -func NewSystemClient(cc *grpc.ClientConn) SystemClient { +func NewSystemClient(cc grpc.ClientConnInterface) SystemClient { return &systemClient{cc} } @@ -155,10 +520,43 @@ func (c *systemClient) GetBIOSSerialNumber(ctx context.Context, in *GetBIOSSeria return out, nil } +func (c *systemClient) StartService(ctx context.Context, in *StartServiceRequest, opts ...grpc.CallOption) (*StartServiceResponse, error) { + out := new(StartServiceResponse) + err := c.cc.Invoke(ctx, "/v1alpha1.System/StartService", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *systemClient) StopService(ctx context.Context, in *StopServiceRequest, opts ...grpc.CallOption) (*StopServiceResponse, error) { + out := new(StopServiceResponse) + err := c.cc.Invoke(ctx, "/v1alpha1.System/StopService", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *systemClient) GetService(ctx context.Context, in *GetServiceRequest, opts ...grpc.CallOption) (*GetServiceResponse, error) { + out := new(GetServiceResponse) + err := c.cc.Invoke(ctx, "/v1alpha1.System/GetService", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // SystemServer is the server API for System service. type SystemServer interface { // GetBIOSSerialNumber returns the device's serial number GetBIOSSerialNumber(context.Context, *GetBIOSSerialNumberRequest) (*GetBIOSSerialNumberResponse, error) + // StartService starts a Windows service + StartService(context.Context, *StartServiceRequest) (*StartServiceResponse, error) + // StopService stops a Windows service + StopService(context.Context, *StopServiceRequest) (*StopServiceResponse, error) + // GetService queries a Windows service state + GetService(context.Context, *GetServiceRequest) (*GetServiceResponse, error) } // UnimplementedSystemServer can be embedded to have forward compatible implementations. @@ -168,6 +566,15 @@ type UnimplementedSystemServer struct { func (*UnimplementedSystemServer) GetBIOSSerialNumber(ctx context.Context, req *GetBIOSSerialNumberRequest) (*GetBIOSSerialNumberResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method GetBIOSSerialNumber not implemented") } +func (*UnimplementedSystemServer) StartService(ctx context.Context, req *StartServiceRequest) (*StartServiceResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method StartService not implemented") +} +func (*UnimplementedSystemServer) StopService(ctx context.Context, req *StopServiceRequest) (*StopServiceResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method StopService not implemented") +} +func (*UnimplementedSystemServer) GetService(ctx context.Context, req *GetServiceRequest) (*GetServiceResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetService not implemented") +} func RegisterSystemServer(s *grpc.Server, srv SystemServer) { s.RegisterService(&_System_serviceDesc, srv) @@ -191,6 +598,60 @@ func _System_GetBIOSSerialNumber_Handler(srv interface{}, ctx context.Context, d return interceptor(ctx, in, info, handler) } +func _System_StartService_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(StartServiceRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(SystemServer).StartService(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/v1alpha1.System/StartService", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(SystemServer).StartService(ctx, req.(*StartServiceRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _System_StopService_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(StopServiceRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(SystemServer).StopService(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/v1alpha1.System/StopService", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(SystemServer).StopService(ctx, req.(*StopServiceRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _System_GetService_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetServiceRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(SystemServer).GetService(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/v1alpha1.System/GetService", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(SystemServer).GetService(ctx, req.(*GetServiceRequest)) + } + return interceptor(ctx, in, info, handler) +} + var _System_serviceDesc = grpc.ServiceDesc{ ServiceName: "v1alpha1.System", HandlerType: (*SystemServer)(nil), @@ -199,7 +660,19 @@ var _System_serviceDesc = grpc.ServiceDesc{ MethodName: "GetBIOSSerialNumber", Handler: _System_GetBIOSSerialNumber_Handler, }, + { + MethodName: "StartService", + Handler: _System_StartService_Handler, + }, + { + MethodName: "StopService", + Handler: _System_StopService_Handler, + }, + { + MethodName: "GetService", + Handler: _System_GetService_Handler, + }, }, Streams: []grpc.StreamDesc{}, - Metadata: "src/github.com/kubernetes-csi/csi-proxy/client/api/system/v1alpha1/api.proto", + Metadata: "github.com/kubernetes-csi/csi-proxy/client/api/system/v1alpha1/api.proto", } diff --git a/client/api/system/v1alpha1/api.proto b/client/api/system/v1alpha1/api.proto index 8640c151..04ee006c 100644 --- a/client/api/system/v1alpha1/api.proto +++ b/client/api/system/v1alpha1/api.proto @@ -7,6 +7,15 @@ option go_package = "github.com/kubernetes-csi/csi-proxy/client/api/system/v1alp service System { // GetBIOSSerialNumber returns the device's serial number rpc GetBIOSSerialNumber(GetBIOSSerialNumberRequest) returns (GetBIOSSerialNumberResponse) {} + + // StartService starts a Windows service + rpc StartService(StartServiceRequest) returns (StartServiceResponse) {} + + // StopService stops a Windows service + rpc StopService(StopServiceRequest) returns (StopServiceResponse) {} + + // GetService queries a Windows service state + rpc GetService(GetServiceRequest) returns (GetServiceResponse) {} } message GetBIOSSerialNumberRequest { @@ -17,3 +26,62 @@ message GetBIOSSerialNumberResponse { // Serial number string serial_number = 1; } + +message StartServiceRequest { + // Service name (as listed in System\CCS\Services keys) + string name = 1; +} + +message StartServiceResponse { + // Intentionally empty +} + +message StopServiceRequest { + // Service name (as listed in System\CCS\Services keys) + string name = 1; + + // Forces stopping of services that has dependant services + bool force = 2; +} + +message StopServiceResponse { + // Intentionally empty +} + + +// https://docs.microsoft.com/en-us/windows/win32/api/winsvc/ns-winsvc-service_status#members +enum ServiceStatus { + SERVICE_STATUS_UNKNOWN = 0; + SERVICE_STATUS_STOPPED = 1; + SERVICE_STATUS_START_PENDING = 2; + SERVICE_STATUS_STOP_PENDING = 3; + SERVICE_STATUS_RUNNING = 4; + SERVICE_STATUS_CONTINUE_PENDING = 5; + SERVICE_STATUS_PAUSE_PENDING = 6; + SERVICE_STATUS_PAUSED = 7; +} + +// https://docs.microsoft.com/en-us/windows/win32/api/winsvc/nf-winsvc-changeserviceconfiga +enum StartType { + START_TYPE_BOOT = 0; + START_TYPE_SYSTEM = 1; + START_TYPE_AUTOMATIC = 2; + START_TYPE_MANUAL = 3; + START_TYPE_DISABLED = 4; +} + +message GetServiceRequest { + // Service name (as listed in System\CCS\Services keys) + string name = 1; +} + +message GetServiceResponse { + // Service display name + string display_name = 1; + + // Service start type + StartType start_type = 2; + + // Service status + ServiceStatus status = 3; +} diff --git a/client/groups/system/v1alpha1/client_generated.go b/client/groups/system/v1alpha1/client_generated.go index 7c8a6d6f..9cbc5268 100644 --- a/client/groups/system/v1alpha1/client_generated.go +++ b/client/groups/system/v1alpha1/client_generated.go @@ -54,3 +54,15 @@ var _ v1alpha1.SystemClient = &Client{} func (w *Client) GetBIOSSerialNumber(context context.Context, request *v1alpha1.GetBIOSSerialNumberRequest, opts ...grpc.CallOption) (*v1alpha1.GetBIOSSerialNumberResponse, error) { return w.client.GetBIOSSerialNumber(context, request, opts...) } + +func (w *Client) GetService(context context.Context, request *v1alpha1.GetServiceRequest, opts ...grpc.CallOption) (*v1alpha1.GetServiceResponse, error) { + return w.client.GetService(context, request, opts...) +} + +func (w *Client) StartService(context context.Context, request *v1alpha1.StartServiceRequest, opts ...grpc.CallOption) (*v1alpha1.StartServiceResponse, error) { + return w.client.StartService(context, request, opts...) +} + +func (w *Client) StopService(context context.Context, request *v1alpha1.StopServiceRequest, opts ...grpc.CallOption) (*v1alpha1.StopServiceResponse, error) { + return w.client.StopService(context, request, opts...) +} diff --git a/integrationtests/system_test.go b/integrationtests/system_test.go index 7ec29016..270e8d86 100644 --- a/integrationtests/system_test.go +++ b/integrationtests/system_test.go @@ -2,12 +2,15 @@ package integrationtests import ( "context" + "encoding/json" + "fmt" "os/exec" "strings" "testing" "github.com/kubernetes-csi/csi-proxy/client/api/system/v1alpha1" v1alpha1client "github.com/kubernetes-csi/csi-proxy/client/groups/system/v1alpha1" + "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -31,3 +34,79 @@ func TestGetBIOSSerialNumber(t *testing.T) { require.True(t, strings.Contains(resultString, response.SerialNumber)) }) } + +func TestServiceCommands(t *testing.T) { + t.Run("GetService", func(t *testing.T) { + const ServiceName = "MSiSCSI" + client, err := v1alpha1client.NewClient() + require.Nil(t, err) + defer client.Close() + + request := &v1alpha1.GetServiceRequest{Name: ServiceName} + response, err := client.GetService(context.TODO(), request) + require.NoError(t, err) + require.NotNil(t, response) + + out, err := runPowershellCmd(fmt.Sprintf(`Get-Service -Name "%s" `+ + `| Select-Object DisplayName, Status, StartType | ConvertTo-Json`, + ServiceName)) + require.NoError(t, err) + + var serviceInfo = struct { + DisplayName string `json:"DisplayName"` + Status uint32 `json:"Status"` + StartType uint32 `json:"StartType"` + }{} + + err = json.Unmarshal([]byte(out), &serviceInfo) + require.NoError(t, err, "failed unmarshalling json out=%v", out) + + assert.Equal(t, serviceInfo.Status, uint32(response.Status)) + assert.Equal(t, serviceInfo.StartType, uint32(response.StartType)) + assert.Equal(t, serviceInfo.DisplayName, response.DisplayName) + }) + + t.Run("Stop/Start Service", func(t *testing.T) { + const ServiceName = "MSiSCSI" + client, err := v1alpha1client.NewClient() + require.Nil(t, err) + defer client.Close() + + _, err = runPowershellCmd(`Stop-Service -Name "MSiSCSI"`) + require.NoError(t, err) + assertServiceStopped(t, ServiceName) + + startReq := &v1alpha1.StartServiceRequest{Name: ServiceName} + startResp, err := client.StartService(context.TODO(), startReq) + + assert.NoError(t, err) + assert.NotNil(t, startResp) + assertServiceStarted(t, ServiceName) + + stopReq := &v1alpha1.StopServiceRequest{Name: ServiceName} + stopResp, err := client.StopService(context.TODO(), stopReq) + + assert.NoError(t, err) + assert.NotNil(t, stopResp) + assertServiceStopped(t, ServiceName) + }) + +} + +func assertServiceStarted(t *testing.T, serviceName string) { + assertServiceStatus(t, serviceName, "Running") +} + +func assertServiceStopped(t *testing.T, serviceName string) { + assertServiceStatus(t, serviceName, "Stopped") +} + +func assertServiceStatus(t *testing.T, serviceName string, status string) { + out, err := runPowershellCmd(fmt.Sprintf(`Get-Service -Name "%s" | `+ + `Select-Object -ExpandProperty Status`, serviceName)) + if !assert.NoError(t, err, "Failed getting service out=%s", out) { + return + } + + assert.Equal(t, strings.TrimSpace(out), status) +} diff --git a/internal/os/system/api.go b/internal/os/system/api.go index 484c7c1e..062f1cb4 100644 --- a/internal/os/system/api.go +++ b/internal/os/system/api.go @@ -1,7 +1,9 @@ package system import ( + "encoding/json" "fmt" + "os" "os/exec" "strings" ) @@ -11,6 +13,17 @@ import ( // internal/server/system/server.go so that logic can be easily unit-tested // without requiring specific OS environments. +type ServiceInfo struct { + // Service display name + DisplayName string `json:"DisplayName"` + + // Service start type + StartType uint32 `json:"StartType"` + + // Service status + Status uint32 `json:"Status"` +} + type APIImplementor struct{} func New() APIImplementor { @@ -37,3 +50,51 @@ func (APIImplementor) GetBIOSSerialNumber() (string, error) { } return lines[1], nil } + +func (APIImplementor) GetService(name string) (*ServiceInfo, error) { + script := `Get-Service -Name $env:ServiceName | Select-Object DisplayName, Status, StartType | ` + + `ConvertTo-JSON` + cmd := exec.Command("powershell", "/c", script) + cmd.Env = append(os.Environ(), fmt.Sprintf("ServiceName=%s", name)) + + out, err := cmd.CombinedOutput() + if err != nil { + return nil, fmt.Errorf("error querying service name=%s. cmd: %s, output: %s, error: %v", name, cmd, string(out), err) + } + + var serviceInfo ServiceInfo + err = json.Unmarshal(out, &serviceInfo) + if err != nil { + return nil, err + } + + return &serviceInfo, nil +} + +func (APIImplementor) StartService(name string) error { + script := `Start-Service -Name $env:ServiceName` + cmd := exec.Command("powershell", "/c", script) + cmd.Env = append(os.Environ(), fmt.Sprintf("ServiceName=%s", name)) + + out, err := cmd.CombinedOutput() + if err != nil { + return fmt.Errorf("error starting service name=%s. cmd: %s, output: %s, error: %v", name, cmd, string(out), err) + } + + return nil +} + +func (APIImplementor) StopService(name string, force bool) error { + script := `Stop-Service -Name $env:ServiceName -Force:$([System.Convert]::ToBoolean($env:Force))` + cmd := exec.Command("powershell", "/c", script) + cmd.Env = append(os.Environ(), + fmt.Sprintf("ServiceName=%s", name), + fmt.Sprintf("Force=%t", force)) + + out, err := cmd.CombinedOutput() + if err != nil { + return fmt.Errorf("error stopping service name=%s. cmd: %s, output: %s, error: %v", name, cmd, string(out), err) + } + + return nil +} diff --git a/internal/server/system/internal/types.go b/internal/server/system/internal/types.go index a08b3fb9..388f18db 100644 --- a/internal/server/system/internal/types.go +++ b/internal/server/system/internal/types.go @@ -6,3 +6,63 @@ type GetBIOSSerialNumberRequest struct { type GetBIOSSerialNumberResponse struct { SerialNumber string } + +type StartServiceRequest struct { + // Service name (as listed in System\CCS\Services keys) + Name string +} + +type StartServiceResponse struct { + // Intentionally empty +} + +type StopServiceRequest struct { + // Service name (as listed in System\CCS\Services keys) + Name string + + // Forces stopping of services that has dependant services + Force bool +} + +type StopServiceResponse struct { + // Intentionally empty +} + +type ServiceStatus uint32 + +const ( + SERVICE_STATUS_UNKNOWN = 0 + SERVICE_STATUS_STOPPED = 1 + SERVICE_STATUS_START_PENDING = 2 + SERVICE_STATUS_STOP_PENDING = 3 + SERVICE_STATUS_RUNNING = 4 + SERVICE_STATUS_CONTINUE_PENDING = 5 + SERVICE_STATUS_PAUSE_PENDING = 6 + SERVICE_STATUS_PAUSED = 7 +) + +type Startype uint32 + +const ( + START_TYPE_BOOT = 0 + START_TYPE_SYSTEM = 1 + START_TYPE_AUTOMATIC = 2 + START_TYPE_MANUAL = 3 + START_TYPE_DISABLED = 4 +) + +type GetServiceRequest struct { + // Service name (as listed in System\CCS\Services keys) + Name string +} + +type GetServiceResponse struct { + // Service display name + DisplayName string + + // Service start type + StartType Startype + + // Service status + Status ServiceStatus +} diff --git a/internal/server/system/internal/types_generated.go b/internal/server/system/internal/types_generated.go index b029dbc9..30add208 100644 --- a/internal/server/system/internal/types_generated.go +++ b/internal/server/system/internal/types_generated.go @@ -16,4 +16,7 @@ type VersionedAPI interface { // All the functions this group's server needs to define. type ServerInterface interface { GetBIOSSerialNumber(context.Context, *GetBIOSSerialNumberRequest, apiversion.Version) (*GetBIOSSerialNumberResponse, error) + GetService(context.Context, *GetServiceRequest, apiversion.Version) (*GetServiceResponse, error) + StartService(context.Context, *StartServiceRequest, apiversion.Version) (*StartServiceResponse, error) + StopService(context.Context, *StopServiceRequest, apiversion.Version) (*StopServiceResponse, error) } diff --git a/internal/server/system/internal/v1alpha1/conversion_generated.go b/internal/server/system/internal/v1alpha1/conversion_generated.go index c92883bb..7976306c 100644 --- a/internal/server/system/internal/v1alpha1/conversion_generated.go +++ b/internal/server/system/internal/v1alpha1/conversion_generated.go @@ -44,3 +44,125 @@ func autoConvert_internal_GetBIOSSerialNumberResponse_To_v1alpha1_GetBIOSSerialN func Convert_internal_GetBIOSSerialNumberResponse_To_v1alpha1_GetBIOSSerialNumberResponse(in *internal.GetBIOSSerialNumberResponse, out *v1alpha1.GetBIOSSerialNumberResponse) error { return autoConvert_internal_GetBIOSSerialNumberResponse_To_v1alpha1_GetBIOSSerialNumberResponse(in, out) } + +func autoConvert_v1alpha1_GetServiceRequest_To_internal_GetServiceRequest(in *v1alpha1.GetServiceRequest, out *internal.GetServiceRequest) error { + out.Name = in.Name + return nil +} + +// Convert_v1alpha1_GetServiceRequest_To_internal_GetServiceRequest is an autogenerated conversion function. +func Convert_v1alpha1_GetServiceRequest_To_internal_GetServiceRequest(in *v1alpha1.GetServiceRequest, out *internal.GetServiceRequest) error { + return autoConvert_v1alpha1_GetServiceRequest_To_internal_GetServiceRequest(in, out) +} + +func autoConvert_internal_GetServiceRequest_To_v1alpha1_GetServiceRequest(in *internal.GetServiceRequest, out *v1alpha1.GetServiceRequest) error { + out.Name = in.Name + return nil +} + +// Convert_internal_GetServiceRequest_To_v1alpha1_GetServiceRequest is an autogenerated conversion function. +func Convert_internal_GetServiceRequest_To_v1alpha1_GetServiceRequest(in *internal.GetServiceRequest, out *v1alpha1.GetServiceRequest) error { + return autoConvert_internal_GetServiceRequest_To_v1alpha1_GetServiceRequest(in, out) +} + +func autoConvert_v1alpha1_GetServiceResponse_To_internal_GetServiceResponse(in *v1alpha1.GetServiceResponse, out *internal.GetServiceResponse) error { + out.DisplayName = in.DisplayName + out.StartType = internal.Startype(in.StartType) + out.Status = internal.ServiceStatus(in.Status) + return nil +} + +// Convert_v1alpha1_GetServiceResponse_To_internal_GetServiceResponse is an autogenerated conversion function. +func Convert_v1alpha1_GetServiceResponse_To_internal_GetServiceResponse(in *v1alpha1.GetServiceResponse, out *internal.GetServiceResponse) error { + return autoConvert_v1alpha1_GetServiceResponse_To_internal_GetServiceResponse(in, out) +} + +func autoConvert_internal_GetServiceResponse_To_v1alpha1_GetServiceResponse(in *internal.GetServiceResponse, out *v1alpha1.GetServiceResponse) error { + out.DisplayName = in.DisplayName + out.StartType = v1alpha1.StartType(in.StartType) + out.Status = v1alpha1.ServiceStatus(in.Status) + return nil +} + +// Convert_internal_GetServiceResponse_To_v1alpha1_GetServiceResponse is an autogenerated conversion function. +func Convert_internal_GetServiceResponse_To_v1alpha1_GetServiceResponse(in *internal.GetServiceResponse, out *v1alpha1.GetServiceResponse) error { + return autoConvert_internal_GetServiceResponse_To_v1alpha1_GetServiceResponse(in, out) +} + +func autoConvert_v1alpha1_StartServiceRequest_To_internal_StartServiceRequest(in *v1alpha1.StartServiceRequest, out *internal.StartServiceRequest) error { + out.Name = in.Name + return nil +} + +// Convert_v1alpha1_StartServiceRequest_To_internal_StartServiceRequest is an autogenerated conversion function. +func Convert_v1alpha1_StartServiceRequest_To_internal_StartServiceRequest(in *v1alpha1.StartServiceRequest, out *internal.StartServiceRequest) error { + return autoConvert_v1alpha1_StartServiceRequest_To_internal_StartServiceRequest(in, out) +} + +func autoConvert_internal_StartServiceRequest_To_v1alpha1_StartServiceRequest(in *internal.StartServiceRequest, out *v1alpha1.StartServiceRequest) error { + out.Name = in.Name + return nil +} + +// Convert_internal_StartServiceRequest_To_v1alpha1_StartServiceRequest is an autogenerated conversion function. +func Convert_internal_StartServiceRequest_To_v1alpha1_StartServiceRequest(in *internal.StartServiceRequest, out *v1alpha1.StartServiceRequest) error { + return autoConvert_internal_StartServiceRequest_To_v1alpha1_StartServiceRequest(in, out) +} + +func autoConvert_v1alpha1_StartServiceResponse_To_internal_StartServiceResponse(in *v1alpha1.StartServiceResponse, out *internal.StartServiceResponse) error { + return nil +} + +// Convert_v1alpha1_StartServiceResponse_To_internal_StartServiceResponse is an autogenerated conversion function. +func Convert_v1alpha1_StartServiceResponse_To_internal_StartServiceResponse(in *v1alpha1.StartServiceResponse, out *internal.StartServiceResponse) error { + return autoConvert_v1alpha1_StartServiceResponse_To_internal_StartServiceResponse(in, out) +} + +func autoConvert_internal_StartServiceResponse_To_v1alpha1_StartServiceResponse(in *internal.StartServiceResponse, out *v1alpha1.StartServiceResponse) error { + return nil +} + +// Convert_internal_StartServiceResponse_To_v1alpha1_StartServiceResponse is an autogenerated conversion function. +func Convert_internal_StartServiceResponse_To_v1alpha1_StartServiceResponse(in *internal.StartServiceResponse, out *v1alpha1.StartServiceResponse) error { + return autoConvert_internal_StartServiceResponse_To_v1alpha1_StartServiceResponse(in, out) +} + +func autoConvert_v1alpha1_StopServiceRequest_To_internal_StopServiceRequest(in *v1alpha1.StopServiceRequest, out *internal.StopServiceRequest) error { + out.Name = in.Name + out.Force = in.Force + return nil +} + +// Convert_v1alpha1_StopServiceRequest_To_internal_StopServiceRequest is an autogenerated conversion function. +func Convert_v1alpha1_StopServiceRequest_To_internal_StopServiceRequest(in *v1alpha1.StopServiceRequest, out *internal.StopServiceRequest) error { + return autoConvert_v1alpha1_StopServiceRequest_To_internal_StopServiceRequest(in, out) +} + +func autoConvert_internal_StopServiceRequest_To_v1alpha1_StopServiceRequest(in *internal.StopServiceRequest, out *v1alpha1.StopServiceRequest) error { + out.Name = in.Name + out.Force = in.Force + return nil +} + +// Convert_internal_StopServiceRequest_To_v1alpha1_StopServiceRequest is an autogenerated conversion function. +func Convert_internal_StopServiceRequest_To_v1alpha1_StopServiceRequest(in *internal.StopServiceRequest, out *v1alpha1.StopServiceRequest) error { + return autoConvert_internal_StopServiceRequest_To_v1alpha1_StopServiceRequest(in, out) +} + +func autoConvert_v1alpha1_StopServiceResponse_To_internal_StopServiceResponse(in *v1alpha1.StopServiceResponse, out *internal.StopServiceResponse) error { + return nil +} + +// Convert_v1alpha1_StopServiceResponse_To_internal_StopServiceResponse is an autogenerated conversion function. +func Convert_v1alpha1_StopServiceResponse_To_internal_StopServiceResponse(in *v1alpha1.StopServiceResponse, out *internal.StopServiceResponse) error { + return autoConvert_v1alpha1_StopServiceResponse_To_internal_StopServiceResponse(in, out) +} + +func autoConvert_internal_StopServiceResponse_To_v1alpha1_StopServiceResponse(in *internal.StopServiceResponse, out *v1alpha1.StopServiceResponse) error { + return nil +} + +// Convert_internal_StopServiceResponse_To_v1alpha1_StopServiceResponse is an autogenerated conversion function. +func Convert_internal_StopServiceResponse_To_v1alpha1_StopServiceResponse(in *internal.StopServiceResponse, out *v1alpha1.StopServiceResponse) error { + return autoConvert_internal_StopServiceResponse_To_v1alpha1_StopServiceResponse(in, out) +} diff --git a/internal/server/system/internal/v1alpha1/server_generated.go b/internal/server/system/internal/v1alpha1/server_generated.go index d4b75a34..72707955 100644 --- a/internal/server/system/internal/v1alpha1/server_generated.go +++ b/internal/server/system/internal/v1alpha1/server_generated.go @@ -45,3 +45,60 @@ func (s *versionedAPI) GetBIOSSerialNumber(context context.Context, versionedReq return versionedResponse, err } + +func (s *versionedAPI) GetService(context context.Context, versionedRequest *v1alpha1.GetServiceRequest) (*v1alpha1.GetServiceResponse, error) { + request := &internal.GetServiceRequest{} + if err := Convert_v1alpha1_GetServiceRequest_To_internal_GetServiceRequest(versionedRequest, request); err != nil { + return nil, err + } + + response, err := s.apiGroupServer.GetService(context, request, version) + if err != nil { + return nil, err + } + + versionedResponse := &v1alpha1.GetServiceResponse{} + if err := Convert_internal_GetServiceResponse_To_v1alpha1_GetServiceResponse(response, versionedResponse); err != nil { + return nil, err + } + + return versionedResponse, err +} + +func (s *versionedAPI) StartService(context context.Context, versionedRequest *v1alpha1.StartServiceRequest) (*v1alpha1.StartServiceResponse, error) { + request := &internal.StartServiceRequest{} + if err := Convert_v1alpha1_StartServiceRequest_To_internal_StartServiceRequest(versionedRequest, request); err != nil { + return nil, err + } + + response, err := s.apiGroupServer.StartService(context, request, version) + if err != nil { + return nil, err + } + + versionedResponse := &v1alpha1.StartServiceResponse{} + if err := Convert_internal_StartServiceResponse_To_v1alpha1_StartServiceResponse(response, versionedResponse); err != nil { + return nil, err + } + + return versionedResponse, err +} + +func (s *versionedAPI) StopService(context context.Context, versionedRequest *v1alpha1.StopServiceRequest) (*v1alpha1.StopServiceResponse, error) { + request := &internal.StopServiceRequest{} + if err := Convert_v1alpha1_StopServiceRequest_To_internal_StopServiceRequest(versionedRequest, request); err != nil { + return nil, err + } + + response, err := s.apiGroupServer.StopService(context, request, version) + if err != nil { + return nil, err + } + + versionedResponse := &v1alpha1.StopServiceResponse{} + if err := Convert_internal_StopServiceResponse_To_v1alpha1_StopServiceResponse(response, versionedResponse); err != nil { + return nil, err + } + + return versionedResponse, err +} diff --git a/internal/server/system/server.go b/internal/server/system/server.go index 964b3734..7dcc5ce8 100644 --- a/internal/server/system/server.go +++ b/internal/server/system/server.go @@ -4,6 +4,7 @@ import ( "context" "github.com/kubernetes-csi/csi-proxy/client/apiversion" + "github.com/kubernetes-csi/csi-proxy/internal/os/system" "github.com/kubernetes-csi/csi-proxy/internal/server/system/internal" "k8s.io/klog" ) @@ -14,6 +15,9 @@ type Server struct { type API interface { GetBIOSSerialNumber() (string, error) + GetService(name string) (*system.ServiceInfo, error) + StartService(name string) error + StopService(name string, force bool) error } func NewServer(hostAPI API) (*Server, error) { @@ -34,3 +38,42 @@ func (s *Server) GetBIOSSerialNumber(context context.Context, request *internal. response.SerialNumber = serialNumber return response, nil } + +func (s *Server) GetService(context context.Context, request *internal.GetServiceRequest, version apiversion.Version) (*internal.GetServiceResponse, error) { + klog.V(4).Infof("calling GetService name=%s", request.Name) + response := &internal.GetServiceResponse{} + info, err := s.hostAPI.GetService(request.Name) + if err != nil { + klog.Errorf("failed GetService: %v", err) + return response, err + } + + response.DisplayName = info.DisplayName + response.StartType = internal.Startype(info.StartType) + response.Status = internal.ServiceStatus(info.Status) + return response, nil +} + +func (s *Server) StartService(context context.Context, request *internal.StartServiceRequest, version apiversion.Version) (*internal.StartServiceResponse, error) { + klog.V(4).Infof("calling StartService name=%s", request.Name) + response := &internal.StartServiceResponse{} + err := s.hostAPI.StartService(request.Name) + if err != nil { + klog.Errorf("failed StartService: %v", err) + return response, err + } + + return response, nil +} + +func (s *Server) StopService(context context.Context, request *internal.StopServiceRequest, version apiversion.Version) (*internal.StopServiceResponse, error) { + klog.V(4).Infof("calling StopService name=%s", request.Name) + response := &internal.StopServiceResponse{} + err := s.hostAPI.StopService(request.Name, request.Force) + if err != nil { + klog.Errorf("failed StopService: %v", err) + return response, err + } + + return response, nil +} diff --git a/vendor/github.com/kubernetes-csi/csi-proxy/client/api/system/v1alpha1/api.pb.go b/vendor/github.com/kubernetes-csi/csi-proxy/client/api/system/v1alpha1/api.pb.go index 6eb3ce7f..e6ba4de1 100644 --- a/vendor/github.com/kubernetes-csi/csi-proxy/client/api/system/v1alpha1/api.pb.go +++ b/vendor/github.com/kubernetes-csi/csi-proxy/client/api/system/v1alpha1/api.pb.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-go. DO NOT EDIT. -// source: src/github.com/kubernetes-csi/csi-proxy/client/api/system/v1alpha1/api.proto +// source: github.com/kubernetes-csi/csi-proxy/client/api/system/v1alpha1/api.proto package v1alpha1 @@ -24,6 +24,85 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package +// https://docs.microsoft.com/en-us/windows/win32/api/winsvc/ns-winsvc-service_status#members +type ServiceStatus int32 + +const ( + ServiceStatus_SERVICE_STATUS_UNKNOWN ServiceStatus = 0 + ServiceStatus_SERVICE_STATUS_STOPPED ServiceStatus = 1 + ServiceStatus_SERVICE_STATUS_START_PENDING ServiceStatus = 2 + ServiceStatus_SERVICE_STATUS_STOP_PENDING ServiceStatus = 3 + ServiceStatus_SERVICE_STATUS_RUNNING ServiceStatus = 4 + ServiceStatus_SERVICE_STATUS_CONTINUE_PENDING ServiceStatus = 5 + ServiceStatus_SERVICE_STATUS_PAUSE_PENDING ServiceStatus = 6 + ServiceStatus_SERVICE_STATUS_PAUSED ServiceStatus = 7 +) + +var ServiceStatus_name = map[int32]string{ + 0: "SERVICE_STATUS_UNKNOWN", + 1: "SERVICE_STATUS_STOPPED", + 2: "SERVICE_STATUS_START_PENDING", + 3: "SERVICE_STATUS_STOP_PENDING", + 4: "SERVICE_STATUS_RUNNING", + 5: "SERVICE_STATUS_CONTINUE_PENDING", + 6: "SERVICE_STATUS_PAUSE_PENDING", + 7: "SERVICE_STATUS_PAUSED", +} + +var ServiceStatus_value = map[string]int32{ + "SERVICE_STATUS_UNKNOWN": 0, + "SERVICE_STATUS_STOPPED": 1, + "SERVICE_STATUS_START_PENDING": 2, + "SERVICE_STATUS_STOP_PENDING": 3, + "SERVICE_STATUS_RUNNING": 4, + "SERVICE_STATUS_CONTINUE_PENDING": 5, + "SERVICE_STATUS_PAUSE_PENDING": 6, + "SERVICE_STATUS_PAUSED": 7, +} + +func (x ServiceStatus) String() string { + return proto.EnumName(ServiceStatus_name, int32(x)) +} + +func (ServiceStatus) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_4066a9d4a9264c6f, []int{0} +} + +// https://docs.microsoft.com/en-us/windows/win32/api/winsvc/nf-winsvc-changeserviceconfiga +type StartType int32 + +const ( + StartType_START_TYPE_BOOT StartType = 0 + StartType_START_TYPE_SYSTEM StartType = 1 + StartType_START_TYPE_AUTOMATIC StartType = 2 + StartType_START_TYPE_MANUAL StartType = 3 + StartType_START_TYPE_DISABLED StartType = 4 +) + +var StartType_name = map[int32]string{ + 0: "START_TYPE_BOOT", + 1: "START_TYPE_SYSTEM", + 2: "START_TYPE_AUTOMATIC", + 3: "START_TYPE_MANUAL", + 4: "START_TYPE_DISABLED", +} + +var StartType_value = map[string]int32{ + "START_TYPE_BOOT": 0, + "START_TYPE_SYSTEM": 1, + "START_TYPE_AUTOMATIC": 2, + "START_TYPE_MANUAL": 3, + "START_TYPE_DISABLED": 4, +} + +func (x StartType) String() string { + return proto.EnumName(StartType_name, int32(x)) +} + +func (StartType) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_4066a9d4a9264c6f, []int{1} +} + type GetBIOSSerialNumberRequest struct { XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` @@ -34,7 +113,7 @@ func (m *GetBIOSSerialNumberRequest) Reset() { *m = GetBIOSSerialNumberR func (m *GetBIOSSerialNumberRequest) String() string { return proto.CompactTextString(m) } func (*GetBIOSSerialNumberRequest) ProtoMessage() {} func (*GetBIOSSerialNumberRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_714d71facb074551, []int{0} + return fileDescriptor_4066a9d4a9264c6f, []int{0} } func (m *GetBIOSSerialNumberRequest) XXX_Unmarshal(b []byte) error { @@ -67,7 +146,7 @@ func (m *GetBIOSSerialNumberResponse) Reset() { *m = GetBIOSSerialNumber func (m *GetBIOSSerialNumberResponse) String() string { return proto.CompactTextString(m) } func (*GetBIOSSerialNumberResponse) ProtoMessage() {} func (*GetBIOSSerialNumberResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_714d71facb074551, []int{1} + return fileDescriptor_4066a9d4a9264c6f, []int{1} } func (m *GetBIOSSerialNumberResponse) XXX_Unmarshal(b []byte) error { @@ -95,40 +174,320 @@ func (m *GetBIOSSerialNumberResponse) GetSerialNumber() string { return "" } +type StartServiceRequest struct { + // Service name (as listed in System\CCS\Services keys) + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *StartServiceRequest) Reset() { *m = StartServiceRequest{} } +func (m *StartServiceRequest) String() string { return proto.CompactTextString(m) } +func (*StartServiceRequest) ProtoMessage() {} +func (*StartServiceRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_4066a9d4a9264c6f, []int{2} +} + +func (m *StartServiceRequest) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_StartServiceRequest.Unmarshal(m, b) +} +func (m *StartServiceRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_StartServiceRequest.Marshal(b, m, deterministic) +} +func (m *StartServiceRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_StartServiceRequest.Merge(m, src) +} +func (m *StartServiceRequest) XXX_Size() int { + return xxx_messageInfo_StartServiceRequest.Size(m) +} +func (m *StartServiceRequest) XXX_DiscardUnknown() { + xxx_messageInfo_StartServiceRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_StartServiceRequest proto.InternalMessageInfo + +func (m *StartServiceRequest) GetName() string { + if m != nil { + return m.Name + } + return "" +} + +type StartServiceResponse struct { + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *StartServiceResponse) Reset() { *m = StartServiceResponse{} } +func (m *StartServiceResponse) String() string { return proto.CompactTextString(m) } +func (*StartServiceResponse) ProtoMessage() {} +func (*StartServiceResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_4066a9d4a9264c6f, []int{3} +} + +func (m *StartServiceResponse) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_StartServiceResponse.Unmarshal(m, b) +} +func (m *StartServiceResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_StartServiceResponse.Marshal(b, m, deterministic) +} +func (m *StartServiceResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_StartServiceResponse.Merge(m, src) +} +func (m *StartServiceResponse) XXX_Size() int { + return xxx_messageInfo_StartServiceResponse.Size(m) +} +func (m *StartServiceResponse) XXX_DiscardUnknown() { + xxx_messageInfo_StartServiceResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_StartServiceResponse proto.InternalMessageInfo + +type StopServiceRequest struct { + // Service name (as listed in System\CCS\Services keys) + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + // Forces stopping of services that has dependant services + Force bool `protobuf:"varint,2,opt,name=force,proto3" json:"force,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *StopServiceRequest) Reset() { *m = StopServiceRequest{} } +func (m *StopServiceRequest) String() string { return proto.CompactTextString(m) } +func (*StopServiceRequest) ProtoMessage() {} +func (*StopServiceRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_4066a9d4a9264c6f, []int{4} +} + +func (m *StopServiceRequest) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_StopServiceRequest.Unmarshal(m, b) +} +func (m *StopServiceRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_StopServiceRequest.Marshal(b, m, deterministic) +} +func (m *StopServiceRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_StopServiceRequest.Merge(m, src) +} +func (m *StopServiceRequest) XXX_Size() int { + return xxx_messageInfo_StopServiceRequest.Size(m) +} +func (m *StopServiceRequest) XXX_DiscardUnknown() { + xxx_messageInfo_StopServiceRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_StopServiceRequest proto.InternalMessageInfo + +func (m *StopServiceRequest) GetName() string { + if m != nil { + return m.Name + } + return "" +} + +func (m *StopServiceRequest) GetForce() bool { + if m != nil { + return m.Force + } + return false +} + +type StopServiceResponse struct { + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *StopServiceResponse) Reset() { *m = StopServiceResponse{} } +func (m *StopServiceResponse) String() string { return proto.CompactTextString(m) } +func (*StopServiceResponse) ProtoMessage() {} +func (*StopServiceResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_4066a9d4a9264c6f, []int{5} +} + +func (m *StopServiceResponse) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_StopServiceResponse.Unmarshal(m, b) +} +func (m *StopServiceResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_StopServiceResponse.Marshal(b, m, deterministic) +} +func (m *StopServiceResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_StopServiceResponse.Merge(m, src) +} +func (m *StopServiceResponse) XXX_Size() int { + return xxx_messageInfo_StopServiceResponse.Size(m) +} +func (m *StopServiceResponse) XXX_DiscardUnknown() { + xxx_messageInfo_StopServiceResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_StopServiceResponse proto.InternalMessageInfo + +type GetServiceRequest struct { + // Service name (as listed in System\CCS\Services keys) + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *GetServiceRequest) Reset() { *m = GetServiceRequest{} } +func (m *GetServiceRequest) String() string { return proto.CompactTextString(m) } +func (*GetServiceRequest) ProtoMessage() {} +func (*GetServiceRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_4066a9d4a9264c6f, []int{6} +} + +func (m *GetServiceRequest) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_GetServiceRequest.Unmarshal(m, b) +} +func (m *GetServiceRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_GetServiceRequest.Marshal(b, m, deterministic) +} +func (m *GetServiceRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_GetServiceRequest.Merge(m, src) +} +func (m *GetServiceRequest) XXX_Size() int { + return xxx_messageInfo_GetServiceRequest.Size(m) +} +func (m *GetServiceRequest) XXX_DiscardUnknown() { + xxx_messageInfo_GetServiceRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_GetServiceRequest proto.InternalMessageInfo + +func (m *GetServiceRequest) GetName() string { + if m != nil { + return m.Name + } + return "" +} + +type GetServiceResponse struct { + // Service display name + DisplayName string `protobuf:"bytes,1,opt,name=display_name,json=displayName,proto3" json:"display_name,omitempty"` + // Service start type + StartType StartType `protobuf:"varint,2,opt,name=start_type,json=startType,proto3,enum=v1alpha1.StartType" json:"start_type,omitempty"` + // Service status + Status ServiceStatus `protobuf:"varint,3,opt,name=status,proto3,enum=v1alpha1.ServiceStatus" json:"status,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *GetServiceResponse) Reset() { *m = GetServiceResponse{} } +func (m *GetServiceResponse) String() string { return proto.CompactTextString(m) } +func (*GetServiceResponse) ProtoMessage() {} +func (*GetServiceResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_4066a9d4a9264c6f, []int{7} +} + +func (m *GetServiceResponse) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_GetServiceResponse.Unmarshal(m, b) +} +func (m *GetServiceResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_GetServiceResponse.Marshal(b, m, deterministic) +} +func (m *GetServiceResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_GetServiceResponse.Merge(m, src) +} +func (m *GetServiceResponse) XXX_Size() int { + return xxx_messageInfo_GetServiceResponse.Size(m) +} +func (m *GetServiceResponse) XXX_DiscardUnknown() { + xxx_messageInfo_GetServiceResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_GetServiceResponse proto.InternalMessageInfo + +func (m *GetServiceResponse) GetDisplayName() string { + if m != nil { + return m.DisplayName + } + return "" +} + +func (m *GetServiceResponse) GetStartType() StartType { + if m != nil { + return m.StartType + } + return StartType_START_TYPE_BOOT +} + +func (m *GetServiceResponse) GetStatus() ServiceStatus { + if m != nil { + return m.Status + } + return ServiceStatus_SERVICE_STATUS_UNKNOWN +} + func init() { + proto.RegisterEnum("v1alpha1.ServiceStatus", ServiceStatus_name, ServiceStatus_value) + proto.RegisterEnum("v1alpha1.StartType", StartType_name, StartType_value) proto.RegisterType((*GetBIOSSerialNumberRequest)(nil), "v1alpha1.GetBIOSSerialNumberRequest") proto.RegisterType((*GetBIOSSerialNumberResponse)(nil), "v1alpha1.GetBIOSSerialNumberResponse") + proto.RegisterType((*StartServiceRequest)(nil), "v1alpha1.StartServiceRequest") + proto.RegisterType((*StartServiceResponse)(nil), "v1alpha1.StartServiceResponse") + proto.RegisterType((*StopServiceRequest)(nil), "v1alpha1.StopServiceRequest") + proto.RegisterType((*StopServiceResponse)(nil), "v1alpha1.StopServiceResponse") + proto.RegisterType((*GetServiceRequest)(nil), "v1alpha1.GetServiceRequest") + proto.RegisterType((*GetServiceResponse)(nil), "v1alpha1.GetServiceResponse") } func init() { - proto.RegisterFile("src/github.com/kubernetes-csi/csi-proxy/client/api/system/v1alpha1/api.proto", fileDescriptor_714d71facb074551) -} - -var fileDescriptor_714d71facb074551 = []byte{ - // 211 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xf2, 0x29, 0x2e, 0x4a, 0xd6, - 0x4f, 0xcf, 0x2c, 0xc9, 0x28, 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0xcf, 0x2e, 0x4d, 0x4a, 0x2d, - 0xca, 0x4b, 0x2d, 0x49, 0x2d, 0xd6, 0x4d, 0x2e, 0xce, 0xd4, 0x4f, 0x2e, 0xce, 0xd4, 0x2d, 0x28, - 0xca, 0xaf, 0xa8, 0xd4, 0x4f, 0xce, 0xc9, 0x4c, 0xcd, 0x2b, 0xd1, 0x4f, 0x2c, 0xc8, 0xd4, 0x2f, - 0xae, 0x2c, 0x2e, 0x49, 0xcd, 0xd5, 0x2f, 0x33, 0x4c, 0xcc, 0x29, 0xc8, 0x48, 0x34, 0x04, 0x89, - 0xe9, 0x15, 0x14, 0xe5, 0x97, 0xe4, 0x0b, 0x71, 0xc0, 0xc4, 0x94, 0x64, 0xb8, 0xa4, 0xdc, 0x53, - 0x4b, 0x9c, 0x3c, 0xfd, 0x83, 0x83, 0x53, 0x8b, 0x32, 0x13, 0x73, 0xfc, 0x4a, 0x73, 0x93, 0x52, - 0x8b, 0x82, 0x52, 0x0b, 0x4b, 0x53, 0x8b, 0x4b, 0x94, 0x9c, 0xb8, 0xa4, 0xb1, 0xca, 0x16, 0x17, - 0xe4, 0xe7, 0x15, 0xa7, 0x0a, 0x29, 0x73, 0xf1, 0x16, 0x83, 0xc5, 0xe3, 0xf3, 0xc0, 0x12, 0x12, - 0x8c, 0x0a, 0x8c, 0x1a, 0x9c, 0x41, 0x3c, 0xc5, 0x48, 0x8a, 0x8d, 0xf2, 0xb8, 0xd8, 0x82, 0xc1, - 0x0e, 0x11, 0x4a, 0xe1, 0x12, 0xc6, 0x62, 0x9a, 0x90, 0x8a, 0x1e, 0xcc, 0x35, 0x7a, 0xb8, 0x9d, - 0x22, 0xa5, 0x4a, 0x40, 0x15, 0xc4, 0x49, 0x4a, 0x0c, 0x4e, 0x0e, 0x51, 0x76, 0x94, 0x85, 0x53, - 0x12, 0x1b, 0x38, 0x90, 0x8c, 0x01, 0x01, 0x00, 0x00, 0xff, 0xff, 0x8b, 0x01, 0xa9, 0x3f, 0x74, - 0x01, 0x00, 0x00, + proto.RegisterFile("github.com/kubernetes-csi/csi-proxy/client/api/system/v1alpha1/api.proto", fileDescriptor_4066a9d4a9264c6f) +} + +var fileDescriptor_4066a9d4a9264c6f = []byte{ + // 589 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x54, 0x5f, 0x6f, 0xd2, 0x50, + 0x1c, 0x5d, 0xd9, 0x86, 0xdb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0xff, 0xdf, 0x1d, 0xd8, 0xcd, 0x46, 0x17, 0xe0, 0x9b, 0x3f, + 0x01, 0x00, 0x00, 0xff, 0xff, 0xbf, 0x78, 0x82, 0xf1, 0x4c, 0x05, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. var _ context.Context -var _ grpc.ClientConn +var _ grpc.ClientConnInterface // This is a compile-time assertion to ensure that this generated file // is compatible with the grpc package it is being compiled against. -const _ = grpc.SupportPackageIsVersion4 +const _ = grpc.SupportPackageIsVersion6 // SystemClient is the client API for System service. // @@ -136,13 +495,19 @@ const _ = grpc.SupportPackageIsVersion4 type SystemClient interface { // GetBIOSSerialNumber returns the device's serial number GetBIOSSerialNumber(ctx context.Context, in *GetBIOSSerialNumberRequest, opts ...grpc.CallOption) (*GetBIOSSerialNumberResponse, error) + // StartService starts a Windows service + StartService(ctx context.Context, in *StartServiceRequest, opts ...grpc.CallOption) (*StartServiceResponse, error) + // StopService stops a Windows service + StopService(ctx context.Context, in *StopServiceRequest, opts ...grpc.CallOption) (*StopServiceResponse, error) + // GetService queries a Windows service state + GetService(ctx context.Context, in *GetServiceRequest, opts ...grpc.CallOption) (*GetServiceResponse, error) } type systemClient struct { - cc *grpc.ClientConn + cc grpc.ClientConnInterface } -func NewSystemClient(cc *grpc.ClientConn) SystemClient { +func NewSystemClient(cc grpc.ClientConnInterface) SystemClient { return &systemClient{cc} } @@ -155,10 +520,43 @@ func (c *systemClient) GetBIOSSerialNumber(ctx context.Context, in *GetBIOSSeria return out, nil } +func (c *systemClient) StartService(ctx context.Context, in *StartServiceRequest, opts ...grpc.CallOption) (*StartServiceResponse, error) { + out := new(StartServiceResponse) + err := c.cc.Invoke(ctx, "/v1alpha1.System/StartService", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *systemClient) StopService(ctx context.Context, in *StopServiceRequest, opts ...grpc.CallOption) (*StopServiceResponse, error) { + out := new(StopServiceResponse) + err := c.cc.Invoke(ctx, "/v1alpha1.System/StopService", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *systemClient) GetService(ctx context.Context, in *GetServiceRequest, opts ...grpc.CallOption) (*GetServiceResponse, error) { + out := new(GetServiceResponse) + err := c.cc.Invoke(ctx, "/v1alpha1.System/GetService", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // SystemServer is the server API for System service. type SystemServer interface { // GetBIOSSerialNumber returns the device's serial number GetBIOSSerialNumber(context.Context, *GetBIOSSerialNumberRequest) (*GetBIOSSerialNumberResponse, error) + // StartService starts a Windows service + StartService(context.Context, *StartServiceRequest) (*StartServiceResponse, error) + // StopService stops a Windows service + StopService(context.Context, *StopServiceRequest) (*StopServiceResponse, error) + // GetService queries a Windows service state + GetService(context.Context, *GetServiceRequest) (*GetServiceResponse, error) } // UnimplementedSystemServer can be embedded to have forward compatible implementations. @@ -168,6 +566,15 @@ type UnimplementedSystemServer struct { func (*UnimplementedSystemServer) GetBIOSSerialNumber(ctx context.Context, req *GetBIOSSerialNumberRequest) (*GetBIOSSerialNumberResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method GetBIOSSerialNumber not implemented") } +func (*UnimplementedSystemServer) StartService(ctx context.Context, req *StartServiceRequest) (*StartServiceResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method StartService not implemented") +} +func (*UnimplementedSystemServer) StopService(ctx context.Context, req *StopServiceRequest) (*StopServiceResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method StopService not implemented") +} +func (*UnimplementedSystemServer) GetService(ctx context.Context, req *GetServiceRequest) (*GetServiceResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetService not implemented") +} func RegisterSystemServer(s *grpc.Server, srv SystemServer) { s.RegisterService(&_System_serviceDesc, srv) @@ -191,6 +598,60 @@ func _System_GetBIOSSerialNumber_Handler(srv interface{}, ctx context.Context, d return interceptor(ctx, in, info, handler) } +func _System_StartService_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(StartServiceRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(SystemServer).StartService(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/v1alpha1.System/StartService", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(SystemServer).StartService(ctx, req.(*StartServiceRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _System_StopService_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(StopServiceRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(SystemServer).StopService(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/v1alpha1.System/StopService", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(SystemServer).StopService(ctx, req.(*StopServiceRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _System_GetService_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetServiceRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(SystemServer).GetService(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/v1alpha1.System/GetService", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(SystemServer).GetService(ctx, req.(*GetServiceRequest)) + } + return interceptor(ctx, in, info, handler) +} + var _System_serviceDesc = grpc.ServiceDesc{ ServiceName: "v1alpha1.System", HandlerType: (*SystemServer)(nil), @@ -199,7 +660,19 @@ var _System_serviceDesc = grpc.ServiceDesc{ MethodName: "GetBIOSSerialNumber", Handler: _System_GetBIOSSerialNumber_Handler, }, + { + MethodName: "StartService", + Handler: _System_StartService_Handler, + }, + { + MethodName: "StopService", + Handler: _System_StopService_Handler, + }, + { + MethodName: "GetService", + Handler: _System_GetService_Handler, + }, }, Streams: []grpc.StreamDesc{}, - Metadata: "src/github.com/kubernetes-csi/csi-proxy/client/api/system/v1alpha1/api.proto", + Metadata: "github.com/kubernetes-csi/csi-proxy/client/api/system/v1alpha1/api.proto", } diff --git a/vendor/github.com/kubernetes-csi/csi-proxy/client/api/system/v1alpha1/api.proto b/vendor/github.com/kubernetes-csi/csi-proxy/client/api/system/v1alpha1/api.proto index 8640c151..002cd2ee 100644 --- a/vendor/github.com/kubernetes-csi/csi-proxy/client/api/system/v1alpha1/api.proto +++ b/vendor/github.com/kubernetes-csi/csi-proxy/client/api/system/v1alpha1/api.proto @@ -7,6 +7,15 @@ option go_package = "github.com/kubernetes-csi/csi-proxy/client/api/system/v1alp service System { // GetBIOSSerialNumber returns the device's serial number rpc GetBIOSSerialNumber(GetBIOSSerialNumberRequest) returns (GetBIOSSerialNumberResponse) {} + + // StartService starts a Windows service + rpc StartService(StartServiceRequest) returns (StartServiceResponse) {} + + // StopService stops a Windows service + rpc StopService(StopServiceRequest) returns (StopServiceResponse) {} + + // GetService queries a Windows service state + rpc GetService(GetServiceRequest) returns (GetServiceResponse) {} } message GetBIOSSerialNumberRequest { @@ -17,3 +26,62 @@ message GetBIOSSerialNumberResponse { // Serial number string serial_number = 1; } + +message StartServiceRequest { + // Service name (as listed in System\CCS\Services keys) + string name = 1; +} + +message StartServiceResponse { + // Intentionally empty +} + +message StopServiceRequest { + // Service name (as listed in System\CCS\Services keys) + string name = 1; + + // Forces stopping of services that has dependant services + bool force = 2; +} + +message StopServiceResponse { + // Intentionally empty +} + + +// https://docs.microsoft.com/en-us/windows/win32/api/winsvc/ns-winsvc-service_status#members +enum ServiceStatus { + SERVICE_STATUS_UNKNOWN = 0; + SERVICE_STATUS_STOPPED = 1; + SERVICE_STATUS_START_PENDING = 2; + SERVICE_STATUS_STOP_PENDING = 3; + SERVICE_STATUS_RUNNING = 4; + SERVICE_STATUS_CONTINUE_PENDING = 5; + SERVICE_STATUS_PAUSE_PENDING = 6; + SERVICE_STATUS_PAUSED = 7; +} + +// https://docs.microsoft.com/en-us/windows/win32/api/winsvc/nf-winsvc-changeserviceconfiga +enum StartType { + START_TYPE_BOOT = 0; + START_TYPE_SYSTEM = 1; + START_TYPE_AUTOMATIC = 2; + START_TYPE_MANUAL = 3; + START_TYPE_DISABLED = 4; +} + +message GetServiceRequest { + // Service name (as listed in System\CCS\Services keys) + string name = 1; +} + +message GetServiceResponse { + // Service display name + string display_name = 1; + + // Service start type + StartType start_type = 2; + + // Service status + ServiceStatus status = 3; +} \ No newline at end of file diff --git a/vendor/github.com/kubernetes-csi/csi-proxy/client/groups/system/v1alpha1/client_generated.go b/vendor/github.com/kubernetes-csi/csi-proxy/client/groups/system/v1alpha1/client_generated.go index 7c8a6d6f..9cbc5268 100644 --- a/vendor/github.com/kubernetes-csi/csi-proxy/client/groups/system/v1alpha1/client_generated.go +++ b/vendor/github.com/kubernetes-csi/csi-proxy/client/groups/system/v1alpha1/client_generated.go @@ -54,3 +54,15 @@ var _ v1alpha1.SystemClient = &Client{} func (w *Client) GetBIOSSerialNumber(context context.Context, request *v1alpha1.GetBIOSSerialNumberRequest, opts ...grpc.CallOption) (*v1alpha1.GetBIOSSerialNumberResponse, error) { return w.client.GetBIOSSerialNumber(context, request, opts...) } + +func (w *Client) GetService(context context.Context, request *v1alpha1.GetServiceRequest, opts ...grpc.CallOption) (*v1alpha1.GetServiceResponse, error) { + return w.client.GetService(context, request, opts...) +} + +func (w *Client) StartService(context context.Context, request *v1alpha1.StartServiceRequest, opts ...grpc.CallOption) (*v1alpha1.StartServiceResponse, error) { + return w.client.StartService(context, request, opts...) +} + +func (w *Client) StopService(context context.Context, request *v1alpha1.StopServiceRequest, opts ...grpc.CallOption) (*v1alpha1.StopServiceResponse, error) { + return w.client.StopService(context, request, opts...) +} From e68936e9863717393a745cfeed6161256b85aecd Mon Sep 17 00:00:00 2001 From: jmpfar Date: Mon, 19 Oct 2020 12:03:39 +0000 Subject: [PATCH 2/2] Fix vendor/protobuf issue Change-Id: I4d3c80b8866683c6d7abb8384d589801b38d20cf --- .../csi-proxy/client/api/system/v1alpha1/api.proto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/github.com/kubernetes-csi/csi-proxy/client/api/system/v1alpha1/api.proto b/vendor/github.com/kubernetes-csi/csi-proxy/client/api/system/v1alpha1/api.proto index 002cd2ee..04ee006c 100644 --- a/vendor/github.com/kubernetes-csi/csi-proxy/client/api/system/v1alpha1/api.proto +++ b/vendor/github.com/kubernetes-csi/csi-proxy/client/api/system/v1alpha1/api.proto @@ -84,4 +84,4 @@ message GetServiceResponse { // Service status ServiceStatus status = 3; -} \ No newline at end of file +}