Import cookiecutter and github code
Change-Id: I22300a14f98dca8936b95162151d87550a2fb919
This commit is contained in:
parent
29a3074259
commit
20151a83d9
7
.coveragerc
Normal file
7
.coveragerc
Normal file
@ -0,0 +1,7 @@
|
||||
[run]
|
||||
branch = True
|
||||
source = cisco_ironic_contrib
|
||||
omit = cisco_ironic_contrib/openstack/*
|
||||
|
||||
[report]
|
||||
ignore_errors = True
|
56
.gitignore
vendored
Normal file
56
.gitignore
vendored
Normal file
@ -0,0 +1,56 @@
|
||||
*.py[cod]
|
||||
|
||||
# C extensions
|
||||
*.so
|
||||
|
||||
# Packages
|
||||
*.egg
|
||||
*.egg-info
|
||||
dist
|
||||
build
|
||||
.eggs
|
||||
eggs
|
||||
parts
|
||||
bin
|
||||
var
|
||||
sdist
|
||||
develop-eggs
|
||||
.installed.cfg
|
||||
lib
|
||||
lib64
|
||||
|
||||
# Installer logs
|
||||
pip-log.txt
|
||||
|
||||
# Unit test / coverage reports
|
||||
.coverage
|
||||
.tox
|
||||
nosetests.xml
|
||||
.testrepository
|
||||
.venv
|
||||
|
||||
# Translations
|
||||
*.mo
|
||||
|
||||
# Mr Developer
|
||||
.mr.developer.cfg
|
||||
.project
|
||||
.pydevproject
|
||||
|
||||
# Complexity
|
||||
output/*.html
|
||||
output/*/index.html
|
||||
|
||||
# Sphinx
|
||||
doc/build
|
||||
|
||||
# pbr generates these
|
||||
AUTHORS
|
||||
ChangeLog
|
||||
|
||||
# Editors
|
||||
*~
|
||||
.*.swp
|
||||
.*sw?
|
||||
|
||||
*.tar.gz
|
3
.mailmap
Normal file
3
.mailmap
Normal file
@ -0,0 +1,3 @@
|
||||
# Format is:
|
||||
# <preferred e-mail> <other e-mail 1>
|
||||
# <preferred e-mail> <other e-mail 2>
|
7
.testr.conf
Normal file
7
.testr.conf
Normal file
@ -0,0 +1,7 @@
|
||||
[DEFAULT]
|
||||
test_command=OS_STDOUT_CAPTURE=${OS_STDOUT_CAPTURE:-1} \
|
||||
OS_STDERR_CAPTURE=${OS_STDERR_CAPTURE:-1} \
|
||||
OS_TEST_TIMEOUT=${OS_TEST_TIMEOUT:-60} \
|
||||
${PYTHON:-python} -m subunit.run discover -t ./ . $LISTOPT $IDOPTION
|
||||
test_id_option=--load-list $IDFILE
|
||||
test_list_option=--list
|
17
CONTRIBUTING.rst
Normal file
17
CONTRIBUTING.rst
Normal file
@ -0,0 +1,17 @@
|
||||
If you would like to contribute to the development of OpenStack, you must
|
||||
follow the steps in this page:
|
||||
|
||||
http://docs.openstack.org/infra/manual/developers.html
|
||||
|
||||
If you already have a good understanding of how the system works and your
|
||||
OpenStack accounts are set up, you can skip to the development workflow
|
||||
section of this documentation to learn how changes to OpenStack should be
|
||||
submitted for review via the Gerrit tool:
|
||||
|
||||
http://docs.openstack.org/infra/manual/developers.html#development-workflow
|
||||
|
||||
Pull requests submitted through GitHub will be ignored.
|
||||
|
||||
Bugs should be filed on Launchpad, not GitHub:
|
||||
|
||||
https://bugs.launchpad.net/cisco-ironic-contrib
|
4
HACKING.rst
Normal file
4
HACKING.rst
Normal file
@ -0,0 +1,4 @@
|
||||
cisco-ironic-contrib Style Commandments
|
||||
===============================================
|
||||
|
||||
Read the OpenStack Style Commandments http://docs.openstack.org/developer/hacking/
|
176
LICENSE
Normal file
176
LICENSE
Normal file
@ -0,0 +1,176 @@
|
||||
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
6
MANIFEST.in
Normal file
6
MANIFEST.in
Normal file
@ -0,0 +1,6 @@
|
||||
include AUTHORS
|
||||
include ChangeLog
|
||||
exclude .gitignore
|
||||
exclude .gitreview
|
||||
|
||||
global-exclude *.pyc
|
19
README.rst
Normal file
19
README.rst
Normal file
@ -0,0 +1,19 @@
|
||||
===============================
|
||||
cisco-ironic-contrib
|
||||
===============================
|
||||
|
||||
Package containing cisco specific ironic work that doesn't fit into the core ironic tree.
|
||||
|
||||
Please feel here a long description which must be at least 3 lines wrapped on
|
||||
80 cols, so that distribution package maintainers can use it in their packages.
|
||||
Note that this is a hard requirement.
|
||||
|
||||
* Free software: Apache license
|
||||
* Documentation: http://docs.openstack.org/developer/cisco-ironic-contrib
|
||||
* Source: http://git.openstack.org/cgit/openstack/cisco-ironic-contrib
|
||||
* Bugs: http://bugs.launchpad.net/cisco-ironic-contrib
|
||||
|
||||
Features
|
||||
--------
|
||||
|
||||
* TODO
|
21
cisco_ironic_contrib/__init__.py
Normal file
21
cisco_ironic_contrib/__init__.py
Normal file
@ -0,0 +1,21 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# 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.
|
||||
|
||||
import oslo_i18n
|
||||
import pbr.version
|
||||
|
||||
oslo_i18n.install('cisco_ironic_contrib')
|
||||
|
||||
__version__ = pbr.version.VersionInfo(
|
||||
'cisco_ironic_contrib').version_string()
|
0
cisco_ironic_contrib/ironic/__init__.py
Normal file
0
cisco_ironic_contrib/ironic/__init__.py
Normal file
0
cisco_ironic_contrib/ironic/cimc/__init__.py
Normal file
0
cisco_ironic_contrib/ironic/cimc/__init__.py
Normal file
132
cisco_ironic_contrib/ironic/cimc/boot.py
Normal file
132
cisco_ironic_contrib/ironic/cimc/boot.py
Normal file
@ -0,0 +1,132 @@
|
||||
# Copyright 2015, Cisco Systems.
|
||||
#
|
||||
# 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.
|
||||
|
||||
import os
|
||||
import shutil
|
||||
|
||||
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
from oslo_utils import importutils
|
||||
|
||||
from ironic.common import boot_devices
|
||||
from ironic.common import pxe_utils
|
||||
from ironic.common import states
|
||||
from ironic.dhcp import neutron
|
||||
from ironic.drivers.modules import deploy_utils
|
||||
from ironic.drivers.modules import pxe
|
||||
from ironic import objects
|
||||
|
||||
from cisco_ironic_contrib.ironic.cimc import common
|
||||
|
||||
imcsdk = importutils.try_import('ImcSdk')
|
||||
|
||||
CONF = cfg.CONF
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class PXEBoot(pxe.PXEBoot):
|
||||
|
||||
def _plug_provisioning(self, task, **kwargs):
|
||||
LOG.debug("Plugging the provisioning!")
|
||||
|
||||
client = neutron._build_client(task.context.auth_token)
|
||||
port = client.create_port({
|
||||
'port': {
|
||||
"network_id":
|
||||
CONF.neutron.cleaning_network_uuid,
|
||||
"extra_dhcp_opts":
|
||||
pxe_utils.dhcp_options_for_instance(task),
|
||||
}
|
||||
})
|
||||
|
||||
name = port['port']['id']
|
||||
network = client.show_network(port['port']['network_id'])
|
||||
seg_id = network['network']['provider:segmentation_id']
|
||||
|
||||
try:
|
||||
common.add_vnic(
|
||||
task, name, port['port']['mac_address'], seg_id, True)
|
||||
except imcsdk.ImcException:
|
||||
# TODO(sambetts) Plumming the port failed, so clean up neutron port
|
||||
# we created before
|
||||
raise
|
||||
|
||||
new_port = objects.Port(
|
||||
task.context, node_id=task.node.id,
|
||||
address=port['port']['mac_address'],
|
||||
extra={"vif_port_id": port['port']['id'],
|
||||
"type": "deploy", "state": "ACTIVE"})
|
||||
new_port.create()
|
||||
|
||||
def _unplug_provisioning(self, task, **kwargs):
|
||||
LOG.debug("Unplugging the provisioning!")
|
||||
client = neutron._build_client(task.context.auth_token)
|
||||
|
||||
ports = objects.Port.list_by_node_id(task.context, task.node.id)
|
||||
todelete = None
|
||||
for port in ports:
|
||||
if port['extra'].get('type') == "deploy":
|
||||
todelete = port
|
||||
break
|
||||
|
||||
common.delete_vnic(task, todelete['extra']['vif_port_id'])
|
||||
client.delete_port(todelete['extra']['vif_port_id'])
|
||||
todelete.destroy()
|
||||
|
||||
def validate(self, task):
|
||||
pass
|
||||
|
||||
def prepare_ramdisk(self, task, ramdisk_params):
|
||||
node = task.node
|
||||
|
||||
# TODO(deva): optimize this if rerun on existing files
|
||||
if CONF.pxe.ipxe_enabled:
|
||||
# Copy the iPXE boot script to HTTP root directory
|
||||
bootfile_path = os.path.join(
|
||||
CONF.deploy.http_root,
|
||||
os.path.basename(CONF.pxe.ipxe_boot_script))
|
||||
shutil.copyfile(CONF.pxe.ipxe_boot_script, bootfile_path)
|
||||
|
||||
self._plug_provisioning(task)
|
||||
|
||||
task.ports = objects.Port.list_by_node_id(task.context, node.id)
|
||||
|
||||
pxe_info = pxe._get_deploy_image_info(node)
|
||||
|
||||
# NODE: Try to validate and fetch instance images only
|
||||
# if we are in DEPLOYING state.
|
||||
if node.provision_state == states.DEPLOYING:
|
||||
pxe_info.update(pxe._get_instance_image_info(node, task.context))
|
||||
|
||||
pxe_options = pxe._build_pxe_config_options(task, pxe_info)
|
||||
pxe_options.update(ramdisk_params)
|
||||
|
||||
if deploy_utils.get_boot_mode_for_deploy(node) == 'uefi':
|
||||
pxe_config_template = CONF.pxe.uefi_pxe_config_template
|
||||
else:
|
||||
pxe_config_template = CONF.pxe.pxe_config_template
|
||||
|
||||
pxe_utils.create_pxe_config(task, pxe_options,
|
||||
pxe_config_template)
|
||||
deploy_utils.try_set_boot_device(task, boot_devices.PXE)
|
||||
|
||||
# FIXME(lucasagomes): If it's local boot we should not cache
|
||||
# the image kernel and ramdisk (Or even require it).
|
||||
pxe._cache_ramdisk_kernel(task.context, node, pxe_info)
|
||||
|
||||
def prepare_instance(self, task):
|
||||
super(PXEBoot, self).prepare_instance(task)
|
||||
if deploy_utils.get_boot_option(task.node) == "local":
|
||||
self._unplug_provisioning(task)
|
76
cisco_ironic_contrib/ironic/cimc/common.py
Normal file
76
cisco_ironic_contrib/ironic/cimc/common.py
Normal file
@ -0,0 +1,76 @@
|
||||
# Copyright 2015, Cisco Systems.
|
||||
#
|
||||
# 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.
|
||||
|
||||
from oslo_log import log as logging
|
||||
from oslo_utils import importutils
|
||||
|
||||
from ironic.drivers.modules.cimc import common
|
||||
|
||||
imcsdk = importutils.try_import('ImcSdk')
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def add_vnic(task, name, mac, vlan, pxe=False):
|
||||
name = name[0:31]
|
||||
with common.cimc_handle(task) as handle:
|
||||
rackunit = handle.get_imc_managedobject(
|
||||
None, imcsdk.ComputeRackUnit.class_id())
|
||||
adaptorunits = handle.get_imc_managedobject(
|
||||
in_mo=rackunit, class_id=imcsdk.AdaptorUnit.class_id())
|
||||
|
||||
dn = "%s/host-eth-%s" % (adaptorunits[0].Dn, name)
|
||||
|
||||
method = imcsdk.ImcCore.ExternalMethod("ConfigConfMo")
|
||||
method.Cookie = handle.cookie
|
||||
method.Dn = dn
|
||||
|
||||
config = imcsdk.Imc.ConfigConfig()
|
||||
|
||||
newVic = imcsdk.ImcCore.ManagedObject("adaptorHostEthIf")
|
||||
newVic.set_attr("name", name)
|
||||
newVic.set_attr("mtu", "1500")
|
||||
newVic.set_attr("pxeBoot", "enabled" if pxe else "disabled")
|
||||
newVic.set_attr("Dn", dn)
|
||||
newVic.set_attr("mac", mac)
|
||||
newVic.set_attr("uplinkPort", "1")
|
||||
|
||||
vlanProfile = imcsdk.ImcCore.ManagedObject("adaptorEthGenProfile")
|
||||
vlanProfile.set_attr("vlanMode", "ACCESS")
|
||||
vlanProfile.set_attr("vlan", str(vlan))
|
||||
vlanProfile.set_attr("Dn", dn)
|
||||
|
||||
newVic.add_child(vlanProfile)
|
||||
config.add_child(newVic)
|
||||
method.InConfig = config
|
||||
|
||||
resp = handle.xml_query(
|
||||
method, imcsdk.WriteXmlOption.DIRTY)
|
||||
error = getattr(resp, 'error_code', None)
|
||||
if error:
|
||||
raise imcsdk.ImcException(error)
|
||||
|
||||
|
||||
def delete_vnic(task, name):
|
||||
name = name[0:31]
|
||||
with common.cimc_handle(task) as handle:
|
||||
rackunit = handle.get_imc_managedobject(
|
||||
None, imcsdk.ComputeRackUnit.class_id())
|
||||
adaptorunits = handle.get_imc_managedobject(
|
||||
in_mo=rackunit, class_id=imcsdk.AdaptorUnit.class_id())
|
||||
vic = {
|
||||
"Dn": "%s/host-eth-%s" % (adaptorunits[0].Dn, name),
|
||||
}
|
||||
handle.remove_imc_managedobject(
|
||||
None, class_id="adaptorHostEthIf", params=vic)
|
89
cisco_ironic_contrib/ironic/cimc/vendor.py
Normal file
89
cisco_ironic_contrib/ironic/cimc/vendor.py
Normal file
@ -0,0 +1,89 @@
|
||||
# Copyright 2015, Cisco Systems.
|
||||
#
|
||||
# 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.
|
||||
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
from oslo_utils import importutils
|
||||
|
||||
from ironic.common import exception
|
||||
from ironic.common import states
|
||||
from ironic.conductor import task_manager
|
||||
from ironic.conductor import utils as manager_utils
|
||||
from ironic.drivers import base
|
||||
from ironic.drivers.modules import iscsi_deploy
|
||||
from ironic import objects
|
||||
|
||||
from cisco_ironic_contrib.ironic.cimc import common
|
||||
|
||||
imcsdk = importutils.try_import('ImcSdk')
|
||||
|
||||
CONF = cfg.CONF
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class CIMCPXEVendorPassthru(iscsi_deploy.VendorPassthru):
|
||||
|
||||
@base.passthru(['POST'], async=True)
|
||||
@task_manager.require_exclusive_lock
|
||||
def add_vnic(self, task, **kwargs):
|
||||
|
||||
LOG.info("ENSURING NODE ON FOR VNIC ADDITION!")
|
||||
if task.node.power_state != states.POWER_ON:
|
||||
manager_utils.node_power_action(task, states.REBOOT)
|
||||
|
||||
LOG.info("ADDING PORT TO IRONIC DB")
|
||||
new_port = objects.Port(
|
||||
task.context, node_id=task.node.id, address=kwargs['mac'],
|
||||
extra={"vif_port_id": kwargs['uuid'],
|
||||
"type": "tenant", "state": "DOWN"})
|
||||
|
||||
new_port.create()
|
||||
|
||||
try:
|
||||
LOG.info("ADDING VNIC TO CIMC")
|
||||
common.add_vnic(
|
||||
task, kwargs['uuid'], kwargs['mac'],
|
||||
kwargs['vlan'], kwargs['pxe'])
|
||||
except imcsdk.ImcException:
|
||||
new_port.extra = {"vif_port_id": kwargs['uuid'], "type": "tenant",
|
||||
"state": "ERROR"}
|
||||
LOG.error("ADDING VNIC FAILED")
|
||||
else:
|
||||
new_port.extra = {"vif_port_id": kwargs['uuid'], "type": "tenant",
|
||||
"state": "UP"}
|
||||
LOG.info("ADDING VNIC SUCCESSFUL")
|
||||
new_port.save()
|
||||
|
||||
@base.passthru(['POST'], async=True)
|
||||
@task_manager.require_exclusive_lock
|
||||
def delete_vnic(self, task, **kwargs):
|
||||
|
||||
# Ensure Node is powered on before changing VNIC settings
|
||||
if task.node.power_state != states.POWER_ON:
|
||||
manager_utils.node_power_action(task, states.REBOOT)
|
||||
|
||||
# Use neutron UUID to get port from ironic DB
|
||||
ports = objects.Port.list_by_node_id(task.context, task.node.id)
|
||||
todelete = None
|
||||
for port in ports:
|
||||
if port['extra']['vif_port_id'] == kwargs['uuid']:
|
||||
todelete = port
|
||||
break
|
||||
|
||||
if todelete is None:
|
||||
raise exception.NotFound("No port matched uuid provided")
|
||||
# Delete vnic from server
|
||||
common.delete_vnic(task, kwargs['uuid'])
|
||||
# Delete port from ironic port DB
|
||||
todelete.destroy()
|
26
cisco_ironic_contrib/ironic/pxe.py
Normal file
26
cisco_ironic_contrib/ironic/pxe.py
Normal file
@ -0,0 +1,26 @@
|
||||
# Copyright 2015, Cisco Systems.
|
||||
#
|
||||
# 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.
|
||||
|
||||
from ironic.drivers import pxe
|
||||
|
||||
from cisco_ironic_contrib.ironic.cimc import boot as cimc_boot
|
||||
from cisco_ironic_contrib.ironic.cimc import vendor as cimc_vendor
|
||||
|
||||
|
||||
class PXEAndCIMCNeutronDriver(pxe.PXEAndCIMCDriver):
|
||||
|
||||
def __init__(self):
|
||||
super(PXEAndCIMCNeutronDriver, self).__init__()
|
||||
self.boot = cimc_boot.PXEBoot()
|
||||
self.vendor = cimc_vendor.CIMCPXEVendorPassthru()
|
0
cisco_ironic_contrib/nova/__init__.py
Normal file
0
cisco_ironic_contrib/nova/__init__.py
Normal file
68
cisco_ironic_contrib/nova/driver.py
Normal file
68
cisco_ironic_contrib/nova/driver.py
Normal file
@ -0,0 +1,68 @@
|
||||
# Copyright 2015 Cisco Systems
|
||||
# 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.
|
||||
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
from oslo_service import loopingcall
|
||||
|
||||
from nova.network.neutronv2 import api as neutron
|
||||
from nova.virt.ironic import driver as ironic_driver
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
CONF = cfg.CONF
|
||||
|
||||
|
||||
class CiscoIronicDriver(ironic_driver.IronicDriver):
|
||||
"""Hypervisor driver for Ironic - bare metal provisioning."""
|
||||
|
||||
def _check_for_vnic_creation(self, ironicclient, address):
|
||||
port = self.ironicclient.call("port.get_by_address", address)
|
||||
if port.extra['state'] == "UP":
|
||||
raise loopingcall.LoopingCallDone()
|
||||
|
||||
def macs_for_instance(self, instance):
|
||||
return None
|
||||
|
||||
def _plug_vifs(self, node, instance, network_info):
|
||||
LOG.debug('Plug VIFs called for instance', instance=instance)
|
||||
node_uuid = instance.get('node')
|
||||
client = neutron.get_client(None, admin=True)
|
||||
for vif in network_info:
|
||||
network = client.show_network(vif['network']['id'])
|
||||
net_info = {
|
||||
'vlan': network['network']['provider:segmentation_id'],
|
||||
'mac': vif['address'],
|
||||
'uuid': vif['id'],
|
||||
'pxe': False
|
||||
}
|
||||
self.ironicclient.call("node.vendor_passthru", node_uuid,
|
||||
"add_vnic", args=net_info)
|
||||
|
||||
timer = loopingcall.FixedIntervalLoopingCall(
|
||||
self._check_for_vnic_creation,
|
||||
self.ironicclient, vif['address'])
|
||||
timer.start(interval=5).wait()
|
||||
LOG.debug('Plug VIFs successful for instance', instance=instance)
|
||||
|
||||
def _unplug_vifs(self, node, instance, network_info):
|
||||
node_uuid = instance.get('node')
|
||||
# Delete vnics from UCS for this node via vendor passthru
|
||||
for vif in network_info:
|
||||
net_info = {
|
||||
'uuid': vif['id']
|
||||
}
|
||||
self.ironicclient.call("node.vendor_passthru", node_uuid,
|
||||
"delete_vnic", args=net_info)
|
39
cisco_ironic_contrib/tests/__init__.py
Normal file
39
cisco_ironic_contrib/tests/__init__.py
Normal file
@ -0,0 +1,39 @@
|
||||
# Copyright 2015 Cisco Systems
|
||||
# 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.
|
||||
|
||||
# Ensure nova configs that conflict with ironic configs are unregistered for
|
||||
# the tests
|
||||
|
||||
from oslo_config import cfg
|
||||
|
||||
from nova.api import auth
|
||||
from nova import exception
|
||||
from nova import netconf
|
||||
from nova.network.neutronv2 import api
|
||||
from nova import paths
|
||||
from nova import utils
|
||||
from nova.virt import images
|
||||
|
||||
CONF = cfg.CONF
|
||||
|
||||
CONF.unregister_opts(exception.exc_log_opts)
|
||||
CONF.unregister_opt(utils.utils_opts[3])
|
||||
CONF.unregister_opt(utils.utils_opts[4])
|
||||
CONF.unregister_opt(netconf.netconf_opts[0])
|
||||
CONF.unregister_opt(netconf.netconf_opts[2])
|
||||
CONF.unregister_opts(paths.path_opts)
|
||||
CONF.unregister_opt(auth.auth_opts[1])
|
||||
CONF.unregister_opts(api.neutron_opts, group='neutron')
|
||||
CONF.unregister_opts(images.image_opts)
|
0
cisco_ironic_contrib/tests/unit/__init__.py
Normal file
0
cisco_ironic_contrib/tests/unit/__init__.py
Normal file
29
cisco_ironic_contrib/tests/unit/ironic/__init__.py
Normal file
29
cisco_ironic_contrib/tests/unit/ironic/__init__.py
Normal file
@ -0,0 +1,29 @@
|
||||
# Copyright 2015, Cisco Systems.
|
||||
#
|
||||
# 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.
|
||||
|
||||
import six
|
||||
import sys
|
||||
|
||||
from ironic.drivers import fake
|
||||
from ironic.tests.unit.drivers import third_party_driver_mocks # noqa
|
||||
|
||||
from cisco_ironic_contrib.ironic.cimc import boot
|
||||
from cisco_ironic_contrib.ironic.cimc import vendor
|
||||
|
||||
if 'ironic.drivers.modules.cimc' in sys.modules:
|
||||
six.moves.reload_module(
|
||||
sys.modules['ironic.drivers.modules.cimc'])
|
||||
|
||||
fake.FakeCIMCDriver.boot = boot.PXEBoot()
|
||||
fake.FakeCIMCDriver.vendor = vendor.CIMCPXEVendorPassthru()
|
178
cisco_ironic_contrib/tests/unit/ironic/cimc/test_boot.py
Normal file
178
cisco_ironic_contrib/tests/unit/ironic/cimc/test_boot.py
Normal file
@ -0,0 +1,178 @@
|
||||
# Copyright 2015, Cisco Systems.
|
||||
#
|
||||
# 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.
|
||||
|
||||
import mock
|
||||
|
||||
from oslo_config import cfg
|
||||
|
||||
from ironic.common import boot_devices
|
||||
from ironic.common import pxe_utils
|
||||
from ironic.common import states
|
||||
from ironic.conductor import task_manager
|
||||
from ironic.dhcp import neutron
|
||||
from ironic.drivers.modules import deploy_utils
|
||||
from ironic.drivers.modules import pxe
|
||||
from ironic import objects
|
||||
from ironic.tests.unit.drivers.modules.cimc import test_common
|
||||
|
||||
from cisco_ironic_contrib.ironic.cimc import boot
|
||||
from cisco_ironic_contrib.ironic.cimc import common
|
||||
|
||||
CONF = cfg.CONF
|
||||
|
||||
|
||||
def with_task(func):
|
||||
|
||||
def wrapper(self, *args, **kwargs):
|
||||
with task_manager.acquire(self.context,
|
||||
self.node.uuid,
|
||||
shared=False) as task:
|
||||
return func(self, task, *args, **kwargs)
|
||||
|
||||
return wrapper
|
||||
|
||||
|
||||
class PXEBootTestCase(test_common.CIMCBaseTestCase):
|
||||
|
||||
@mock.patch.object(objects, 'Port', autospec=True)
|
||||
@mock.patch.object(common, 'add_vnic', autospec=True)
|
||||
@mock.patch.object(neutron, '_build_client', autospec=True)
|
||||
@with_task
|
||||
def test_plug_provisioning(self, task, mock__build_client,
|
||||
mock_add_vnic, mock_port):
|
||||
client = mock__build_client.return_value
|
||||
client.create_port.return_value = {
|
||||
'port': {
|
||||
'id': 'fake_id',
|
||||
'network_id': CONF.neutron.cleaning_network_uuid,
|
||||
'mac_address': 'fake_address'
|
||||
}
|
||||
}
|
||||
|
||||
client.show_network.return_value = {
|
||||
'network': {
|
||||
'provider:segmentation_id': 600
|
||||
}
|
||||
}
|
||||
|
||||
task.driver.boot._plug_provisioning(task)
|
||||
|
||||
neutron_data = {
|
||||
'port': {
|
||||
"network_id": CONF.neutron.cleaning_network_uuid,
|
||||
"extra_dhcp_opts": pxe_utils.dhcp_options_for_instance(task),
|
||||
}
|
||||
}
|
||||
|
||||
client.create_port.assert_called_once_with(neutron_data)
|
||||
client.show_network.assert_called_once_with(
|
||||
CONF.neutron.cleaning_network_uuid)
|
||||
mock_add_vnic.assert_called_once_with(
|
||||
task, 'fake_id', 'fake_address', 600, True)
|
||||
mock_port.assert_called_once_with(task.context, node_id=task.node.id,
|
||||
address='fake_address',
|
||||
extra={
|
||||
"vif_port_id": 'fake_id',
|
||||
"type": "deploy",
|
||||
"state": "ACTIVE"})
|
||||
mock_port.return_value.create.assert_called_once_with()
|
||||
|
||||
@mock.patch.object(objects, 'Port', autospec=True)
|
||||
@mock.patch.object(neutron, '_build_client', autospec=True)
|
||||
@mock.patch.object(common, 'delete_vnic', autospec=True)
|
||||
@with_task
|
||||
def test_unplug_provisioning(
|
||||
self, task, mock_delete_vnic, mock__build_client, mock_port):
|
||||
|
||||
portMock1 = mock.MagicMock()
|
||||
portMock1.__getitem__.return_value = {
|
||||
'type': 'tenant',
|
||||
'vif_port_id': 'port1'
|
||||
}
|
||||
|
||||
portMock2 = mock.MagicMock()
|
||||
portMock2.__getitem__.return_value = {
|
||||
'type': 'deploy',
|
||||
'vif_port_id': 'port2'
|
||||
}
|
||||
|
||||
portMock3 = mock.MagicMock()
|
||||
portMock3.__getitem__.return_value = {
|
||||
'type': 'tenant',
|
||||
'vif_port_id': 'port3'
|
||||
}
|
||||
|
||||
mock_port.list_by_node_id.return_value = [portMock1,
|
||||
portMock2,
|
||||
portMock3]
|
||||
|
||||
client = mock__build_client.return_value
|
||||
|
||||
task.driver.boot._unplug_provisioning(task)
|
||||
|
||||
mock_delete_vnic.assert_called_once_with(task, 'port2')
|
||||
client.delete_port.assert_called_once_with('port2')
|
||||
portMock2.destroy.assert_called_once_with()
|
||||
|
||||
@with_task
|
||||
def test_validate(self, task):
|
||||
result = task.driver.boot.validate(task)
|
||||
self.assertIsNone(result)
|
||||
|
||||
@mock.patch.object(deploy_utils, 'try_set_boot_device', autospec=True)
|
||||
@mock.patch.object(boot.PXEBoot, '_plug_provisioning', autospec=True)
|
||||
@mock.patch.object(pxe, '_get_deploy_image_info', autospec=True)
|
||||
@mock.patch.object(pxe, '_build_pxe_config_options', autospec=True)
|
||||
@mock.patch.object(pxe, '_get_instance_image_info', autospec=True)
|
||||
@mock.patch.object(pxe_utils, 'create_pxe_config', autospec=True)
|
||||
@mock.patch.object(pxe, '_cache_ramdisk_kernel', autospec=True)
|
||||
def test_prepare_ramdisk(self, mock_cache_ramdisk, mock_create_pxe,
|
||||
mock_get_instance, mock_build_pxe,
|
||||
mock_get_deploy, mock_plug_pro, mock_set_boot):
|
||||
self.node.provision_state = states.DEPLOYING
|
||||
self.node.save()
|
||||
|
||||
with task_manager.acquire(self.context,
|
||||
self.node.uuid,
|
||||
shared=False) as task:
|
||||
task.driver.boot.prepare_ramdisk(task, {'foo': 'bar'})
|
||||
|
||||
mock_set_boot.assert_called_once_with(task, boot_devices.PXE)
|
||||
mock_plug_pro.assert_called_once_with(mock.ANY, task)
|
||||
mock_get_deploy.assert_called_once_with(task.node)
|
||||
mock_build_pxe.assert_called_once_with(
|
||||
task, mock_get_deploy.return_value)
|
||||
mock_get_instance.assert_called_once_with(task.node, task.context)
|
||||
mock_create_pxe.assert_called_once_with(
|
||||
task, mock_build_pxe.return_value,
|
||||
CONF.pxe.pxe_config_template)
|
||||
mock_cache_ramdisk.assert_called_once_with(
|
||||
task.context, task.node, mock_get_deploy.return_value)
|
||||
|
||||
@mock.patch.object(pxe.PXEBoot, 'prepare_instance', autospec=True)
|
||||
@mock.patch.object(boot.PXEBoot, '_unplug_provisioning', autospec=True)
|
||||
@with_task
|
||||
def test_prepare_instance(self, task, mock_unplug, mock_prepare):
|
||||
task.driver.boot.prepare_instance(task)
|
||||
mock_prepare.assert_called_once_with(mock.ANY, task)
|
||||
self.assertFalse(mock_unplug.called)
|
||||
|
||||
@mock.patch.object(pxe.PXEBoot, 'prepare_instance', autospec=True)
|
||||
@mock.patch.object(boot.PXEBoot, '_unplug_provisioning', autospec=True)
|
||||
@with_task
|
||||
def test_prepare_instance_local(self, task, mock_unplug, mock_prepare):
|
||||
task.node.instance_info['capabilities'] = {"boot_option": "local"}
|
||||
task.driver.boot.prepare_instance(task)
|
||||
mock_prepare.assert_called_once_with(mock.ANY, task)
|
||||
mock_unplug.assert_called_once_with(mock.ANY, task)
|
145
cisco_ironic_contrib/tests/unit/ironic/cimc/test_common.py
Normal file
145
cisco_ironic_contrib/tests/unit/ironic/cimc/test_common.py
Normal file
@ -0,0 +1,145 @@
|
||||
# Copyright 2015, Cisco Systems.
|
||||
#
|
||||
# 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.
|
||||
|
||||
import mock
|
||||
|
||||
from oslo_config import cfg
|
||||
from oslo_utils import importutils
|
||||
|
||||
from ironic.conductor import task_manager
|
||||
from ironic.drivers.modules.cimc import common as cimc_common
|
||||
from ironic.tests.unit.drivers.modules.cimc import test_common
|
||||
|
||||
from cisco_ironic_contrib.ironic.cimc import common
|
||||
|
||||
imcsdk = importutils.try_import('ImcSdk')
|
||||
|
||||
CONF = cfg.CONF
|
||||
|
||||
|
||||
@mock.patch.object(cimc_common, 'cimc_handle', autospec=True)
|
||||
class AddVnicTestCase(test_common.CIMCBaseTestCase):
|
||||
|
||||
def _test_add_vnic(self, mock_mo, mock_handle, pxe=False):
|
||||
with task_manager.acquire(self.context, self.node.uuid,
|
||||
shared=False) as task:
|
||||
with mock_handle(task) as handle:
|
||||
first_mock = mock.MagicMock()
|
||||
second_mock = mock.MagicMock()
|
||||
mock_mo.side_effect = [first_mock, second_mock]
|
||||
|
||||
mo = handle.get_imc_managedobject.return_value
|
||||
mo.__getitem__.return_value.Dn = "DN"
|
||||
handle.xml_query.return_value.error_code = None
|
||||
|
||||
dn = "DN/host-eth-name"
|
||||
|
||||
common.add_vnic(task, "name", "mac_address", 600, pxe)
|
||||
|
||||
mock_mo.assert_any_call("adaptorEthGenProfile")
|
||||
mock_mo.assert_any_call("adaptorHostEthIf")
|
||||
|
||||
first_mock.set_attr.assert_any_call("name", "name")
|
||||
first_mock.set_attr.assert_any_call("mtu", "1500")
|
||||
first_mock.set_attr.assert_any_call(
|
||||
"pxeBoot", "enabled" if pxe else "disabled")
|
||||
first_mock.set_attr.assert_any_call("Dn", dn)
|
||||
first_mock.set_attr.assert_any_call("mac", "mac_address")
|
||||
first_mock.set_attr.assert_any_call("uplinkPort", "1")
|
||||
|
||||
second_mock.set_attr.assert_any_call("vlanMode", "ACCESS")
|
||||
second_mock.set_attr.assert_any_call("vlan", "600")
|
||||
second_mock.set_attr.assert_any_call("Dn", dn)
|
||||
|
||||
handle.xml_query.assert_called_once_with(
|
||||
imcsdk.ImcCore.ExternalMethod.return_value,
|
||||
imcsdk.WriteXmlOption.DIRTY)
|
||||
|
||||
@mock.patch.object(imcsdk.ImcCore, 'ManagedObject', autospec=True)
|
||||
def test_add_vnic(self, mock_mo, mock_handle):
|
||||
self._test_add_vnic(mock_mo, mock_handle)
|
||||
|
||||
@mock.patch.object(imcsdk.ImcCore, 'ManagedObject', autospec=True)
|
||||
def test_add_vnic_pxe(self, mock_mo, mock_handle):
|
||||
self._test_add_vnic(mock_mo, mock_handle, pxe=True)
|
||||
|
||||
@mock.patch.object(imcsdk.ImcCore, 'ManagedObject', autospec=True)
|
||||
def test_add_vnic_long_name(self, mock_mo, mock_handle):
|
||||
with task_manager.acquire(self.context, self.node.uuid,
|
||||
shared=False) as task:
|
||||
with mock_handle(task) as handle:
|
||||
mo = handle.get_imc_managedobject.return_value
|
||||
mo.__getitem__.return_value.Dn = "DN"
|
||||
handle.xml_query.return_value.error_code = None
|
||||
dn = "DN/host-eth-namenamenamenamenamenamenamenam"
|
||||
common.add_vnic(
|
||||
task, "namenamenamenamenamenamenamenamename",
|
||||
"mac_address", 600)
|
||||
mock_mo.return_value.set_attr.assert_any_call("Dn", dn)
|
||||
|
||||
def test_add_vnic_fail(self, mock_handle):
|
||||
with task_manager.acquire(self.context, self.node.uuid,
|
||||
shared=False) as task:
|
||||
with mock_handle(task) as handle:
|
||||
handle.xml_query.return_value.error_code = "123456"
|
||||
self.assertRaises(imcsdk.ImcException, common.add_vnic,
|
||||
task, "name", "mac_address", 600)
|
||||
|
||||
|
||||
@mock.patch.object(cimc_common, 'cimc_handle', autospec=True)
|
||||
class DeleteVnicTestCase(test_common.CIMCBaseTestCase):
|
||||
|
||||
def test_delete_vnic(self, mock_handle):
|
||||
with task_manager.acquire(self.context, self.node.uuid,
|
||||
shared=False) as task:
|
||||
with mock_handle(task) as handle:
|
||||
mo = handle.get_imc_managedobject.return_value
|
||||
mo.__getitem__.return_value.Dn = "DN"
|
||||
|
||||
common.delete_vnic(task, "name")
|
||||
|
||||
expected_params = {"Dn": "DN/host-eth-name"}
|
||||
handle.remove_imc_managedobject.assert_called_once_with(
|
||||
None, class_id="adaptorHostEthIf", params=expected_params)
|
||||
|
||||
def test_delete_vnic_fail(self, mock_handle):
|
||||
with task_manager.acquire(self.context, self.node.uuid,
|
||||
shared=False) as task:
|
||||
with mock_handle(task) as handle:
|
||||
mo = handle.get_imc_managedobject.return_value
|
||||
mo.__getitem__.return_value.Dn = "DN"
|
||||
handle.remove_imc_managedobject.side_effect = (
|
||||
imcsdk.ImcException("Boom"))
|
||||
|
||||
self.assertRaises(imcsdk.ImcException,
|
||||
common.delete_vnic, task, "name")
|
||||
|
||||
expected_params = {"Dn": "DN/host-eth-name"}
|
||||
handle.remove_imc_managedobject.assert_called_once_with(
|
||||
None, class_id="adaptorHostEthIf", params=expected_params)
|
||||
|
||||
def test_delete_vnic_long_name(self, mock_handle):
|
||||
with task_manager.acquire(self.context, self.node.uuid,
|
||||
shared=False) as task:
|
||||
with mock_handle(task) as handle:
|
||||
mo = handle.get_imc_managedobject.return_value
|
||||
mo.__getitem__.return_value.Dn = "DN"
|
||||
|
||||
common.delete_vnic(
|
||||
task, "namenamenamenamenamenamenamenamename")
|
||||
|
||||
expected_params = {
|
||||
"Dn": "DN/host-eth-namenamenamenamenamenamenamenam"}
|
||||
handle.remove_imc_managedobject.assert_called_once_with(
|
||||
None, class_id="adaptorHostEthIf", params=expected_params)
|
143
cisco_ironic_contrib/tests/unit/ironic/cimc/test_vendor.py
Normal file
143
cisco_ironic_contrib/tests/unit/ironic/cimc/test_vendor.py
Normal file
@ -0,0 +1,143 @@
|
||||
# Copyright 2015, Cisco Systems.
|
||||
#
|
||||
# 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.
|
||||
|
||||
import mock
|
||||
|
||||
from oslo_utils import importutils
|
||||
|
||||
from ironic.common import exception
|
||||
from ironic.common import states
|
||||
from ironic.conductor import task_manager
|
||||
from ironic.conductor import utils as manager_utils
|
||||
from ironic import objects
|
||||
from ironic.tests.unit.drivers.modules.cimc import test_common
|
||||
|
||||
from cisco_ironic_contrib.ironic.cimc import common
|
||||
|
||||
imcsdk = importutils.try_import('ImcSdk')
|
||||
|
||||
TEST_DATA = {
|
||||
"uuid": "uuiduuiduuiduuiduuiduuid",
|
||||
"mac": "fake_mac_address",
|
||||
"vlan": 600,
|
||||
"pxe": False
|
||||
}
|
||||
|
||||
|
||||
class CIMCPXEVendorPassthruTestCase(test_common.CIMCBaseTestCase):
|
||||
|
||||
@mock.patch.object(common, 'add_vnic', autospec=True)
|
||||
@mock.patch.object(manager_utils, 'node_power_action', autospec=True)
|
||||
@mock.patch.object(objects, 'Port', autospec=True)
|
||||
def _test_add_vnic(self, mock_port, mock_power_action,
|
||||
mock_add_vnic, initial_state=states.POWER_OFF):
|
||||
with task_manager.acquire(self.context, self.node.uuid,
|
||||
shared=False) as task:
|
||||
task.node.power_state = initial_state
|
||||
mock_port.return_value.extra = {}
|
||||
|
||||
task.driver.vendor.add_vnic(task, **TEST_DATA)
|
||||
|
||||
if initial_state != states.POWER_ON:
|
||||
mock_power_action.assert_called_once_with(task, states.REBOOT)
|
||||
else:
|
||||
self.assertFalse(mock_power_action.called)
|
||||
|
||||
mock_port.assert_called_once_with(
|
||||
task.context, node_id=task.node.id, address=TEST_DATA['mac'],
|
||||
extra={"type": "tenant", "state": "DOWN",
|
||||
"vif_port_id": TEST_DATA['uuid']})
|
||||
|
||||
mock_port.return_value.create.assert_called_once_with()
|
||||
|
||||
mock_add_vnic.assert_called_once_with(
|
||||
task, TEST_DATA['uuid'], TEST_DATA['mac'],
|
||||
TEST_DATA['vlan'], TEST_DATA['pxe'])
|
||||
|
||||
self.assertEqual(mock_port.return_value.extra['state'],
|
||||
"UP")
|
||||
|
||||
mock_port.return_value.save.assert_called_once_with()
|
||||
|
||||
def test_add_vnic_node_off(self):
|
||||
self._test_add_vnic()
|
||||
|
||||
def test_add_vnic_node_already_on(self):
|
||||
self._test_add_vnic(initial_state=states.POWER_ON)
|
||||
|
||||
@mock.patch.object(common, 'add_vnic', autospec=True)
|
||||
@mock.patch.object(objects, 'Port', autospec=True)
|
||||
def test_add_vnic_fail(self, mock_port, mock_add_vnic):
|
||||
with task_manager.acquire(self.context, self.node.uuid,
|
||||
shared=False) as task:
|
||||
task.node.power_state = states.POWER_ON
|
||||
mock_port.return_value.extra = {}
|
||||
|
||||
mock_add_vnic.side_effect = imcsdk.ImcException("Boom")
|
||||
|
||||
task.driver.vendor.add_vnic(task, **TEST_DATA)
|
||||
|
||||
self.assertEqual(mock_port.return_value.extra['state'],
|
||||
"ERROR")
|
||||
|
||||
mock_port.return_value.save.assert_called_once_with()
|
||||
|
||||
@mock.patch.object(common, 'delete_vnic', autospec=True)
|
||||
@mock.patch.object(manager_utils, 'node_power_action', autospec=True)
|
||||
@mock.patch.object(objects, 'Port', autospec=True)
|
||||
def _test_delete_vnic(self, mock_port, mock_power_action, mock_delete_vnic,
|
||||
initial_state=states.POWER_OFF):
|
||||
with task_manager.acquire(self.context, self.node.uuid,
|
||||
shared=False) as task:
|
||||
task.node.power_state = initial_state
|
||||
|
||||
port1 = mock.MagicMock()
|
||||
port1.__getitem__.return_value = {'vif_port_id': "1"}
|
||||
|
||||
port2 = mock.MagicMock()
|
||||
port2.__getitem__.return_value = {'vif_port_id': "2"}
|
||||
|
||||
port3 = mock.MagicMock()
|
||||
port3.__getitem__.return_value = {'vif_port_id': "3"}
|
||||
|
||||
mock_port.list_by_node_id.return_value = [port1, port2, port3]
|
||||
|
||||
task.driver.vendor.delete_vnic(task, uuid="1")
|
||||
|
||||
if initial_state != states.POWER_ON:
|
||||
mock_power_action.assert_called_once_with(task, states.REBOOT)
|
||||
else:
|
||||
self.assertFalse(mock_power_action.called)
|
||||
|
||||
mock_port.list_by_node_id.assert_called_with(
|
||||
task.context, task.node.id)
|
||||
|
||||
mock_delete_vnic.assert_called_once_with(task, "1")
|
||||
|
||||
def test_delete_vnic_node_off(self):
|
||||
self._test_delete_vnic()
|
||||
|
||||
def test_delete_vnic_node_already_on(self):
|
||||
self._test_delete_vnic(initial_state=states.POWER_ON)
|
||||
|
||||
@mock.patch.object(objects, 'Port', autospec=True)
|
||||
def test_delete_vnic_port_not_found(self, mock_port):
|
||||
with task_manager.acquire(self.context, self.node.uuid,
|
||||
shared=False) as task:
|
||||
task.node.power_state = states.POWER_ON
|
||||
mock_port.list_by_node_id.return_value = []
|
||||
|
||||
self.assertRaises(exception.NotFound,
|
||||
task.driver.vendor.delete_vnic,
|
||||
task, uuid="1")
|
0
cisco_ironic_contrib/tests/unit/nova/__init__.py
Normal file
0
cisco_ironic_contrib/tests/unit/nova/__init__.py
Normal file
129
cisco_ironic_contrib/tests/unit/nova/test_driver.py
Normal file
129
cisco_ironic_contrib/tests/unit/nova/test_driver.py
Normal file
@ -0,0 +1,129 @@
|
||||
# Copyright 2015, Cisco Systems.
|
||||
#
|
||||
# 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.
|
||||
|
||||
import mock
|
||||
|
||||
from oslo_config import cfg
|
||||
|
||||
from nova import context as nova_context
|
||||
from nova.network.neutronv2 import api as neutron
|
||||
from nova import test
|
||||
from nova.tests.unit import fake_instance
|
||||
from nova.tests.unit import utils
|
||||
from nova.tests.unit.virt.ironic import utils as ironic_utils
|
||||
from nova.virt.ironic import client_wrapper as cw
|
||||
|
||||
from cisco_ironic_contrib.nova import driver
|
||||
|
||||
CONF = cfg.CONF
|
||||
FAKE_CLIENT = ironic_utils.FakeClient()
|
||||
|
||||
|
||||
class FakeClientWrapper(cw.IronicClientWrapper):
|
||||
def _get_client(self):
|
||||
return FAKE_CLIENT
|
||||
|
||||
|
||||
def vendor_passthru(self, *args, **kwargs):
|
||||
pass
|
||||
|
||||
|
||||
def get_by_address(self, *args, **kwargs):
|
||||
pass
|
||||
|
||||
|
||||
FAKE_CLIENT_WRAPPER = FakeClientWrapper()
|
||||
|
||||
ironic_utils.FakeNodeClient.vendor_passthru = vendor_passthru
|
||||
ironic_utils.FakePortClient.get_by_address = get_by_address
|
||||
|
||||
|
||||
@mock.patch.object(cw, 'IronicClientWrapper', lambda *_: FAKE_CLIENT_WRAPPER)
|
||||
class CiscoIronicDriverTestCase(test.NoDBTestCase):
|
||||
|
||||
@mock.patch.object(cw, 'IronicClientWrapper',
|
||||
lambda *_: FAKE_CLIENT_WRAPPER)
|
||||
def setUp(self):
|
||||
super(CiscoIronicDriverTestCase, self).setUp()
|
||||
self.driver = driver.CiscoIronicDriver(None)
|
||||
self.ctx = nova_context.get_admin_context()
|
||||
|
||||
@mock.patch.object(FAKE_CLIENT, 'node')
|
||||
def test_macs_for_instance(self, mock_node):
|
||||
node = ironic_utils.get_test_node()
|
||||
mock_node.get.return_value = node
|
||||
instance = fake_instance.fake_instance_obj(self.ctx,
|
||||
node=node.uuid)
|
||||
result = self.driver.macs_for_instance(instance)
|
||||
self.assertIsNone(result)
|
||||
|
||||
@mock.patch.object(neutron, 'get_client')
|
||||
@mock.patch.object(FAKE_CLIENT.node, 'vendor_passthru')
|
||||
@mock.patch.object(FAKE_CLIENT.port, 'get_by_address')
|
||||
def test_plug_vifs_with_port(self, mock_address, mock_vp, mock_neutron):
|
||||
node = ironic_utils.get_test_node()
|
||||
instance = fake_instance.fake_instance_obj(self.ctx,
|
||||
node=node.uuid)
|
||||
network_info = utils.get_test_network_info()
|
||||
mock_neutron.return_value.show_network.return_value = {
|
||||
'network': {
|
||||
'provider:segmentation_id': 600}}
|
||||
mock_address.return_value = ironic_utils.get_test_port(
|
||||
extra={'state': 'UP'})
|
||||
|
||||
self.driver._plug_vifs(node, instance, network_info)
|
||||
expected_info = {
|
||||
'vlan': 600,
|
||||
'mac': network_info[0]['address'],
|
||||
'uuid': network_info[0]['id'],
|
||||
'pxe': False
|
||||
}
|
||||
mock_vp.assert_called_once_with(node.uuid, 'add_vnic',
|
||||
args=expected_info)
|
||||
mock_address.assert_called_once_with(network_info[0]['address'])
|
||||
|
||||
@mock.patch.object(neutron, 'get_client')
|
||||
@mock.patch.object(FAKE_CLIENT.node, 'vendor_passthru')
|
||||
@mock.patch.object(FAKE_CLIENT.port, 'get_by_address')
|
||||
def test_plug_vifs_no_network_info(self, mock_address, mock_vp,
|
||||
mock_neutron):
|
||||
node = ironic_utils.get_test_node()
|
||||
instance = fake_instance.fake_instance_obj(self.ctx,
|
||||
node=node.uuid)
|
||||
network_info = []
|
||||
self.driver._plug_vifs(node, instance, network_info)
|
||||
self.assertFalse(mock_vp.called)
|
||||
self.assertFalse(mock_address.called)
|
||||
|
||||
@mock.patch.object(FAKE_CLIENT.node, 'vendor_passthru')
|
||||
def test_unplug_vifs(self, mock_vp):
|
||||
node = ironic_utils.get_test_node()
|
||||
instance = fake_instance.fake_instance_obj(self.ctx,
|
||||
node=node.uuid)
|
||||
network_info = utils.get_test_network_info()
|
||||
expected_info = {
|
||||
'uuid': network_info[0]['id'],
|
||||
}
|
||||
self.driver._unplug_vifs(node, instance, network_info)
|
||||
mock_vp.assert_called_once_with(node.uuid, 'delete_vnic',
|
||||
args=expected_info)
|
||||
|
||||
@mock.patch.object(FAKE_CLIENT.node, 'vendor_passthru')
|
||||
def test_unplug_vifs_no_network_info(self, mock_vp):
|
||||
node = ironic_utils.get_test_node()
|
||||
instance = fake_instance.fake_instance_obj(self.ctx,
|
||||
node=node.uuid)
|
||||
network_info = []
|
||||
self.driver._unplug_vifs(node, instance, network_info)
|
||||
self.assertFalse(mock_vp.called)
|
75
doc/source/conf.py
Executable file
75
doc/source/conf.py
Executable file
@ -0,0 +1,75 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# 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.
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
sys.path.insert(0, os.path.abspath('../..'))
|
||||
# -- General configuration ----------------------------------------------------
|
||||
|
||||
# Add any Sphinx extension module names here, as strings. They can be
|
||||
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
|
||||
extensions = [
|
||||
'sphinx.ext.autodoc',
|
||||
#'sphinx.ext.intersphinx',
|
||||
'oslosphinx'
|
||||
]
|
||||
|
||||
# autodoc generation is a bit aggressive and a nuisance when doing heavy
|
||||
# text edit cycles.
|
||||
# execute "export SPHINX_DEBUG=1" in your terminal to disable
|
||||
|
||||
# The suffix of source filenames.
|
||||
source_suffix = '.rst'
|
||||
|
||||
# The master toctree document.
|
||||
master_doc = 'index'
|
||||
|
||||
# General information about the project.
|
||||
project = u'cisco-ironic-contrib'
|
||||
copyright = u'2013, OpenStack Foundation'
|
||||
|
||||
# If true, '()' will be appended to :func: etc. cross-reference text.
|
||||
add_function_parentheses = True
|
||||
|
||||
# If true, the current module name will be prepended to all description
|
||||
# unit titles (such as .. function::).
|
||||
add_module_names = True
|
||||
|
||||
# The name of the Pygments (syntax highlighting) style to use.
|
||||
pygments_style = 'sphinx'
|
||||
|
||||
# -- Options for HTML output --------------------------------------------------
|
||||
|
||||
# The theme to use for HTML and HTML Help pages. Major themes that come with
|
||||
# Sphinx are currently 'default' and 'sphinxdoc'.
|
||||
# html_theme_path = ["."]
|
||||
# html_theme = '_theme'
|
||||
# html_static_path = ['static']
|
||||
|
||||
# Output file base name for HTML help builder.
|
||||
htmlhelp_basename = '%sdoc' % project
|
||||
|
||||
# Grouping the document tree into LaTeX files. List of tuples
|
||||
# (source start file, target name, title, author, documentclass
|
||||
# [howto/manual]).
|
||||
latex_documents = [
|
||||
('index',
|
||||
'%s.tex' % project,
|
||||
u'%s Documentation' % project,
|
||||
u'OpenStack Foundation', 'manual'),
|
||||
]
|
||||
|
||||
# Example configuration for intersphinx: refer to the Python standard library.
|
||||
#intersphinx_mapping = {'http://docs.python.org/': None}
|
4
doc/source/contributing.rst
Normal file
4
doc/source/contributing.rst
Normal file
@ -0,0 +1,4 @@
|
||||
============
|
||||
Contributing
|
||||
============
|
||||
.. include:: ../../CONTRIBUTING.rst
|
25
doc/source/index.rst
Normal file
25
doc/source/index.rst
Normal file
@ -0,0 +1,25 @@
|
||||
.. cisco-ironic-contrib documentation master file, created by
|
||||
sphinx-quickstart on Tue Jul 9 22:26:36 2013.
|
||||
You can adapt this file completely to your liking, but it should at least
|
||||
contain the root `toctree` directive.
|
||||
|
||||
Welcome to cisco-ironic-contrib's documentation!
|
||||
========================================================
|
||||
|
||||
Contents:
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
|
||||
readme
|
||||
installation
|
||||
usage
|
||||
contributing
|
||||
|
||||
Indices and tables
|
||||
==================
|
||||
|
||||
* :ref:`genindex`
|
||||
* :ref:`modindex`
|
||||
* :ref:`search`
|
||||
|
12
doc/source/installation.rst
Normal file
12
doc/source/installation.rst
Normal file
@ -0,0 +1,12 @@
|
||||
============
|
||||
Installation
|
||||
============
|
||||
|
||||
At the command line::
|
||||
|
||||
$ pip install cisco-ironic-contrib
|
||||
|
||||
Or, if you have virtualenvwrapper installed::
|
||||
|
||||
$ mkvirtualenv cisco-ironic-contrib
|
||||
$ pip install cisco-ironic-contrib
|
1
doc/source/readme.rst
Normal file
1
doc/source/readme.rst
Normal file
@ -0,0 +1 @@
|
||||
.. include:: ../../README.rst
|
7
doc/source/usage.rst
Normal file
7
doc/source/usage.rst
Normal file
@ -0,0 +1,7 @@
|
||||
========
|
||||
Usage
|
||||
========
|
||||
|
||||
To use cisco-ironic-contrib in a project::
|
||||
|
||||
import cisco_ironic_contrib
|
6
openstack-common.conf
Normal file
6
openstack-common.conf
Normal file
@ -0,0 +1,6 @@
|
||||
[DEFAULT]
|
||||
|
||||
# The list of modules to copy from oslo-incubator.git
|
||||
|
||||
# The base module to hold the copy of openstack.common
|
||||
base=cisco_ironic_contrib
|
30
pip_install
Executable file
30
pip_install
Executable file
@ -0,0 +1,30 @@
|
||||
#!/bin/sh
|
||||
set -ex
|
||||
|
||||
ZUUL_CLONER=/usr/zuul-env/bin/zuul-cloner
|
||||
|
||||
mkdir -p .test-tars
|
||||
|
||||
if $(python -c "import ironic" 2> /dev/null); then
|
||||
echo "Ironic already installed."
|
||||
elif [ -x $ZUUL_CLONER ]; then
|
||||
$ZUUL_CLONER --cache-dir /opt/git --workspace /tmp git://git.openstack.org openstack/ironic
|
||||
pip install /tmp/openstack/ironic
|
||||
else
|
||||
( cd .test-tars && wget -N http://tarballs.openstack.org/ironic/ironic-master.tar.gz )
|
||||
pip install .test-tars/ironic-master.tar.gz
|
||||
fi
|
||||
|
||||
if $(python -c "import nova" 2> /dev/null); then
|
||||
echo "Nova already installed."
|
||||
elif [ -x $ZUUL_CLONER ]; then
|
||||
$ZUUL_CLONER --cache-dir /opt/git --workspace /tmp git://git.openstack.org openstack/nova
|
||||
pip install /tmp/openstack/nova
|
||||
else
|
||||
( cd .test-tars && wget -N http://tarballs.openstack.org/nova/nova-master.tar.gz )
|
||||
pip install .test-tars/nova-master.tar.gz
|
||||
fi
|
||||
|
||||
pip install -U $*
|
||||
|
||||
exit $?
|
10
requirements.txt
Normal file
10
requirements.txt
Normal file
@ -0,0 +1,10 @@
|
||||
# The order of packages is significant, because pip processes them in the order
|
||||
# of appearance. Changing the order has an impact on the overall integration
|
||||
# process, which may cause wedges in the gate later.
|
||||
|
||||
pbr>=1.6
|
||||
Babel>=1.3
|
||||
oslo.config>=2.3.0 # Apache-2.0
|
||||
oslo.utils>=2.0.0 # Apache-2.0
|
||||
oslo.i18n>=1.5.0 # Apache-2.0
|
||||
mock>=1.2
|
50
setup.cfg
Normal file
50
setup.cfg
Normal file
@ -0,0 +1,50 @@
|
||||
[metadata]
|
||||
name = cisco-ironic-contrib
|
||||
summary = Package containing cisco specific ironic work that doesn't fit into the core ironic tree.
|
||||
description-file =
|
||||
README.rst
|
||||
author = OpenStack
|
||||
author-email = openstack-dev@lists.openstack.org
|
||||
home-page = http://www.openstack.org/
|
||||
classifier =
|
||||
Environment :: OpenStack
|
||||
Intended Audience :: Information Technology
|
||||
Intended Audience :: System Administrators
|
||||
License :: OSI Approved :: Apache Software License
|
||||
Operating System :: POSIX :: Linux
|
||||
Programming Language :: Python
|
||||
Programming Language :: Python :: 2
|
||||
Programming Language :: Python :: 2.7
|
||||
Programming Language :: Python :: 3
|
||||
Programming Language :: Python :: 3.3
|
||||
Programming Language :: Python :: 3.4
|
||||
|
||||
[files]
|
||||
packages =
|
||||
cisco_ironic_contrib
|
||||
|
||||
[entry_points]
|
||||
ironic.drivers =
|
||||
pxe_iscsi_cimc_neutron = cisco_ironic_contrib.ironic.pxe:PXEAndCIMCNeutronDriver
|
||||
|
||||
[build_sphinx]
|
||||
source-dir = doc/source
|
||||
build-dir = doc/build
|
||||
all_files = 1
|
||||
|
||||
[upload_sphinx]
|
||||
upload-dir = doc/build/html
|
||||
|
||||
[compile_catalog]
|
||||
directory = cisco_ironic_contrib/locale
|
||||
domain = cisco-ironic-contrib
|
||||
|
||||
[update_catalog]
|
||||
domain = cisco-ironic-contrib
|
||||
output_dir = cisco_ironic_contrib/locale
|
||||
input_file = cisco_ironic_contrib/locale/cisco-ironic-contrib.pot
|
||||
|
||||
[extract_messages]
|
||||
keywords = _ gettext ngettext l_ lazy_gettext
|
||||
mapping_file = babel.cfg
|
||||
output_file = cisco_ironic_contrib/locale/cisco-ironic-contrib.pot
|
29
setup.py
Normal file
29
setup.py
Normal file
@ -0,0 +1,29 @@
|
||||
# Copyright (c) 2013 Hewlett-Packard Development Company, L.P.
|
||||
#
|
||||
# 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.
|
||||
|
||||
# THIS FILE IS MANAGED BY THE GLOBAL REQUIREMENTS REPO - DO NOT EDIT
|
||||
import setuptools
|
||||
|
||||
# In python < 2.7.4, a lazy loading of package `pbr` will break
|
||||
# setuptools if some other modules registered functions in `atexit`.
|
||||
# solution from: http://bugs.python.org/issue15881#msg170215
|
||||
try:
|
||||
import multiprocessing # noqa
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
setuptools.setup(
|
||||
setup_requires=['pbr'],
|
||||
pbr=True)
|
16
test-requirements.txt
Normal file
16
test-requirements.txt
Normal file
@ -0,0 +1,16 @@
|
||||
# The order of packages is significant, because pip processes them in the order
|
||||
# of appearance. Changing the order has an impact on the overall integration
|
||||
# process, which may cause wedges in the gate later.
|
||||
|
||||
hacking<0.11,>=0.10.2
|
||||
|
||||
coverage>=3.6
|
||||
discover
|
||||
python-subunit>=0.0.18
|
||||
sphinx!=1.2.0,!=1.3b1,<1.3,>=1.1.2
|
||||
oslosphinx>=2.5.0 # Apache-2.0
|
||||
oslotest>=1.10.0 # Apache-2.0
|
||||
testscenarios>=0.4
|
||||
testtools>=1.4.0
|
||||
os-testr>=0.4.1
|
||||
python-ironicclient>=0.8.0
|
39
tox.ini
Normal file
39
tox.ini
Normal file
@ -0,0 +1,39 @@
|
||||
[tox]
|
||||
minversion = 1.8
|
||||
skipsdist = True
|
||||
envlist = py34,py27,pep8
|
||||
|
||||
[testenv]
|
||||
usedevelop = True
|
||||
install_command = {toxinidir}/pip_install {opts} {packages}
|
||||
setenv =
|
||||
VIRTUAL_ENV={envdir}
|
||||
PYTHONDONTWRITEBYTECODE = 1
|
||||
LANGUAGE=en_us
|
||||
deps = -r{toxinidir}/requirements.txt
|
||||
-r{toxinidir}/test-requirements.txt
|
||||
whitelist_externals = bash
|
||||
commands = ostestr {posargs}
|
||||
|
||||
[testenv:pep8]
|
||||
commands = flake8
|
||||
|
||||
[testenv:venv]
|
||||
commands = {posargs}
|
||||
|
||||
[testenv:cover]
|
||||
commands = python setup.py test --coverage --testr-args='{posargs}'
|
||||
|
||||
[testenv:docs]
|
||||
commands = python setup.py build_sphinx
|
||||
|
||||
[testenv:debug]
|
||||
commands = oslo_debug_helper {posargs}
|
||||
|
||||
[flake8]
|
||||
# E123, E125 skipped as they are invalid PEP-8.
|
||||
|
||||
show-source = True
|
||||
ignore = E123,E125
|
||||
builtins = _
|
||||
exclude=.venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg,build
|
Loading…
x
Reference in New Issue
Block a user