Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
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
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include common/graphql/*.graphql
7 changes: 6 additions & 1 deletion rubrik_polaris/common/graphql.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"""

import re
import sys

def _build_graphql_maps(self):
from os import listdir
Expand All @@ -36,8 +37,12 @@ def _build_graphql_maps(self):
file_mutation_prefix = 'mutation'
file_suffix = '.graphql'

graphql_files = [f for f in listdir(self._data_path)
try:
graphql_files = [f for f in listdir(self._data_path)
if isfile(join(self._data_path, f)) and f.endswith(file_suffix)]
except:
print("Unexpected error:", sys.exc_info()[0])
raise

for f in graphql_files:
query_name = f.replace(file_suffix, '')
Expand Down
7 changes: 7 additions & 0 deletions rubrik_polaris/common/graphql/query_accounts_aws.graphql
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
query RubrikPolarisSDKRequest($awsNativeProtectionFeature: AwsNativeProtectionFeature = EC2, $filter: String = "" ) {
anomalyResults{
edges {
node {

}
}
}
awsNativeAccounts(awsNativeProtectionFeature: $awsNativeProtectionFeature, accountFilters: {
nameSubstringFilter: {
nameSubstring: $filter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ query RubrikPolarisSDKRequest($first: Int, $after: String, $filter: [Filter!]!)
scheduledCount
totalCount
}
resourceSpec {
networkInterfaces {
macAddress,
v4Addresses
}
}
reportSnappable : reportWorkload {
id
archiveStorage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ query RubrikPolarisSDKRequest($object_id: UUID!) {
name
}
protectionDate
resourceSpec {
networkInterfaces {
macAddress,
v4Addresses
}
}
reportSnappable : reportWorkload {
id
logicalBytes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ query RubrikPolarisSDKRequest($id: UUID!) {
authorizedOperations
name
isRelic
defaultAddress
effectiveSlaDomain {
...EffectiveSLADomainFragment
}
Expand Down
25 changes: 25 additions & 0 deletions rubrik_polaris/common/graphql/test.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
query VSphereVMsListQuery($first: Int!, $after: String, $filter: [Filter!]!, $sortBy: HierarchySortByField, $sortOrder: HierarchySortOrder) {
vSphereVmNewConnection(
filter: $filter
first: $first
after: $after
sortBy: $sortBy
sortOrder: $sortOrder
) {
edges {
cursor
node {
resourceSpec {
networkInterfaces {
macAddress,
v4Addresses
}
}
id

}
__typename
}
}
}

13 changes: 11 additions & 2 deletions rubrik_polaris/compute/vsphere.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def get_compute_object_ids_vsphere(self, match_all=True, **kwargs):
raise


def get_compute_vsphere(self):
def get_compute_vsphere(self, vmid=None):
"""Retrieves all VMware VM object details (Under development)

Returns:
Expand All @@ -47,11 +47,20 @@ def get_compute_vsphere(self):
RequestException: If the query to Polaris returned an error
"""
try:
if vmid:
query_name = "compute_vmware_vsphere_detail"
self._validate(
query_name=query_name
)
variables = {"object_id": vmid}
return self._query(query_name, variables)
query_name = "compute_vmware_vsphere"
# self._validate(
# query_name=query_name
# )
variables = {"filter": [], "first": 500}
return self._query(query_name, variables)
except Exception:
raise
raise


3 changes: 2 additions & 1 deletion rubrik_polaris/rubrik_polaris.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import pprint
import urllib3
import re
import sys
import json
import logging
from .exceptions import RequestException
Expand Down Expand Up @@ -123,7 +124,7 @@ def __init__(self, domain=None, username=None, password=None, json_keyfile=None,

# Set base variables
self._kwargs = kwargs
self._data_path = "{}/graphql/".format(os.path.dirname(os.path.realpath(__file__)))
self._data_path = "{}/common/graphql/".format(os.path.dirname(os.path.realpath(__file__)))

# Switch off SSL checks if needed
if 'insecure' in self._kwargs and self._kwargs['insecure']:
Expand Down
Loading