Last active
October 21, 2015 21:31
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
DEBUG:lavaadminclient2.cli:Error while executing command | |
Traceback (most recent call last): | |
File "/big_data/fork_code/python-lavaadminclient2/lavaadminclient2/cli.py", line 241, in main | |
execute_command(client, args) | |
File "/big_data/fork_code/python-lavaadminclient2/lavaadminclient2/cli.py", line 138, in execute_command | |
call_action(action, args) | |
File "/big_data/fork_code/python-lavaadminclient2/lavaadminclient2/cli.py", line 108, in call_action | |
return print_action(func, *f_args, **f_kwargs) | |
File "/big_data/fork_code/python-lavaadminclient2/lavaadminclient2/cli.py", line 95, in print_action | |
func.display(func.__self__, *args, **kwargs) | |
File "/virtualenvs/admin2/lib/python2.7/site-packages/lavaclient/util.py", line 253, in display_func | |
response_config.display(result) | |
File "/big_data/fork_code/python-lavaadminclient2/lavaadminclient2/api/response.py", line 346, in display | |
display_result(self, NetworkDetail, title='Network') | |
File "/virtualenvs/admin2/lib/python2.7/site-packages/lavaclient/util.py", line 230, in display_result | |
print_single_table(data, header, title=title) | |
File "/virtualenvs/admin2/lib/python2.7/site-packages/lavaclient/util.py", line 172, in print_single_table | |
print_titled(create_single_table(data, header), title) | |
File "/virtualenvs/admin2/lib/python2.7/site-packages/lavaclient/util.py", line 141, in print_titled | |
width = len(str(table).split('\n', 1)[0]) | |
File "/virtualenvs/admin2/lib/python2.7/site-packages/prettytable.py", line 240, in __str__ | |
return self.__unicode__().encode(self.encoding) | |
File "/virtualenvs/admin2/lib/python2.7/site-packages/prettytable.py", line 243, in __unicode__ | |
return self.get_string() | |
File "/virtualenvs/admin2/lib/python2.7/site-packages/prettytable.py", line 984, in get_string | |
rows = self._get_rows(options) | |
File "/virtualenvs/admin2/lib/python2.7/site-packages/prettytable.py", line 926, in _get_rows | |
rows = copy.deepcopy(self._rows[options["start"]:options["end"]]) | |
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py", line 163, in deepcopy | |
y = copier(x, memo) | |
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py", line 230, in _deepcopy_list | |
y.append(deepcopy(a, memo)) | |
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py", line 163, in deepcopy | |
y = copier(x, memo) | |
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py", line 230, in _deepcopy_list | |
y.append(deepcopy(a, memo)) | |
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py", line 163, in deepcopy | |
y = copier(x, memo) | |
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py", line 230, in _deepcopy_list | |
y.append(deepcopy(a, memo)) | |
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py", line 190, in deepcopy | |
y = _reconstruct(x, rv, 1, memo) | |
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py", line 334, in _reconstruct | |
state = deepcopy(state, memo) | |
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py", line 163, in deepcopy | |
y = copier(x, memo) | |
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py", line 257, in _deepcopy_dict | |
y[deepcopy(key, memo)] = deepcopy(value, memo) | |
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py", line 190, in deepcopy | |
y = _reconstruct(x, rv, 1, memo) | |
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py", line 334, in _reconstruct | |
state = deepcopy(state, memo) | |
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py", line 163, in deepcopy | |
y = copier(x, memo) | |
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py", line 257, in _deepcopy_dict | |
y[deepcopy(key, memo)] = deepcopy(value, memo) | |
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py", line 190, in deepcopy | |
y = _reconstruct(x, rv, 1, memo) | |
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py", line 329, in _reconstruct | |
y = callable(*args) | |
File "/virtualenvs/admin2/lib/python2.7/copy_reg.py", line 93, in __newobj__ | |
return cls.__new__(cls, *args) | |
TypeError: object.__new__(thread.lock) is not safe, use thread.lock.__new__() |
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
import six | |
import logging | |
from figgis import Config, Field, ListField | |
from lavaclient.util import display_table, CommandLine, command, display_result, print_table, \ | |
argument, confirm | |
from lavaadminclient2.api.response import Network, NetworkDetail | |
from lavaclient.api import resource | |
LOG = logging.getLogger(__name__) | |
###################################################################### | |
# API Response | |
###################################################################### | |
class NetworksResponse(Config): | |
networks = ListField(Network, required=True) | |
class NetworkResponse(Config): | |
network = Field(NetworkDetail, required=True) | |
###################################################################### | |
# API Resource | |
###################################################################### | |
@six.add_metaclass(CommandLine) | |
class Resource(resource.Resource): | |
"""Networks API methods""" | |
@command( | |
parser_options=dict( | |
description='List all rackconnect networks', | |
), | |
) | |
@display_table(Network) | |
def list(self): | |
return self._parse_response( | |
self._client._get('/networks'), | |
NetworksResponse, | |
wrapper='networks') | |
@command( | |
parser_options=dict( | |
description='Display an existing rackconnect network in detail', | |
), | |
network_id=argument(help='The ID of network') | |
) | |
@display_table(NetworkDetail) | |
def get(self, network_id): | |
return self._parse_response( | |
self._client._get("/networks/{0}".format(network_id)), | |
NetworkResponse, | |
wrapper='network') | |
@command( | |
parser_options=dict( | |
description='Create a rackconnect network', | |
), | |
name=argument(help='Rackconnect network name'), | |
tenant_id=argument(help='Customer rackconnect tenant_id'), | |
) | |
@display_table(NetworkDetail) | |
def create(self, name, tenant_id): | |
return self._parse_response( | |
self._client._post('/networks', | |
json={'network': {'name': name, 'admin_state_up': True, | |
'tenant_id': tenant_id}}), | |
NetworkResponse, | |
wrapper='network') | |
@command( | |
parser_options=dict( | |
description='Update rackconnect network status', | |
), | |
network_id=argument(help='The ID of network'), | |
status=argument(help='Rackconnect network status, choose from ACTIVE, PENDING, DELETED'), | |
) | |
@display_table(Network) | |
def update(self, network_id, status): | |
return self._parse_response( | |
self._client._put('networks/{0}'.format(network_id), | |
json={'availability': status}), | |
NetworkResponse, | |
wrapper='network') | |
@command( | |
parser_options=dict( | |
description='Delete a rackconnect network', | |
), | |
network_id=argument(help='The ID of network'), | |
force=argument( | |
action='store_true', | |
help="Suppress delete confirmation dialog") | |
) | |
def delete(self, network_id, force=False): | |
if not force: | |
if not confirm('Remove this rackconnect network?'): | |
return | |
self._client._delete('networks/{0}'.format(network_id)) |
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
class AllocationPools(Config, ReprMixin): | |
table_columns = ('start', 'end') | |
table_header = ('Start IP', 'End IP') | |
start = Field(six.text_type, required=True) | |
end = Field(six.text_type, required=True) | |
def display(self): | |
display_result(self, AllocationPools, title='Allocation Pools') | |
class HostRoutes(Config, ReprMixin): | |
table_columns = ('next_hop', 'destination') | |
table_header = ('Nexthop', 'Destination') | |
next_hop = Field(six.text_type, required=True, key='nexthop') | |
destination = Field(six.text_type, required=True, key='destination') | |
def display(self): | |
display_result(self, HostRoutes, title='Host Routes') | |
class Subnet(Config, ReprMixin): | |
table_columns = ('id', 'cidr', 'network_id') | |
table_header = ('ID', 'CIDR', 'Network') | |
id = Field(six.text_type, required=True) | |
cidr = Field(six.text_type, required=True) | |
network_id = Field(six.text_type, required=True) | |
class SubnetDetail(Config, ReprMixin): | |
__inherits__ = [Subnet] | |
name = Field(six.text_type, required=False) | |
ip_version = Field(six.text_type, required=False) | |
allocation_pools = ListField(AllocationPools) | |
host_routes = ListField(HostRoutes) | |
def display(self): | |
display_result(self, SubnetDetail, title='Subnet') | |
if self.host_routes: | |
six.print_() | |
display_result(self.routes, HostRoutes) | |
if self.allocation_pools: | |
six.print_() | |
display_result(self.allocation_pools, AllocationPools) | |
class Network(Config, ReprMixin): | |
table_columns = ('id', 'tenant_id', 'status') | |
table_header = ('ID', 'Tenant', 'Status') | |
id = Field(six.text_type, required=True,) | |
tenant_id = Field(six.text_type, required=True) | |
status = Field(six.text_type, required=True) | |
class NetworkDetail(Config, ReprMixin): | |
__inherits__ = [Network] | |
subnets = ListField(Subnet) | |
def display(self): | |
display_result(self, NetworkDetail, title='Network') | |
if self.subnets: | |
six.print_() | |
display_result(self.subnets, Subnet, title='Subnet') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment