tag:blogger.com,1999:blog-24751570724998448942024-03-20T12:46:22.608+05:30Geek In Linuxmy journalGilhttp://www.blogger.com/profile/13054047395328845300noreply@blogger.comBlogger585125tag:blogger.com,1999:blog-2475157072499844894.post-57708166253911307582021-12-11T01:52:00.005+05:302021-12-11T01:52:41.490+05:30How kubernetes load balancer traffic between pods<p> </p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/a/AVvXsEiy5UROSAGe9tfaYusp-61KzQmjbwGi1J7KhR8b1nPrW7Ss_OPQbFYmseGE73_FMEP-0Q0IHZq9Nanc5sZ2d17A8TPXGIqSp7Eo-i4Llh2XivFPM7f9Z7uI5lQUSqQsx_vuufmGml2HQpRQZThIphNkJZQfL6lutw_AKiW39LldhweK4tH9B5Y8rwMVqQ=s2048" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="1365" data-original-width="2048" height="427" src="https://blogger.googleusercontent.com/img/a/AVvXsEiy5UROSAGe9tfaYusp-61KzQmjbwGi1J7KhR8b1nPrW7Ss_OPQbFYmseGE73_FMEP-0Q0IHZq9Nanc5sZ2d17A8TPXGIqSp7Eo-i4Llh2XivFPM7f9Z7uI5lQUSqQsx_vuufmGml2HQpRQZThIphNkJZQfL6lutw_AKiW39LldhweK4tH9B5Y8rwMVqQ=w640-h427" width="640" /></a></div><div class="separator" style="clear: both; text-align: center;"><br /></div><div class="separator" style="clear: both; text-align: center;"><br /></div><div class="separator" style="clear: both; text-align: center;"></div>
<span> </span><span> </span><span> </span>Service is an abstraction for the app running inside the pod. It's the entry point to reach the app. If an app runs multiple replicas then the service acts as a load balancer and distributes the traffic.
I'm going to show you how it's working under the hood. <div><br /></div><div>Let clone my repo that has `helm charts` and `terraform scripts`.
<pre><code class="lang-bash">
$ git clone https://github.com/related2blog/gil.git
</code></pre>I use `eks` to spin a Kubernetes cluster quickly.
<pre><code class="lang-bash">
$ cd git/terraform/aws_eks/simple_cluster
$ terraform init
Initializing the backend...
Initializing provider plugins...
Terraform has been successfully initialized!
You may now begin working with Terraform. Try running "terraform plan" to see
any changes that are required for your infrastructure. All Terraform commands
should now work.
If you ever set or change modules or backend configuration for Terraform,
rerun this command to reinitialize your working directory. If you forget, other
commands will detect it and remind you to do so if necessary.
$ terraform apply
Do you want to perform these actions?
Terraform will perform the actions described above.
Only 'yes' will be accepted to approve.
Destroy complete! Resources: 18 destroyed.
Enter a value: yes
.
.
Apply complete! Resources: 18 added, 0 changed, 0 destroyed.
</code></pre><b>
Note:</b> `apply` will prompt you to type `yes` and hit enter after verifying all the resources terraform going to create in your AWS infrastructure. <div><b>Disclaimer:</b> Don't use the production environment.
The cluster takes around 20 minutes to come online completely. Once the eks cluster is online, we have to update kubeconfig with the newly created cluster so that cluster can be managed by `kubectl`.
<pre><code class="lang-bash">
$ aws eks --region ap-northeast-1 update-kubeconfig --name eks-c1
Updated context arn:aws:eks:ap-northeast-1:548748595146:cluster/eks-c1 in /Users/manny/.kube/config
$ kubectl get all
kubectl get all
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/kubernetes ClusterIP 172.20.0.1 <none> 443/TCP 15m
</none></code></pre>
Cool kubectl can now access the Kubernetes cluster. Let's run `helm charts` to deploy the `busy_box` app.
<pre><code class="lang-bash">
$ cd kubernates
$ helm install apple lb_ex_1/
NAME: apple
LAST DEPLOYED: Fri Dec 10 21:37:11 2021
NAMESPACE: default
STATUS: deployed
REVISION: 1
TEST SUITE: None
</code></pre>
after successful install, you can see helm chart details, as shown above, now make sure pods are not crashing and `load balancer` DNS name showing.
<pre><code class="lang-bash">
$ kubectl get all
NAME READY STATUS RESTARTS AGE
pod/apple-db75469fb-k8mc9 1/1 Running 0 4m42s
pod/apple-db75469fb-tth2f 1/1 Running 0 4m42s
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/apple LoadBalancer 172.20.237.216 ad44317af518843aa92b909f6a277a9b-1681034099.ap-northeast-1.elb.amazonaws.com 8080:30000/TCP 4m45s
service/kubernetes ClusterIP 172.20.0.1 <none> 443/TCP 26m
NAME READY UP-TO-DATE AVAILABLE AGE
deployment.apps/apple 2/2 2 2 4m45s
NAME DESIRED CURRENT READY AGE
replicaset.apps/apple-db75469fb 2 2 2 4m46s
</none></code></pre>
everything on the Kubernetes side looking fine. I'm going to quickly access our app at the load balancer's endpoint to make sure the app is running.<div><br /></div><div><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiyTS5aAw98lqYMI54cd2_FC-BUsm_FfqQmkaKhvMEd_F0ygGPJIu5ogj45pWk9bD9uMTKIbKC1jlHenZipMx7nu8JY36CMQPEN7qYctkS2_uGL2S1lB21L1JR-h7ndTRUPUGIVccRpxA03/" style="margin-left: 1em; margin-right: 1em; text-align: center;"><img alt="" data-original-height="238" data-original-width="1020" height="150" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiyTS5aAw98lqYMI54cd2_FC-BUsm_FfqQmkaKhvMEd_F0ygGPJIu5ogj45pWk9bD9uMTKIbKC1jlHenZipMx7nu8JY36CMQPEN7qYctkS2_uGL2S1lB21L1JR-h7ndTRUPUGIVccRpxA03/w640-h150/image.png" width="640" /></a></div><div><br /></div><div> well, the container doesn't have any HTML file so we `404 File Not Found` which is a good sign and expected.
What we going to do is, log in to each pod and create `index.html` with two words in it ex: app1 and app2, and run the `httpd` server.
<pre><code class="lang-bash">
kubectl exec -it pod/apple-db75469fb-k8mc9 -- /bin/sh
/ # echo "<html><h1>App1</h1></html>" > index.html
/ # exit
</code></pre>
do the with second pod only difference is to change the content of index.html to `App2` </div><div><br /></div><div><b>Note:</b> Since `/` is the `httpd` server's root directory on the `busy_box` image, you don't have to run another instance of the `httpd` command.
</div><div><br /></div><div>finally, we completed the setup and it's time to test, what I'm doing do is refreshing the browser. What we trying to see is how the Kubernetes service routes traffic. Each time I refresh the page I see HTML content change, it switches between App1 and App2.</div><div><br /></div><div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhSS1sUkYQ_Qws9bbFKy3E4Xt9SCeKBPGGEZ_xeCWyo36yXulfMFHGq0kiKeKk0Mpkhcbr0-FUbQna601iO-wkdabVSPJWHYuSA-5R0lvHxtXgqtN1BEG2bSFfNphXNizEVh-1a-LwvAV8C/" style="margin-left: 1em; margin-right: 1em;"><img alt="" data-original-height="267" data-original-width="1027" height="166" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhSS1sUkYQ_Qws9bbFKy3E4Xt9SCeKBPGGEZ_xeCWyo36yXulfMFHGq0kiKeKk0Mpkhcbr0-FUbQna601iO-wkdabVSPJWHYuSA-5R0lvHxtXgqtN1BEG2bSFfNphXNizEVh-1a-LwvAV8C/w640-h166/image.png" width="640" /></a></div><br /><div class="separator" style="clear: both; text-align: center;"><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjH4zrZTa-waxpLNSTrKnnXfDbOqxV8cDy8hbQ1Qf3iLuJD-1o_XhzZbVpZj1qsUZkFx_GI3IbDYGM37lDC4o3jxoZOj5H8mgAJNXFDB8Webxx9BiapPNRCe5LSfAFhcSrxr9yf5LCUByMG/" style="margin-left: 1em; margin-right: 1em;"><img alt="" data-original-height="235" data-original-width="1025" height="146" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjH4zrZTa-waxpLNSTrKnnXfDbOqxV8cDy8hbQ1Qf3iLuJD-1o_XhzZbVpZj1qsUZkFx_GI3IbDYGM37lDC4o3jxoZOj5H8mgAJNXFDB8Webxx9BiapPNRCe5LSfAFhcSrxr9yf5LCUByMG/w640-h146/image.png" width="640" /></a></div><br /></div></div></div><div class="separator" style="clear: both; text-align: left;"><span> I even applied `helm upgrade` with 3 replicas.
<pre><code class="lang-bash">
$ helm upgrade apple lb_ex_1 --set replicas=3
Release "apple" has been upgraded. Happy Helming!
NAME: apple
LAST DEPLOYED: Fri Dec 10 22:20:13 2021
NAMESPACE: default
STATUS: deployed
REVISION: 2
TEST SUITE: None
</code></pre><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgRADcOwUhiRP9uZEowCcpafCjuHXxSS6oJfOqrRcfk-4-HXm93yk_RHpIyKPKcVUpEJZRD2sxwBYtYYaVfbKYTGPFslxFYjdNe9dQ2qZkE1VctFgbcfHOxxIbSq3o-EDdBw9MQg0UY37V0/" style="margin-left: 1em; margin-right: 1em;"><img alt="" data-original-height="237" data-original-width="1025" height="148" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgRADcOwUhiRP9uZEowCcpafCjuHXxSS6oJfOqrRcfk-4-HXm93yk_RHpIyKPKcVUpEJZRD2sxwBYtYYaVfbKYTGPFslxFYjdNe9dQ2qZkE1VctFgbcfHOxxIbSq3o-EDdBw9MQg0UY37V0/w640-h148/image.png" width="640" /></a></div><br /><b>Conclusion: </b>It worked as expected, what I notice is I couldn't figure out which one I see on a refresh, every pod gets a chance but not in a specific order.</span></div><div class="separator" style="clear: both; text-align: left;"><span><br /></span></div><div class="separator" style="clear: both; text-align: left;"><span><b>Cleaning up the resources:</b><pre><code class="lang-bash">
$ cd gil/kubernates
$ helm uninstall apple
release "apple" uninstalled
$ cd gil/terraform/aws_eks/simple_cluster
$ terraform destroy
Changes to Outputs:
You can apply this plan to save these new output values to the Terraform state, without changing any real infrastructure.
Do you really want to destroy all resources?
Terraform will destroy all your managed infrastructure, as shown above.
There is no undo. Only 'yes' will be accepted to confirm.
Enter a value:yes
.
.
.
Destroy complete! Resources: 18 destroyed.
</code></pre>
gil,</span></div></div>Subbarao Ganeshnahttp://www.blogger.com/profile/01855743078913014384noreply@blogger.com0tag:blogger.com,1999:blog-2475157072499844894.post-49264018656860364702021-11-02T16:29:00.003+05:302021-11-02T16:29:29.040+05:30Exiting due to PR_HYPERKIT_VMNET_FRAMEWORK; Minikube<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgjw19Cc8wWhe_n55CPfXBAPQHVrAqo_0p-KOqsyohYuUoXuit1ugwc2wHvaHm_5Q7WV5gwGCeHq-bu6EihG-Plf36XV6qQqcToT-c_0Y3qlGVm6K07mdwz06_KUDD1V8b5HGQUhCxaf6BN/s621/Minikube_workflows__Minikube_is_a_terrific_tool_for_running%25E2%2580%25A6___by_Martin_Jensen___kubecloud.jpg" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="419" data-original-width="621" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgjw19Cc8wWhe_n55CPfXBAPQHVrAqo_0p-KOqsyohYuUoXuit1ugwc2wHvaHm_5Q7WV5gwGCeHq-bu6EihG-Plf36XV6qQqcToT-c_0Y3qlGVm6K07mdwz06_KUDD1V8b5HGQUhCxaf6BN/s16000/Minikube_workflows__Minikube_is_a_terrific_tool_for_running%25E2%2580%25A6___by_Martin_Jensen___kubecloud.jpg" /></a></div><br /><div><br />I came across this error while setting up `minikube`, writing this post to save your time, so that you can spend time on learning mikube not debugging setup.</div><div><br /></div><pre><code class="lang-bash">minikube start --driver=hyperkit --disk-size 5500MB --host-only-cidr "192.168.59.1/24"
😄 minikube v1.23.2 on Darwin 11.3
✨ Using the hyperkit driver based on user configuration
👍 Starting control plane node minikube in cluster minikube
🔥 Creating hyperkit VM (CPUs=2, Memory=2200MB, Disk=5500MB) ...
🔥 Deleting "minikube" in hyperkit ...
🤦 StartHost failed, but will try again: creating host: create: Error creating machine: Error in driver during machine creation: getting MAC address from UUID: vmnet: error from vmnet.framework: -1
🔥 Creating hyperkit VM (CPUs=2, Memory=2200MB, Disk=5500MB) ...
😿 Failed to start hyperkit VM. Running "minikube delete" may fix it: creating host: create: Error creating machine: Error in driver during machine creation: getting MAC address from UUID: vmnet: error from vmnet.framework: -1
❌ Exiting due to PR_HYPERKIT_VMNET_FRAMEWORK: Failed to start host: creating host: create: Error creating machine: Error in driver during machine creation: getting MAC address from UUID: vmnet: error from vmnet.framework: -1
💡 Suggestion: Hyperkit networking is broken. Upgrade to the latest hyperkit version and/or Docker for Desktop. Alternatively, you may choose an alternate --driver
🍿 Related issues:
▪ https://github.com/kubernetes/minikube/issues/6028
▪ https://github.com/kubernetes/minikube/issues/5594
</code></pre>It's an issue with the network. I use mac OS and enabled `Internet Sharing` which caused problem. I simply disabled it.<div><br /></div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhYLLGQ09u6HXOnhCQwjzHABW0RDwrt2VstXOetHnuFQ-ub38GMSUYYpAlADIu-SfIxKjkcYeC0Jn6V0Uc4olnqSyBODW0F3NOfk6f2GXYgvNVHGPo0YVdSdk3F4LGebW5Nx9W8Hd0qqupo/s667/Minikube_workflows__Minikube_is_a_terrific_tool_for_running%25E2%2580%25A6___by_Martin_Jensen___kubecloud.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="540" data-original-width="667" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhYLLGQ09u6HXOnhCQwjzHABW0RDwrt2VstXOetHnuFQ-ub38GMSUYYpAlADIu-SfIxKjkcYeC0Jn6V0Uc4olnqSyBODW0F3NOfk6f2GXYgvNVHGPo0YVdSdk3F4LGebW5Nx9W8Hd0qqupo/s16000/Minikube_workflows__Minikube_is_a_terrific_tool_for_running%25E2%2580%25A6___by_Martin_Jensen___kubecloud.jpg" /></a></div><br /><div>Source: <a href="https://github.com/kubernetes/minikube/issues/5594" target="_blank">https://github.com/kubernetes/minikube</a></div>Subbarao Ganeshnahttp://www.blogger.com/profile/01855743078913014384noreply@blogger.com0tag:blogger.com,1999:blog-2475157072499844894.post-11796559476112657612021-07-22T23:31:00.006+05:302021-07-22T23:31:51.751+05:30Installing pyinstaller on raspberry<p> </p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhfSc70OfBC89WJubjZqI9Xn3m665RgN57s9h9zmdVzCaw6yvAO4yfk_tb5uAYJo9NcQN7WkisJwZTfceKcBwAxTvpIp3KMSRWSP0dhnpG-xPgLY9HG1mu7_Y-Gg0Y10JpIk2rOYeNNdT-C/s2048/rasp-berry-pi.jpeg" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="1365" data-original-width="2048" height="427" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhfSc70OfBC89WJubjZqI9Xn3m665RgN57s9h9zmdVzCaw6yvAO4yfk_tb5uAYJo9NcQN7WkisJwZTfceKcBwAxTvpIp3KMSRWSP0dhnpG-xPgLY9HG1mu7_Y-Gg0Y10JpIk2rOYeNNdT-C/w640-h427/rasp-berry-pi.jpeg" width="640" /></a></div><br /><p></p><p> <a href="https://pyinstaller.readthedocs.io/en/stable/index.html">Pyinstaller</a> bundles python projects into a single file along with all dependencies as per wiki. Since its a python package installation is quite simple, use pip for linux based machines and brew install for mac. But i had tough time installing it on raspberry pi. I want to share my experience and how i solved it. </p><p>I installed it from source, documentation says pyinstaller's bootloader has to be built first. Here are the exact steps.</p><p><span style="font-family: courier;">zlib1g-dev</span> is required to compile boottloader </p><pre><code class="lang-bash">sudo apt-get update
sudo apt-get install zlib1g-dev</code></pre>Clone the repo and follow the steps.<pre class="lang-bash">git clone https://github.com/pyinstaller/pyinstaller.git
cd bootloader
python3 ./waf all
</pre><p></p>after building bootloader go back to repo's root directory and install<div><br /></div><pre><code class="lang-bash">cd ../pyinstaller
python3 setup.py install</code></pre>after successful installation, try using pyinstaller with any arguments, which supposed to show help and that verifies your installation.<pre><code class="lang-bash">root@raspberry:/tmp/python-pkg# pyinstaller
usage: pyinstaller [-h] [-v] [-D] [-F] [--specpath DIR] [-n NAME]
[--add-data <SRC;DEST or SRC:DEST>]
[--add-binary <SRC;DEST or SRC:DEST>] [-p DIR]
[--hidden-import MODULENAME]
[--collect-submodules MODULENAME]
[--collect-data MODULENAME] [--collect-binaries MODULENAME]
[--collect-all MODULENAME] [--copy-metadata PACKAGENAME]
[--recursive-copy-metadata PACKAGENAME]
[--additional-hooks-dir HOOKSPATH]
[--runtime-hook RUNTIME_HOOKS] [--exclude-module EXCLUDES]
[--key KEY] [--splash IMAGE_FILE]
[-d {all,imports,bootloader,noarchive}] [-s] [--noupx]
[--upx-exclude FILE] [-c] [-w]
[-i <FILE.ico or FILE.exe,ID or FILE.icns or "NONE">]
[--disable-windowed-traceback] [--version-file FILE]
[-m <FILE or XML>] [-r RESOURCE] [--uac-admin]
[--uac-uiaccess] [--win-private-assemblies]
[--win-no-prefer-redirects]
[--osx-bundle-identifier BUNDLE_IDENTIFIER]
[--target-architecture ARCH] [--codesign-identity IDENTITY]
[--osx-entitlements-file FILENAME] [--runtime-tmpdir PATH]
[--bootloader-ignore-signals] [--distpath DIR]
[--workpath WORKPATH] [-y] [--upx-dir UPX_DIR] [-a]
[--clean] [--log-level LEVEL]
scriptname [scriptname ...]
pyinstaller: error: the following arguments are required: scriptname
</code></pre>Hopy you liked it.Subbarao Ganeshnahttp://www.blogger.com/profile/01855743078913014384noreply@blogger.com0tag:blogger.com,1999:blog-2475157072499844894.post-72190156758945704182021-07-18T09:00:00.001+05:302021-07-18T09:00:30.296+05:30Install Python Packages Without an Internet<p> <a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjG7kDjBYZT6p1ZnSXxQ45N8NBlk3vvOMwOUqmNYdZMIQC-0y1hr-TQ7SLEnXVNDbgOAkhL-y3NDH2rvJ4y1N7wVo_UcY3T37-mk59HG0CxrUjbyKY0yhW7scsj7cQpH6XoUGZeZTThCEgm/s2048/python_pip_install_no_internet.jpeg" style="margin-left: 1em; margin-right: 1em; text-align: center;"><img border="0" data-original-height="1388" data-original-width="2048" height="434" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjG7kDjBYZT6p1ZnSXxQ45N8NBlk3vvOMwOUqmNYdZMIQC-0y1hr-TQ7SLEnXVNDbgOAkhL-y3NDH2rvJ4y1N7wVo_UcY3T37-mk59HG0CxrUjbyKY0yhW7scsj7cQpH6XoUGZeZTThCEgm/w640-h434/python_pip_install_no_internet.jpeg" width="640" /></a></p><div class="separator" style="clear: both; text-align: left;">Python package installation is quite simple using python package manager pip. But how do you install it if you don't have an internet connection to the machine? LOL
You know why I was laughing that's why you are reading this post. Servers in any organisations that are in the restricted area are never exposed to the internet. The ideal way of installing packages is like binaries and deb packages. Copy them in a thumb drive and install. You are good to go. We are going to see such practice here.
Pip already has a solution for this scenario i.e., `--no-index` and `--find-links`. Let's see how to do it. The first thing to do is, download the python package files(.whl) file from https://pypi.org/ onto a pen drive and copy them to the machine you want to install.
Installation:
I will install Flask for demo purposes. I have my .whl package ready and copied to local machines under /tmp. I use this below command to install</div><pre class="lang-bash"><code>pip3 install --no-index --find-links=/tmp flask</code></pre>
<pre class="lang-python"><code>manny@manny:/tmp$ pip3 install --no-index --find-links=/tmp/ flask
Looking in links: /tmp/
Processing ./Flask-2.0.1-py3-none-any.whl
Requirement already satisfied: Werkzeug>=2.0 in /usr/local/lib/python3.8/dist-packages (from flask) (2.0.1)
Requirement already satisfied: Jinja2>=3.0 in /usr/local/lib/python3.8/dist-packages (from flask) (3.0.1)
Requirement already satisfied: itsdangerous>=2.0 in /usr/local/lib/python3.8/dist-packages (from flask) (2.0.1)
Requirement already satisfied: click>=7.1.2 in /usr/local/lib/python3.8/dist-packages (from flask) (8.0.1)
Requirement already satisfied: MarkupSafe>=2.0 in /usr/local/lib/python3.8/dist-packages (from Jinja2>=3.0->flask) (2.0.1)
Installing collected packages: flask
Successfully installed flask-2.0.1</code></pre>
try importing and you successfully installed your python package.
Few things to note:
The package installed using this process is visible in the pip list, so you can't uninstall using pip install <pkg name=""> which is fair enough.
<pre class="lang-bash"><code>pip3 list|grep -i flask</code></pre>
So fix for that is, use the below command to uninstall which worked for me.
<pre class="lang-python"><code>manny@manny:/tmp$ python3 -m pip uninstall flask
Found existing installation: Flask 2.0.1
Uninstalling Flask-2.0.1:
Would remove:
/home/manny/.local/bin/flask
/home/manny/.local/lib/python3.8/site-packages/Flask-2.0.1.dist-info/*
/home/manny/.local/lib/python3.8/site-packages/flask/*
Proceed (y/n)? y
Successfully uninstalled Flask-2.0.1</code></pre></pkg><p></p>Subbarao Ganeshnahttp://www.blogger.com/profile/01855743078913014384noreply@blogger.com2tag:blogger.com,1999:blog-2475157072499844894.post-48682261230573241682021-06-01T18:11:00.002+05:302021-06-01T18:11:30.314+05:30how to turn off video autoplay on facebook<div class="separator" style="clear: both; text-align: center;"><br /></div><br /><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEixVtXvoVkjpMSN4uDVZ18_oMQPKh3xBPsgQ8R_lhWKKPYZ6IMwmbcyCNg2LKBiJjmgHW37EXnlR9dEYyPnsFv02QX4Wjizgm2tze964QsAd9haBRQBt5PdsG2dHBWQg-lO0GaJnefjI7nQ/s2048/pexels-pixabay-267399.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="1287" data-original-width="2048" height="402" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEixVtXvoVkjpMSN4uDVZ18_oMQPKh3xBPsgQ8R_lhWKKPYZ6IMwmbcyCNg2LKBiJjmgHW37EXnlR9dEYyPnsFv02QX4Wjizgm2tze964QsAd9haBRQBt5PdsG2dHBWQg-lO0GaJnefjI7nQ/w640-h402/pexels-pixabay-267399.jpg" width="640" /></a></div><p><span style="color: #0e101a;"><span> <span> </span></span></span></p><p><span style="color: #0e101a;"><span></span><span> </span>Scrolling videos on Facebook is fun, you can watch without having to click to play, but it's not as fun when you are scrolling through posts in a quiet place like an office or in a bedroom. It leaves you with the worst experience because you could distract the person next to you which is embarrassing. This happens because autoplay is enabled for Facebook videos (by default), which you might want to turn off so that your videos can be played on demand not on scroll.</span></p><p style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; color: #0e101a; margin-bottom: 0pt; margin-top: 0pt;"><span data-preserver-spaces="true" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; margin-bottom: 0pt; margin-top: 0pt;">It's very simple to turn that feature, let me walk you through this real quick.</span></p><p style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; color: #0e101a; margin-bottom: 0pt; margin-top: 0pt;"><br /></p><p style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; color: #0e101a; margin-bottom: 0pt; margin-top: 0pt;"><span data-preserver-spaces="true" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; margin-bottom: 0pt; margin-top: 0pt;">Login to Facebook account on a computer.</span></p><p style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; color: #0e101a; margin-bottom: 0pt; margin-top: 0pt;"><span data-preserver-spaces="true" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; margin-bottom: 0pt; margin-top: 0pt;">Click on the top right to go to <b>Settings & Privacy</b></span></p><p style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; color: #0e101a; margin-bottom: 0pt; margin-top: 0pt;"><span data-preserver-spaces="true" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; margin-bottom: 0pt; margin-top: 0pt;">Scroll the left pane all the way to the bottom till you see </span><strong style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; margin-bottom: 0pt; margin-top: 0pt;">Videos</strong></p><p style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; color: #0e101a; margin-bottom: 0pt; margin-top: 0pt;"><strong style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; margin-bottom: 0pt; margin-top: 0pt;"><br /></strong></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgSTTPRpypT_glw8ORuwxA-hHA42IP8YxBmCXR_dzgiJFYFV8Jz94LKhYTqU-P_PrBczkJ8-b-Iuo5cASKzvMbqsw80wI9se6aBTHNzBoUwNPPWIoklHz3gFRiBWnrE9x5yk2splEDW-6di/s486/disable-auto-play-videos-facebook-1.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="486" data-original-width="361" height="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgSTTPRpypT_glw8ORuwxA-hHA42IP8YxBmCXR_dzgiJFYFV8Jz94LKhYTqU-P_PrBczkJ8-b-Iuo5cASKzvMbqsw80wI9se6aBTHNzBoUwNPPWIoklHz3gFRiBWnrE9x5yk2splEDW-6di/w298-h400/disable-auto-play-videos-facebook-1.jpg" width="298" /></a></div><div class="separator" style="clear: both; text-align: center;"><br /></div>Go to <b>Settings</b><div><b><br /></b><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEintwR7jYvCioYVRL6lgNUxGHHX4tFHZwtoIdblyOVx1UBu73zI59VNHHktyQw_w9ZhYSpr6OpnXdmfxoMSEYLkqrqv_JMb8MIpSBm4WdA7nWHkMREZJdWKb_I06-WFy9-imYM6TYh37bj_/s385/disable-auto-play-videos-faceboo-2.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="385" data-original-width="361" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEintwR7jYvCioYVRL6lgNUxGHHX4tFHZwtoIdblyOVx1UBu73zI59VNHHktyQw_w9ZhYSpr6OpnXdmfxoMSEYLkqrqv_JMb8MIpSBm4WdA7nWHkMREZJdWKb_I06-WFy9-imYM6TYh37bj_/w300-h320/disable-auto-play-videos-faceboo-2.jpg" width="300" /></a></div><div class="separator" style="clear: both; text-align: center;"><br /></div>Scroll the left pane all the way to the bottom till you see <b>Videos</b> <br /><span><br /></span><p></p><p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhWOwxmaVkuZvrmNw9orYNOS6KI-1GrEwrsvL4xnazCaJpfExB6xhKv0-nZ4jAj_cfNShQVN5Bb82fcG0SU5O8xb2I0phVr15L3bf_u2U3CF8nqyPs0GQZEj9CV58adgeaw-clgNeRpaOWs/s784/disable-auto-play-videos-faceboo-3.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="784" data-original-width="647" height="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhWOwxmaVkuZvrmNw9orYNOS6KI-1GrEwrsvL4xnazCaJpfExB6xhKv0-nZ4jAj_cfNShQVN5Bb82fcG0SU5O8xb2I0phVr15L3bf_u2U3CF8nqyPs0GQZEj9CV58adgeaw-clgNeRpaOWs/w330-h400/disable-auto-play-videos-faceboo-3.jpg" width="330" /></a></div><p></p><p style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; color: #0e101a; margin-bottom: 0pt; margin-top: 0pt;"><span data-preserver-spaces="true" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; margin-bottom: 0pt; margin-top: 0pt;"><br /></span></p><p style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; color: #0e101a; margin-bottom: 0pt; margin-top: 0pt;"><span data-preserver-spaces="true" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; margin-bottom: 0pt; margin-top: 0pt;">On the right side set </span><strong style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; margin-bottom: 0pt; margin-top: 0pt;">Auto-Play Videos </strong><span data-preserver-spaces="true" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; margin-bottom: 0pt; margin-top: 0pt;">Off</span></p><p style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; color: #0e101a; margin-bottom: 0pt; margin-top: 0pt;"><span data-preserver-spaces="true" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; margin-bottom: 0pt; margin-top: 0pt;"><br /></span></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh8ko6v-l_BlOEVoPof1wJK5tOeZ5JU6cZOV_Pqy3Nka-K9MND48H_FungMHFO04ToIsCRCPpwg0i09R__U1ZSgOBTB5C-im47uDoDiYjf3iTWy8uAhq7cKbumYY5fN7_PbcUq_EzpcyG80/s1007/disable-auto-play-videos-faceboo-4.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="279" data-original-width="1007" height="178" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh8ko6v-l_BlOEVoPof1wJK5tOeZ5JU6cZOV_Pqy3Nka-K9MND48H_FungMHFO04ToIsCRCPpwg0i09R__U1ZSgOBTB5C-im47uDoDiYjf3iTWy8uAhq7cKbumYY5fN7_PbcUq_EzpcyG80/w640-h178/disable-auto-play-videos-faceboo-4.jpg" width="640" /></a></div><div class="separator" style="clear: both; text-align: center;"><br /></div><div class="separator" style="clear: both; text-align: left;">Quite easy isn't it, now you will not see sudden surprises hope it works out for you. Appriciate your feedback in the comments.</div></div>Subbarao Ganeshnahttp://www.blogger.com/profile/01855743078913014384noreply@blogger.com0tag:blogger.com,1999:blog-2475157072499844894.post-59356644372628716722021-05-30T20:59:00.005+05:302021-05-31T00:40:29.270+05:30Reduce video file size<div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEizdx33G8G0X8fuIz_sRLOSSz4aeUZkcYd__VcVlEFaKnt9lBPYFfzHWeRz-vsUvJZCuVM__A3kH-8g8QDLdS4hl7iL9CLK1O3pRzzcbfOFKXyjtAchlmyYE8CIAmanTPw6Uqo71GSXcC4/s1920/ffmpeg.jpg" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="1080" data-original-width="1920" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEizdx33G8G0X8fuIz_sRLOSSz4aeUZkcYd__VcVlEFaKnt9lBPYFfzHWeRz-vsUvJZCuVM__A3kH-8g8QDLdS4hl7iL9CLK1O3pRzzcbfOFKXyjtAchlmyYE8CIAmanTPw6Uqo71GSXcC4/w640-h360/ffmpeg.jpg" width="640" /></a></div><br /></div><div><span> </span>Videos shot on mobile often huge in size, because they cam set to high resolution. Of course most of the cases those settings were intentional but my motive is to help people who wanted to reduce the size of a video, whether it is shot on mobile or a movie file.</div><div><br /></div><div>Let me share my experience, I shot a video of my nephew's school event which is 30 min long, later I noticed my mobile was dying without space. I found the video clip was huge it's 2.2 GB, I couldn't figure out that, even a 2-hour movie doesn't exceed 1 Gb with 720p. I want the video but not at the cost of 2.2Gb. So I wanted to compress the video, sorry sorry, not compress reduce the size, hope you figured out the difference. </div><div><br /></div><div>Lots of online websites I found on google say that help me, but I don't want to upload my video. I'm going to use a command-line tool called FFmpeg. It's a huge framework with tons of options, what we do is not even 1% of its capacity. You can read more at <a href="https://ffmpeg.org/about.html">https://ffmpeg.org/about.html</a>. </div><div> </div><div><b>Installation</b>: </div><div><span> </span></div><div><span> </span><span style="font-family: courier;">brew install ffmpeg</span> on mac</div><div><span> you can download FFmpeg for other OS from official download here <a href="https://ffmpeg.org/download.html" target="_blank">https://ffmpeg.org/download.html</a></span></div><div><br /></div><div><b>Usage</b>:</div><div><span> </span> </div><div><span> </span>Specifications of video I'm using for tutorial.
Shot on mobile at 1080p
Duration 1 Min
Size 116Mb
I want to reduce its resolution to 720p and 480p to see how much I reduce the size and how good video quality is preserved. </div><div><br /></div><div><span style="caret-color: rgb(14, 16, 26); color: #0e101a; font-style: italic;"><blockquote>disclaimer: it's the reader's responsibility to take a backup of your original video clip before following this tutorial, you could end up overwriting/corrupting the original clip if something goes wrong.</blockquote></span></div><div><br /></div><div><b>720p
</b><pre class="lang-bash">gil@localhost# ffmpeg -i ~/Desktop/116MB.mp4 -s 1280x720 /tmp/hd720.mp4
ffmpeg version 4.4 Copyright (c) 2000-2021 the FFmpeg developers
built with Apple clang version 12.0.0 (clang-1200.0.32.29)
configuration: --prefix=/usr/local/Cellar/ffmpeg/4.4_1 --enable-shared --enable-pthreads --enable-version3 --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libbluray --enable-libdav1d --enable-libmp3lame --enable-libopus --enable-librav1e --enable-librubberband --enable-libsnappy --enable-libsrt --enable-libtesseract --enable-libtheora --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libspeex --enable-libsoxr --enable-libzmq --enable-libzimg --disable-libjack --disable-indev=jack --enable-videotoolbox
libavutil 56. 70.100 / 56. 70.100
libavcodec 58.134.100 / 58.134.100
libavformat 58. 76.100 / 58. 76.100
libavdevice 58. 13.100 / 58. 13.100
libavfilter 7.110.100 / 7.110.100
libavresample 4. 0. 0 / 4. 0. 0
libswscale 5. 9.100 / 5. 9.100
libswresample 3. 9.100 / 3. 9.100
libpostproc 55. 9.100 / 55. 9.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/Users/gil/Desktop/116MB.mp4':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: isommp42
creation_time : 2021-05-30T06:03:44.000000Z
com.android.version: 10
Duration: 00:01:00.39, start: 0.000000, bitrate: 15393 kb/s
Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, smpte170m/bt470bg/smpte170m), 1080x2340, 15195 kb/s, SAR 1:1 DAR 6:13, 47.32 fps, 60 tbr, 90k tbn, 180k tbc (default)
Metadata:
creation_time : 2021-05-30T06:03:44.000000Z
handler_name : VideoHandle
vendor_id : [0][0][0][0]
Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, mono, fltp, 192 kb/s (default)
Metadata:
creation_time : 2021-05-30T06:03:44.000000Z
handler_name : SoundHandle
vendor_id : [0][0][0][0]
Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
Stream #0:1 -> #0:1 (aac (native) -> aac (native))
Press [q] to stop, [?] for help
[libx264 @ 0x7f8bbd02be00] using SAR=27/104
[libx264 @ 0x7f8bbd02be00] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 @ 0x7f8bbd02be00] profile High, level 3.2, 4:2:0, 8-bit
[libx264 @ 0x7f8bbd02be00] 264 - core 161 r3049 55d517b - H.264/MPEG-4 AVC codec - Copyleft 2003-2021 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=6 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to '/tmp/hd720.mp4':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: isommp42
com.android.version: 10
encoder : Lavf58.76.100
Stream #0:0(eng): Video: h264 (avc1 / 0x31637661), yuv420p(tv, smpte170m/bt470bg/smpte170m, progressive), 1280x720 [SAR 27:104 DAR 6:13], q=2-31, 60 fps, 15360 tbn (default)
Metadata:
creation_time : 2021-05-30T06:03:44.000000Z
handler_name : VideoHandle
vendor_id : [0][0][0][0]
encoder : Lavc58.134.100 libx264
Side data:
cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A
Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, mono, fltp, 69 kb/s (default)
Metadata:
creation_time : 2021-05-30T06:03:44.000000Z
handler_name : SoundHandle
vendor_id : [0][0][0][0]
encoder : Lavc58.134.100 aac
frame= 3624 fps= 49 q=-1.0 Lsize= 9216kB time=00:01:00.35 bitrate=1251.0kbits/s dup=766 drop=0 speed=0.823x
video:9111kB audio:11kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 1.028394%
[libx264 @ 0x7f8bbd02be00] frame I:18 Avg QP:20.63 size: 51692
[libx264 @ 0x7f8bbd02be00] frame P:1129 Avg QP:21.59 size: 6286
[libx264 @ 0x7f8bbd02be00] frame B:2477 Avg QP:20.21 size: 525
[libx264 @ 0x7f8bbd02be00] consecutive B-frames: 6.2% 5.7% 7.4% 80.8%
[libx264 @ 0x7f8bbd02be00] mb I I16..4: 30.0% 36.2% 33.9%
[libx264 @ 0x7f8bbd02be00] mb P I16..4: 4.8% 3.1% 1.5% P16..4: 11.3% 3.4% 2.1% 0.0% 0.0% skip:73.8%
[libx264 @ 0x7f8bbd02be00] mb B I16..4: 0.4% 0.2% 0.0% B16..8: 7.8% 0.4% 0.0% direct: 0.3% skip:90.9% L0:50.2% L1:46.0% BI: 3.8%
[libx264 @ 0x7f8bbd02be00] 8x8 transform intra:32.7% inter:49.7%
[libx264 @ 0x7f8bbd02be00] coded y,uvDC,uvAC intra: 14.9% 17.9% 9.9% inter: 2.3% 1.6% 0.5%
[libx264 @ 0x7f8bbd02be00] i16 v,h,dc,p: 18% 79% 2% 1%
[libx264 @ 0x7f8bbd02be00] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 15% 25% 54% 1% 1% 0% 2% 0% 2%
[libx264 @ 0x7f8bbd02be00] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 18% 48% 19% 1% 2% 1% 5% 1% 5%
[libx264 @ 0x7f8bbd02be00] i8c dc,h,v,p: 62% 33% 4% 1%
[libx264 @ 0x7f8bbd02be00] Weighted P-Frames: Y:1.9% UV:1.6%
[libx264 @ 0x7f8bbd02be00] ref P L0: 62.0% 9.4% 16.7% 11.9% 0.1%
[libx264 @ 0x7f8bbd02be00] ref B L0: 69.9% 23.9% 6.2%
[libx264 @ 0x7f8bbd02be00] ref B L1: 95.0% 5.0%
[libx264 @ 0x7f8bbd02be00] kb/s:1235.58
[aac @ 0x7f8bbd02d600] Qavg: 65521.922<code></code></pre><b><div><b>480p</b></div></b><pre class="lang-bash"><code>
git@localhost# ffmpeg version 4.4 Copyright (c) 2000-2021 the FFmpeg developers
built with Apple clang version 12.0.0 (clang-1200.0.32.29)
configuration: --prefix=/usr/local/Cellar/ffmpeg/4.4_1 --enable-shared --enable-pthreads --enable-version3 --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libbluray --enable-libdav1d --enable-libmp3lame --enable-libopus --enable-librav1e --enable-librubberband --enable-libsnappy --enable-libsrt --enable-libtesseract --enable-libtheora --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libspeex --enable-libsoxr --enable-libzmq --enable-libzimg --disable-libjack --disable-indev=jack --enable-videotoolbox
libavutil 56. 70.100 / 56. 70.100
libavcodec 58.134.100 / 58.134.100
libavformat 58. 76.100 / 58. 76.100
libavdevice 58. 13.100 / 58. 13.100
libavfilter 7.110.100 / 7.110.100
libavresample 4. 0. 0 / 4. 0. 0
libswscale 5. 9.100 / 5. 9.100
libswresample 3. 9.100 / 3. 9.100
libpostproc 55. 9.100 / 55. 9.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/Users/gil/Desktop/116MB.mp4':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: isommp42
creation_time : 2021-05-30T06:03:44.000000Z
com.android.version: 10
Duration: 00:01:00.39, start: 0.000000, bitrate: 15393 kb/s
Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, smpte170m/bt470bg/smpte170m), 1080x2340, 15195 kb/s, SAR 1:1 DAR 6:13, 47.32 fps, 60 tbr, 90k tbn, 180k tbc (default)
Metadata:
creation_time : 2021-05-30T06:03:44.000000Z
handler_name : VideoHandle
vendor_id : [0][0][0][0]
Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, mono, fltp, 192 kb/s (default)
Metadata:
creation_time : 2021-05-30T06:03:44.000000Z
handler_name : SoundHandle
vendor_id : [0][0][0][0]
Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
Stream #0:1 -> #0:1 (aac (native) -> aac (native))
Press [q] to stop, [?] for help
[libx264 @ 0x7f8585815600] using SAR=9/26
[libx264 @ 0x7f8585815600] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 @ 0x7f8585815600] profile High, level 3.1, 4:2:0, 8-bit
[libx264 @ 0x7f8585815600] 264 - core 161 r3049 55d517b - H.264/MPEG-4 AVC codec - Copyleft 2003-2021 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=6 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to '/tmp/420.mp4':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: isommp42
com.android.version: 10
encoder : Lavf58.76.100
Stream #0:0(eng): Video: h264 (avc1 / 0x31637661), yuv420p(tv, smpte170m/bt470bg/smpte170m, progressive), 640x480 [SAR 9:26 DAR 6:13], q=2-31, 60 fps, 15360 tbn (default)
Metadata:
creation_time : 2021-05-30T06:03:44.000000Z
handler_name : VideoHandle
vendor_id : [0][0][0][0]
encoder : Lavc58.134.100 libx264
Side data:
cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A
Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, mono, fltp, 69 kb/s (default)
Metadata:
creation_time : 2021-05-30T06:03:44.000000Z
handler_name : SoundHandle
vendor_id : [0][0][0][0]
encoder : Lavc58.134.100 aac
frame= 3624 fps= 88 q=-1.0 Lsize= 4485kB time=00:01:00.35 bitrate= 608.8kbits/s dup=766 drop=0 speed=1.47x
video:4380kB audio:11kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 2.139495%
[libx264 @ 0x7f8585815600] frame I:18 Avg QP:20.86 size: 28212
[libx264 @ 0x7f8585815600] frame P:1130 Avg QP:22.35 size: 3083
[libx264 @ 0x7f8585815600] frame B:2476 Avg QP:22.88 size: 199
[libx264 @ 0x7f8585815600] consecutive B-frames: 6.1% 6.2% 6.3% 81.3%
[libx264 @ 0x7f8585815600] mb I I16..4: 28.2% 27.7% 44.1%
[libx264 @ 0x7f8585815600] mb P I16..4: 4.6% 2.0% 1.7% P16..4: 13.8% 4.1% 2.7% 0.0% 0.0% skip:70.9%
[libx264 @ 0x7f8585815600] mb B I16..4: 0.3% 0.1% 0.0% B16..8: 8.0% 0.5% 0.1% direct: 0.2% skip:90.8% L0:47.1% L1:48.0% BI: 4.9%
[libx264 @ 0x7f8585815600] 8x8 transform intra:24.0% inter:44.1%
[libx264 @ 0x7f8585815600] coded y,uvDC,uvAC intra: 19.6% 22.3% 13.8% inter: 3.1% 1.7% 0.7%
[libx264 @ 0x7f8585815600] i16 v,h,dc,p: 20% 77% 2% 2%
[libx264 @ 0x7f8585815600] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 13% 27% 52% 1% 1% 1% 2%5 0% 3%
[libx264 @ 0x7f8585815600] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 15% 47% 18% 2% 3% 2% 6% 1% 5%
[libx264 @ 0x7f8585815600] i8c dc,h,v,p: 55% 39% 5% 1%
[libx264 @ 0x7f8585815600] Weighted P-Frames: Y:2.4% UV:1.9%
[libx264 @ 0x7f8585815600] ref P L0: 60.7% 9.7% 15.9% 13.5% 0.2%
[libx264 @ 0x7f8585815600] ref B L0: 69.2% 22.0% 8.7%
[libx264 @ 0x7f8585815600] ref B L1: 94.1% 5.9%
[libx264 @ 0x7f8585815600] kb/s:593.92
[aac @ 0x7f8585816e00] Qavg: 65521.922
</code></pre>
Video is successfully converted 720p and 480p, let's if this method worth trying.
<pre class="lang-bash"><code>
git@localhost #
-rwxr-----@ 1 gil wheel 111M May 30 19:59 /tmp/116MB.mp4
-rw-r--r-- 1 gil wheel 9.0M May 30 19:51 /tmp/hd720.mp4
-rw-r--r-- 1 gil wheel 4.4M May 30 19:57 /tmp/420.mp4
</code></pre>
</div><div><p style="color: #0e101a; margin-bottom: 0pt; margin-top: 0pt;"><span data-preserver-spaces="true" style="margin-bottom: 0pt; margin-top: 0pt;"><span> </span></span></p><p style="color: #0e101a; margin-bottom: 0pt; margin-top: 0pt;"><span data-preserver-spaces="true" style="margin-bottom: 0pt; margin-top: 0pt;"><span> </span>Not much difference between the original clip and 720p, but a significant change in size, it's 12 times. In the case of 480p size is reduced like 26 times but the quality of the clip is not ok.</span></p><p style="color: #0e101a; margin-bottom: 0pt; margin-top: 0pt;"><span data-preserver-spaces="true" style="margin-bottom: 0pt; margin-top: 0pt;"><br /></span></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi_auNnGC9OYrzQXK7MGyRlAbLbyFFzKzROQOLmW0geqZ7yEhIW5VxqpYSPNDtrNiXTWImScDXQmFbMw7cmvuvuvh08nfNY58NJd7nziFzaExhvb0dLmxsNSW3Cj_AJbgmOHdMQcyheNZY/s1006/reduce_video_size.jpg" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="735" data-original-width="1006" height="468" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi_auNnGC9OYrzQXK7MGyRlAbLbyFFzKzROQOLmW0geqZ7yEhIW5VxqpYSPNDtrNiXTWImScDXQmFbMw7cmvuvuvh08nfNY58NJd7nziFzaExhvb0dLmxsNSW3Cj_AJbgmOHdMQcyheNZY/w640-h468/reduce_video_size.jpg" width="640" /></a></div><p style="color: #0e101a; margin-bottom: 0pt; margin-top: 0pt;"><br /></p><p style="color: #0e101a; margin-bottom: 0pt; margin-top: 0pt;"><br /></p><div><p style="color: #0e101a; margin-bottom: 0pt; margin-top: 0pt;"><strong style="margin-bottom: 0pt; margin-top: 0pt;">Conclusion: </strong><span data-preserver-spaces="true" style="margin-bottom: 0pt; margin-top: 0pt;">720p reduced a very good amount of size without having to lose video quality.</span></p></div></div>Gilhttp://www.blogger.com/profile/13054047395328845300noreply@blogger.com0tag:blogger.com,1999:blog-2475157072499844894.post-40893213605006006692021-05-29T18:26:00.000+05:302021-05-29T20:09:01.034+05:30Syntax highlighter for blogger with Prism JS<p> Syntax highlighter gives more readability to blog posts while sharing code snippets. A lot of them are out there, but I'll walk you through the installation of `prism js` for blogger, in this post.<br></p><p style="text-align: left;"><br>Prism js has multiple themes which you can try out all them <a href="https://prismjs.com/ " target="_blank">here</a> and you can pick one get css path from <a href="https://cdnjs.com/libraries/prism" target="_blank">https://cdnjs.com/libraries/prism</a></p><div style="margin-left: 1em; margin-right: 1em; text-align: left;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjQfbGp9yrar2a0Tp1KCDVxi-GE-9MKZ3g-lYQOLcgeBh10TaRbaByONWrDg7H7OI_-Z0ZgGeblI0v4kotQj8sX3_q_s9CnAejThj5szyo4zC08z16PaFWVS5iKdsmpv9rtWcWGntC-I88/s1048/Prism.jpg" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="725" data-original-width="1048" height="443" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjQfbGp9yrar2a0Tp1KCDVxi-GE-9MKZ3g-lYQOLcgeBh10TaRbaByONWrDg7H7OI_-Z0ZgGeblI0v4kotQj8sX3_q_s9CnAejThj5szyo4zC08z16PaFWVS5iKdsmpv9rtWcWGntC-I88/w640-h443/Prism.jpg" width="640"></a></div><div><div><br></div><div><br><div><div>Disclaimer: Take a backup of your blogger template as this post includes modifications to the blogger template, otherwise you might end up losing your template if you do any mistake.</div></div><div><br></div><div>We are adding CDN to blogger templates now, which includes a couple of javascript files and a CSS file. Javascript files are common in all installations but CSS files are different for each theme, check them <a href="https://cdnjs.com/libraries/prism" target="_blank">here</a>. I'm using <b>tomorrow-night</b><br><br>Let's modify the template.</div><div> </div>
</div></div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi__c49pLNixtgUmJwkJPP0bHrKbi3uYT6ImJ3uu0GAMJ8SBdLok9P1kI5yckHTGEERvx5DFGgI36tPBHDePrbcX9gJ0oxAg_w98MUSNk1EqCk14p_t9_42IwR2z9W7FOOgLuxLEdR1dpM/s779/edit.jpg" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="572" data-original-width="779" height="470" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi__c49pLNixtgUmJwkJPP0bHrKbi3uYT6ImJ3uu0GAMJ8SBdLok9P1kI5yckHTGEERvx5DFGgI36tPBHDePrbcX9gJ0oxAg_w98MUSNk1EqCk14p_t9_42IwR2z9W7FOOgLuxLEdR1dpM/w640-h470/edit.jpg" width="640"></a></div><div><br></div>Edit HTML<br><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjRDrrkOnZLHNMrmKqJDwCHxjJXJATMUuaK_PHgd83TnXPQN6Q8ZXgHN3DC1xtMDpjvBF6sZM27EjHzwVUaQs6Qk_LZmbOH2WAOeW2wVDjfJ7Zp0mRz1mq9GiT4E9espha2z3q8IPRLHUE/s320/edit2.jpg" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="242" data-original-width="320" height="151" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjRDrrkOnZLHNMrmKqJDwCHxjJXJATMUuaK_PHgd83TnXPQN6Q8ZXgHN3DC1xtMDpjvBF6sZM27EjHzwVUaQs6Qk_LZmbOH2WAOeW2wVDjfJ7Zp0mRz1mq9GiT4E9espha2z3q8IPRLHUE/w200-h151/edit2.jpg" width="200"></a></div><div class="separator" style="clear: both; text-align: center;"><br></div><div class="separator" style="clear: both; text-align: center;"><div class="separator" style="clear: both; text-align: left;">Search for <b></head</b> and add css path right above it. </div></div><div class="separator" style="clear: both; text-align: left;"><br></div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgi13Oyz8PpGJ28qWgHteoVxb_Wrjh6SLuZrEIlKUoIPwnynKxCreu6yTHmxkuF8qvFzwNEuvunEUbfY-sV8kbeFzKq5aws4Z5UyHPSz-oH6MAVth-7MkJleeNeT7JQ5IxMKh9ic1Ga5WU/s1009/css.jpg" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="80" data-original-width="1009" height="51" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgi13Oyz8PpGJ28qWgHteoVxb_Wrjh6SLuZrEIlKUoIPwnynKxCreu6yTHmxkuF8qvFzwNEuvunEUbfY-sV8kbeFzKq5aws4Z5UyHPSz-oH6MAVth-7MkJleeNeT7JQ5IxMKh9ic1Ga5WU/w640-h51/css.jpg" width="640"></a></div><br><div class="separator" style="clear: both; text-align: left;">Search for <b></body </b>and add js path.</div><div class="separator" style="clear: both; text-align: left;"><br></div><div class="separator" style="clear: both; text-align: left;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi8sMcgNwAh1uKts9c8LeFfCaPYELFzeDqnuNMZt6PPPial4IQq7PuyDsXPPpUuCjjUorE7yfMiKgOdKq_nwNI4Jg1i7DcOOO5g3IuxbIVFQUCRDnoCscX1Peb_-xK5V-ByaGrIiYCe0_E/s947/js.jpg" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="59" data-original-width="947" height="40" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi8sMcgNwAh1uKts9c8LeFfCaPYELFzeDqnuNMZt6PPPial4IQq7PuyDsXPPpUuCjjUorE7yfMiKgOdKq_nwNI4Jg1i7DcOOO5g3IuxbIVFQUCRDnoCscX1Peb_-xK5V-ByaGrIiYCe0_E/w640-h40/js.jpg" width="640"></a></div><div class="separator" style="clear: both; text-align: center;"><br></div><div>Great you installed it successfully. Now it's very easy to use every time you write a blog post without any extra effort.</div><div style="font-weight: bold;"><b><br></b></div><b>Usage:</b><div><b><br></b></div><div>Change post to <b>HTML view </b>mode put your snippet between <b><pre></b> tags and specify snippet language in <b>class.</b> </div><div><br></div><div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj1IvxkLZOcSnXfe424iFt1E08XP7ps6prbNcrPdZtcHajmbX26AHuERRw53Y_M4ZD-rt_ChpBtj3PEO0VcILY7d3R403N_eKqneHUwykFC_zkmvVby6avWM3mGYMI9ErSdIGXbkENmIDw/s782/samp.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="250" data-original-width="782" height="204" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj1IvxkLZOcSnXfe424iFt1E08XP7ps6prbNcrPdZtcHajmbX26AHuERRw53Y_M4ZD-rt_ChpBtj3PEO0VcILY7d3R403N_eKqneHUwykFC_zkmvVby6avWM3mGYMI9ErSdIGXbkENmIDw/w640-h204/samp.jpg" width="640"></a></div><br><div class="separator" style="clear: both; text-align: center;"><br></div>Hope you liked it, share your feedback in the comments.<br><div class="separator" style="clear: both; text-align: center;"><br></div><br></div><div><br><br><div class="separator" style="clear: both; text-align: center;"><br></div><br></div><br>Gilhttp://www.blogger.com/profile/13054047395328845300noreply@blogger.com0tag:blogger.com,1999:blog-2475157072499844894.post-5854028615260855872021-05-29T14:56:00.010+05:302021-05-29T15:40:33.329+05:30Start Index at 1 Python Data Frame<p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh6izMPe8a2tTWhJSyKBsEeKF1GD5854MQSvOx8YpHCu0q6ymxUvPonOHbFfZCX-o4AXrCAjZ1tjXT-t4Y67Z25EI6tmI0NxIpoDB69CXKZpnZ1iFRrIABwjn0ySuiSp2R5NeWaz5-UMmI/s1920/pandas.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="776" data-original-width="1920" height="258" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh6izMPe8a2tTWhJSyKBsEeKF1GD5854MQSvOx8YpHCu0q6ymxUvPonOHbFfZCX-o4AXrCAjZ1tjXT-t4Y67Z25EI6tmI0NxIpoDB69CXKZpnZ1iFRrIABwjn0ySuiSp2R5NeWaz5-UMmI/w640-h258/pandas.png" width="640" /></a></div><br /><div class="separator" style="clear: both; text-align: justify;">Pandas is a powerful python library to analyze and manipulate data. By default data frame's index starts with 0, which I don't like so much. Let's start the index with 1.</div><div class="separator" style="clear: both; text-align: justify;"><br /></div><pre class="lang-py"><code>import pandas
data=[{'name': 'alex', 'age': 30}, {'name': 'manny', 'age': 32}, {'name': 'mike', 'age': 29}]
df=pandas.DataFrame(data)
df.sort_values('age',inplace=True)
df.reset_index(drop=True,inplace=True)
df.index+=1
print(df)</code></pre>
<div><div>python3.8 /tmp/pd.py</div><div><span style="font-family: courier;"> name age</span></div><div><span style="font-family: courier;">1 mike 29</span></div><div><span style="font-family: courier;">2 alex 30</span></div><div><span style="font-family: courier;">3 manny 32</span></div></div>Gilhttp://www.blogger.com/profile/13054047395328845300noreply@blogger.com0tag:blogger.com,1999:blog-2475157072499844894.post-38015360443994918272020-07-23T02:42:00.004+05:302021-05-12T01:45:19.028+05:30Time Zone Conversion in Linux bash script<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEilDd6k1s2yvNkZoH427HkTJ8os1nrL1FQRZh5EC46vCldABQfxxZNX8FcW2ayRdBs-pceelu7cgDnbhyYO8RQmR57KFiFe16m_zXgb9bz80WB8QVbtY6T51QgBNb5JQ-BQHVDO_6q5ftk4/s1280/timezone.jpg" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="768" data-original-width="1280" height="375" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEilDd6k1s2yvNkZoH427HkTJ8os1nrL1FQRZh5EC46vCldABQfxxZNX8FcW2ayRdBs-pceelu7cgDnbhyYO8RQmR57KFiFe16m_zXgb9bz80WB8QVbtY6T51QgBNb5JQ-BQHVDO_6q5ftk4/w625-h375/timezone.jpg" width="625" /></a></div><div class="separator" style="clear: both; text-align: left;"><br /></div><div class="separator" style="clear: both; text-align: left;"><div class="separator" style="clear: both; text-align: left;"><span> </span><span> </span><span> </span>Linux machines use <font face="courier">UTC</font> clock so does bash script, If your script needs time from a different timezone then you have to convert current <font face="courier">UTC</font> to let's say <font face="courier">PDT</font>, how do we do it in bash. </div></div><div><span> </span></div><div style="text-align: left;">Python has widely used programing language and has lots of libraries for this, But funny this is bash very answer for this, just export <font face="courier">TZ</font> variable. As simple as this. </div><div style="text-align: left;"><br /></div><div style="text-align: left;">Let's try this snippet on a Linux machine. It prints time from 3 timezones <font face="courier">PDT</font>, <font face="courier">UTC</font>, and <font face="courier">IST</font>.</div><div style="text-align: left;"><br /></div>
<script src="https://gist.github.com/subbaraoganeshna/4fd0805382d24f2f56ad301885d1153e.js"></script>If you notice I'm not exporting <font face="courier">TZ</font>, just using variable while running date command, You can simply do <font face="courier">export TZ=<span style="background-color: white; color: #24292e; white-space: pre;">America/Los_Angeles</span></font><span style="background-color: white; color: #24292e; font-size: 12px; white-space: pre;">, </span>but if you export then you can't use <font face="courier">UTC</font> unless you change it back to <font face="courier">UTC</font>.Subbarao Ganeshnahttp://www.blogger.com/profile/01855743078913014384noreply@blogger.com0tag:blogger.com,1999:blog-2475157072499844894.post-73993487550469704282018-06-24T14:11:00.000+05:302018-06-24T14:26:36.032+05:30raspberry pi 3 b+ no wireless interfaces found<div dir="ltr" style="text-align: left;" trbidi="on">
<div dir="ltr" style="text-align: left;" trbidi="on">
<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgKica6gBW4ayHh6fbm8lPsaHOhx2bds3b3cxptH6J_8fWmSi1HlsuXSmaK85FL-cNAkItN_uCyQj1yrIiac8FG-4sDTvuzZ2IcMCE23vjfYPt7wsRogm1plltjWq7HyAZGYr960iL6RkfU/s1600/raspberry_pi_logo_rgb_552x650-500x589.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="589" data-original-width="500" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgKica6gBW4ayHh6fbm8lPsaHOhx2bds3b3cxptH6J_8fWmSi1HlsuXSmaK85FL-cNAkItN_uCyQj1yrIiac8FG-4sDTvuzZ2IcMCE23vjfYPt7wsRogm1plltjWq7HyAZGYr960iL6RkfU/s1600/raspberry_pi_logo_rgb_552x650-500x589.png" /></a></div>
<br />
When i loaded Raspberry Pi 3 B+ with the SD Card from Raspberry Pi 3 B, it didn't boot later that it needs latest kernel and i have the old one. I could have installed rasjpbian stretch, but my app currently not ready for stretch so i have to use jessy.<br />
<br />
I finally update ran rpi-update wow, my Raspberry 3 B+ is up withe jessy, but later i was unhappy because i don't see wifi adapter, after a debug found dmsg yelling at me saying driver failed to load.<br />
<br />
<br /></div>
<pre br="“”" class="““brush: py,nolinenums;””">[ 3.495761] brcmfmac: F1 signature read @0x18000000=0x15264345
[ 3.504770] brcmfmac: brcmf_fw_map_chip_to_name: using brcm/brcmfmac43455-sdio.bin for chip 0x004345(17221) rev 0x000006
[ 3.505168] usbcore: registered new interface driver brcmfmac
[ 3.514427] brcmfmac mmc1:0001:1: Direct firmware load for brcm/brcmfmac43455-sdio.bin failed with error -2
[ 5.574616] brcmfmac: brcmf_sdio_htclk: HT Avail timeout (1000000): clkctl 0x50
</pre>
<br />
Existing driver is not working with B+, so i installed new driver which fixed it for me. Let show you.<br />
First download the .deb from raspberry archives and install with dpkg.
<br />
<br />
<pre br="“”" class="““brush: py,nolinenums;””">root@raspB+:~# wget https://archive.raspberrypi.org/debian/pool/main/f/firmware-nonfree/firmware-brcm80211_20161130-3+rpt3_all.deb
root@raspB+:~# dpkg -i firmware-brcm80211_20161130-3+rpt3_all.deb
</pre>
<br />
Now reboot the Raspberry Pi to load the driver on next boot. After reboot you can check ifconfig/iwconfig to list the wlan interface.
<br />
<br />
<pre br="“”" class="““brush: py,nolinenums;””">root@raspB+:~# ifconfig -a
eth0 Link encap:Ethernet HWaddr 11:27:eb:1d:a6:22
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
wlan0 Link encap:Ethernet HWaddr 11:27:eb:1d:a6:22
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)</pre>
<br />
Awesome you fixed it, let's also see how dmsg doing to confirm driver is loaded without any errors in case.<br />
<br /></div>
<pre br="“”" class="““brush: py,nolinenums;””">root@raspB+:~# dmesg |grep brcmac
[ 4.417688] brcmfmac: F1 signature read @0x18000000=0x15264345
[ 4.424231] brcmfmac: brcmf_fw_map_chip_to_name: using brcm/brcmfmac43455-sdio.bin for chip 0x004345(17221) rev 0x000006
[ 4.424788] usbcore: registered new interface driver brcmfmac
[ 4.763266] brcmfmac: brcmf_c_preinit_dcmds: Firmware version = wl0: Feb 27 2018 03:15:32 version 7.45.154 (r684107 CY) FWID 01-4fbe0b04
[ 4.763840] brcmfmac: brcmf_c_preinit_dcmds: CLM version = API: 12.2 Data: 9.10.105 Compiler: 1.29.4 ClmImport: 1.36.3 Creation: 2018-03-09 18:56:28
[ 884.068594] brcmfmac: power management disabled
</pre>
<br />
See driver loaded and registered... </div>
Subbarao Ganeshnahttp://www.blogger.com/profile/01855743078913014384noreply@blogger.com2tag:blogger.com,1999:blog-2475157072499844894.post-41713116962503926892018-06-08T13:14:00.002+05:302018-06-09T04:12:14.562+05:30Install cookie notification bar for European Union countries<div dir="ltr" style="text-align: left;" trbidi="on">
<div>
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhkoEcEo80NQYDijD2_mBOGOCMdjT-tFGG_FAoJw1yRfx71Q5GGC_BZYQ56-Y2ZC-1crX7NVRKl7vVOcRV87Xlvb3HuXmb85pLCrX478uZDQSuTA6B8rqRSxGEb2dPVQltlOJjQfCC66-U/s1600/pam-menegakis-388875-unsplash.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="1067" data-original-width="1600" height="426" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhkoEcEo80NQYDijD2_mBOGOCMdjT-tFGG_FAoJw1yRfx71Q5GGC_BZYQ56-Y2ZC-1crX7NVRKl7vVOcRV87Xlvb3HuXmb85pLCrX478uZDQSuTA6B8rqRSxGEb2dPVQltlOJjQfCC66-U/s640/pam-menegakis-388875-unsplash.jpg" width="640" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
You have already notice annoying pop up saying, This website uses cookies to ensure you get the best experience on our website. Of course it's annoying but there is a valid reason for this.<br />
<div style="text-align: left;">
<br /></div>
European Union Laws made all website and blogs to give this information to visitors from EU Countries. Google already embedded this notification into blogger but some times it might not work if you have modified or changed the blogger templated. So let's see how to generate it for your blog and add it to the template so that you visitors get notified about cookies.<br />
<br />
Just to copy paste the below part of code in your blogger template's html code right above </head>. I'll show how to do find it.<br />
<br />
<script src="https://gist.github.com/subbaraoganeshna/be0d6a34fb3d37db885796217a0eddcc.js"></script>
<br />
<ul style="text-align: left;">
<li>Log into your blogger dashboard. Select Theme from the left pane.</li>
</ul>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhO-iMOrD06GsMabTlRUiTAEp1csuzfq1c8bdc0fyIKtkS9RM_37YaWMzErp7ef514EGQQbUDmCeIk1fBNig9Wy901mWCj0W2xcDQft1ewHDgW6ykVXvC3wLmOH8cFYdOtF7mTR3V10D_Q/s1600/1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="541" data-original-width="620" height="556" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhO-iMOrD06GsMabTlRUiTAEp1csuzfq1c8bdc0fyIKtkS9RM_37YaWMzErp7ef514EGQQbUDmCeIk1fBNig9Wy901mWCj0W2xcDQft1ewHDgW6ykVXvC3wLmOH8cFYdOtF7mTR3V10D_Q/s640/1.png" width="640" /></a></div>
<div>
<br /></div>
<ul style="text-align: left;">
<li>Click Edit HTML.</li>
</ul>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgL6Myi-zRN88rbfdMb2f6kVmOuhEZX6APExTunFlGV5U9hnnAVgFBKxHtraZSSWSnCFprAC_W749p1azvkKoAgFwS9z1VtAVWyw7vfM7vwKEhrwKIP4E5RI7Ql9RRY9VkSr-wtYFu8lh0/s1600/2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="421" data-original-width="620" height="434" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgL6Myi-zRN88rbfdMb2f6kVmOuhEZX6APExTunFlGV5U9hnnAVgFBKxHtraZSSWSnCFprAC_W749p1azvkKoAgFwS9z1VtAVWyw7vfM7vwKEhrwKIP4E5RI7Ql9RRY9VkSr-wtYFu8lh0/s640/2.png" width="640" /></a></div>
<div>
<br /></div>
<ul style="text-align: left;">
<li>Now HTML editor opens. Click anywhere in the editor preferably white space and hit Ctrl+F. Did you figure out why do you need to click inside HTML editor ?. We need to search for tag </head>. If you hit Ctrl+F without clicking inside editor you are searching the webpage not the code inside the editor. So do it.</li>
</ul>
<div>
<span style="color: red;"> Note: Before editing HTML template, don't forget to back it up.</span></div>
<div>
<span style="color: red;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiOsW81TKuJU_uZjvHepnG-13_Y0lY9CF9OyxvIyOP_QoPSoL4uRjbq7wyIOapBRPjgdz57gos7L06Ke7IBbSFLff3Atkcfwn0KUyqZDWNSBtRqUs4KsgCHX7gaqJT9uUpHngAOITgLqz4/s1600/3.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="542" data-original-width="972" height="356" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiOsW81TKuJU_uZjvHepnG-13_Y0lY9CF9OyxvIyOP_QoPSoL4uRjbq7wyIOapBRPjgdz57gos7L06Ke7IBbSFLff3Atkcfwn0KUyqZDWNSBtRqUs4KsgCHX7gaqJT9uUpHngAOITgLqz4/s640/3.png" width="640" /></a></div>
<ul style="text-align: left;">
<li>Search for the tag </head> and paste the below chunk of code just above it. If you not cautious you could mess up your template, So keep it in mind. </li>
</ul>
<div>
Great you did it. do you want to see the notification looks like ? then go to Europe :) just kidding. just change the .com in your blog url to .co.uk.</div>
<div>
<br /></div>
<div>
Ex: www.geekinlinux.blogspot.co.uk and hit enter</div>
<div>
<br /></div>
<div>
There you are. See how nice you done. You blog now prompting visitors to click ok to use cookies.</div>
<div>
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj99qn4nPW5xDsyUvMriCuOFkh8ILBmo7f4Q8EL4eqajiP1rkXH2x8mN14Ur4MqN5PqesJMDO_Ud2bk3kv5LNDqoyDEqgKJDcirQWRHse14whrFC_M3tGH12A4ZZHUYODYJ3ZhUG_57Lvk/s1600/6.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="781" data-original-width="1284" height="388" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj99qn4nPW5xDsyUvMriCuOFkh8ILBmo7f4Q8EL4eqajiP1rkXH2x8mN14Ur4MqN5PqesJMDO_Ud2bk3kv5LNDqoyDEqgKJDcirQWRHse14whrFC_M3tGH12A4ZZHUYODYJ3ZhUG_57Lvk/s640/6.png" width="640" /></a></div>
<div>
<br /></div>
</div>Gilhttp://www.blogger.com/profile/13054047395328845300noreply@blogger.com0tag:blogger.com,1999:blog-2475157072499844894.post-64560516735060163052016-05-06T01:23:00.000+05:302016-05-06T01:23:45.716+05:30check if remote directory exists via ssh <div dir="ltr" style="text-align: left;" trbidi="on">
<div dir="ltr" style="text-align: left;" trbidi="on">
I use python libraries to check if dir exists or not during the automation to make sure my script will create the dir i want is not present locally. But what if i want to do the same thing remotely.<br />
<div>
<br /></div>
<div>
I found few posts showing the same stuff with paramiko's sftp and other ways. I'm ok with paramiko but i have to install it via pip install, i can't simple use paramiko library with out install like any other standard library. So i liked ssh way.</div>
<div>
<br /></div>
<div>
I use 'test' command remotely, let's see </div>
<div>
<br /></div>
</div>
<pre br="“”" class="““brush:bash,nolinenums;””">if (sudo ssh -i /home/downloads/server.pem ubuntu@1.1.1.1 -o "StrictHostKeyChecking no" 'test -d /home/ubuntu/test_dir');
then
echo 'yes'
fi
</pre>
which is working fine. </div>
Gilhttp://www.blogger.com/profile/13054047395328845300noreply@blogger.com0tag:blogger.com,1999:blog-2475157072499844894.post-74565332647723836422016-04-21T02:58:00.001+05:302018-06-08T02:40:14.121+05:30Automate SCP in python to retry <div dir="ltr" style="text-align: left;" trbidi="on">
<img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgRdEvFbBJ7a6jOudGGE0JTcvo01knKOLuMIBxkQqNutVv_iYsPBReSFBr5A1xVRJkbpipJmELKYUYKaluwiY9dCzN7y9GeqsFWVi2EDZw-nPFe4J8KapeGPyaKGT-WkFkkQPK5yJB2FOA/s1600/chris-ried-512801-unsplash.jpg" style="display: none;" />
<br />
<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="separator" style="clear: both; text-align: center;">
</div>
<br />
<br />
Here is a small script to retry scp in python, i added few exceptions. You can use them or replace all of them with single generic exception.<br />
<br />
<pre br="“”" class="““brush: py,nolinenums;””">#!/usr/bin/python
def scp_Retry(self, cmd):
while True:
try:
run = Popen(cmd, shell=True, stdout=PIPE, stderr=PIPE)
logger.info('Executing: '+cmd)
out, err = run.communicate()
print(out,err)
logger.info('SCP StdOut: '+out)
if err == "":
print('copied*****')
break elif "Operation timed out" in err:
raise RuntimeError('Connection timed out')
elif "Network is unreachable" in err:
raise ValueError('Network Error, con connectivity')
elif "Permission denied (publickey,password,keyboard-interactive)" in err:
raise BaseException('Ssh is not ready yet ...')
except RuntimeError as e:
logger.error("SCP StdErr: " + err)
except ValueError as e:
logger.error("SCP StdErr: " + err)
except BaseException as e:
logger.error("SCP StdErr: " + err)
print('retrying')
time.sleep(5)
return True
scp_cmd = 'scp -B -o "StrictHostKeyChecking no" -o LogLevel=ERROR -i /Users/gil/.ssh/server.pem /Users/gil/Desktop/ca.crt ubuntu@104.154.92.0:/home/ubuntu/'
self.scp_Retry(core_reg_ca_scp)</pre>
<br />
Very important thing to keep in mind is "scp" options, reason is i worte the above scirpt when i was automation in aws cloud, where i create a vm and immediately scp few files, Since vm will not be ready before min or so, i'll keep retrying and get those different types of Excpetion.<br />
<br />
First exception is for connection timed out, my script will start pushing files to newly created vm immediately after creating even before scp port is open, so i get "connection timed out" for few seconds.<br />
<br />
Second error for internet connectivity, if you are running the script from a computer with out internet connectivity, then you'll see this.<br />
<br />
Third one is very important, After scp port is ready and before vm is ready to validate the ssh key we are using. Here what happens is you'll be prompted for the password even you are using ssh key. VM will be in this state for couple of seconds or more.<br />
<br />
-B option will avoid prompting for password at above mentioned state, advantage of using this option is you'll not be blocked prompting for password, this option will times out the connection and our script will retry again and we'll succeed at later retries.<br />
<br />
"StrictHostKeyChecking no" This will disables Host Key Checking, so that you don't have to press "yes" while connecting to new vm for the first time.<br />
<br />
"LogLevel=ERROR": This will disable all log messages show up while ssh/scp. Reason i use is i'm using Popen.communicate, i'm capturing stdout and stderr, to check if stderr is None or not.
If i don't use this option, even successful scp, warning messages will be piped into stderr and my if condition will fail even after successful scp.
Below is the warning message you see , while you do scp for the first time.<br />
<br />
example ": Warning: Permanently added 'x.x.x.x' (ED25519) to the list of known hosts.\r\n"
gil...</div>
</div>Gilhttp://www.blogger.com/profile/13054047395328845300noreply@blogger.com1tag:blogger.com,1999:blog-2475157072499844894.post-67238093787818677212016-04-06T20:24:00.000+05:302016-04-21T15:43:25.664+05:30Creating VPC in AWS Cloud<div dir="ltr" style="text-align: left;" trbidi="on">
VPC let's you isolate your subnets, you can have multiple VPC depending on your requirements, As AWS documentations says, you can have your web server in a VPC which is exposed to internet and all DB servers in another VPC doesn't exposed to internet.<br />
<div>
<br /></div>
<div>
Reason i writing this post was i deleted my default VPC accidentally, so i want to create one which has same functionality similar to Default one, which mean instances in this VPC should be exposed to internet.</div>
<div>
<br /></div>
<div>
Please follow the below link from AWS to create a VPC , which have very good documentation.</div>
<div>
<br /></div>
<div>
<a href="http://docs.aws.amazon.com/AmazonVPC/latest/GettingStartedGuide/getting-started-create-vpc.html">http://docs.aws.amazon.com/AmazonVPC/latest/GettingStartedGuide/getting-started-create-vpc.html</a></div>
<div>
<br /></div>
<div>
Few things i just want to highlight, </div>
<div>
<br /></div>
<div>
1. Create a VPC.</div>
<div>
2. Create a subnet under newly created VPC.</div>
<div>
3. Create a Internet Gateway and attach it to new VPC.</div>
<div>
4. Edit the route table and add an entry to allow all traffic via Internet Gateway to the outside world.</div>
<div>
<br /></div>
<div>
Thing i would like to highlight and make sure you don't miss and end up wasting time in troubleshooting.</div>
<div>
<br /></div>
<div>
<br /></div>
<div>
1. After creating subnet, right click on the subnet and "Modify Auto-Assign Public IP"</div>
<div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiwL6anbQ_PBRvuCfDIuTsKXeHnHUDsmILmWlWbH7Pum4II9gmdgbHQKVUHSQGETu3fRIYyJmx0Hd3aPnNJb9Q2XpS_jRyMIuae6HMqwuiV74EP__UdXcgJYtf0zfPrzLRy3hzQH_qAOek/s1600/post.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="141" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiwL6anbQ_PBRvuCfDIuTsKXeHnHUDsmILmWlWbH7Pum4II9gmdgbHQKVUHSQGETu3fRIYyJmx0Hd3aPnNJb9Q2XpS_jRyMIuae6HMqwuiV74EP__UdXcgJYtf0zfPrzLRy3hzQH_qAOek/s400/post.jpg" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
Enable it.<br />
<br /></div>
<div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhn2fyj0R6Z7spnfkyGIyfxJYCXi9QQSeIHEIJ3lJaa0n398I4Mz4se77cZGyV5-8vIZUmwnaIuwu-2bdF-m-gajQRU9n4JB2I_34sK_1Oh4oCCKhh7rtesXyMgdiqIh5ShAglXTMMwRTs/s1600/post.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="181" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhn2fyj0R6Z7spnfkyGIyfxJYCXi9QQSeIHEIJ3lJaa0n398I4Mz4se77cZGyV5-8vIZUmwnaIuwu-2bdF-m-gajQRU9n4JB2I_34sK_1Oh4oCCKhh7rtesXyMgdiqIh5ShAglXTMMwRTs/s400/post.jpg" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
</div>
If you don't don't enable it, your instances under new VPC won't get public ipaddresses automatically.
<br />
<div>
<br /></div>
<div>
2. Go to "Route Tables" and add entry to allow all traffic to outside world via Internet Gateway.</div>
<div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjou1AcmN81_GVCV6uVyQpeDOOI0xgmH6Y6ESXWMM5NoMPSQkogxodwPX-JCBv6uZrr30M7lEHbcd2WUxfJskB8gfaWGO6bV258ZHLELrm4ZKA2ET6Gpn6K9vYcHln5NoyiE1HHbHCoxfk/s1600/post.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="128" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjou1AcmN81_GVCV6uVyQpeDOOI0xgmH6Y6ESXWMM5NoMPSQkogxodwPX-JCBv6uZrr30M7lEHbcd2WUxfJskB8gfaWGO6bV258ZHLELrm4ZKA2ET6Gpn6K9vYcHln5NoyiE1HHbHCoxfk/s400/post.jpg" width="400" /></a></div>
<br /></div>
<br />
<div>
Unless you do this step you'll not access Instances from Outside world using public ip. What see is above route allows Instaces reach internet, if you don't add this entry, your request from outside world will reach the instance but they can't reply or acknowledge since traffic to outside world is not allowed via Internet Gateway.</div>
<div>
<br /></div>
<div>
I tested this using tcpdump, i see requests on the instances from outside world but instances can't talk back.</div>
<div>
<br /></div>
<div>
My intention is to expose the points that was documentation didn't do.</div>
<div>
<br /></div>
<div>
gil ...</div>
</div>
Subbarao Ganeshnahttp://www.blogger.com/profile/01855743078913014384noreply@blogger.com0tag:blogger.com,1999:blog-2475157072499844894.post-16161592587496733332016-04-05T03:12:00.003+05:302016-04-05T03:12:47.475+05:30Python Decorators<div dir="ltr" style="text-align: left;" trbidi="on">
Decorators take functions as argument and manipulates with having to modify the original function.<br />
<br />
Here is a small example of decorators, my base function which is "run_cmd" takes any bash command as argument and executes them using subprocess.Popen which then returns two values "stdout"and "stderr".<br />
<br />
What i want to do is with out touching "run_cmd" function i would like to add some checks like say , if "stderr" is None print as "no error" , else print "stdout", something like that.<br />
<br />
So i'm writing a decorator function and add all these checks then i decorate my "run_cmd". Let's see how<br />
<br />
<pre style="background-color: white; font-family: Monaco; font-size: 10.5pt;"><span style="color: grey; font-style: italic;">#!/usr/bin/python</span><span style="color: navy; font-weight: bold;">import </span>subprocess
<span style="color: navy; font-weight: bold;">def </span>checker(f):
<span style="color: navy; font-weight: bold;">def </span>inner(a):
o, e = f(a)
<span style="color: navy; font-weight: bold;">if </span>e != <span style="color: green; font-weight: bold;">''</span>:
<span style="color: navy;">exit</span>(e)
<span style="color: navy; font-weight: bold;">else</span>:
<span style="color: navy; font-weight: bold;">print</span>(<span style="color: green; font-weight: bold;">"Output of your command is: "</span>+o)
<span style="color: navy; font-weight: bold;">return </span>inner
@<span style="color: #0000b2;">checker</span><span style="color: navy; font-weight: bold;">def </span>run_cmd(value):
p = subprocess.Popen(value, <span style="color: #660099;">shell</span>=<span style="color: navy;">True</span>, <span style="color: #660099;">stdout</span>=subprocess.PIPE, <span style="color: #660099;">stderr</span>=subprocess.PIPE)
out, err = p.communicate()
<span style="color: navy; font-weight: bold;">return </span>out.strip(<span style="color: green; font-weight: bold;">'</span><span style="color: navy; font-weight: bold;">\n</span><span style="color: green; font-weight: bold;">'</span>), err.strip(<span style="color: green; font-weight: bold;">'</span><span style="color: navy; font-weight: bold;">\n</span><span style="color: green; font-weight: bold;">'</span>)
</pre>
<br />
Here if you observe i'm passing a command to "run_cmd", since it's decorated this whole function will be taken as an argument by "checker", but the arguments i pass to "run_cmd" will be passed to "inner" function that is in "checker", So there i'm creating an instance of "run_cmd" assigning the return values to "o" and "e", Then everything is as usual , write your if conditions blah blah<br />
<br />
See the output of above command:<br />
<br />
<pre style="background-color: white; font-family: Monaco; font-size: 10.5pt;">run_cmd('whoami')</pre>
<pre style="background-color: white; font-family: Monaco; font-size: 10.5pt;">
<pre style="font-family: Monaco; font-size: 10.5pt;">/usr/<span style="color: navy;">bin</span>/python /Users/gil/Desktop/decorator.py</pre>
</pre>
<pre style="background-color: white; font-family: Monaco; font-size: 10.5pt;">Output of your command <span style="color: navy; font-weight: bold;">is</span>: gil
Process finished <span style="color: navy; font-weight: bold;">with </span><span style="color: navy;">exit </span>code <span style="color: blue;">0</span></pre>
<br />
See output of wrong command<br />
<br />
<pre style="background-color: white; font-family: Monaco; font-size: 10.5pt;">run_cmd(<span style="color: green; font-weight: bold;">'whoamia'</span>)
/usr/<span style="color: navy;">bin</span>/python /Users/gil/Desktop/decorator.py
/<span style="color: navy;">bin</span>/sh: whoamia: command <span style="color: navy; font-weight: bold;">not </span>found
Process finished <span style="color: navy; font-weight: bold;">with </span><span style="color: navy;">exit </span>code <span style="color: blue;">1</span></pre>
<br />
gil...<br />
<br /></div>
Subbarao Ganeshnahttp://www.blogger.com/profile/01855743078913014384noreply@blogger.com0tag:blogger.com,1999:blog-2475157072499844894.post-81857081938783271432016-03-23T16:41:00.000+05:302016-03-23T16:41:50.627+05:30Where= setting doesn't match unit name. Refusing. Systems<div dir="ltr" style="text-align: left;" trbidi="on">
First thing you should keep in mind while creating "mount units" is m<span style="background-color: white; font-family: Times; line-height: normal; widows: 1;">ount units must be named after the mount point directories they control. Ex: if the mount point is "/var/storage/disk1", then mount unit name should be like "var-storage-disk1.mount". </span><div>
<div style="widows: 1;">
<span style="font-family: Times;"><span style="background-color: white;"><br /></span></span></div>
<div style="widows: 1;">
<span style="font-family: Times;"><span style="background-color: white;">If you mount unit name and mount point path are different you'll hit below error.</span></span></div>
<div style="widows: 1;">
<span style="font-family: Times;"><span style="background-color: white;"><br /></span></span></div>
<div style="widows: 1;">
<span style="font-family: Courier New, Courier, monospace;">storage.mount: Where= setting doesn't match unit name. Refusing.</span></div>
<div>
<span style="background-color: white; font-family: Times; line-height: normal; widows: 1;"><br /></span></div>
<div style="widows: 1;">
<span style="font-family: Times;"><span style="background-color: white;">so be cautions while creating mount units.</span></span></div>
</div>
<div style="widows: 1;">
<span style="font-family: Times;"><span style="background-color: white;"><br /></span></span></div>
<div style="widows: 1;">
<span style="font-family: Times;"><span style="background-color: white;">gil ...</span></span></div>
</div>
Subbarao Ganeshnahttp://www.blogger.com/profile/01855743078913014384noreply@blogger.com0tag:blogger.com,1999:blog-2475157072499844894.post-30135553539949486932016-03-12T18:55:00.001+05:302016-03-12T18:55:51.045+05:30Sed error, sed: -e expression #1, char 91: unterminated `s' command<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
I was modifying a file using sed, all went well except a line, similar lines were ok but the one line.<br />
<br />
i did lot of changes to sed but no use it keeps yelling at me<br />
<br />
<b><span style="font-family: Courier New, Courier, monospace;">sed: -e expression #1, char 91: unterminated `s' command</span></b><br />
<b><span style="font-family: Courier New, Courier, monospace;"><br /></span></b>
Here is my piece of code:<br />
<br />
<span style="font-family: Courier New, Courier, monospace;">VAR=$(FUNC string)</span><br />
<span style="font-family: Courier New, Courier, monospace;">sed -i "s/^Name .*.*/Name $VAR/" /etc/file.conf</span><br />
<div>
<br /></div>
<div>
Spent lot of time and what i found finally was, usually sed uses "s" as a separator, here the string i was supplying to function FUNC has a letter "s", in fact "VAR" doesn't have anything "s" in it.</div>
<div>
Truth is while substituting sed sees letter "s" in the string i was supplying to the function as a separator and throws an error.</div>
<div>
<br /></div>
<div>
So i used fuction call as variable here to get what i want so to solve the issue.</div>
<div>
<br /></div>
<div>
<span style="font-family: 'Courier New', Courier, monospace;">sed -i "s/^Name .*.*/Name </span><span style="font-family: 'Courier New', Courier, monospace;">$(FUNC string)</span><span style="font-family: 'Courier New', Courier, monospace;">/" /etc/file.conf</span></div>
<div>
<br /></div>
<div>
Source:</div>
<div>
<a href="http://unix.stackexchange.com/questions/75310/why-is-sed-giving-me-an-error-about-an-unterminated-s">http://unix.stackexchange.com/questions/75310/why-is-sed-giving-me-an-error-about-an-unterminated-s</a></div>
<br />
gil...</div>
Subbarao Ganeshnahttp://www.blogger.com/profile/01855743078913014384noreply@blogger.com0tag:blogger.com,1999:blog-2475157072499844894.post-85494778029923255712015-09-18T18:04:00.001+05:302015-09-18T18:11:56.469+05:30Customize or remove X-Powered-By response header for your node js App.<div dir="ltr" style="text-align: left;" trbidi="on">
Are you using Express with node js and want to get rid of "X-Powered-By" response header or you want to replace it with you domain name ???<br />
<br />
all you need to do is just write a simple middleware. First we'll see how to remove it and then how to customize.<br />
<br />
add this line of code to your app.js.<br />
<br />
<pre style="background-color: #2b2b2b; color: #a9b7c6; font-family: 'Menlo'; font-size: 10.0pt;"><span style="color: grey;">// x-powered by ionos</span><span style="color: grey;">
</span><span style="background-color: #344134;">app</span>.<span style="color: #ffc66d;">disable</span>(<span style="color: #6a8759;">'x-powered-by'</span>)<span style="color: #cc7832;">; </span><span style="color: grey;">//to disable</span></pre>
<br />
to modify you have to write a simple middle ware just like this.<br />
<br />
<pre style="background-color: #2b2b2b; color: #a9b7c6; font-family: 'Menlo'; font-size: 10.0pt;"><span style="color: grey;">// x-powered by </span><span style="color: grey;">
</span>app.<span style="color: #ffc66d;">use</span>(<span style="color: #cc7832; font-weight: bold;">function </span>(req<span style="color: #cc7832;">, </span>res<span style="color: #cc7832;">, </span>next) {
res.<span style="color: #ffc66d;">header</span>(<span style="color: #6a8759;">'X-powered-by'</span><span style="color: #cc7832;">, </span><span style="color: #6a8759;">'geekinlinux'</span>)
next()<span style="color: #cc7832;">;</span>})<span style="color: #cc7832;">;</span></pre>
<br />
now try restarting node js service and refresh your webpage to see the changes.<br />
<br />
gil...</div>
Gilhttp://www.blogger.com/profile/13054047395328845300noreply@blogger.com0tag:blogger.com,1999:blog-2475157072499844894.post-90466799232455283242015-09-18T03:01:00.001+05:302015-09-18T03:01:33.242+05:30how to print stdout as stderr<div dir="ltr" style="text-align: left;" trbidi="on">
<div dir="ltr" style="text-align: left;" trbidi="on">
we use different file discriptors like, 2> , 2>&1 etc ... to capture stdout, stderr, but how to generate or print stderr. I was working with some nodejs project and i need to some msg as an error, but my bash script on the server prints msg as stdout which is why node js can't print, so i have to print my msg as stderr.<br />
<br />
let's see how to do it using these discrptors.</div>
<pre br="“”" class="““brush:bash,nolinenums;””">>&2 echo ‘my message'
</pre>
i put ">&2" infront of my message which i want to print as stderr. So it worked for me.<br />
<br />
<br /></div>
Gilhttp://www.blogger.com/profile/13054047395328845300noreply@blogger.com0tag:blogger.com,1999:blog-2475157072499844894.post-31455720957398887472015-08-22T02:54:00.001+05:302015-08-22T02:54:48.549+05:30Run commands on login, ubuntu<div dir="ltr" style="text-align: left;" trbidi="on">
i was trying to source a file on login, so i have to execute "source my filename" which is a bash command. I tried putting this command in ".bash_login" and ".profile" but didn't work. After spending some time i came to know that it bash looks for ".bashrc", ".profile", ".bash_login" in an order and ignores other files if it found any of the file, which means if ".bashrc" present on the machine other other files will be ignored and won't be working.<br />
<br />
So i put my command in ".bashrc" in the bottom of the file. It worked like a charm. I could have put all my 10 export commands into ".bashrc" instead of using separate file with export commands but the reason was those are not permanent and i want to maintain separate file only for these env variables.<br />
<br />
great no worries. i don't have to mess with ".bashrc" by flooding with all my env variables.<br />
<br />
gil ...</div>
Gilhttp://www.blogger.com/profile/13054047395328845300noreply@blogger.com0tag:blogger.com,1999:blog-2475157072499844894.post-86155679988852612732015-08-22T02:43:00.004+05:302015-08-22T02:44:12.382+05:30openstack console unable to resolve the server's dns address. Unable to connect to instance console<div dir="ltr" style="text-align: left;" trbidi="on">
<div dir="ltr" style="text-align: left;" trbidi="on">
During the openstack installation first basic setup is to create hostname entries for controller, network and compute nodes. When you create an instance on your openstack and using openstack dashboard and try to connect newly created instance via console and you hit this error.<br />
<div>
<br /></div>
<div>
Reason is your openstack machines running on different machine and you are accessing dashboard on different machine when you don't have hostname entry for compute node, i mean you can ping your compute node via ip but not hostname(unless you have dns name, if you have that you wouldn't have hit this error).</div>
<div>
<br /></div>
<div>
Now observe below picture, i have create one instance and at console tab.</div>
<div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiBo3SsANhCQYLFs3OeJmwB4PP9H5KZksExQte377Pbo3i721VSHpyHP1jmrpy63Sjb2wPcEEWEyH7r7l9qWelwMZqJfcw4-MhVdFgYpdrau06lhynfyiv1y080-FQD8m9OD3VBJRyDMBs/s1600/resolution+problem.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="228" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiBo3SsANhCQYLFs3OeJmwB4PP9H5KZksExQte377Pbo3i721VSHpyHP1jmrpy63Sjb2wPcEEWEyH7r7l9qWelwMZqJfcw4-MhVdFgYpdrau06lhynfyiv1y080-FQD8m9OD3VBJRyDMBs/s400/resolution+problem.png" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
URL is 192.168.56.10 my compute nodes address, running some where in my lan, but horizon is trying to access console of the instance using hostname you can see url at the backend, if you want to see it, click on "Click here to show only console" link which i highlighted, then you'll come know what was the issue. Check this screen shot.</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEirQYK0YTMRJT_eOEljlEGwZRy80M7kAbbJMM8Jm28ia8yJAa08JknqEnJK40Ie9mMX4DBOh_mZjPxRw2KDjfgV8BLbRcLdUXa3M0NYm_g6_L2oIsCY5v_BwcEWvyIJ-tuQ1EYjdByD-sA/s1600/resolution+vnc.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="183" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEirQYK0YTMRJT_eOEljlEGwZRy80M7kAbbJMM8Jm28ia8yJAa08JknqEnJK40Ie9mMX4DBOh_mZjPxRw2KDjfgV8BLbRcLdUXa3M0NYm_g6_L2oIsCY5v_BwcEWvyIJ-tuQ1EYjdByD-sA/s400/resolution+vnc.png" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
see ??? this url says "controller", which is my controller node. </div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<b>Quick Fix:</b></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
To resolve this quickly replace "controller" with you controller node's ip, then you'll see instance's console.</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
Note: Dont remove any colun.</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<b>Permanent Fix:</b></div>
<div class="separator" style="clear: both; text-align: left;">
<b><br /></b></div>
<div class="separator" style="clear: both; text-align: left;">
Edit nova.conf on compute node and replace controller's hostname with paddles at vnc connection.</div>
<div class="separator" style="clear: both; text-align: left;">
Open /etc/nova/nova.conf and search for </div>
<div class="separator" style="clear: both; text-align: left;">
</div>
<pre br="“”" class="““brush:bash,nolinenums;””">novncproxy_base_url = http://controller:6080/vnc_auto.html
</pre>
and modify it to
</div>
<pre br="“”" class="““brush:bash,nolinenums;””">novncproxy_base_url = http://192.168.56.10:6080/vnc_auto.html
</pre>
Note: 192.168.56.10 is my controller's ip address and you use your controller's ip.<br />
<br />
Finally restart nova compute service<br />
<pre br="“”" class="““brush:bash,nolinenums;””">root@compute1:~# service nova-compute restart
nova-compute stop/waiting
nova-compute start/running, process 12094
root@compute1:~#
</pre>
now go to dashboard refresh it and try to access your instance's console. Now you should see console url with ip address instead of hostname.<br />
<br />
gil ...</div>
</div>
Gilhttp://www.blogger.com/profile/13054047395328845300noreply@blogger.com0tag:blogger.com,1999:blog-2475157072499844894.post-65853612675747134542015-08-21T02:08:00.001+05:302015-08-21T02:08:50.924+05:30Delete duplicate entries for service-list and agent-list after changing hostnames<div dir="ltr" style="text-align: left;" trbidi="on">
<div dir="ltr" style="text-align: left;" trbidi="on">
Every entity in openstack maintains db in MySQL, which is the first thing to do before installing any component during openstack installation. If you change hostname for any node after installation what happens is it will show both new and old entries.<br />
<div>
<br /></div>
<div>
For instance take a look at neutron agent-list on my network node.</div>
</div>
<pre br="“”" class="““brush:bash,nolinenums;””">root@stack:/var/log/nova# neutron agent-list
+--------------------------------------+--------------------+----------+-------+----------------+---------------------------+
| id | agent_type | host | alive | admin_state_up | binary |
+--------------------------------------+--------------------+----------+-------+----------------+---------------------------+
| 03588302-7014-41a9-a1a7-b22dba6c8c4b | Open vSwitch agent | ubuntu | xxx | True | neutron-openvswitch-agent |
| 2a7c7776-3e53-4c38-8663-a5ff2e337eed | Metadata agent | ubuntu | xxx | True | neutron-metadata-agent |
| 66e550af-af58-4d96-a035-00f3bc2057c7 | DHCP agent | network | :-) | True | neutron-dhcp-agent |
| 732e5f52-35ea-4ba8-be8b-c6b26f10d5df | Metadata agent | network | :-) | True | neutron-metadata-agent |
| 759d8e43-a2f8-4305-bae5-85793ac1b46a | Open vSwitch agent | compute1 | :-) | True | neutron-openvswitch-agent |
| 964ae8a8-4e5e-45f1-893f-4dec689e7e03 | L3 agent | network | :-) | True | neutron-l3-agent |
| a2d42630-3cdd-41d0-ac0e-32e97b599f6c | DHCP agent | ubuntu | xxx | True | neutron-dhcp-agent |
| df4d1f59-8f68-4a0c-9288-61922b77c6dd | Open vSwitch agent | network | :-) | True | neutron-openvswitch-agent |
| e4eddde1-0bb1-44d5-b9d9-6ed6882dd46d | L3 agent | ubuntu | xxx | True | neutron-l3-agent |
+--------------------------------------+--------------------+----------+-------+----------------+---------------------------+
</pre>
if you observe “host” and “alive” column, ubuntu host is not reachable, so “alive” column shows “xxx”. As a matter of fact it there is no host with name “ubuntu”. It was old name for network node. After changing hostname it is connected to controller and agent-list shows all my agent services and status as “:)” which mean fine.
//
But old entries looks ugly and difficult during debug. I want to get rid of them so i only way is to delete entries for host ubuntu in MySQL.
//
If you are familiar with MySQL with command line, you can delete them as i show here, other wise you can setup phpmyadmin which is a gui management tool for MySQL and easy to do stuff like this.
//
Let’s try command line for now.
//
<br />
<pre br="“”" class="““brush:bash,nolinenums;””">root@stack:~# mysql -u root -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 373
Server version: 5.5.44-MariaDB-1ubuntu0.14.04.1 (Ubuntu)
Copyright (c) 2000, 2015, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> use neutron
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
MariaDB [neutron]> DELETE FROM agents WHERE host='ubuntu';
Query OK, 4 rows affected (0.00 sec)
MariaDB [neutron]> exit
Bye
</pre>
you can follow the same procedure for other entities in case they have db.<br />
Note: Becareful while deleting entries via MySQL command line.<br />
<br />
gil ...
</div>
Gilhttp://www.blogger.com/profile/13054047395328845300noreply@blogger.com0tag:blogger.com,1999:blog-2475157072499844894.post-89938018813936264102015-08-21T01:40:00.000+05:302015-08-21T01:44:29.411+05:30neutron agent-list is showing empty ; OpenStack<div dir="ltr" style="text-align: left;" trbidi="on">
<div dir="ltr" style="text-align: left;" trbidi="on">
Neutron agent-list shows agents status running on compute and network nodes. If you run this command to check agent list after your OpenStack and it returns empty then there is some thing wrong with configuration at compute or network nodes.<br />
<div>
<br /></div>
<div>
you better check logs first, i hit this error on network node so i'll concentrate on network node only, so as we are discussing, logged into my network node and started monitoring my neutron and tailed all agent logs.</div>
</div>
<pre br="“”" class="““brush:bash,nolinenums;””">root@network:~# cd /var/log/neutron/
root@network:/var/log/neutron# tail -f *agent*
</pre>
the moment i hit enter i was flooded with logs from l3-agent.log.
<br />
<pre br="“”" class="““brush:bash,nolinenums;””">==> l3-agent.log <==
2015-08-20 23:47:53.338 18029 TRACE neutron.openstack.common.service File "/usr/lib/python2.7/dist-packages/neutron/openstack/common/service.py", line 184, in _wait_for_exit_or_signal
2015-08-20 23:47:53.338 18029 TRACE neutron.openstack.common.service rpc.cleanup()
2015-08-20 23:47:53.338 18029 TRACE neutron.openstack.common.service File "/usr/lib/python2.7/dist-packages/neutron/openstack/common/rpc/__
init__.py", line 208, in cleanup
2015-08-20 23:47:53.338 18029 TRACE neutron.openstack.common.service return _get_impl().cleanup()
2015-08-20 23:47:53.338 18029 TRACE neutron.openstack.common.service File "/usr/lib/python2.7/dist-packages/neutron/openstack/common/rpc/__
init__.py", line 274, in _get_impl
2015-08-20 23:47:53.338 18029 TRACE neutron.openstack.common.service _RPCIMPL = importutils.import_module(impl)
2015-08-20 23:47:53.338 18029 TRACE neutron.openstack.common.service File "/usr/lib/python2.7/dist-packages/neutron/openstack/common/import
utils.py", line 57, in import_module
2015-08-20 23:47:53.338 18029 TRACE neutron.openstack.common.service __import__(import_str)
2015-08-20 23:47:53.338 18029 TRACE neutron.openstack.common.service ImportError: No module named rabbit
2015-08-20 23:47:53.338 18029 TRACE neutron.openstack.common.service
</pre>
all it shouting at me was that there was no module called "rabbit"
so i started reading a little about rabbitMQ then i found <a href="http://docs.openstack.org/juno/config-reference/content/networking-configuring-rpc.html" target="_blank">a huge reference guide from openstack</a>.
It explains configuring RPC messaging system using different message brokers like RabbitMQ, Qpid, and ZeroMQ.<br />
<br />
It shows how to configure “rpc_backend” in neutron.conf file. Openstack installation guide says "rpc_backend = rabbit” but this guide says “rpc_backend=neutron.openstack.common.rpc.impl_kombu” which is correct and works fine.<br />
<br />
so i modified /etc/neutron/neutron.conf as mention in this doc and the restart neutron-l3-agent since it was the only one failing.
take a look at the l3-agent.log after restart
<br />
<pre br="“”" class="““brush:bash,nolinenums;””">root@network:/var/log/neutron# tail -f l3-agent.log
==> l3-agent.log <==
2015-08-21 01:30:50.236 10786 INFO neutron.openstack.common.rpc.common [req-9b23691a-cbce-41ab-a98e-686fb0473475 None] Connected to AMQP server on controller:5672
2015-08-21 01:30:50.238 10786 INFO neutron.openstack.common.rpc.common [req-9b23691a-cbce-41ab-a98e-686fb0473475 None] Connected to AMQP server on controller:5672
2015-08-21 01:30:50.265 10786 INFO neutron.openstack.common.rpc.common [req-9b23691a-cbce-41ab-a98e-686fb0473475 None] Connected to AMQP server on controller:5672
2015-08-21 01:30:50.282 10786 INFO neutron.agent.l3_agent [req-9b23691a-cbce-41ab-a98e-686fb0473475 None] L3 agent started
2015-08-21 01:31:01.903 10786 INFO neutron.openstack.common.service [req-9b23691a-cbce-41ab-a98e-686fb0473475 None] Caught SIGTERM, exiting
2015-08-21 01:31:02.721 10835 INFO neutron.common.config [-] Logging enabled!
2015-08-21 01:31:02.843 10835 INFO neutron.openstack.common.rpc.common [req-7c918e45-aad3-4a20-b303-0d3a8964be97 None] Connected to AMQP server on controller:5672
2015-08-21 01:31:02.846 10835 INFO neutron.openstack.common.rpc.common [req-7c918e45-aad3-4a20-b303-0d3a8964be97 None] Connected to AMQP server on controller:5672
2015-08-21 01:31:02.868 10835 INFO neutron.openstack.common.rpc.common [req-7c918e45-aad3-4a20-b303-0d3a8964be97 None] Connected to AMQP server on controller:5672
2015-08-21 01:31:02.872 10835 INFO neutron.agent.l3_agent [req-7c918e45-aad3-4a20-b303-0d3a8964be97 None] L3 agent started
</pre>
wonderful it is connected to rabbitMQ server successfully.<br />
<br />
gil ...</div>
Gilhttp://www.blogger.com/profile/13054047395328845300noreply@blogger.com1tag:blogger.com,1999:blog-2475157072499844894.post-25916609613140098762015-08-20T23:09:00.003+05:302015-08-20T23:10:16.047+05:30Enable RabbitMQ Management, easiest way to manage via Web Management Console.<div dir="ltr" style="text-align: left;" trbidi="on">
<div dir="ltr" style="text-align: left;" trbidi="on">
<div dir="ltr" style="text-align: left;" trbidi="on">
RabbitMQ has few useful plugins built in, one of them simple Web Management Console where you can monitor all the connections, queues etc ... which is a cool thing. <br />
<br />
Since it's is builtin plugin it doesn't need any installation or setup, all you need is just to enable particular plug in via single command. </div>
<pre br="“”" class="““brush:bash,nolinenums;””">root@stack:~# rabbitmq-plugins enable rabbitmq_management
</pre>
to list all the available rabbitMQ plugins and their status, "rabbitmq-plugins list" is useful. Let's use it.
<br />
<pre br="“”" class="““brush:bash,nolinenums;””">root@stack:~# rabbitmq-plugins list
[e] amqp_client 3.2.4
[ ] cowboy 0.5.0-rmq3.2.4-git4b93c2d
[ ] eldap 3.2.4-gite309de4
[e] mochiweb 2.7.0-rmq3.2.4-git680dba8
[ ] rabbitmq_amqp1_0 3.2.4
[ ] rabbitmq_auth_backend_ldap 3.2.4
[ ] rabbitmq_auth_mechanism_ssl 3.2.4
[ ] rabbitmq_consistent_hash_exchange 3.2.4
[ ] rabbitmq_federation 3.2.4
[ ] rabbitmq_federation_management 3.2.4
[ ] rabbitmq_jsonrpc 3.2.4
[ ] rabbitmq_jsonrpc_channel 3.2.4
[ ] rabbitmq_jsonrpc_channel_examples 3.2.4
[E] rabbitmq_management 3.2.4
[e] rabbitmq_management_agent 3.2.4
[ ] rabbitmq_management_visualiser 3.2.4
[ ] rabbitmq_mqtt 3.2.4
[ ] rabbitmq_shovel 3.2.4
[ ] rabbitmq_shovel_management 3.2.4
[ ] rabbitmq_stomp 3.2.4
[ ] rabbitmq_tracing 3.2.4
[e] rabbitmq_web_dispatch 3.2.4
[ ] rabbitmq_web_stomp 3.2.4
[ ] rabbitmq_web_stomp_examples 3.2.4
[ ] rfc4627_jsonrpc 3.2.4-git5e67120
[ ] sockjs 0.3.4-rmq3.2.4-git3132eb9
[e] webmachine 1.10.3-rmq3.2.4-gite9359c7
</pre>
</div>
see you it has quite more plugins in built, you can also see status of the plugin.
"[ ]" means not enabled
"[e]" means enabled by default by rabbitMQ.
"[E]" means Explicitly enabled, which means by you.
rabbitMQ writes names of Explicitly enabled plugins to a "/etc/rabbitmq/enabled_plugins"
<br />
<pre br="“”" class="““brush:bash,nolinenums;””">root@stack:~# cat /etc/rabbitmq/enabled_plugins
[rabbitmq_management].
</pre>
Note: Don't try to modify manually it unless you are confident of what you are doing.<br />
<br />
Try <a href="https://www.rabbitmq.com/man/rabbitmq-plugins.1.man.html" target="_blank">rabbitMQ man page</a> to explore more help and info.<br />
<a href="https://www.blogger.com/"></a><span id="goog_1427742896"></span><span id="goog_1427742897"></span><br />
<br />
gil ...</div>
Gilhttp://www.blogger.com/profile/13054047395328845300noreply@blogger.com0tag:blogger.com,1999:blog-2475157072499844894.post-26172735019127840772015-08-11T19:09:00.002+05:302015-08-11T19:09:47.631+05:30No support for ALTER of constraints in SQLite dialect, OpenStack<div dir="ltr" style="text-align: left;" trbidi="on">
<div dir="ltr" style="text-align: left;" trbidi="on">
You may hit this error while populating database for any of the service for OpenStack. Below is the error output thrown while populating database for neutron service on OpenStack (Juno). </div>
<pre br="“”" class="““brush:bash,nolinenums;””">root@stack:~# /bin/sh -c "neutron-db-manage --config-file /etc/neutron/neutron.conf \
> --config-file /etc/neutron/plugins/ml2/ml2_conf.ini upgrade juno" neutron
INFO [alembic.migration] Context impl SQLiteImpl.
INFO [alembic.migration] Will assume non-transactional DDL.
INFO [alembic.migration] Running upgrade None -> havana, havana_initial
INFO [alembic.migration] Running upgrade havana -> e197124d4b9, add unique constraint to members
Traceback (most recent call last):
File "/usr/bin/neutron-db-manage", line 10, in <module>
sys.exit(main())
File "/usr/lib/python2.7/dist-packages/neutron/db/migration/cli.py", line 173, in main
CONF.command.func(config, CONF.command.name)
File "/usr/lib/python2.7/dist-packages/neutron/db/migration/cli.py", line 83, in do_upgrade_downgrade
do_alembic_command(config, cmd, revision, sql=CONF.command.sql)
File "/usr/lib/python2.7/dist-packages/neutron/db/migration/cli.py", line 61, in do_alembic_command
getattr(alembic_command, cmd)(config, *args, **kwargs)
File "/usr/lib/python2.7/dist-packages/alembic/command.py", line 125, in upgrade
script.run_env()
File "/usr/lib/python2.7/dist-packages/alembic/script.py", line 203, in run_env
util.load_python_file(self.dir, 'env.py')
File "/usr/lib/python2.7/dist-packages/alembic/util.py", line 212, in load_python_file
module = load_module_py(module_id, path)
File "/usr/lib/python2.7/dist-packages/alembic/compat.py", line 58, in load_module_py
mod = imp.load_source(module_id, path, fp)
File "/usr/lib/python2.7/dist-packages/neutron/db/migration/alembic_migrations/env.py", line 108, in <module>
run_migrations_online()
File "/usr/lib/python2.7/dist-packages/neutron/db/migration/alembic_migrations/env.py", line 100, in run_migrations_online
context.run_migrations()
File "<string>", line 7, in run_migrations
File "/usr/lib/python2.7/dist-packages/alembic/environment.py", line 688, in run_migrations
self.get_context().run_migrations(**kw)
File "/usr/lib/python2.7/dist-packages/alembic/migration.py", line 258, in run_migrations
change(**kw)
File "/usr/lib/python2.7/dist-packages/neutron/db/migration/alembic_migrations/versions/e197124d4b9_add_unique_constrain.py", line 42, in upgrade
local_cols=['pool_id', 'address', 'protocol_port']
File "<string>", line 7, in create_unique_constraint
File "/usr/lib/python2.7/dist-packages/alembic/operations.py", line 621, in create_unique_constraint
schema=schema, **kw)
File "/usr/lib/python2.7/dist-packages/alembic/ddl/sqlite.py", line 21, in add_constraint
"No support for ALTER of constraints in SQLite dialect")
NotImplementedError: No support for ALTER of constraints in SQLite dialect
</string></string></module></module></pre>
This error is because config file has two database connections, one is for MySQL and other is for Sqlite, since i'm using mysql and i forgot to comment Sqlite, i hit this error.<br />
<br />
All you need to do to fix this is comment/remove sqlite connection from /etc/neutron/neutron.conf and then populate it.<br />
<br />
gil ...</div>
Gilhttp://www.blogger.com/profile/13054047395328845300noreply@blogger.com1