Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add list services #27

Merged
merged 1 commit into from
Jun 19, 2024
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
9 changes: 5 additions & 4 deletions .env.dist
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
OVH_APPLICATION_KEY=
OVH_APPLICATION_SECRET=
OVH_CONSUMER_KEY=
OVH_ENDPOINT=

export OVH_APPLICATION_KEY=""
export OVH_APPLICATION_SECRET=""
export OVH_CONSUMER_KEY=""
export OVH_ENDPOINT="ovh-eu"
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
###############################################################
# RENSEIGNEZ LE(S) NOM(S) DE DOMAINES #
###############################################################
include_domains = ["crysalide.fr"]
include_domains = ["citae.fr"]

###############################################################
# RENSEIGNEZ L'ADRESSE IP A SUPPRIMER #
###############################################################
address_to_delete = "37.59.56.80"
address_to_delete = "54.194.75.31"

class OVHClient:
def __init__(self, application_key, application_secret, consumer_key):
Expand Down
74 changes: 74 additions & 0 deletions List-services.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import datetime
from decouple import config
from tabulate import tabulate
import os
import ovh

# Services type desired to mine. To speed up the script, delete service type you don't use!
service_types = [
"allDom",
"cdn/dedicated",
"cdn/website",
"cdn/webstorage",
"cloud/project",
"cluster/hadoop",
"dedicated/housing",
"dedicated/nas",
"dedicated/nasha",
"dedicated/server",
"dedicatedCloud",
"domain/zone",
"email/domain",
"email/exchange",
"freefax",
"hosting/privateDatabase",
"hosting/web",
"hosting/windows",
"hpcspot",
"license/cloudLinux",
"license/cpanel",
"license/directadmin",
"license/office",
"license/plesk",
"license/sqlserver",
"license/virtuozzo",
"license/windows",
"license/worklight",
"overTheBox",
"pack/xdsl",
"partner",
"router",
"sms",
"telephony",
"telephony/spare",
"veeamCloudConnect",
"vps",
"xdsl",
"xdsl/spare",
]

# # Create a client using ovh.conf
# client = ovh.Client()


client = ovh.Client(
endpoint=config("OVH_ENDPOINT"),
application_key=config("OVH_APPLICATION_KEY"),
application_secret=config("OVH_APPLICATION_SECRET"),
consumer_key=config("OVH_CONSUMER_KEY"),
)

services_will_expired = []

# Check all OVH product (service type)
for service_type in service_types:
service_list = client.get("/%s" % service_type)

# If we found you have this one or more of this product, we get these information
for service in service_list:
service_infos = client.get("/%s/%s/serviceInfos" % (service_type, service))
service_expiration_date = datetime.datetime.strptime(service_infos["expiration"], "%Y-%m-%d")
services_will_expired.append([service_type, service, service_infos["status"], service_infos["expiration"]])

# At the end, we show service expired or that will expire (in a table with tabulate)
print(tabulate(services_will_expired, headers=["Type", "ID", "status", "expiration date"]))
Loading