-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6703588
commit e100089
Showing
5 changed files
with
92 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
Overview | ||
======== | ||
This is a simple nova extension to demonstrate how to write extensions for | ||
nova. | ||
nova. The files included in this repo are designed to be 'dropped' into nova | ||
and python-novaclient. | ||
|
||
Installing | ||
========== | ||
Installing Server Component | ||
=========================== | ||
This is designed as a minimal base for a "core extension," meaning it is | ||
designed to be run from the nova source tree. To use it: | ||
|
||
|
@@ -15,7 +16,56 @@ designed to be run from the nova source tree. To use it: | |
|
||
cd /opt/stack/ | ||
git clone [email protected]:cloudbuilders/simple_nova_extension.git | ||
cp simple_nova_extension/nova/api/openstack/compute/contrib/cats.py nova/nova/api/openstack/compute/contrib/cats.py | ||
cp simple_nova_extension/nova/tests/api/openstack/compute/contrib/test_cats.py nova/nova/tests/api/openstack/compute/contrib/test_cats.py | ||
cp simple_nova_extension/nova/nova/api/openstack/compute/contrib/cats.py nova/nova/api/openstack/compute/contrib/cats.py | ||
cp simple_nova_extension/nova/nova/tests/api/openstack/compute/contrib/test_cats.py nova/nova/tests/api/openstack/compute/contrib/test_cats.py | ||
|
||
# Then, restart your nova-api process! | ||
|
||
Installing Client Component | ||
=========================== | ||
python-novaclient has no direct extension mechanism, but it | ||
is easy to modify. To add cat support to python-novaclient, | ||
first, copy the client code to python-novaclient | ||
|
||
cp simple_nova_extension/python-novaclient/novaclient/v1_1/cats.py python-novaclient/novaclient/v1_1/cats.py | ||
|
||
Now, we will add api client support by modifying python-novaclient/novaclient/v1_1/client.py: | ||
|
||
--- a/novaclient/v1_1/client.py | ||
+++ b/novaclient/v1_1/client.py | ||
@@ -1,4 +1,5 @@ | ||
from novaclient import client | ||
+from novaclient.v1_1 import cats | ||
from novaclient.v1_1 import certs | ||
from novaclient.v1_1 import aggregates | ||
from novaclient.v1_1 import flavors | ||
@@ -54,6 +55,7 @@ class Client(object): | ||
# extensions | ||
self.dns_domains = floating_ip_dns.FloatingIPDNSDomainManager(self) | ||
self.dns_entries = floating_ip_dns.FloatingIPDNSEntryManager(self) | ||
+ self.cats = cats.CatManager(self) | ||
self.certs = certs.CertificateManager(self) | ||
self.floating_ips = floating_ips.FloatingIPManager(self) | ||
self.floating_ip_pools = floating_ip_pools.FloatingIPPoolManager(self) | ||
|
||
This diff is approximate, and only intended as a hint! | ||
|
||
Finally, add cli support by adding this to python-novaclient/novaclient/v1_1/shell.py | ||
|
||
--- a/novaclient/v1_1/shell.py | ||
+++ b/novaclient/v1_1/shell.py | ||
@@ -1640,3 +1640,12 @@ def do_ssh(cs, args): | ||
print "ERROR: No %s %s address found." % (address_type, | ||
pretty_version) | ||
return | ||
+ | ||
+ | ||
+def do_cat_list(cs, args): | ||
+ """Print a list of available 'flavors' (sizes of servers).""" | ||
+ cats = cs.cats.list() | ||
+ utils.print_list(cats, [ | ||
+ 'ID', | ||
+ 'THUMB', | ||
+ 'URL']) | ||
|
||
This diff is approximate, and only intended as a hint! |
Binary file not shown.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# Copyright 2011 OpenStack LLC. | ||
# All Rights Reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); you may | ||
# not use this file except in compliance with the License. You may obtain | ||
# a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
# License for the specific language governing permissions and limitations | ||
# under the License. | ||
|
||
""" | ||
Cats interface (1.1 extension). | ||
""" | ||
|
||
from novaclient import base | ||
|
||
|
||
class Cat(base.Resource): | ||
""" | ||
A cat is a furry creature with 4 legs and whiskers. | ||
""" | ||
pass | ||
|
||
|
||
class CatManager(base.ManagerWithFind): | ||
resource_class = Cat | ||
|
||
def list(self): | ||
""" | ||
Get a list of cats. | ||
""" | ||
return self._list('/os-cats', 'cats') |