Skip to content

Commit

Permalink
Gcp expandr 5021 (demisto#28195)
Browse files Browse the repository at this point in the history
* Update command to return CommandResults with message, instead of throwing an error
* Upated RNs
* Updated docker image
  • Loading branch information
content-bot authored and xsoar-bot committed Aug 2, 2023
1 parent 4a1a99a commit 31c8390
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 38 deletions.
Expand Up @@ -4416,46 +4416,47 @@ def aggregated_list_instances_ip(args: Dict[str, Any]) -> CommandResults:
project = raw.split('/')[-1]
else:
raise ValueError("Unable to find project of the asset")
else:
raise ValueError("Unable to find asset with IP address. If you are using an organization service account, \
please make sure the default_search_scope integration parameter is set.")

output = []
data_res = []
output = []
data_res = []

request_comp = get_compute().instances().aggregatedList(
project=project,
)
while request_comp:
response_comp = request_comp.execute()
if 'items' in response_comp.keys():
for _, instances_scoped_list in response_comp['items'].items():
if 'warning' not in instances_scoped_list.keys():
for inst in instances_scoped_list.get('instances', []):
for interface in inst.get('networkInterfaces', []):
for config in interface.get('accessConfigs', []):
# only add if 'natIP' (public IP) matches.
if config.get('natIP') == ip:
output.append(inst)
data_res_item = {
'id': inst.get('id'),
'name': inst.get('name'),
'machineType': inst.get('machineType'),
'zone': inst.get('zone'),
}
data_res.append(data_res_item)

request_comp = get_compute().instances().aggregatedList_next(
previous_request=request_comp, previous_response=response_comp
request_comp = get_compute().instances().aggregatedList(
project=project,
)
while request_comp:
response_comp = request_comp.execute()
if 'items' in response_comp.keys():
for _, instances_scoped_list in response_comp['items'].items():
if 'warning' not in instances_scoped_list.keys():
for inst in instances_scoped_list.get('instances', []):
for interface in inst.get('networkInterfaces', []):
for config in interface.get('accessConfigs', []):
# only add if 'natIP' (public IP) matches.
if config.get('natIP') == ip:
output.append(inst)
data_res_item = {
'id': inst.get('id'),
'name': inst.get('name'),
'machineType': inst.get('machineType'),
'zone': inst.get('zone'),
}
data_res.append(data_res_item)

request_comp = get_compute().instances().aggregatedList_next(
previous_request=request_comp, previous_response=response_comp
)

return CommandResults(
readable_output=tableToMarkdown('Google Cloud Compute Instances', data_res, removeNull=True),
raw_response=response_comp,
outputs_prefix='GoogleCloudCompute.Instances',
outputs_key_field='id',
outputs=output
)
return CommandResults(
readable_output=tableToMarkdown('Google Cloud Compute Instances', data_res, removeNull=True),
raw_response=response_comp,
outputs_prefix='GoogleCloudCompute.Instances',
outputs_key_field='id',
outputs=output
)
else:
return CommandResults(
readable_output='Unable to find asset with IP address. If you are using an organization service account,'
'please make sure the default_search_scope integration parameter is set.')


def add_networks_tag(args: Dict[str, Any]) -> CommandResults:
Expand Down
Expand Up @@ -8418,7 +8418,7 @@ script:
- contextPath: GoogleCloudCompute.Instances.kind
description: '] Type of the resource. Always compute#instance for instances.'
type: string
dockerimage: demisto/googleapi-python3:1.0.0.64077
dockerimage: demisto/googleapi-python3:1.0.0.65068
script: ''
subtype: python3
type: python
Expand Down
7 changes: 7 additions & 0 deletions Packs/GoogleCloudCompute/ReleaseNotes/1_1_4.md
@@ -0,0 +1,7 @@

#### Integrations

##### Google Cloud Compute

- Updated the docker image to: **demisto/googleapi-python3:1.0.0.65068**.
- Updated the **!gcp-compute-aggregated-list-instances-by-ip** command to return a message when no Virtual Machines are found, instead of an error.
2 changes: 1 addition & 1 deletion Packs/GoogleCloudCompute/pack_metadata.json
Expand Up @@ -2,7 +2,7 @@
"name": "Google Cloud Compute",
"description": "Google Compute Engine delivers virtual machines running in Google's innovative data centers and worldwide fiber network. Compute Engine's tooling and workflow support enable scaling from single instances to global, load-balanced cloud computing.",
"support": "xsoar",
"currentVersion": "1.1.3",
"currentVersion": "1.1.4",
"author": "Cortex XSOAR",
"url": "https://www.paloaltonetworks.com/cortex",
"email": "",
Expand Down

0 comments on commit 31c8390

Please sign in to comment.