Generating a uuid for a copied VMWare virtual machine - vmware

As per http://www.vmware.com/support/esx15/doc/esx15_runvm5.html, how would one go about generating the UUID format that is specified in the docs?
I'd like this to be a command line utility so I can re-use this in an automation script.

Command:
uuidgen | perl -ne '{ s/-//g; s/(.{2})/\1 /g; substr($_,23,1,"-"); print ; }'
Outputs:
CB 7B E9 47 F7 55 42 42-AC 16 46 C1 E9 08 35 53

Related

JREPL.BAT - regex to remove lines in file

I have a source data file which I have been using JREPL.BAT to perform some very simple search and replace operations quite successfully. I now need to expand on that to do 2 jobs.
1. remove all lines that start with the string "appX_formContent". This line contain a lot of html output also, it all needs to be deleted on that line.
2. remove all lines that start with "Hex Payload:" and the subsequent line that comes with it.
This is an example of the input data file which shows 2 records. The delimiter between each record is the row that contains "-----------------".
-----------------
Message Headers
JMSCorrelationID: 60bb7750-e9e2-11e9-98bb-42010a961307
JMSPriority: 4
JMSRedelivered: false
Message Properties
app_trackingId: 190990a2-d8d8-43eb-814a-36ceba7a9111
appX_formInstanceIdentifier: FRM389083
appX_formContent: {"data":{"C7d14a6eb-70e7-402d-9d6e-4efd01ba561c":"N","Y","test.</p>\n<p>test form data to be informed </p>\n<p>...............</p>\n<p><strong>Update</strong></p>\n<p><strong>years</strong>"<p>supervision</p>","<p>:true,"c9377ae2-901d-4461-929c-c76e26dc6183":false}}}
app_sourceSystemId: source
app_eventCode: FORM_OUTPUT
app_instigatingUserId: 66
JMSXGroupSeq: 0
Hex Payload:
25 50 44 46 2D 31 2E 35 0D 0A 34 20 30 20 6F 62 6A 0D 0A 3C 3C 2F 54
-----------------
Message Headers
JMSCorrelationID: 641a80d0-e9e2-11e9-98bb-42010a961307
JMSPriority: 4
JMSTimestamp: 2019 10 08 16:43:40
JMSRedelivered: false
Message Properties
app_trackingId: a3c2fe93-ef71-4611-9605-9858ff67a6e8
appX_formInstanceIdentifier: FRM388843
appX_formContent: {"data":{"C7d14a6eb-70e7-402d-9d6e-4efd01ba561c":"N","Y","test.</p>\n<p>test form data to be informed </p>\n<p>...............</p>\n<p><strong>Update</strong></p>\n<p><strong>years</strong>"<p>supervision</p>","<p>:true,"c9377ae2-901d-4461-929c-c76e26dc6183":false}}}
app_sourceSystemId: source
app_eventCode: FORM_OUTPUT
app_instigatingUserId: 433
JMSXGroupSeq: 0
Hex Payload:
25 50 44 46 2D 31 2E 35 0D 0A 34 20 30 20 6F 62 6A 0D 0A 3C 3C 2F
-----------------
This is the batch file that I use to call jrepl - very simple.
call jrepl ".*(?:appX_formContent: .*)" "" /m /f "inpu.txt" /o "output.txt"
I've only tried to remove the appX_formContent line with the regex but it isn't producing any output. I'm not good with regex so help appreciated.
Not sure how to handle the second task of deleting the Hex Payload: line.

Google Deployment Manager stored runtime-config variables appear corrupted

