quinta-feira, 29 de outubro de 2015

Install AWSCLI on Mac OS X El Capitan (python error solution)

So you installed the new OS X El Capitan in your MacBook. Then you tried to install AWSCLI... and it did not worked, right?

Probably you got the following error message:

sudo -H pip2.7 install awscli
Collecting awscli
Installing collected packages: six, python-dateutil, docutils, botocore, awscli
 Found existing installation: six 1.4.1
   DEPRECATION: Uninstalling a distutils installed project (six) has been deprecated and will be removed in a future version. This is due to the fact that uninstalling a distutils project will only partially uninstall the project.
   Uninstalling six-1.4.1:
Traceback (most recent call last):
 File "/Library/Python/2.7/site-packages/pip/basecommand.py", line 211, in main
   status = self.run(options, args)
 File "/Library/Python/2.7/site-packages/pip/commands/install.py", line 311, in run
 File "/Library/Python/2.7/site-packages/pip/req/req_set.py", line 640, in install
 File "/Library/Python/2.7/site-packages/pip/req/req_install.py", line 716, in uninstall
 File "/Library/Python/2.7/site-packages/pip/req/req_uninstall.py", line 125, in remove
   renames(path, new_path)
 File "/Library/Python/2.7/site-packages/pip/utils/__init__.py", line 315, in renames
   shutil.move(old, new)
 File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 302, in move
   copy2(src, real_dst)
 File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 131, in copy2
   copystat(src, dst)
 File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 103, in copystat
   os.chflags(dst, st.st_flags)
OSError: [Errno 1] Operation not permitted: '/tmp/pip-Za5ewE-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/six-1.4.1-py2.7.egg-info'

How to fix it?

1) Install brew (if not installed):
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

2) Install xcode:
xcode-select --install

3) Reinstall python with brew:
brew reinstall python

4) Reinstall the failing package (in this case six-1.4.1):
sudo pip install -U six

5) And finally install the AWSCLI:
sudo -H pip install awscli

This fix worked for me perfectly and now I can start working with the awscli (see my other blogs to know how to setup the cli in your MAC).

terça-feira, 28 de julho de 2015

AWS: Resize Root EBS Volume - Linux Partition

The goal from this document is to be clear and help you as quick as possible to achieve your goal. Further recommended reading is provided in the end of this tutorial - I am considering you have basic knowledge in AWS Console.

  1. Expanding your EBS Volume: by default you can't extend an EBS volume attached to an instance. To do so you need to perform the following steps:
    1. Stop your instance (take care to verify if the Stop behavior is STOP and not TERMINATE - otherwise you will lose your instance).

    2. Create a snapshot from the volume you want to expand (this can take a while).

    3. Right click the snapshot and select "Create Volume" choose the size you want the disk to have (consider current space + increase needed => plan for future). Important here is to make sure that you are creating the new EBS volume in the same availability zone from your instance, otherwise you will not be able to attach the new volume to the instance.

    4. After Volume is ready:

      1. Detach the former volume from your instance (the one you are "increasing")

      2. Attach the new volume, make sure you type /dev/sda1 in the Device Name (if this is the root volume), otherwise your instance will not boot.

    5. Start the instance with the newly created expanded EBS volume. 

  2. Expanding your Linux Root partition [Tested on CentOS]: 

    1. When you type df -h you will see that the new space is not reclaimed. 
    2. Get the partition name from df -h and the volume name, for example, /dev/xvda1 mounted as / and /dev/xvda for your device.
    3. Run fdisk -l /dev/xvda to list the partitions, probably the data partition you want to expand is the last one (hope to be). This command will also show the size from /dev/xvda which must reflect your expanded disk size. 
    4. Take note from the Start and End sectors from your partitions, specially the one you want to extend. 
    5. Delete your partition (the one you want to extend - no data will be lost but remember, you have one snapshot and the original volume is untouched):
    6. fdisk /dev/xvda
      Command (m for help): d
      Selected partition 1

      Command (m for help): n

    7. Now you deleted your partition, time to recreate it. Usually keeping the defaults is OK, check the previously noted Start and End cylinders.   
    8. Command (m for help): n
      Command action
      e extended
      p primary partition (1-4)
      Partition number (1-4): 1
      First cylinder (1-634, default 1):
      Using default value 1
      Last cylinder or +size or +sizeM or +sizeK (1-634, default 634):
      Using default value 634
      Command (m for help): d

    9. If your partition had a "*" present in the Boot column, we have to add it with the command, change the partition number to your situation:
    10. Command (m for help): a
      Partition number (1-4): 1

    11. Now is time to write down the changes:
    12. Command (m for help): w
      The partition table has been altered!

    13. Reboot your instance. After reboot the partition will have the new space but it will not be allocated yet, so a df -h will still show the old values.

    14. After reboot, type the following command to extend your online partition to its full size (the size we gave with fdisk), here you will use the partition name, not the disk, so, instead of using /dev/xvda (our example) as you did for fdisk, here we use the partition number /dev/xvda1:
    15. resize2fs /dev/xvda1

  3. Additional Resources:
    1. http://possiblelossofprecision.net/?p=228
    2. http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ebs-expand-volume.html
    3. http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ebs-using-volumes.html
    4. https://www.howtoforge.com/linux_resizing_ext3_partitions

