From 28fc8accc64801859eedffd41b61fc2ec526b393 Mon Sep 17 00:00:00 2001 From: Rorist Date: Tue, 17 Jun 2014 14:48:16 +0200 Subject: [PATCH 01/11] dependencies --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 571d9df..eb316c9 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ Installation * Install dependencies sudo pip install ipaddr - sudo apt-get install python-novaclient + sudo apt-get install python-novaclient python-neutronclient * Download openrc file to your computer ** Go to Access & Security > API Access From 5b4b405f04dde27c5fb438c0f2209d95d398595d Mon Sep 17 00:00:00 2001 From: Rorist Date: Tue, 17 Jun 2014 15:12:13 +0200 Subject: [PATCH 02/11] More deps --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index eb316c9..74dec98 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ Installation * Install dependencies sudo pip install ipaddr - sudo apt-get install python-novaclient python-neutronclient + sudo apt-get install python-novaclient python-neutronclient python-keystoneclient * Download openrc file to your computer ** Go to Access & Security > API Access From d171d427820f77112bed6d7eec452ef507160666 Mon Sep 17 00:00:00 2001 From: Rorist Date: Tue, 17 Jun 2014 15:59:58 +0200 Subject: [PATCH 03/11] catch pickle error when theres no openrc file --- cloud | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/cloud b/cloud index 25bc1a0..504b9a9 100755 --- a/cloud +++ b/cloud @@ -33,12 +33,15 @@ CLEANUPS = [] def setup_environment(): if not 'OS_PASSWORD' in os.environ: - source = '. ~/.openrc' - dump = '/usr/bin/python -c "import os,pickle;print pickle.dumps(os.environ)"' - penv = os.popen('%s && %s' %(source,dump)) - env = pickle.loads(penv.read()) - os.environ = env - + try: + source = '. ~/.openrc' + dump = '/usr/bin/python -c "import os,pickle;print pickle.dumps(os.environ)"' + penv = os.popen('%s && %s' %(source,dump)) + env = pickle.loads(penv.read()) + os.environ = env + except: + pass + if not 'OS_PASSWORD' in os.environ: raise Exception('No Openstack environnment variables found!') From e9872e2d5572c20dd14ce90a3c314385f500edae Mon Sep 17 00:00:00 2001 From: Rorist Date: Tue, 17 Jun 2014 16:00:16 +0200 Subject: [PATCH 04/11] Remove trailing spaces --- cloud | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/cloud b/cloud index 504b9a9..cb9023d 100755 --- a/cloud +++ b/cloud @@ -132,7 +132,7 @@ def get_bdm(nt, args, image): def main(args): logging.debug("Connecting to Openstack cloud at %s" % (os.environ['OS_AUTH_URL'])) - + try: nt = nova_client.Client(os.environ['OS_USERNAME'], os.environ['OS_PASSWORD'], os.environ['OS_TENANT_NAME'], os.environ['OS_AUTH_URL'], service_type="compute") @@ -148,7 +148,7 @@ def main(args): except IndexError: logging.error("Image %s not found!" % args.image.lower()) sys.exit(1) - + flavor = get_flavor(nt, args.flavor) nics = get_nics(keystone, args.net) bdm, image = get_bdm(nt, args, image) @@ -164,7 +164,7 @@ def main(args): CLEANUPS.append(instance) logging.debug("Instance %s" % instance.id) - + while True: instance = nt.servers.get(instance.id) logging.debug(instance.status) @@ -186,9 +186,9 @@ def main(args): except novaclient.exceptions.NotFound: if args.secgroup == 'all': secgroup = nt.security_groups.create('all', 'The world famous any any rule') - nt.security_group_rules.create(secgroup.id, 'icmp', '-1', '-1', '0.0.0.0/0') - nt.security_group_rules.create(secgroup.id, 'udp', '1', '65535', '0.0.0.0/0') - nt.security_group_rules.create(secgroup.id, 'tcp', '1', '65535', '0.0.0.0/0') + nt.security_group_rules.create(secgroup.id, 'icmp', '-1', '-1', '0.0.0.0/0') + nt.security_group_rules.create(secgroup.id, 'udp', '1', '65535', '0.0.0.0/0') + nt.security_group_rules.create(secgroup.id, 'tcp', '1', '65535', '0.0.0.0/0') instance.add_security_group(secgroup.id) # API not supported by rackspace cloud From cf2a53bc318e34421e04eb84eb19391df512996c Mon Sep 17 00:00:00 2001 From: Aubort Jean-Baptiste Date: Mon, 23 Jun 2014 14:02:39 +0200 Subject: [PATCH 05/11] neutronclient is not in debian stable so use pip version --- README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 74dec98..ad4442a 100644 --- a/README.md +++ b/README.md @@ -8,8 +8,10 @@ Installation * Install dependencies - sudo pip install ipaddr - sudo apt-get install python-novaclient python-neutronclient python-keystoneclient +``` +sudo pip install ipaddr python-neutronclient +sudo apt-get install python-novaclient python-keystoneclient +``` * Download openrc file to your computer ** Go to Access & Security > API Access From 046d96bd26c5f57cc76f442a9fc194ed32d69961 Mon Sep 17 00:00:00 2001 From: Aubort Jean-Baptiste Date: Mon, 23 Jun 2014 14:02:45 +0200 Subject: [PATCH 06/11] README cosmetic --- README.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index ad4442a..0904f19 100644 --- a/README.md +++ b/README.md @@ -16,15 +16,17 @@ sudo apt-get install python-novaclient python-keystoneclient * Download openrc file to your computer ** Go to Access & Security > API Access ** Click Download OpenStack RC File -** Put the openrc file in ~/openrc +** Put the openrc file in ```~/openrc``` Usage ----- -* Source openrc file, from your .bashrc for instance +* Source openrc file, from your ```~/.bashrc``` for instance - echo '. ~/openrc' >> ~/.bashrc +``` +echo '. ~/openrc' >> ~/.bashrc +``` * Run the script without argument to launch a VM ! -* ./cloud -h # for help +* ```./cloud -h``` # for help From deb684781f8255944ec7a45a05516462f083a856 Mon Sep 17 00:00:00 2001 From: Aubort Jean-Baptiste Date: Mon, 23 Jun 2014 14:04:17 +0200 Subject: [PATCH 07/11] README nested list --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 0904f19..02e0f33 100644 --- a/README.md +++ b/README.md @@ -14,9 +14,9 @@ sudo apt-get install python-novaclient python-keystoneclient ``` * Download openrc file to your computer -** Go to Access & Security > API Access -** Click Download OpenStack RC File -** Put the openrc file in ```~/openrc``` + * Go to Access & Security > API Access + * Click Download OpenStack RC File + * Put the openrc file in ```~/openrc``` Usage ----- From 1a4e1b36bb0caf50601d5a3d594216d46b8b5854 Mon Sep 17 00:00:00 2001 From: Aubort Jean-Baptiste Date: Mon, 23 Jun 2014 15:36:19 +0200 Subject: [PATCH 08/11] Use pip requirement file --- README.md | 3 +-- requirements.txt | 4 ++++ 2 files changed, 5 insertions(+), 2 deletions(-) create mode 100644 requirements.txt diff --git a/README.md b/README.md index 02e0f33..01fcdf9 100644 --- a/README.md +++ b/README.md @@ -9,8 +9,7 @@ Installation * Install dependencies ``` -sudo pip install ipaddr python-neutronclient -sudo apt-get install python-novaclient python-keystoneclient +sudo pip install -r requirements.txt ``` * Download openrc file to your computer diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..cfb9d28 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,4 @@ +ipAddr +python-novaclient +python-neutronclient +python-keystoneclient From 91daf18965c1230dbd0846fd455ece6dccd4f805 Mon Sep 17 00:00:00 2001 From: Aubort Jean-Baptiste Date: Mon, 23 Jun 2014 15:58:31 +0200 Subject: [PATCH 09/11] Use openstack username instead of operating system one... --- cloud | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cloud b/cloud index cb9023d..688b51f 100755 --- a/cloud +++ b/cloud @@ -25,7 +25,7 @@ from keystoneclient.v2_0 import client as keystone_client IMAGE = 'trusty-server-cloudimg-amd64' FLAVOR = 'm1.small' -KEY_NAME = os.environ['USER'] +KEY_NAME = os.environ['OS_USERNAME'] NAME = 'cloud-script-disposable-vm' KNOWN_HOSTS = tempfile.NamedTemporaryFile() @@ -239,7 +239,7 @@ if __name__ == '__main__': parser.add_argument('--permanent', '-p', action='store_true') parser.add_argument('--root', '-r', action='store_true') parser.add_argument('--command', '-c') - parser.add_argument('--key-name', '-k', default=KEY_NAME) + parser.add_argument('--key-name', '-k', default=KEY_NAME, help='SSH key pair username (created with nova keypair or from the OS web interface)') parser.add_argument('--volume', '-v', action='store_true') parser.add_argument('--volume-size', '-s', type=int, default=10) parser.add_argument('--user', '-u', default='ubuntu') From 11edb96a65fbf85d8e11939ba0d219bcc7747aaf Mon Sep 17 00:00:00 2001 From: Aubort Jean-Baptiste Date: Mon, 23 Jun 2014 16:11:10 +0200 Subject: [PATCH 10/11] Ignore vim swap file --- .gitignore | 1 + 1 file changed, 1 insertion(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1377554 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*.swp From 6a511811a11f5e3eb6023288987b2b25a2997434 Mon Sep 17 00:00:00 2001 From: Rorist Date: Fri, 16 Oct 2015 10:46:20 +0200 Subject: [PATCH 11/11] note on novaclient --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index 01fcdf9..a67f5a6 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,13 @@ Installation sudo pip install -r requirements.txt ``` +novaclient in pip doesn't work atm, better use the repo one, + +``` +sudo pip uninstall python-novaclient +sudo apt-get install python-novaclient +``` + * Download openrc file to your computer * Go to Access & Security > API Access * Click Download OpenStack RC File