def env(*_vars, **kwargs): """Search for the first defined of possibly many env vars Returns the first environment variable defined in vars, or returns the default defined in kwargs. """ for v in _vars: value = os.environ.get(v, None) if value: return value return kwargs.get('default', '') COMMAND_V2 = { 'net-list': utils.import_class( 'quantumclient.quantum.v2_0.network.ListNetwork'), 'net-show': utils.import_class( 'quantumclient.quantum.v2_0.network.ShowNetwork'), 'net-create': utils.import_class( 'quantumclient.quantum.v2_0.network.CreateNetwork'), 'net-delete': utils.import_class( 'quantumclient.quantum.v2_0.network.DeleteNetwork'), 'net-update': utils.import_class( 'quantumclient.quantum.v2_0.network.UpdateNetwork'), 'subnet-list': utils.import_class( 'quantumclient.quantum.v2_0.subnet.ListSubnet'), 'subnet-show': utils.import_class( 'quantumclient.quantum.v2_0.subnet.ShowSubnet'), 'subnet-create': utils.import_class( 'quantumclient.quantum.v2_0.subnet.CreateSubnet'), 'subnet-delete': utils.import_class(
def env(*_vars, **kwargs): """Search for the first defined of possibly many env vars Returns the first environment variable defined in vars, or returns the default defined in kwargs. """ for v in _vars: value = os.environ.get(v, None) if value: return value return kwargs.get("default", "") COMMAND_V2 = { "net-list": utils.import_class("quantumclient.quantum.v2_0.network.ListNetwork"), "net-external-list": utils.import_class("quantumclient.quantum.v2_0.network.ListExternalNetwork"), "net-show": utils.import_class("quantumclient.quantum.v2_0.network.ShowNetwork"), "net-create": utils.import_class("quantumclient.quantum.v2_0.network.CreateNetwork"), "net-delete": utils.import_class("quantumclient.quantum.v2_0.network.DeleteNetwork"), "net-update": utils.import_class("quantumclient.quantum.v2_0.network.UpdateNetwork"), "subnet-list": utils.import_class("quantumclient.quantum.v2_0.subnet.ListSubnet"), "subnet-show": utils.import_class("quantumclient.quantum.v2_0.subnet.ShowSubnet"), "subnet-create": utils.import_class("quantumclient.quantum.v2_0.subnet.CreateSubnet"), "subnet-delete": utils.import_class("quantumclient.quantum.v2_0.subnet.DeleteSubnet"), "subnet-update": utils.import_class("quantumclient.quantum.v2_0.subnet.UpdateSubnet"), "port-list": utils.import_class("quantumclient.quantum.v2_0.port.ListPort"), "port-show": utils.import_class("quantumclient.quantum.v2_0.port.ShowPort"), "port-create": utils.import_class("quantumclient.quantum.v2_0.port.CreatePort"), "port-delete": utils.import_class("quantumclient.quantum.v2_0.port.DeletePort"), "port-update": utils.import_class("quantumclient.quantum.v2_0.port.UpdatePort"),
def env(*vars, **kwargs): """Search for the first defined of possibly many env vars Returns the first environment variable defined in vars, or returns the default defined in kwargs. """ for v in vars: value = os.environ.get(v, None) if value: return value return kwargs.get("default", "") COMMAND_V1 = { "list_nets": utils.import_class("quantumclient.quantum.v1_1.network.ListNetwork"), "show_net": utils.import_class("quantumclient.quantum.v1_1.network.ShowNetwork"), "create_net": utils.import_class("quantumclient.quantum.v1_1.network.CreateNetwork"), "delete_net": utils.import_class("quantumclient.quantum.v1_1.network.DeleteNetwork"), "update_net": utils.import_class("quantumclient.quantum.v1_1.network.UpdateNetwork"), "list_ports": utils.import_class("quantumclient.quantum.v1_1.port.ListPort"), "show_port": utils.import_class("quantumclient.quantum.v1_1.port.ShowPort"), "create_port": utils.import_class("quantumclient.quantum.v1_1.port.CreatePort"), "delete_port": utils.import_class("quantumclient.quantum.v1_1.port.DeletePort"), "update_port": utils.import_class("quantumclient.quantum.v1_1.port.UpdatePort"), "plug_iface": utils.import_class("quantumclient.quantum.v1_1.interface.PlugInterface"), "unplug_iface": utils.import_class("quantumclient.quantum.v1_1.interface.UnPlugInterface"), "show_iface": utils.import_class("quantumclient.quantum.v1_1.interface.ShowInterface"), } COMMAND_V2 = { "list_nets": utils.import_class("quantumclient.quantum.v2_0.network.ListNetwork"),
def env(*_vars, **kwargs): """Search for the first defined of possibly many env vars Returns the first environment variable defined in vars, or returns the default defined in kwargs. """ for v in _vars: value = os.environ.get(v, None) if value: return value return kwargs.get('default', '') COMMAND_V2 = { 'net-list': utils.import_class( 'quantumclient.quantum.v2_0.network.ListNetwork'), 'net-external-list': utils.import_class( 'quantumclient.quantum.v2_0.network.ListExternalNetwork'), 'net-show': utils.import_class( 'quantumclient.quantum.v2_0.network.ShowNetwork'), 'net-create': utils.import_class( 'quantumclient.quantum.v2_0.network.CreateNetwork'), 'net-delete': utils.import_class( 'quantumclient.quantum.v2_0.network.DeleteNetwork'), 'net-update': utils.import_class( 'quantumclient.quantum.v2_0.network.UpdateNetwork'), 'subnet-list': utils.import_class( 'quantumclient.quantum.v2_0.subnet.ListSubnet'), 'subnet-show': utils.import_class( 'quantumclient.quantum.v2_0.subnet.ShowSubnet'), 'subnet-create': utils.import_class(
# License for the specific language governing permissions and limitations # under the License. import sys from quantum.agent.common import config from quantum.agent.linux import interface from quantum.debug.debug_agent import QuantumDebugAgent from quantum.openstack.common import cfg from quantum.openstack.common import importutils from quantumclient.common import exceptions as exc from quantumclient.common import utils from quantumclient.shell import env, QuantumShell, QUANTUM_API_VERSION COMMAND_V2 = { 'probe-create': utils.import_class( 'quantum.debug.commands.CreateProbe'), 'probe-delete': utils.import_class( 'quantum.debug.commands.DeleteProbe'), 'probe-list': utils.import_class( 'quantum.debug.commands.ListProbe'), 'probe-clear': utils.import_class( 'quantum.debug.commands.ClearProbe'), 'probe-exec': utils.import_class( 'quantum.debug.commands.ExecProbe'), 'ping-all': utils.import_class( 'quantum.debug.commands.PingAll'), #TODO(nati) ping, netcat , nmap, bench } COMMANDS = {'2.0': COMMAND_V2}
import itertools import sys from quantum.agent.common import config from quantum.agent.linux import interface import quantum.debug.commands from quantum.debug.debug_agent import QuantumDebugAgent from quantum.openstack.common import cfg from quantum.openstack.common import importutils from quantumclient.common import exceptions as exc from quantumclient.common import utils from quantumclient.shell import env, QuantumShell, QUANTUM_API_VERSION COMMAND_V2 = { 'probe-create': utils.import_class('quantum.debug.commands.CreateProbe'), 'probe-delete': utils.import_class('quantum.debug.commands.DeleteProbe'), 'probe-list': utils.import_class('quantum.debug.commands.ListProbe'), 'probe-clear': utils.import_class('quantum.debug.commands.ClearProbe'), 'probe-exec': utils.import_class('quantum.debug.commands.ExecProbe'), 'ping-all': utils.import_class('quantum.debug.commands.PingAll'), #TODO(nati) ping, netcat , nmap, bench } COMMANDS = {'2.0': COMMAND_V2} class QuantumDebugShell(QuantumShell): def __init__(self, api_version): super(QuantumDebugShell, self).__init__(api_version) for k, v in COMMANDS[api_version].items(): self.command_manager.add_command(k, v)
# License for the specific language governing permissions and limitations # under the License. import sys from quantum.agent.common import config from quantum.agent.linux import interface from quantum.debug.debug_agent import QuantumDebugAgent from quantum.openstack.common import cfg from quantum.openstack.common import importutils from quantumclient.common import exceptions as exc from quantumclient.common import utils from quantumclient.shell import env, QuantumShell, QUANTUM_API_VERSION COMMAND_V2 = { "probe-create": utils.import_class("quantum.debug.commands.CreateProbe"), "probe-delete": utils.import_class("quantum.debug.commands.DeleteProbe"), "probe-list": utils.import_class("quantum.debug.commands.ListProbe"), "probe-clear": utils.import_class("quantum.debug.commands.ClearProbe"), "probe-exec": utils.import_class("quantum.debug.commands.ExecProbe"), "ping-all": utils.import_class("quantum.debug.commands.PingAll"), # TODO(nati) ping, netcat , nmap, bench } COMMANDS = {"2.0": COMMAND_V2} class QuantumDebugShell(QuantumShell): def __init__(self, api_version): super(QuantumDebugShell, self).__init__(api_version) for k, v in COMMANDS[api_version].items(): self.command_manager.add_command(k, v)
def test_import_class(self): dt = utils.import_class('datetime.datetime') self.assertTrue(sys.modules['datetime'].datetime is dt)