Ejemplo n.º 1
0
class Cloud:
    def __init__(self, cloud_name):
        self.cloud_id = None
        self.cloud_name = cloud_name
        self.url = None
        self.protocol = None
        self.region = None
        self.provider = None
        self.default_account = None
        self.path = "/"
        self.conn = None
        self.api_version = None
    
        db = catocommon.new_conn()
        sql = """select cloud_id, provider, api_url, api_protocol, default_account_id, region
            from clouds where cloud_name = %s"""
        row = db.select_row(sql, (cloud_name))
        db.close()
        if not row:
            msg = "The Cloud endpoint name %s is not configured in the database" % cloud_name
            raise Exception(msg) 

        self.cloud_id, self.provider, self.url, self.protocol, self.default_account, self.region = row[:]
        self.cloud_name = cloud_name

        if self.provider == "Amazon AWS":
            self.url = None
        elif self.provider == "Eucalyptus":
            self.path = "/services/Eucalyptus/"
            self.api_version = "2010-08-31"
        

    def connect(self, uid, pwd):
        # from vmware.vsphere import Server
        from catosphere import Server
        self.server = Server()
        self.server.connect(url=self.url, username=uid, password=pwd)
Ejemplo n.º 2
0
 def connect(self, uid, pwd):
     # from vmware.vsphere import Server
     from catosphere import Server
     self.server = Server()
     self.server.connect(url=self.url, username=uid, password=pwd)