Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 5 additions & 12 deletions SoftLayer/CLI/virt/list.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,11 @@
column_helper.Column('backend_ip', ('primaryBackendIpAddress',)),
column_helper.Column('datacenter', ('datacenter', 'name')),
column_helper.Column('action', lambda guest: formatting.active_txn(guest),
mask='''
activeTransaction[
id,transactionStatus[name,friendlyName]
]'''),
mask='activeTransaction[id,transactionStatus[name,friendlyName]]'),
column_helper.Column('power_state', ('powerState', 'name')),
column_helper.Column(
'created_by',
('billingItem', 'orderItem', 'order', 'userRecord', 'username')),
column_helper.Column(
'tags',
lambda server: formatting.tags(server.get('tagReferences')),
mask="tagReferences.tag.name"),
column_helper.Column('created_by', ('billingItem', 'orderItem', 'order', 'userRecord', 'username')),
column_helper.Column('tags', lambda server: formatting.tags(server.get('tagReferences')),
mask="tagReferences.tag.name"),
column_helper.Column(
'createDate',
lambda guest: utils.clean_time(guest.get('createDate'),
Expand Down Expand Up @@ -59,7 +52,7 @@
@click.option('--network', '-n', help='Network port speed in Mbps')
@click.option('--hourly', is_flag=True, help='Show only hourly instances')
@click.option('--monthly', is_flag=True, help='Show only monthly instances')
@click.option('--tag', '-t', help='list of tags')
@click.option('--tag', '-t', help='list of tags', multiple=True)
@click.option('--transient', help='Filter by transient instances', type=click.BOOL)
@click.option('--search', is_flag=False, flag_value="", default=None,
help="Use the more flexible Search API to list instances. See `slcli search --types` for list " +
Expand Down
4 changes: 2 additions & 2 deletions SoftLayer/managers/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ def search_instances(self, search_string, mask=None, **kwargs):
if kwargs.get('datacenter'):
search_string = f"{search_string} datacenter.longName: *{kwargs.get('datacenter')}*"
if kwargs.get('tags'):
tags = " ".join(kwargs.get("tags", []))
search_string = f"{search_string} internalTagReferences.tag.name: {tags}"
tags = " ".join(f"tagReferences.tag.name: \"{t}\"" for t in kwargs.get("tags", []))
search_string = f"{search_string} {tags}"
result = self.search_manager.advancedSearch(search_string, mask=mask)
guests = []
for resource in result:
Expand Down
2 changes: 1 addition & 1 deletion SoftLayer/managers/vs.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def list_instances(self, hourly=True, monthly=True, tags=None, cpus=None,
if tags:
_filter['virtualGuests']['tagReferences']['tag']['name'] = {
'operation': 'in',
'options': [{'name': 'data', 'value': tags}],
'options': [{'name': 'data', 'value': list(tags)}],
}

if cpus:
Expand Down
2 changes: 1 addition & 1 deletion tests/managers/search_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@ def test_search_instances_basic(self):
args=(f"{expected} datacenter.longName: *dal13*",))
self.search.search_instances(search_string, tags=["thisTag"])
self.assert_called_with('SoftLayer_Search', 'advancedSearch',
args=(f"{expected} internalTagReferences.tag.name: thisTag",))
args=(f"{expected} tagReferences.tag.name: \"thisTag\"",))