I'm having trouble with encrypted base64 encoded values I'm using in Google Deployment Manager via runtimeconfig.v1beta1.config resource declarations.
After I perform the deployment, the value that I stored using Deployment Manager appear to be quite different to what I retrieve using gcloud beta runtime-configs. As a result, I can't decrypt the value.
First I encrypted and base64 encoded some secret text:
$ echo "secret"|gcloud kms encrypt --key my-crypto-key \
--keyring my-keyring --location australia-southeast1 \
--plaintext-file - --ciphertext-file - | base64 -w0
CiQAsOSNmVXBs2ayUjRePnE5+Oi5dUPuVvjn6UKKUXgxMTA56koSMABDkVUGnXlocFgdUEsQ5qLCF3PVIz5zit+ZCSXjSvNzEAO5XRv6WBRkxBJMjVcheg==
Which I then store in a deployment manager YAML file:
resources:
- name: my-config
type: runtimeconfig.v1beta1.config
properties:
config: my-config
description: "A demo configuration"
- name: dummy-secret
type: runtimeconfig.v1beta1.variable
properties:
parent: $(ref.my-config.name)
variable: 'dummy/secret'
value: "CiQAsOSNmVXBs2ayUjRePnE5+Oi5dUPuVvjn6UKKUXgxMTA56koSMABDkVUGnXlocFgdUEsQ5qLCF3PVIz5zit+ZCSXjSvNzEAO5XRv6WBRkxBJMjVcheg=="
Then I create the deployment (which completes without errors or warnings):
$ gcloud deployment-manager deployments create my-config \
--config my-config.yaml
But when I try extracting the variable value, it is completely different from what I stored:
$ gcloud beta runtime-config configs variables \
get-value 'dummy/secret' --config-name my-config|base64 -w0
CiQAPz8/P1U/P2Y/UjRePnE5Pz8/dUM/Vj8/P0I/UXgxMTA5P0oSMABDP1UGP3locFgdUEsQPz8/F3M/Iz5zPz8/CSU/Sj9zEAM/XRs/WBRkPxJMP1cheg==
This is repeatable / reproducible and I haven't a clue what I'm doing wrong. I don't have this problem using gcloud beta runtime-config variables set followed by get-value.
Looking at the decoded base64 binary of your content, we notice that all the bytes with values >= 0x80 have been changed to 0x3F, ASCII '?'. We suspect you're passing the binary data through the shell or some other pipe which isn't binary-clean.
Corrupted value:
dierks#dierks:~$ base64 -d | hexdump -C
CiQAPz8/P1U/P2Y/UjRePnE5Pz8/dUM/Vj8/P0I/UXgxMTA5P0oSMABDP1UGP3locFgdUEsQPz8/F3M/Iz5zPz8/CSU/Sj9zEAM/XRs/WBRkPxJMP1cheg==
00000000 0a 24 00 3f 3f 3f 3f 55 3f 3f 66 3f 52 34 5e 3e |.$.????U??f?R4^>|
00000010 71 39 3f 3f 3f 75 43 3f 56 3f 3f 3f 42 3f 51 78 |q9???uC?V???B?Qx|
00000020 31 31 30 39 3f 4a 12 30 00 43 3f 55 06 3f 79 68 |1109?J.0.C?U.?yh|
00000030 70 58 1d 50 4b 10 3f 3f 3f 17 73 3f 23 3e 73 3f |pX.PK.???.s?#>s?|
00000040 3f 3f 09 25 3f 4a 3f 73 10 03 3f 5d 1b 3f 58 14 |??.%?J?s..?].?X.|
00000050 64 3f 12 4c 3f 57 21 7a |d?.L?W!z|
00000058
Original value:
dierks#dierks:~$ base64 -d | hexdump -C
CiQAsOSNmVXBs2ayUjRePnE5+Oi5dUPuVvjn6UKKUXgxMTA56koSMABDkVUGnXlocFgdUEsQ5qLCF3PVIz5zit+ZCSXjSvNzEAO5XRv6WBRkxBJMjVcheg==
00000000 0a 24 00 b0 e4 8d 99 55 c1 b3 66 b2 52 34 5e 3e |.$.....U..f.R4^>|
00000010 71 39 f8 e8 b9 75 43 ee 56 f8 e7 e9 42 8a 51 78 |q9...uC.V...B.Qx|
00000020 31 31 30 39 ea 4a 12 30 00 43 91 55 06 9d 79 68 |1109.J.0.C.U..yh|
00000030 70 58 1d 50 4b 10 e6 a2 c2 17 73 d5 23 3e 73 8a |pX.PK.....s.#>s.|
00000040 df 99 09 25 e3 4a f3 73 10 03 b9 5d 1b fa 58 14 |...%.J.s...]..X.|
00000050 64 c4 12 4c 8d 57 21 7a |d..L.W!z|