quinta-feira, 25 de junho de 2015

Setup AWS cli to access your account [for a Linux/Mac client]

This short recipe shows how to setup your Access Key to view, change and manage your AWS resources.

1) You need to get your access keys. When you create a new account you have the option to generate an Access Key to the new user on creation. Take in mind that after generation the key is displayed only ONCE. You CANNOT recover a secret key, for obvious security reasons.

Best practice hint: NEVER use the Access keys from the root account (the Mail you used to create your AWS account), create an IAM account to manage all AWS resources.

2) After you have your Access Key ID and Secret Acess Key we can move forward.

3) Here we will cover the most simple way to setup your credentials, for a detailed overview, please check the document link in the end of this tech recipe.

If you have only one account you may type only

$ aws configure
AWS Secret Access Key [None]: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
Default region name [None]: us-west-2
Default output format [None]: json
Replace the red options with your settings, the region you use the most and the output format, for the output we have 3 options: json, text or table, default is json.

You must specify the AWS Access Key ID, the Secret Access Key and the Region. For a list of regions and endpoints, please refer to this document: http://docs.aws.amazon.com/general/latest/gr/rande.html

If you have multiple AWS customers or IAM accounts you can define different profiles for each of these.
$ aws configure --profile TEST-ENVIRONMENT
AWS Secret Access Key [None]: je7MtGbClwBF/2Zp9Utk/h3yCo8nvbEXAMPLEKEY
Default region name [None]: us-east-1
Default output format [None]: text
4) Test if your configured account is working: And you are done! Now it is time to explore the AWS CLI documentation and see what you can do with it.
$ aws ec2 describe-volumes --profile TEST-ENVIRONMENT
5. Further reading:
http://docs.aws.amazon.com/cli/latest/userguide/tutorial-ec2-ubuntu.html#configure-cli-launch-ec2 http://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-set-up.html

terça-feira, 23 de junho de 2015

Setup AWSCLI on MacOS 10.9.5

A very short recipe how I just did it on my client:

1) Download Python: as I write the latest version is 3.4.3 -  https://www.python.org/downloads/release/python-343/

2) Install it (GUI installer);

3) Install pip [easy installer for Python tools (easier to setup awscli later)]:

$ sudo easy_install pip

4) Install awscli  with pip
$ sudo pip install awscli

5) Test it:

$ aws --version

aws-cli/1.7.35 Python/2.7.5 Darwin/13.4.0

And you are ready to setup your access to AWS. I will talk  about it in another article.

quinta-feira, 5 de fevereiro de 2015

VSphere Web Cli: change the default language

If you had like me, the experience to work for multinacional companies and have several customers in different countries, you could have the need to support systems on foreign languages.

Recently I had to support a vSphere environment in Germany, and I got confused with the huge names on Web Cli. Here's how you workaround the language issue:

Append the localization parameter to the URL used for accessing the web client:

Note: Languages supported are English, German, French, Japanese, Korean, and Chinese.

  • The default URL for the vSphere Web Client is:

  • To specify a language, append:

    • English: /?locale=en_US
    • German: /?locale=de_DE
    • French: /?locale=fr_FR
    • Japanese: /?locale=ja_JP
    • Korean: /?locale=ko_KR
    • Chinese: /?locale=zh_CN
  • For example, to display the vSphere Web Client in French, use:

Source: http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1016403