Esempio n. 1
0
 def __init__(self, conn, result):
     self.conn = conn
     self.update_info(result)
     self.rescue = RescueSystem(self)
     self.reset = Reset(self)
     self.ips = IpManager(self.conn, self.ip)
     self.subnets = SubnetManager(self.conn, self.ip)
     self.rdns = ReverseDNSManager(self.conn, self.ip)
     self._admin_account = None
     self.logger = logging.getLogger("Server #{0}".format(self.number))
Esempio n. 2
0
 def __init__(self, conn, result):
     self.conn = conn
     self.update_info(result)
     self.rescue = RescueSystem(self)
     self.reset = Reset(self)
     self.ips = IpManager(self.conn, self.ip)
     self.subnets = SubnetManager(self.conn, self.ip)
     self.rdns = ReverseDNSManager(self.conn, self.ip)
     self._admin_account = None
     self.logger = logging.getLogger("Server #{0}".format(self.number))
Esempio n. 3
0
class Server(object):
    def __init__(self, conn, result):
        self.conn = conn
        self.update_info(result)
        self.rescue = RescueSystem(self)
        self.reset = Reset(self)
        self.ips = IpManager(self.conn, self.ip)
        self.subnets = SubnetManager(self.conn, self.ip)
        self.rdns = ReverseDNSManager(self.conn, self.ip)
        self._admin_account = None
        self.logger = logging.getLogger("Server #{0}".format(self.number))

    @property
    def admin(self):
        """
        Update, create and delete admin accounts.
        """
        if self._admin_account is None:
            self._admin_account = AdminAccount(self)
        return self._admin_account

    def update_info(self, result=None):
        """
        Updates the information of the current Server instance either by
        sending a new GET request or by parsing the response given by result.
        """
        if result is None:
            result = self.conn.get('/server/{0}'.format(self.ip))

        data = result['server']

        self.ip = data['server_ip']
        self.number = data['server_number']
        self.name = data['server_name']
        self.product = data['product']
        self.datacenter = data['dc']
        self.traffic = data['traffic']
        self.flatrate = data['flatrate']
        self.status = data['status']
        self.throttled = data['throttled']
        self.cancelled = data['cancelled']
        self.paid_until = datetime.strptime(data['paid_until'], '%Y-%m-%d')
        self.is_vserver = self.product.startswith('VQ')

    def observed_reboot(self, *args, **kwargs):
        msg = ("Server.observed_reboot() is deprecated. Please use"
               " Server.reset.observed_reboot() instead.")
        warnings.warn(msg, DeprecationWarning)
        return self.reset.observed_reboot(*args, **kwargs)

    def reboot(self, *args, **kwargs):
        msg = ("Server.reboot() is deprecated. Please use"
               " Server.reset.reboot() instead.")
        warnings.warn(msg, DeprecationWarning)
        return self.reset.reboot(*args, **kwargs)

    def set_name(self, name):
        result = self.conn.post('/server/{0}'.format(self.ip),
                                {'server_name': name})
        self.update_info(result)

    def __repr__(self):
        return "<{0} (#{1} {2})>".format(self.ip, self.number, self.product)
Esempio n. 4
0
class Server(object):
    def __init__(self, conn, result):
        self.conn = conn
        self.update_info(result)
        self.rescue = RescueSystem(self)
        self.reset = Reset(self)
        self.ips = IpManager(self.conn, self.ip)
        self.subnets = SubnetManager(self.conn, self.ip)
        self.rdns = ReverseDNSManager(self.conn, self.ip)
        self._admin_account = None
        self.logger = logging.getLogger("Server #{0}".format(self.number))

    @property
    def admin(self):
        """
        Update, create and delete admin accounts.
        """
        if self._admin_account is None:
            self._admin_account = AdminAccount(self)
        return self._admin_account

    def update_info(self, result=None):
        """
        Updates the information of the current Server instance either by
        sending a new GET request or by parsing the response given by result.
        """
        if result is None:
            result = self.conn.get('/server/{0}'.format(self.ip))

        data = result['server']

        self.ip = data['server_ip']
        self.number = data['server_number']
        self.name = data['server_name']
        self.product = data['product']
        self.datacenter = data['dc']
        self.traffic = data['traffic']
        self.flatrate = data['flatrate']
        self.status = data['status']
        self.throttled = data['throttled']
        self.cancelled = data['cancelled']
        self.paid_until = datetime.strptime(data['paid_until'], '%Y-%m-%d')
        self.is_vserver = self.product.startswith('VQ')

    def observed_reboot(self, *args, **kwargs):
        msg = ("Server.observed_reboot() is deprecated. Please use"
               " Server.reset.observed_reboot() instead.")
        warnings.warn(msg, DeprecationWarning)
        return self.reset.observed_reboot(*args, **kwargs)

    def reboot(self, *args, **kwargs):
        msg = ("Server.reboot() is deprecated. Please use"
               " Server.reset.reboot() instead.")
        warnings.warn(msg, DeprecationWarning)
        return self.reset.reboot(*args, **kwargs)

    def set_name(self, name):
        result = self.conn.post('/server/{0}'.format(self.ip),
                                {'server_name': name})
        self.update_info(result)

    def __repr__(self):
        return "<{0} (#{1} {2})>".format(self.ip, self.number, self.product)