Intel Edison UART1 cannot export gpio 214

Background:
I am using the "base block" to power and access the UART2 console on the edison.
I have an arduino block with a sketch to print data to serial.
https://www.sparkfun.com/products/13036
The serial data is transmitted from the arduino and I intend to use a node script to read that data and perform network related functions.
Intel Edison and NodeJS serial port communication: I am receiving strange characters
I attempted to follow the edison serial instructions:
https://communities.intel.com/message/265411#265411
However at the GPIO configuration at line 2 it already fails.
root#edison:~# echo -n "214" > /sys/class/gpio/export
sh: write error: No such device
Interestingly if I run the "uart.js" from the "Intel Edison and NodeJS..." question I do get data, but it's not what's expected:
<Buffer 84 e9 f3 f4 e1 ee c3 e5 7a 20 72 75 75 0d 0a 8d c5 f3 f3 c1 c7 e5 20 f3 e5 ee f4 7a 60 70 0d 0a c2 c5 e1 ed 40 e2 f2 cf eb e5 ce 7a 60 30 0d 0a>
<Buffer 84 c9 f3 f4 e1>
<Buffer ce e3 e5 7a 60 72 75 75 0d 0a 8d e5 f3 f3 e1 e7 c5 60 f3 c5 ce f4 3a 40 70 0d 0a 82 e5 c1 ed 60 e2 f2 ef eb c5 ee 7a 40 70 0d 0a>
Lastly using mraa.getPinCount(); I always get 56 back. (Found that while searching around the net)
Thanks for the help!
It appears 115200 is an unusable baud for the Edison serial to Arduino block!
I set the baud to 9600 and have successfully gotten the expected data.
Additionally, the gpio pins for the Arduino block is 130 and 131. (130==rx, 131==tx)
echo -n 130 > /sys/class/gpio/export //may not need, may already be exported
echo -n 131 > /sys/class/gpio/export //may not need, may already be exported
echo mode1 > /sys/kernel/debug/gpio_debug/gpio130/current_pinmux // potentially unneeded as well.
echo mode1 > /sys/kernel/debug/gpio_debug/gpio131/current_pinmux // potentially unneeded as well.
echo in > /sys/class/gpio/gpio130/direction
echo out > /sys/class/gpio/gpio131/direction
..
cat /dev/ttyMFD1

Perf reported IP value incomplete

I try to profile my program myprog using perf, and here's what I get:
#
# Overhead Symbol Shared Object
# ........ ................................................................... .....................................
#
7.71% 0x743a l [.] list_iter_next myprog
I use objdump -D to see which instruction the IP refers to.
The thing is, the 0x743a IP shown here is in a .debug section of the myprog.
$ grep -ne ' 743a' dump
418233: 743a: 65 gs
429445: 743a: 40 00 00 add %al,(%rax)
The hex value provided by perf could match several places in the dump, as shown by:
$ grep -ne 743a dump
7973: 40743a: 48 8b 00 mov (%rax),%rax
72861: 44743a: 66 0f f8 c8 psubb %xmm0,%xmm1
87650: 45743a: 41 d3 e9 shr %cl,%r9d
The correct IP is 0x40743a, as shown here:
$ grep -n4 40743a dump
7969-0000000000407430 <list_iter_next>:
7970- 407430: 48 8b 07 mov (%rdi),%rax
7971- 407433: 48 8b 40 08 mov 0x8(%rax),%rax
7972- 407437: 48 89 07 mov %rax,(%rdi)
7973: 40743a: 48 8b 00 mov (%rax),%rax
7974- 40743d: c3 retq
7975- 40743e: 66 90 xchg %ax,%ax
7976-
Does anybody know what's going on?
Have you compiled your program with debug options (-g with gcc)? It seems that debug information is missing, as explained in the perf tutorial at : https://perf.wiki.kernel.org/index.php/Tutorial
When the symbol is printed as an hexadecimal address, this is because the ELF image does not have a symbol table. This happens when binaries are stripped.
About the symbol value you get, I don't know where it comes from and if we can interpret it like you did.

