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
unattachedDisk=`az disk list --query "[?diskState=='Unattached'].id" --output table | grep sub` | |
for diskId in ${unattachedDisk} | |
do | |
echo ${diskId} | |
az disk delete --ids ${diskId} --yes --no-wait | |
done |
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
#vars | |
# SERVICE_ACCOUNT_FILE --> Service Account Json file | |
# project --> Gcp Project Name | |
# zone --> zone in which instance is created | |
# instance_name --> Instance name | |
from google.oauth2 import service_account | |
from googleapiclient import discovery | |
SCOPES = ["https://www.googleapis.com/auth/cloud-platform"] |
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
from datetime import datetime | |
from pytz import timezone | |
def get_pst_time(): | |
date_format='%m_%d_%Y_%H_%M_%S_%Z' | |
date = datetime.now(tz=pytz.utc) | |
date = date.astimezone(timezone('US/Pacific')) | |
pstDateTime=date.strftime(date_format) | |
return pstDateTime |
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 logging | |
import paramiko | |
class SSH: | |
def __init__(self): | |
pass | |
def get_ssh_connection(self, ssh_machine, ssh_username, ssh_password): | |
"""Establishes a ssh connection to execute command. | |
:param ssh_machine: IP of the machine to which SSH connection to be established. |
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 logging | |
import paramiko | |
class SSH: | |
def __init__(self): | |
pass | |
def get_ssh_connection(self, ssh_machine, ssh_username, ssh_password): | |
"""Establishes a ssh connection to execute command. | |
:param ssh_machine: IP of the machine to which SSH connection to be established. |
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
''' | |
@author: vladwa | |
@Email : [email protected] | |
''' | |
# importing the smtplib library | |
import smtplib | |
from email.mime.multipart import MIMEMultipart | |
from email.mime.base import MIMEBase | |
from email.mime.text import MIMEText |
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
# importing the requests library | |
import requests | |
def postFileAttachment(url,fileName,contentType): | |
"""Sends a POST request. | |
:param url: URL for the new :class:`Request` object. | |
:param fileName: File to be sent/attached in the body of the request. | |
:return: :class:`Response <Response>` object. | |
""" | |
multipart = MultipartEncoder( |
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
# importing the requests library | |
import requests | |
def getResponse(url,header,contentType): | |
"""Sends a getRequest. | |
:param url: URL for the new :class:`Request` object. | |
:return: :class:`Response <Response>` object. | |
""" | |
headers1={'Authorization': headerToken} | |
response = requests.get(url, headers=headers1,timeout=5) |
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
# importing the requests library | |
import requests | |
def getPostRestResponse(restUrl,inputRequest,contentType): | |
"""Sends a POST request. | |
:param url: URL for the new :class:`Request` object. | |
:param inputRequest: Data to send in the body of the request. | |
:return: :class:`Response <Response>` object. | |
""" | |
content = {'content-type': contentType} |