I import the WSDL file. GetCA from the WSDL file that were imported rust is in the function.
The following example of a block of code when I run the program.
Where the function is called whoami in receipt of the certificate has not been installed error. How to install and Certificates HTTPRIO connection?
begin
HTTPRIO1.WSDLLocation := defWSDL;
HTTPRIO1.Service := defSvc ;
HTTPRIO1.Port := defPrt ;
HTTPRIO1.URL := defURL;
b := WhoAmIMessage.Create;
a := ReplyMessage.Create;
Cert := TElX509Certificate.Create(nil);
try
F := TFileStream.Create(CertFile, fmOpenRead or fmShareDenyWrite);
CERT.LoadFromStreamPFX(f, CertPass);
F.Position := 0;
HTTPRIO1.HTTPWebNode.OnBeforePost := OnBeforePost;
Trs := GetCA(True, ' ', HTTPRIO1);
B := Trs.WhoAmI;
ShowMessage(BoolToStr(B.IsAuthenticated));
finally
a.Free;
b.Free;
Cert.Free;
FreeAndNil(F);
end;
end;
Related
Need to download a file from s3 bucket and store in to tmp directory in lambda function. After that need apply grep command into file using "os/exec". I tried to do this algorithm using golang.
I tried through following way but it is not successful approach.
func MyHandler(ctx context.Context, s3Event events.S3Event) {
for _, record := range s3Event.Records {
s3record := record.S3
bucketName := s3record.Bucket.Name
fileName := s3record.Object.Key
download_path := "/tmp/"
file, err := os.Create(download_path + fileName)
if err != nil {
fmt.Println(err)
}
defer file.Close()
sess, _ := session.NewSession(&aws.Config{Region: aws.String("us-east-1")})
downloader := s3manager.NewDownloader(sess)
numBytes, err := downloader.Download(file,
&s3.GetObjectInput{
Bucket: aws.String(bucketName),
Key: aws.String(fileName),
})
if err != nil {
fmt.Println(err)
}
fmt.Println("Downloaded", file.Name(), numBytes, "bytes")
}
}
Please verify may approach correct or suggest a correct approach to store the file from s3 bucket into tem folder of lambda function everything I need to do using golang.
I have following confusion also
Do we need to create directory folder in lambda function or it is a default directory already there.
Can we apply os/exec command into tem folder and can we grep the file.
Do we need to delete uploaded file from tem folder then How? or The file will be deleted a automatically.
I am new to golang so it's kind of hard to understand what would be the best way to test prometheus.GuageVec.
Here is my try 1. where i am trying to get metrics channel. But this request is timing out?
cb, _ := GaugeVecs[name]
ch := make(chan prometheus.Metric)
cb.Collect(ch)
metric := <-ch
fmt.Printf("%+v", metric)
The second try that i did was
cb, _ := GaugeVecs[name]
err := testutil.CollectAndCompare(cb, strings.NewReader(`expected outcome`), "name")
assert.Nil(t, err)
^^^ this one got error that parsing expected metrics failed: text format parsing error in line 1: unexpected end of input stream.
How can i test the output of metric?
I'm trying to launch jasperreports (on jaspersoft server) via APEX dynamic actions.
When I am executing this i receive a error:
Even when I'm only trying to login
DECLARE
v_blob BLOB;
v_file_name VARCHAR2 (25) := 'TestReport.pdf';
v_vcContentDisposition VARCHAR2 (25) := 'inline';
v_invoice_id VARCHAR2(10) := :INVOICE_ID; -- your NumberField Item
v_hostname VARCHAR2(30) := #HOST#; -- your hostname, eg: localhost
v_port NUMBER := #PORT#; -- port for your JasperReports Server, eg: 8081
v_username VARCHAR2(50) := 'jasperadmin'; -- jasperreports server username
v_password VARCHAR2(50) := 'jasperadmin'; -- jaspereports server password
v_jasper_string VARCHAR2(30) := v_username || ';' || v_password;
v_login_url VARCHAR2(100) :=
'http://' || v_hostname || ':' || v_port || '/jasperserver/rest/login';
v_report_url VARCHAR2(100) :=
'http://' || v_hostname || ':' || v_port || '/jasperserver/rest_v2/reports/Reports/' || v_file_name;
BEGIN
-- log into jasper server
v_blob := apex_web_service.make_rest_request_b(
p_url => v_login_url,
p_http_method => 'GET',
p_parm_name => apex_util.string_to_table('j_username;j_password',';'),
p_parm_value => apex_util.string_to_table(v_jasper_string,';')
); APEX_APPLICATION.STOP_APEX_ENGINE;
EXCEPTION
WHEN OTHERS THEN
RAISE;
END;
The APEX and JasperServer are on different ports.
Have you added the target ip:port to the ACL?
https://docs.oracle.com/database/121/ARPLS/d_networkacl_adm.htm#ARPLS148
Problem was with the https protocol. Apex had https and Jasperserver didn't.
The conclusion is that both (apex and jasperserver) need to have https.
Edit:
In addittional I needed to create proper ACL and create Oracle Wallet to avoid "Certificate Validation Error"
I am trying to achieve following using my program:
Create log-group on aws cloudwatch
Create log-stream under above log-group
Put log-events under above log-stream
All this using go lang
package main
import (
"time"
"fmt"
"github.com/jcxplorer/cwlogger"
"github.com/aws/aws-sdk-go/service/cloudwatchlogs"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/aws"
)
func main() {
sess := session.Must(session.NewSessionWithOptions(session.Options{
SharedConfigState: session.SharedConfigEnable,
}))
svc := cloudwatchlogs.New(sess)
logGroupName := "my-log-group";
logStreamName := "my-log-stream";
logGroupInput := cloudwatchlogs.CreateLogGroupInput{LogGroupName: &logGroupName}
svc.CreateLogGroup(&logGroupInput);
logStreamInput := cloudwatchlogs.CreateLogStreamInput{LogGroupName: &logGroupName, LogStreamName: &logStreamName}
svc.CreateLogStream(&logStreamInput)
logevents := make([]*cloudwatchlogs.InputLogEvent, 1)
logevents = append(logevents, &cloudwatchlogs.InputLogEvent{
Message: aws.String("Simple log message"),
Timestamp: aws.Int64(111),
})
p := cloudwatchlogs.PutLogEventsInput{LogEvents: logevents, LogGroupName: &logGroupName, LogStreamName: &logStreamName}
resp, err := svc.PutLogEvents(&p)
if err != nil {
panic(err)
}
fmt.Print("Next Token: {}", resp.NextSequenceToken)
}
Now when I run above code, it successfully creates log-group and log-stream and I can verify that in aws cloudwatch. But for some reason PutLogEvents fails with following error:
panic: SerializationException:
status code: 400, request id: 0685efcc-47e3-11e9-b528-81f33ec2f468
I am not sure what may be wrong here. Any suggestion or direction will be really helpful.
Thanks in advance.
Reason for SerializationException was:logevents := make([]*cloudwatchlogs.InputLogEvent, 1)
followed by append which created first empty entry in slice. I replaced code with
logevents := make([]*cloudwatchlogs.InputLogEvent, 0) and it got resolved.
Additionally while debugging to find why logs were not getting populated I figured out that timestamp value used is not valid one. According to aws documentation timestamp for each event can't be older than 14 days and can't be more than 2hr in future.
Here is link: https://docs.aws.amazon.com/AmazonCloudWatchLogs/latest/APIReference/API_PutLogEvents.html
Hope it will be helpful to someone facing similar issue in future.
I have written a lambda function that executes another exe file named abc.exe.
Now I have created a zip of lambda function and uploaded it to aws. I am not sure where to put my "abc.exe"
I tried putting it in the same zip but I get below error:
exec: "abc": executable file not found in $PATH:
Here is my lambda function code:
func HandleLambdaEvent(request Request) (Response, error) {
fmt.Println("Input", request.Input)
fmt.Println("Output", request.Output)
cmd := exec.Command("abc", "-v", "--lambda", request.Input, "--out", request.Output)
var out bytes.Buffer
var stderr bytes.Buffer
cmd.Stdout = &out
cmd.Stderr = &stderr
err := cmd.Run()
if err != nil {
fmt.Println(fmt.Sprint(err) + ": " + stderr.String())
return Response{Message: fmt.Sprintf(stderr.String())}, nil
}
fmt.Println("Result: " + out.String())
return Response{Message: fmt.Sprintf(" %s and %s are input and output", request.Input, request.Output)}, nil
}
Update:
Trial 1:
I uploaded abc.exe to s3 then in my HandleLambdaEvent function I am downloading it to tmp/ folder. And next when i try to access it after successful download, it shows below error:
fork/exec /tmp/abc: no such file or directory:
Code to download abc.exe :
file, err2 := os.Create("tmp/abc.exe")
if err2 != nil {
fmt.Println("Unable to create file %q, %v", err2)
}
defer file.Close()
sess, _ := session.NewSession(&aws.Config{
Region: aws.String(region)},
)
downloader := s3manager.NewDownloader(sess)
numBytes, err2 := downloader.Download(file,
&s3.GetObjectInput{
Bucket: aws.String(bucket),
Key: aws.String("abc.exe"),
})
if err2 != nil {
fmt.Println("Unable to download item %q, %v", fileName, err2)
}
fmt.Println("Downloaded", file.Name(), numBytes, "bytes")
file.Close()
are you sure you even can execute an external binary? That seems counter-intuitive to me, like it violates the point of Lambda
Perfectly acceptable. Have a look at Running Arbitrary Executables in AWS Lambda on the AWS Compute Blog.
I am not sure where to put my "abc.exe"
To run executables on Lambda package them in the ZIP file you upload. Then do something like
exec.Command(path.Join(os.GetEnv("LAMBDA_TASK_ROOT"), "abc.exe"))
What sort of file is the .exe file? Is it a Windows app?
You won't be able to run Windows apps on Lambda. The linked blog post says: If you compile your own binaries, ensure that they’re either statically linked or built for the matching version of Amazon Linux