Help needed in converting a few lines of ruby code to c++!

I have to convert the following code into Qt c++
So I need to understand what these lines to.
#key in this code is a pem key file contents by openssl
key = KEY+#key.public_key.to_der
so i think this is converting that key to der format and then combining it with KEY.
is it right?
whats does this do? to_sizet(key.size)
As you can see the function returns [num].pack('V'). But i dont know wht does it do? I mean [num].pavck('V'). what is it?
And whats does this mean. key.size is it the strlen of key?
def write_crx
print "write crx..." if #verbose
key = KEY+#key.public_key.to_der
File.open(#crx, 'wb') do |file|
file << MAGIC
file << EXT_VERSION
file << to_sizet(key.size)
file << to_sizet(#sig.size)
file << key
file << #sig
File.open(#zip, 'rb') do |zip|
file << zip.read
end
end
puts "done at \"#{#crx}\"" if #verbose
end
def to_sizet num
return [num].pack('V')
end
Well I have one more Question. Forgot to add last time.
what does this line do?
KEY = %w(30 81 9F 30 0D 06 09 2A 86 48 86 F7 0D 01 01 01 05 00 03 81 8D 00).map{|s| s.hex}.pack('C*')
so i think this is converting that key to der format and then combining it with KEY. is it right?
Yes.
whats does this do? to_sizet(key.size) As you can see the function returns [num].pack('V'). But i dont know wht does it do? I mean [num].pavck('V'). what is it?
Well, just have a look at what the documentation on Array#pack says. With the V modifier, it just converts the array to a binary representation of a 32 bit unsigned integer type.
And whats does this mean. key.size is it the strlen of key?
Again, the Ruby documentation helps. String#size is indeed the string length.
what does this line do?
KEY = %w(30 81 9F 30 0D 06 09 2A 86 48 86 F7 0D 01 01 01 05 00 03 81 8D 00)
.map{|s| s.hex}.pack('C*')
%(…) defines an array where each of its entries, separated by whitespace is treated as a separate string. %w(one two) is essentially a shorthand for ["one", "two"].
After that, we have to look up (again in the documentation) the meanings of Array#map and String#hex.
map simply applies an operation to each element of an array and creates a new array with the result. The operation is s.hex – that is, parse each of the strings as a hexadecimal number.
The result is once again packed, this time using the C* operation which, the documentation tells us, converts the numbers into their corresponding (unsigned) 8-bit character codes.
In summary: that line converts the hexadecimal values into a string of their respective characters.
Afterthought: you should really install Ruby and play a bit with the interactive Ruby console, irb. Keying in the above line already helps a lot:
$ irb
>> %w(30 81 9F 30 0D 06 09 2A 86 48 86 F7 0D 01 01 01 05 00 03 81 8D 00).map{|s| s.hex}
=> [48, 129, 159, 48, 13, 6, 9, 42, 134, 72, 134, 247, 13, 1, 1, 1, 5, 0, 3, 129, 141, 0]
>> %w(30 81 9F 30 0D 06 09 2A 86 48 86 F7 0D 01 01 01 05 00 03 81 8D 00).map{|s| s.hex}.pack('C*')
=> "0\201\2370\r\006\t*\206H\206\367\r\001\001\001\005\000\003\201\215\000"