{"type":"api","title":"Get sample arbitration executable","meta":{"id":"/apps/pubhub/media/crosswork-network-controller-7-1/f445c17e25a1120e8fbde4bd413083d0fd88b2b3/40d706fd-9f3a-3ab1-a34b-943159096796","info":{"title":"Crosswork Crosscluster Service APIs","description":"Cross cluster provides API methods for handling geo synchronization, leadership operations, and multi-cluster showtech collection on Crosswork.","version":"3.0.0","contact":{"name":"Crosswork Team, Cisco","email":"support@cisco.com"},"license":{"name":"Cisco Software License Agreement","url":"https://www.cisco.com/public/sw-license-agreement.html"}},"x-parser-conf":{"overview":{"markdownPath":"reference/INFRA/CROSSCLUSTER/crosscluster-overview.md"}},"swagger":"2.0","basePath":"/crosswork/crosscluster/v1","schemes":["http","https"],"securityDefinitions":{"bearerAuth":{"type":"apiKey","name":"Authorization","in":"header","description":"Security definitions details."}}},"spec":{"summary":"Get sample arbitration executable","description":"Get a sample arbitration executable example.","operationId":"CrossClusterManager_GetSampleArbitrationExecutable","responses":{"200":{"description":"A successful response.","schema":{"type":"object","properties":{"sample":{"type":"string","description":"DNS update sample file."},"result":{"title":"Result","type":"object","properties":{"request_result":{"description":"ResultValue indicated accept/reject for a request, not the outcome of the work itself.","type":"string","enum":["UNKNOWN_RESULT","REJECTED","ACCEPTED"],"default":"UNKNOWN_RESULT","title":"Request - reply\nresponse","$$ref":"#/definitions/common_geo_platformRequestResult"},"error":{"description":"Message is a textual description of reason for rejection, and can be safely passed on to operator through logs\nor UI.","type":"object","properties":{"message":{"type":"string","title":"Message is a textual description of reason for rejection, and can be safely passed on to operator through logs\nor UI"}},"title":"Error associated with an Object","$$ref":"#/definitions/common_geo_platformError"}},"description":"Result is used to convey whether an operation (individual or in a batch)\nhas been accepted or rejected. For sync API's an error or rejection indicates failure of operation.\nA string error message accompanies rejection to support troubleshooting. For notification objects,\nrejection represents failure to do intended operation.","$$ref":"#/definitions/common_geo_platformResult"}},"$$ref":"#/definitions/crosscluster_serviceCrossClusterGetSampleArbitrationExecutableResponse"},"examples":{"example":{"sample":"// Copyright (c) 2024 by cisco Systems, Inc.\n// All rights reserved.\n//\n// ** Crosscluster Orchestrator Arbitration Executable Sample **\n//\n// The sample contains an example code to update the DNS server (Cisco Prime Network Registrar v11.1) given some argument\n// inputs. Note that this sample was saved in a file named 'arbitration_executable_example.go'. For successful DNS\n// updates the program should return an exit code of 0. If any issues, problems, or errors are encountered which prevent\n// the update of the DNS the program should return a non-zero exit code.\n//\n// Compiled with the following command:\n// $ env GOOS=linux GOARCH=amd64 go1.23.1 build -o arbitration_executable arbitration_executable_example.go\n//\n// The file should then produce similar output as below when running 'file -b {filename}' command. It is important that the output includes:\n// - 'ELF' ==\u003e Indicated 'Extensible Linking Format' which is just a common standard file format for executable files.\n// - 'executable' ==\u003e Indicates the file is executable (can be run as a command).\n// - 'x86-64' ==\u003e Architecture is 64-bit x86.\n// - 'statically linked' ==\u003e Indicates that the executable includes all necessary libraries within itself, so it does not rely on external shared libraries.\n//\n// $ file -b arbitration_executable\n// ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, Go BuildID=_MweKwdeiNnA8Ximr7qF/ern57s8Q1uhy6ShtQZiK/tyOVKMjaq7ibYJu2roxG/fM-fGBcqUHuITUw7I2IF, with debug_info, not stripped\n//\n// NOTE that the expected binary produced should be less than or equal to 20Mb in size. You can get the size using the\n// following command which shows this file when compiled produces a binary that is 17Mb:\n// $ du -sh arbitration_executable\n// 17M\tarbitration_executable\n//\n// Sample invocations:\n//\n// IPv4 stack:\n// $ ./arbitration_executable '{\"dns_server\":{\"dns_host\":\"172.23.210.55\",\"port\":53},\"dns_updates\":[{\"fqdn\":{\"host_name\":\"geodata\",\"domain_name\":\"cw.cisco.\"},\"addresses\":[\"10.10.10.110\"]},{\"fqdn\":{\"host_name\":\"geomanagement\",\"domain_name\":\"cw.cisco.\"},\"addresses\":[\"192.168.133.170\"]}]}'\n//\n// IPv6 stack:\n// $ ./arbitration_executable '{\"dns_server\":{\"dns_host\":\"172.23.210.55\",\"port\":53},\"dns_updates\":[{\"fqdn\":{\"host_name\":\"geodata\",\"domain_name\":\"cw.cisco.\"},\"addresses\":[\"fded:1bc1:fc3e:96d0:10:10:10:110\"]},{\"fqdn\":{\"host_name\":\"geomanagement\",\"domain_name\":\"cw.cisco.\"},\"addresses\":[\"fded:1bc1:fc3e:96d0:192:168:133:170\"]}]}'\n//\n// Dual stack (IPv4 + IPv6):\n// $ ./arbitration_executable '{\"dns_server\":{\"dns_host\":\"172.23.210.55\",\"port\":53},\"dns_updates\":[{\"fqdn\":{\"host_name\":\"geodata\",\"domain_name\":\"cw.cisco.\"},\"addresses\":[\"10.10.10.110\",\"fded:1bc1:fc3e:96d0:10:10:10:110\"]},{\"fqdn\":{\"host_name\":\"geomanagement\",\"domain_name\":\"cw.cisco.\"},\"addresses\":[\"192.168.133.170\",\"fded:1bc1:fc3e:96d0:192:168:133:170\"]}]}'\n//\npackage main\n\nimport (\n\t\"crypto/tls\"\n\t\"fmt\"\n\t\"net\"\n\t\"net/http\"\n\t\"os\"\n\t\"strings\"\n\n\t\"github.com/golang/protobuf/jsonpb\"\n\n\t\"github3.cisco.com/ROBOT/robot-api/golang/crosscluster_service\"\n)\n\nfunc main() {\n\t// The executable only takes a single argument so the command line is just the program name and the arguments object.\n\tif len(os.Args) != 2 {\n\t\tos.Exit(1)\n\t}\n\n\t// Create an empty structure to hold the command line arguments.\n\targuments := new(crosscluster_service.DNSArbitrationExecutableArguments)\n\n\t// Unmarshal the command line arguments into the above empty structure so it is properly populated.\n\tif err := jsonpb.UnmarshalString(os.Args[1], arguments); err != nil {\n\t\tos.Exit(2)\n\t}\n\n\t// NOTE: arguments.GetDnsServer().GetPort() is ignored since the DNS authoritative server was passed in, which uses port\n\t// 53. Since communication with CPNR here is done via HTTP REST requests, port 8443 is used instead.\n\tdnsEndpoint := fmt.Sprintf(\"%s:%d\", arguments.GetDnsServer().GetDnsHost(), 8443)\n\n\t// Create a HTTP client to talk to the DNS server. Skip TLS verification.\n\thttpClient := &http.Client{\n\t\tTransport: &http.Transport{\n\t\t\tTLSClientConfig: &tls.Config{\n\t\t\t\tInsecureSkipVerify: true,\n\t\t\t},\n\t\t},\n\t}\n\n\t// Login to the DNS server.\n\trequest, err := http.NewRequest(http.MethodGet, \"https://\"+dnsEndpoint+\"/web-services/rest/session\", nil)\n\tif err != nil {\n\t\tos.Exit(3)\n\t}\n\n\trequest.SetBasicAuth(\"admin\", \"********\")\n\n\tresponse, err := httpClient.Do(request)\n\tif err != nil {\n\t\tos.Exit(4)\n\t}\n\n\tresponse.Body.Close()\n\n\t// Log out once done with the update(s). Note that 'defer' is a special golang keyword which runs this function when main returns.\n\tdefer func() {\n\t\trequest, err = http.NewRequest(http.MethodDelete, \"https://\"+dnsEndpoint+\"/web-services/rest/session\", nil)\n\t\tif err != nil {\n\t\t\tos.Exit(5)\n\t\t}\n\n\t\trequest.SetBasicAuth(\"admin\", \"********\")\n\n\t\tresponse, err = httpClient.Do(request)\n\t\tif err != nil {\n\t\t\tos.Exit(6)\n\t\t}\n\n\t\tresponse.Body.Close()\n\t}()\n\n\t// Update the DNS server to point to the correct addresses. If the record does not previously exist, create it.\n\tfor _, dnsUpdate := range arguments.GetDnsUpdates() {\n\n\t\tcrossworkHostName := dnsUpdate.GetFqdn().GetHostName()\n\n\t\tcrossworkDomainName := dnsUpdate.GetFqdn().GetDomainName()\n\n\t\tpayload := \"{\\\"name\\\":\\\"\"+crossworkHostName+\"\\\",\\\"rrList\\\":{\\\"CCMRRItem\\\":[\"\n\n\t\tfor i, address := range dnsUpdate.GetAddresses() {\n\t\t\t// NOTE: assume IPv6 record type. If IP is correctly parsed and converted to\n\t\t\t// an IPv4 address then update the record type.\n\t\t\trecordType := \"AAAA\"\n\n\t\t\tif net.ParseIP(address).To4() != nil {\n\t\t\t\trecordType = \"A\"\n\t\t\t}\n\n\t\t\tif i \u003e 0 {\n\t\t\t\tpayload += \",\"\n\t\t\t}\n\n\t\t\tpayload += \"{\\\"rdata\\\":\\\"\"+address+\"\\\",\\\"rrClass\\\":\\\"IN\\\",\\\"rrType\\\":\\\"\"+recordType+\"\\\",\\\"ttl\\\":\\\"30\\\"}\"\n\t\t}\n\n\t\tpayload += \"]}}\"\n\n\t\tendpoint := \"https://\"+dnsEndpoint+\"/web-services/rest/resource/CCMRRSet/\"+crossworkHostName+\"?zoneOrigin=\"+crossworkDomainName\n\n\t\trequest, err = http.NewRequest(http.MethodPut, endpoint, strings.NewReader(payload))\n\t\tif err != nil {\n\t\t\tos.Exit(7)\n\t\t}\n\n\t\trequest.SetBasicAuth(\"admin\", \"********\")\n\n\t\trequest.Header.Set(\"content-type\", \"application/json\")\n\n\t\tresponse, err = httpClient.Do(request)\n\t\tif err != nil {\n\t\t\tos.Exit(8)\n\t\t}\n\n\t\tresponse.Body.Close()\n\t}\n\n\t// Successfully updated the DNS server.\n\tos.Exit(0)\n}","result":{"request_result":"ACCEPTED","error":{}}}}},"default":{"description":"An unexpected error response.","schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"integer","format":"int32"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"type_url":{"type":"string","description":"A URL/resource name that uniquely identifies the type of the serialized\nprotocol buffer message. This string must contain at least\none \"/\" character. The last segment of the URL's path must represent\nthe fully qualified name of the type (as in\n`path/google.protobuf.Duration`). The name should be in a canonical form\n(e.g., leading \".\" is not accepted).\n\nIn practice, teams usually precompile into the binary all types that they\nexpect it to use in the context of Any. However, for URLs which use the\nscheme `http`, `https`, or no scheme, one can optionally set up a type\nserver that maps type URLs to message definitions as follows:\n\n* If no scheme is provided, `https` is assumed.\n* An HTTP GET on the URL must yield a [google.protobuf.Type][]\n value in binary format, or produce an error.\n* Applications are allowed to cache lookup results based on the\n URL, or have them precompiled into a binary to avoid any\n lookup. Therefore, binary compatibility needs to be preserved\n on changes to types. (Use versioned type names to manage\n breaking changes.)\n\nNote: this functionality is not currently available in the official\nprotobuf release, and it is not used for type URLs beginning with\ntype.googleapis.com.\n\nSchemes other than `http`, `https` (or the empty scheme) might be\nused with implementation specific semantics."},"value":{"type":"string","format":"byte","description":"Must be a valid serialized protocol buffer of the above specified type."}},"description":"`Any` contains an arbitrary serialized protocol buffer message along with a\nURL that describes the type of the serialized message.\n\nProtobuf library provides support to pack/unpack Any values in the form\nof utility functions or additional generated methods of the Any type.\n\nExample 1: Pack and unpack a message in C++.\n\n Foo foo = ...;\n Any any;\n any.PackFrom(foo);\n ...\n if (any.UnpackTo(&foo)) {\n ...\n }\n\nExample 2: Pack and unpack a message in Java.\n\n Foo foo = ...;\n Any any = Any.pack(foo);\n ...\n if (any.is(Foo.class)) {\n foo = any.unpack(Foo.class);\n }\n\n Example 3: Pack and unpack a message in Python.\n\n foo = Foo(...)\n any = Any()\n any.Pack(foo)\n ...\n if any.Is(Foo.DESCRIPTOR):\n any.Unpack(foo)\n ...\n\n Example 4: Pack and unpack a message in Go\n\n foo := &pb.Foo{...}\n any, err := ptypes.MarshalAny(foo)\n ...\n foo := &pb.Foo{}\n if err := ptypes.UnmarshalAny(any, foo); err != nil {\n ...\n }\n\nThe pack methods provided by protobuf library will by default use\n'type.googleapis.com/full.type.name' as the type URL and the unpack\nmethods only use the fully qualified type name after the last '/'\nin the type URL, for example \"foo.bar.com/x/y.z\" will yield type\nname \"y.z\".\n\n\nJSON\n====\nThe JSON representation of an `Any` value uses the regular\nrepresentation of the deserialized, embedded message, with an\nadditional field `@type` which contains the type URL. Example:\n\n package google.profile;\n message Person {\n string first_name = 1;\n string last_name = 2;\n }\n\n {\n \"@type\": \"type.googleapis.com/google.profile.Person\",\n \"firstName\": \u003cstring\u003e,\n \"lastName\": \u003cstring\u003e\n }\n\nIf the embedded message type is well-known and has a custom JSON\nrepresentation, that representation will be embedded adding a field\n`value` which holds the custom JSON in addition to the `@type`\nfield. Example (for message [google.protobuf.Duration][]):\n\n {\n \"@type\": \"type.googleapis.com/google.protobuf.Duration\",\n \"value\": \"1.212s\"\n }","$$ref":"#/definitions/protobufAny"}}},"$$ref":"#/definitions/gatewayruntimeError"},"examples":{"example":{"error":"","code":13,"message":"failed to marshal error message","details":[]}}}},"parameters":[{"name":"body","in":"body","required":true,"description":"Cross cluster sample arbitration executable request data","schema":{"type":"null","properties":{},"description":"Request payload to get a sample arbitration executable binary example for geo H/A auto arbitration.","$$ref":"#/definitions/crosscluster_serviceCrossClusterGetSampleArbitrationExecutableRequest"}}],"tags":["CrossClusterManager"],"__originalOperationId":"CrossClusterManager_GetSampleArbitrationExecutable","consumes":["application/json"],"produces":["application/json"],"method":"post","path":"/arbitrationexecutable/sample/query"}}