Esempio n. 1
0

"""
from boto import ec2
from boto.exception import EC2ResponseError
import boto
import pymongo
from pymongo.read_preferences import ReadPreference
from django.db import models

from mongoengine import DynamicDocument, StringField, DateTimeField, ListField, connect, DictField, BooleanField

from sysadmin.base import get_env_variable


con = connect(get_env_variable("MONGODB_DATABASE"), host=get_env_variable("MONGO_HOST"),
              port=int(get_env_variable("MONGO_PORT")), username=get_env_variable("MONGO_USER"),
              password=get_env_variable("MONGO_PASS"),read_preference=ReadPreference.PRIMARY)

class AwsAccounts(models.Model):
    #aws账号ID 074470703156
    account_id=models.CharField(null=False,blank=False,db_column="account_id",db_index=True,unique=True,verbose_name="账号",max_length=50)
    #Acess key id
    access_key_id=models.CharField(null=False,blank=False,db_column="access_key_id",db_index=True,unique=True,verbose_name="ACCESS_KEY_ID",max_length=50)
    #Access key
    access_key=models.CharField(null=False,blank=False,db_column="access_key",db_index=True,unique=True,verbose_name="ACCESS_KEY",max_length=50)


class EC2Instance(DynamicDocument):
    instance_id = StringField(primary_key=True)
    account_id = StringField()
Esempio n. 2
0
 def __init__(self):
     self.collection = con[get_env_variable("MONGODB_DATABASE")].instances
Esempio n. 3
0

"""
from boto import ec2
from boto.exception import EC2ResponseError
import boto
import pymongo
from pymongo.read_preferences import ReadPreference
from django.db import models

from mongoengine import DynamicDocument, StringField, DateTimeField, ListField, connect, DictField, BooleanField

from sysadmin.base import get_env_variable

con = connect(
    get_env_variable("MONGODB_DATABASE"),
    host=get_env_variable("MONGO_HOST"),
    port=int(get_env_variable("MONGO_PORT")),
    username=get_env_variable("MONGO_USER"),
    password=get_env_variable("MONGO_PASS"),
    read_preference=ReadPreference.PRIMARY)


class AwsAccounts(models.Model):
    #aws账号ID 074470703156
    account_id = models.CharField(
        null=False,
        blank=False,
        db_column="account_id",
        db_index=True,
        unique=True,