Esempio n. 1
0
def vm_list(options):

    return [{
        'cores': 1,
        'hostname': 'arch64',
        'datacenter_id': 1,
        'state': 'running',
        'id': 80458,
        'ifaces_id': [65087],
        'description': None,
        'date_updated': DateTime('20141008T16:13:59'),
        'memory': 512,
        'console': 0,
        'disks_id': [4204, 4126],
        'date_created': DateTime('20130601T10:33:53'),
        'flex_shares': 0,
        'ai_active': 0,
        'vm_max_memory': 2048
    }, {
        'cores': 1,
        'hostname': 'docker',
        'datacenter_id': 3,
        'state': 'running',
        'id': 128620,
        'ifaces_id': [126368],
        'description': None,
        'date_updated': DateTime('20150103T15:27:57'),
        'memory': 256,
        'console': 0,
        'disks_id': [9184],
        'date_created': DateTime('20150103T15:26:52'),
        'flex_shares': 0,
        'ai_active': 0,
        'vm_max_memory': 2048
    }]
Esempio n. 2
0
def list(options):
    return [{'authinfo': 'abcdef0001',
             'autorenew': None,
             'zone_id': 424242,
             'tags': 'bla',
             'contacts': {'owner': {'handle': 'AA1-GANDI'},
                          'admin': {'handle': 'AA2-GANDI'},
                          'bill': {'handle': 'AA3-GANDI'},
                          'reseller': {'handle': 'AA4-GANDI'},
                          'tech': {'handle': 'AA5-GANDI'}},
             'date_created': datetime(2010, 9, 22, 15, 6, 18),
             'date_delete': datetime(2015, 10, 19, 19, 14, 0),
             'date_hold_begin': datetime(2015, 9, 22, 22, 0, 0),
             'date_registry_creation': datetime(2010, 9, 22, 13, 6, 16),
             'date_registry_end': datetime(2015, 9, 22, 0, 0, 0),
             'date_updated': datetime(2014, 9, 21, 3, 10, 7),
             'nameservers': ['a.dns.gandi.net', 'b.dns.gandi.net',
                             'c.dns.gandi.net'],
             'services': ['gandidns'],
             'fqdn': 'iheartcli.com',
             'id': 236816922,
             'status': [],
             'tld': 'com'},
            {'authinfo': 'abcdef0002',
             'autorenew': None,
             'contacts': {'admin': {'handle': 'PXP561-GANDI', 'id': 2920674},
                          'bill': {'handle': 'PXP561-GANDI', 'id': 2920674},
                          'owner': {'handle': 'PXP561-GANDI', 'id': 2920674},
                          'reseller': None,
                          'tech': {'handle': 'PXP561-GANDI', 'id': 2920674}},
             'date_created': DateTime('20130410T12:46:05'),
             'date_delete': DateTime('20160507T07:14:00'),
             'date_hold_begin': DateTime('20160410T00:00:00'),
             'date_registry_creation': DateTime('20140410T10:46:04'),
             'date_registry_end': DateTime('20140410T00:00:00'),
             'date_updated': DateTime('20150313T10:30:05'),
             'date_hold_end': DateTime('20151020T20:00:00'),
             'date_pending_delete_end': DateTime('20151119T00:00:00'),
             'date_renew_begin': DateTime('20120101T00:00:00'),
             'date_restore_end': DateTime('20151119T00:00:00'),
             'fqdn': 'cli.sexy',
             'id': 3412062241,
             'nameservers': ['a.dns.gandi.net', 'b.dns.gandi.net',
                             'c.dns.gandi.net'],
             'services': ['gandidns', 'gandimail', 'paas'],
             'status': [],
             'tags': [],
             'tld': 'sexy',
             'zone_id': None}]
Esempio n. 3
0
def get_ptn(game) -> str:
    ptn = ''

    wn = 'Anon' if game['date'] < 1461430800000 else game['player_white']
    bn = 'Anon' if game['date'] < 1461430800000 else game['player_black']

    ptn += get_header('Site', 'PlayTak.com')
    ptn += get_header('Event', 'Online Play')

    ptn += get_header('Player1', wn)
    ptn += get_header('Player2', bn)

    ptn += get_header('Result', game['result'])
    ptn += get_header('Size', game['size'])

    # rating header
    ptn += get_header('Rating1', game['rating_white'])
    ptn += get_header('Rating2', game['rating_black'])

    ptn += get_header('playtak_id', game['id'])

    # date and time headers
    dt = str(DateTime((game['date'] / 1000)))
    dt_d = dt.split('T')[0]
    dt_d = ''+dt_d[6:8]+'.'+dt_d[4:6]+'.'+dt_d[0:4]
    ptn += get_header('Date', dt_d)
    ptn += get_header('Time', dt.split('T')[1])

    # TODO clock header
    #    ptn += get_header('Clock', get_timer_info(game.timertime, game.timerinc))

    ptn += get_moves(game['notation'])
    ptn += '\n\n\n'

    return ptn
Esempio n. 4
0
def post_structure(entry, site):
    """
    A post structure with extensions.
    """
    author = entry.authors.all()[0]
    return {'title': entry.title,
            'description': six.text_type(entry.html_content),
            'link': '%s://%s%s' % (PROTOCOL, site.domain,
                                   entry.get_absolute_url()),
            # Basic Extensions
            'permaLink': '%s://%s%s' % (PROTOCOL, site.domain,
                                        entry.get_absolute_url()),
            'categories': [cat.title for cat in entry.categories.all()],
            'dateCreated': DateTime(entry.creation_date.isoformat()),
            'postid': entry.pk,
            'userid': author.get_username(),
            # Useful Movable Type Extensions
            'mt_excerpt': entry.excerpt,
            'mt_allow_comments': int(entry.comment_enabled),
            'mt_allow_pings': (int(entry.pingback_enabled) or
                               int(entry.trackback_enabled)),
            'mt_keywords': entry.tags,
            # Useful Wordpress Extensions
            'wp_author': author.get_username(),
            'wp_author_id': author.pk,
            'wp_author_display_name': author.__str__(),
            'wp_password': entry.password,
            'wp_slug': entry.slug,
            'sticky': entry.featured}
Esempio n. 5
0
def rating_list():
    return [{
        'bw_out': None,
        'cpu': {
            'default': 168
        },
        'disk_data': {
            'default': 135
        },
        'disk_snapshot': None,
        'disk_snapshot_auto': None,
        'instance': {
            'default': 0
        },
        'ip': {
            'v4_public': 210,
            'v6': 0
        },
        'ram': {
            'default': 120
        },
        'rproxy': None,
        'rproxy_server': None,
        'rproxy_ssl': None,
        'timestamp': DateTime('20150319T15:07:24')
    }]
Esempio n. 6
0
def list(options):

    ret = [{
        'catalog_name': 'phpmysql_s',
        'console': '*****@*****.**',
        'data_disk_additional_size': 0,
        'datacenter_id': 1,
        'date_end': DateTime('20160408T00:00:00'),
        'date_end_commitment': None,
        'date_start': DateTime('20130903T22:14:13'),
        'id': 126276,
        'name': 'paas_owncloud',
        'need_upgrade': False,
        'servers': [{
            'id': 126273
        }],
        'size': 's',
        'snapshot_profile': None,
        'state': 'halted',
        'type': 'phpmysql'
    }, {
        'catalog_name': 'nodejsmongodb_s',
        'console': '*****@*****.**',
        'data_disk_additional_size': 0,
        'datacenter_id': 3,
        'date_end': DateTime('20161125T15:52:56'),
        'date_end_commitment': DateTime('20151118T18:00:00'),
        'date_start': DateTime('20141025T15:52:56'),
        'id': 163744,
        'name': 'paas_cozycloud',
        'need_upgrade': False,
        'servers': [{
            'id': 163728
        }],
        'size': 's',
        'snapshot_profile': None,
        'state': 'running',
        'type': 'nodejsmongodb'
    }]

    options.pop('items_per_page', None)

    for fkey in options:
        ret = [paas for paas in ret if paas[fkey] == options[fkey]]

    return ret
Esempio n. 7
0
def vhost_list(options):

    ret = [{
        'cert_id': None,
        'date_creation': DateTime('20130903T22:11:54'),
        'id': 160126,
        'name': 'aa3e0e26f8.url-de-test.ws',
        'paas_id': 126276,
        'state': 'running'
    }, {
        'cert_id': None,
        'date_creation': DateTime('20130903T22:24:06'),
        'id': 160127,
        'name': 'cloud.cat.lol',
        'paas_id': 126276,
        'state': 'running'
    }, {
        'cert_id': None,
        'date_creation': DateTime('20141025T15:50:54'),
        'id': 1177216,
        'name': '187832c2b34.testurl.ws',
        'paas_id': 163744,
        'state': 'running'
    }, {
        'cert_id': None,
        'date_creation': DateTime('20141025T15:50:54'),
        'id': 1177220,
        'name': 'cloud.iheartcli.com',
        'paas_id': 163744,
        'state': 'running'
    }, {
        'cert_id': None,
        'date_creation': DateTime('20150728T17:50:56'),
        'id': 1365951,
        'name': 'cli.sexy',
        'paas_id': 163744,
        'state': 'running'
    }]

    options.pop('items_per_page', None)

    for fkey in options:
        ret = [paas for paas in ret if paas[fkey] == options[fkey]]

    return ret
Esempio n. 8
0
    def exp_metaWeblog_getRecentPosts(self, blogid, username, password, numberOfPosts=20):
        '''
        Params 
            blogid, string

        Return list of post struct
            dateCreated, dateTime.iso8601
            description, string
            title, string
            enclosure struct
                length, int4
                type, string, optional
                url, string, optional
            categories, list of string, optional
            link, optional
            permalink, optional
            postid, string, optional
            userid, string, optional
            source
                name, string, optional
                url, string, optional

        '''
        if not self.check_permission(username, password):
            return

        data = []
        blog_post_ids = self.env['blog.post'].search([('blog_id', '=', int(blogid))], limit=numberOfPosts)

        for blog_post in blog_post_ids:
            post = {
                'dateCreated': blog_post.post_date and DateTime(blog_post.post_date),
                'description': blog_post.content,
                'title': blog_post.name,
                'enclosure': {
                    'length': 0
                },
                'link': '%s%s' % (self.base_url.strip('/'), blog_post.website_url),
                'permalink': '%s%s' % (self.base_url.strip('/'), blog_post.website_url),
                'postid': str(blog_post['id']),
                'source': {},
                'userid': str(self.env.uid)
            }

            if blog_post.tag_ids:
                post.update({
                    'categories': blog_post.tag_ids.mapped('name'),
                })

            data.append(post)

        return data
Esempio n. 9
0
def vm_list(options):

    ret = [{
        'ai_active': 0,
        'console': 0,
        'cores': 1,
        'datacenter_id': 3,
        'date_created': DateTime('20141008T16:13:59'),
        'date_updated': DateTime('20150319T11:11:31'),
        'description': None,
        'disks_id': [4969232],
        'flex_shares': 0,
        'hostname': 'vm1426759833',
        'id': 152966,
        'ifaces_id': [156572],
        'memory': 256,
        'state': 'running',
        'vm_max_memory': 2048
    }, {
        'ai_active': 0,
        'console': 0,
        'cores': 1,
        'datacenter_id': 1,
        'date_created': DateTime('20150319T11:14:13'),
        'date_updated': DateTime('20150319T11:14:55'),
        'description': None,
        'disks_id': [4969249],
        'flex_shares': 0,
        'hostname': 'server01',
        'id': 152967,
        'ifaces_id': [156573],
        'memory': 256,
        'state': 'running',
        'vm_max_memory': 2048
    }, {
        'ai_active': 0,
        'console': 0,
        'cores': 1,
        'datacenter_id': 1,
        'date_created': DateTime('20150319T11:14:13'),
        'date_updated': DateTime('20150319T11:14:55'),
        'description': None,
        'disks_id': [4969250],
        'flex_shares': 0,
        'hostname': 'server02',
        'id': 152968,
        'ifaces_id': [156574],
        'memory': 256,
        'state': 'halted',
        'vm_max_memory': 2048
    }]

    options.pop('items_per_page', None)

    for fkey in options:
        ret = [vm for vm in ret if vm[fkey] == options[fkey]]

    return ret
Esempio n. 10
0
def account_info():
    return {'average_credit_cost': 0.0,
            'credits': 2335360,
            'cycle_day': 23,
            'date_credits_expiration': DateTime('20160319T10:07:24'),
            'fullname': 'Peter Parker',
            'handle': 'PXP561-GANDI',
            'id': 2920674,
            'products': None,
            'rating_enabled': True,
            'resources': {'available': None,
                          'expired': None,
                          'granted': None,
                          'used': None},
            'share_definition': None}
Esempio n. 11
0
def testParamState(master, myState):
    callerId = 'master'  #validate from root
    for (k, v) in myState.items():
        if HAS_PARAM:
            assert apiSuccess(master.hasParam(callerId, k))
        print "verifying parameter %s" % k
        v2 = apiSuccess(master.getParam(callerId, k))
        if isinstance(v2, DateTime):
            assert DateTime(v) == v2, "[%s]: %s != %s, %s" % (k, v, v2,
                                                              v2.__class__)
        else:
            assert v == v2, "[%s]: %s != %s, %s" % (k, v, v2, v2.__class__)
    paramNames = myState.keys()
    remoteParamNames = apiSuccess(master.getParamNames(callerId))
    assert not set(paramNames) ^ set(
        remoteParamNames), "parameter server keys do not match local"
Esempio n. 12
0
    def exp_metaWeblog_getPost(self, postid, username, password):
        '''
        Params 
            postid, string

        Return post struct
            dateCreated, dateTime.iso8601
            description, string
            title, string
            enclosure struct
                length, int4
                type, string, optional
                url, string, optional
            categories, list of string, optional
            link, optional
            permalink, optional
            postid, string, optional
            userid, string, optional
            source
                name, string, optional
                url, string, optional

        '''

        if not self.check_permission(username, password):
            return
        blog_post = self.env['blog.post'].search([('id', '=', int(postid))])

        post = {
            'dateCreated': blog_post.post_date and DateTime(blog_post.post_date),
            'description': blog_post.content,
            'title': blog_post.name,
            'enclosure': {
                'length': 0,
            },
            'link': '%s%s' % (self.base_url.strip('/'), blog_post.website_url),
            'permalink': '%s%s' % (self.base_url.strip('/'), blog_post.website_url),
            'postid': blog_post.id,
            'userid': str(self.env.uid),
            'source': {},
            'mt_keywords': ''
        }
        if blog_post.tag_ids:
            post.update({'categories': blog_post.tag_ids.mapped('name')})

        return post
Esempio n. 13
0
def post_structure(entry):
    """
    A post structure with extensions.
    """
    author = entry.author
    return {
        'title':
        entry.title,
        'description':
        entry.content,
        'link':
        '%s://%s%s' %
        (PROTOCOL, DOMAIN,
         reverse('blog:post_detail', kwargs={'slug': entry.slug})),
        # Basic Extensions
        # 'permaLink': '%s://%s%s' % (PROTOCOL, site.domain,
        # entry.get_absolute_url()),
        'categories':
        entry.category,
        'dateCreated':
        DateTime(entry.created_time.isoformat()),
        'postid':
        entry.pk,
        'userid':
        author.pk,
        # Useful Movable Type Extensions
        'mt_excerpt':
        entry.excerpt,
        # 'mt_allow_comments': int(entry.comment_enabled),
        # 'mt_allow_pings': (int(entry.pingback_enabled) or
        # int(entry.trackback_enabled)),
        'mt_keywords':
        ', '.join([tag.name for tag in entry.tags.all()]),
        # Useful Wordpress Extensions
        'wp_author':
        author.username,
        'wp_author_id':
        author.pk,
        'wp_author_display_name':
        author.__str__(),
        'wp_slug':
        entry.slug
        # 'sticky': entry.featured}
    }
Esempio n. 14
0
def ip_list(options):

    ips = [{
        'datacenter_id': 1,
        'date_created': DateTime('20150317T16:20:10'),
        'date_updated': DateTime('20150319T11:14:13'),
        'id': 203968,
        'iface_id': 156573,
        'ip': '95.142.160.181',
        'num': 0,
        'reverse': 'xvm-160-181.dc0.ghst.net',
        'state': 'created',
        'version': 4
    }, {
        'datacenter_id': 3,
        'date_created': DateTime('20150319T11:10:34'),
        'date_updated': DateTime('20150319T11:10:36'),
        'id': 204557,
        'iface_id': 156572,
        'ip': '2001:4b98:dc2:43:216:3eff:fece:e25f',
        'num': 0,
        'reverse': 'xvm6-dc2-fece-e25f.ghst.net',
        'state': 'created',
        'version': 6
    }, {
        'datacenter_id': 1,
        'date_created': DateTime('20150319T11:14:16'),
        'date_updated': DateTime('20150319T11:14:16'),
        'id': 204558,
        'iface_id': 156573,
        'ip': '2001:4b98:dc0:47:216:3eff:feb2:3862',
        'num': 1,
        'reverse': 'xvm6-dc0-feb2-3862.ghst.net',
        'state': 'created',
        'version': 6
    }]

    options.pop('items_per_page', None)

    for fkey in options:
        ret = []
        for ip in ips:
            if isinstance(options[fkey], list):
                if ip[fkey] in options[fkey]:
                    ret.append(ip)
            elif ip[fkey] == options[fkey]:
                ret.append(ip)
        ips = ret

    return ips
Esempio n. 15
0
    def _checkParamState(self, myState):
        master = self.master
        callerId = 'master'  #validate from root
        for (k, v) in myState.items():
            assert self.apiSuccess(master.hasParam(callerId, k))
            #print("verifying parameter %s"%k)
            try:
                v2 = self.apiSuccess(master.getParam(callerId, k))
            except:
                raise Exception(
                    "Exception raised while calling master.getParam(%s,%s): %s"
                    % (callerId, k, traceback.format_exc()))
            if isinstance(v2, DateTime):
                self.assertEquals(
                    DateTime(v), v2,
                    "[%s]: %s != %s, %s" % (k, v, v2, v2.__class__))
            elif type(v2) == float:
                self.assertAlmostEqual(
                    v, v2, 3, "[%s]: %s != %s, %s" % (k, v, v2, v2.__class__))
            else:
                self.assertEquals(v, v2)
        paramNames = myState.keys()
        remoteParamNames = self.apiSuccess(master.getParamNames(callerId))
        # filter out the roslaunch params like run id and roslaunch/, which are always set
        remoteParamNames = [
            p for p in remoteParamNames
            if not p in ['/run_id', '/rosdistro', '/rosversion']
        ]
        remoteParamNames = [
            p for p in remoteParamNames if not p.startswith('/roslaunch/')
        ]

        assert not set(paramNames) ^ set(
            remoteParamNames
        ), "parameter server keys do not match local: %s" % (
            set(paramNames) ^ set(remoteParamNames))
Esempio n. 16
0
def disk_list(options):

    disks = [{
        'can_snapshot': True,
        'datacenter_id': 3,
        'date_created': DateTime('20150319T11:10:34'),
        'date_updated': DateTime('20150319T11:10:58'),
        'id': 4969232,
        'is_boot_disk': True,
        'kernel_version': '3.12-x86_64 (hvm)',
        'label': 'Debian 7 64 bits (HVM)',
        'name': 'sys_1426759833',
        'size': 3072,
        'snapshot_profile_id': None,
        'snapshots_id': [],
        'source': 1401327,
        'state': 'created',
        'total_size': 3072,
        'type': 'data',
        'visibility': 'private',
        'vms_id': [152966]
    }, {
        'can_snapshot': True,
        'datacenter_id': 1,
        'date_created': DateTime('20150319T11:14:13'),
        'date_updated': DateTime('20150319T11:14:29'),
        'id': 4969249,
        'is_boot_disk': True,
        'kernel_version': '3.12-x86_64 (hvm)',
        'label': 'Debian 7 64 bits (HVM)',
        'name': 'sys_server01',
        'size': 3072,
        'snapshot_profile_id': None,
        'snapshots_id': [],
        'source': 1349810,
        'state': 'created',
        'total_size': 3072,
        'type': 'data',
        'visibility': 'private',
        'vms_id': [152967]
    }, {
        'can_snapshot': True,
        'datacenter_id': 1,
        'date_created': DateTime('20150319T15:39:54'),
        'date_updated': DateTime('20150319T15:40:24'),
        'id': 4970079,
        'is_boot_disk': False,
        'kernel_version': None,
        'label': None,
        'name': 'data',
        'size': 3072,
        'snapshot_profile_id': 1,
        'snapshots_id': [663497],
        'source': None,
        'state': 'created',
        'total_size': 3072,
        'type': 'data',
        'visibility': 'private',
        'vms_id': [152967]
    }, {
        'can_snapshot': False,
        'datacenter_id': 1,
        'date_created': DateTime('20140826T00:00:00'),
        'date_updated': DateTime('20140826T00:00:00'),
        'id': 663497,
        'is_boot_disk': False,
        'kernel_version': '3.2-x86_64',
        'label': 'Debian 7 64 bits',
        'name': 'snaptest',
        'size': 3072,
        'snapshot_profile_id': None,
        'snapshots_id': [],
        'source': 4970079,
        'state': 'created',
        'total_size': 3072,
        'type': 'snapshot',
        'visibility': 'private',
        'vms_id': []
    }]

    options.pop('items_per_page', None)

    for fkey in options:
        ret = []
        for disk in disks:
            if isinstance(options[fkey], list):
                if disk[fkey] in options[fkey]:
                    ret.append(disk)
            elif disk[fkey] == options[fkey]:
                ret.append(disk)
        disks = ret

    return disks
Esempio n. 17
0
def iface_list(options):

    ret = [{
        'bandwidth':
        102400.0,
        'datacenter_id':
        1,
        'date_created':
        DateTime('20140423T00:00:00'),
        'date_updated':
        DateTime('20140423T00:00:00'),
        'id':
        156573,
        'ips_id': [203968, 204558],
        'ips': [{
            'datacenter_id': 1,
            'date_created': DateTime('20150317T16:20:10'),
            'date_updated': DateTime('20150319T11:14:13'),
            'id': 203968,
            'iface_id': 156573,
            'ip': '95.142.160.181',
            'num': 0,
            'reverse': 'xvm-160-181.dc0.ghst.net',
            'state': 'created',
            'version': 4
        }, {
            'datacenter_id': 1,
            'date_created': DateTime('20150319T11:14:16'),
            'date_updated': DateTime('20150319T11:14:16'),
            'id': 204558,
            'iface_id': 156573,
            'ip': '2001:4b98:dc0:47:216:3eff:feb2:3862',
            'num': 1,
            'reverse': 'xvm6-dc0-feb2-3862.ghst.net',
            'state': 'created',
            'version': 6
        }],
        'num':
        0,
        'state':
        'used',
        'type':
        'public',
        'vlan':
        None,
        'vm_id':
        152967
    }, {
        'bandwidth': 102400.0,
        'datacenter_id': 1,
        'date_created': DateTime('20141009T00:00:00'),
        'date_updated': DateTime('20141105T00:00:00'),
        'id': 1416,
        'ips_id': [],
        'num': None,
        'state': 'free',
        'type': 'private',
        'vlan': {
            'id': 717,
            'name': 'pouet'
        },
        'vm_id': None
    }, {
        'bandwidth': 204800.0,
        'datacenter_id': 1,
        'date_created': DateTime('20150105T00:00:00'),
        'date_updated': DateTime('20150105T00:00:00'),
        'id': 1914,
        'ips_id': [2361],
        'num': None,
        'state': 'free',
        'type': 'private',
        'vlan': {
            'id': 717,
            'name': 'pouet'
        },
        'vm_id': None
    }, {
        'bandwidth':
        204800.0,
        'datacenter_id':
        1,
        'date_created':
        DateTime('20150105T00:00:00'),
        'date_updated':
        DateTime('20150105T00:00:00'),
        'id':
        156572,
        'ips_id': [204557],
        'ips': [{
            'datacenter_id': 3,
            'date_created': DateTime('20150319T11:10:34'),
            'date_updated': DateTime('20150319T11:10:36'),
            'id': 204557,
            'iface_id': 156572,
            'ip': '10.50.10.10',
            'num': 0,
            'reverse': 'xvm6-dc2-fece-e25f.ghst.net',
            'state': 'created',
            'version': 4
        }],
        'num':
        None,
        'state':
        'free',
        'type':
        'private',
        'vlan': {
            'id': 717,
            'name': 'pouet'
        },
        'vm_id':
        None
    }]

    options.pop('items_per_page', None)

    for fkey in options:
        if fkey == 'vlan':
            ret_ = []
            for iface in ret:
                if iface['vlan'] and iface['vlan']['name'] == options['vlan']:
                    ret_.append(iface)
            ret = ret_
        else:
            ret = [iface for iface in ret if iface[fkey] == options[fkey]]

    return ret
Esempio n. 18
0
    def testXmlRpc(self):

        scheme = self.scheme
        if scheme == "https":
            url = 'https://%s:%s/xmlrpc/' % (self.interface(), self.PORT)
            proxy = ServerProxy(url, transport=HTTPSTransport())
        else:
            url = 'http://%s:%s/xmlrpc/' % (self.interface(), self.PORT)
            proxy = ServerProxy(url)

        # begin the tests ...
        self.getPage("/xmlrpc/foo")
        self.assertBody("Hello world!")

        self.assertEqual(proxy.return_single_item_list(), [42])
        self.assertNotEqual(proxy.return_single_item_list(), 'one bazillion')
        self.assertEqual(proxy.return_string(), "here is a string")
        self.assertEqual(proxy.return_tuple(), list(
            ('here', 'is', 1, 'tuple')))
        self.assertEqual(proxy.return_dict(), {'a': 1, 'c': 3, 'b': 2})
        self.assertEqual(proxy.return_composite(), [{
            'a': 1,
            'z': 26
        }, 'hi', ['welcome', 'friend']])
        self.assertEqual(proxy.return_int(), 42)
        self.assertEqual(proxy.return_float(), 3.14)
        self.assertEqual(proxy.return_datetime(),
                         DateTime((2003, 10, 7, 8, 1, 0, 1, 280, -1)))
        self.assertEqual(proxy.return_boolean(), True)
        self.assertEqual(proxy.test_argument_passing(22), 22 * 2)

        # Test an error in the page handler (should raise an xmlrpclib.Fault)
        try:
            proxy.test_argument_passing({})
        except Exception:
            x = sys.exc_info()[1]
            self.assertEqual(x.__class__, Fault)
            self.assertEqual(x.faultString, ("unsupported operand type(s) "
                                             "for *: 'dict' and 'int'"))
        else:
            self.fail("Expected xmlrpclib.Fault")

        # http://www.cherrypy.org/ticket/533
        # if a method is not found, an xmlrpclib.Fault should be raised
        try:
            proxy.non_method()
        except Exception:
            x = sys.exc_info()[1]
            self.assertEqual(x.__class__, Fault)
            self.assertEqual(x.faultString,
                             'method "non_method" is not supported')
        else:
            self.fail("Expected xmlrpclib.Fault")

        # Test returning a Fault from the page handler.
        try:
            proxy.test_returning_Fault()
        except Exception:
            x = sys.exc_info()[1]
            self.assertEqual(x.__class__, Fault)
            self.assertEqual(x.faultString, ("custom Fault response"))
        else:
            self.fail("Expected xmlrpclib.Fault")
Esempio n. 19
0
def list(options):

    ret = [
        {
            'date_created': DateTime('20150915T18:29:16'),
            'date_start': None,
            'date_updated': DateTime('20150915T18:29:17'),
            'errortype': None,
            'eta': -1863666,
            'id': 100100,
            'cert_id': None,
            'infos': {
                'extras': {},
                'id': '',
                'label': 'iheartcli.com',
                'product_action': 'renew',
                'product_name': 'com',
                'product_type': 'domain',
                'quantity': ''
            },
            'last_error': None,
            'params': {
                'auth_id': 99999999,
                'current_year': 2015,
                'domain': 'iheartcli.com',
                'domain_id': 1234567,
                'duration': 1,
                'param_type': 'domain',
                'remote_addr': '127.0.0.1',
                'session_id': 2920674,
                'tld': 'com',
                'tracker_id': '621cb9f4-472d-4cc1-b4b9-b18cc61e2914'
            },
            'session_id': 2920674,
            'source': 'PXP561-GANDI',
            'step': 'BILL',
            'type': 'domain_renew'
        },
        {
            'date_created': DateTime('20150505T00:00:00'),
            'date_start': None,
            'date_updated': DateTime('20150505T00:00:00'),
            'errortype': None,
            'eta': 0,
            'id': 100200,
            'cert_id': None,
            'infos': {
                'extras': {},
                'id': '',
                'label': '',
                'product_action': 'billing_prepaid_add_money',
                'product_name': '',
                'product_type': 'corporate',
                'quantity': ''
            },
            'last_error': None,
            'params': {
                'amount': 50.0,
                'auth_id': 99999999,
                'param_type': 'prepaid_add_money',
                'prepaid_id': 100000,
                'remote_addr': '127.0.0.1',
                'tracker_id': 'ab0e5e67-6ca7-4afc-8311-f20080f15cf1'
            },
            'session_id': 9844958,
            'source': 'PXP561-GANDI',
            'step': 'BILL',
            'type': 'billing_prepaid_add_money'
        },
        {
            'step': 'RUN',
            'cert_id': 710,
            'id': 100300,
            'type': 'certificate_update',
            'params': {
                'cert_id':
                710,
                'param_type':
                'certificate_update',
                'prepaid_id':
                100000,
                'inner_step':
                'comodo_oper_updated',
                'dcv_method':
                'email',
                'csr':
                '-----BEGIN CERTIFICATE REQUEST-----'
                'MIICxjCCAa4CAQAwgYAxCzAJBgNVBAYTAkZSMQsw'
                '0eWfyJJTOypoToCtdGoye507GOsgIysfRWaExay5'
                '-----END CERTIFICATE REQUEST-----',
                'remote_addr':
                '127.0.0.1'
            }
        },
        {
            'step': 'RUN',
            'cert_id': 706,
            'id': 100302,
            'type': 'certificate_update',
            'params': {
                'cert_id':
                706,
                'param_type':
                'certificate_update',
                'prepaid_id':
                100000,
                'inner_step':
                'comodo_oper_updated',
                'dcv_method':
                'dns',
                'csr':
                '-----BEGIN CERTIFICATE REQUEST-----'
                'MIICxjCCAa4CAQAwgYAxCzAJBgNVBAYTAkZSMQsw'
                '0eWfyJJTOypoToCtdGoye507GOsgIysfRWaExay5'
                '-----END CERTIFICATE REQUEST-----',
                'remote_addr':
                '127.0.0.1'
            }
        },
        {
            'step': 'WAIT',
            'cert_id': 701,
            'id': 100303,
            'type': 'certificate_update',
            'params': {
                'cert_id': 706,
                'param_type': 'certificate_update',
                'prepaid_id': 100000,
                'inner_step': 'check_email_sent',
                'dcv_method': 'dns',
                'remote_addr': '127.0.0.1'
            }
        },
        {
            'step': 'RUN',
            'id': 99001,
            'vm_id': 152967,
            'type': 'hosting_migration_vm',
            'params': {
                'inner_step': 'wait_sync'
            }
        },
        {
            'step': 'RUN',
            'id': 99002,
            'vm_id': 152966,
            'type': 'hosting_migration_vm',
            'params': {
                'inner_step': 'wait_finalize'
            }
        },
    ]

    options.pop('sort_by', None)
    options.pop('items_per_page', None)

    def compare(op, option):
        if isinstance(option, (type_list, tuple)):
            return op in option
        return op == option

    for fkey in options:
        ret = [op for op in ret if compare(op.get(fkey), options[fkey])]

    return ret
Esempio n. 20
0
 def return_datetime(self):
     return DateTime((2003, 10, 7, 8, 1, 0, 1, 280, -1))
Esempio n. 21
0
def time_result():
    # 時刻返却
    return DateTime(datetime.now())
Esempio n. 22
0
def hosted_list(options):
    fqdns_id = {'test1.domain.fr': [1, 2],
                'test2.domain.fr': [3],
                'test3.domain.fr': [4],
                'test4.domain.fr': [5],
                '*.domain.fr': [6]}

    ret = [{'date_created': DateTime('20150407T00:00:00'),
            'date_expire': DateTime('20160316T00:00:00'),
            'id': 1,
            'state': u'created',
            'subject': u'/OU=Domain Control Validated/OU=Gandi Standard '
                       'SSL/CN=test1.domain.fr'},
           {'date_created': DateTime('20150407T00:00:00'),
            'date_expire': DateTime('20160316T00:00:00'),
            'id': 2,
            'state': u'created',
            'subject': u'/OU=Domain Control Validated/OU=Gandi Standard '
                       'SSL/CN=test1.domain.fr'},
           {'date_created': DateTime('20150408T00:00:00'),
            'date_expire': DateTime('20160408T00:00:00'),
            'id': 3,
            'state': u'created',
            'subject': u'/OU=Domain Control Validated/OU=Gandi Standard '
                       'SSL/CN=test2.domain.fr'},
           {'date_created': DateTime('20150408T00:00:00'),
            'date_expire': DateTime('20160408T00:00:00'),
            'id': 4,
            'state': u'created',
            'subject': u'/OU=Domain Control Validated/OU=Gandi Standard '
                       'SSL/CN=test3.domain.fr'},
           {'date_created': DateTime('20150408T00:00:00'),
            'date_expire': DateTime('20160408T00:00:00'),
            'id': 5,
            'state': u'created',
            'subject': u'/OU=Domain Control Validated/OU=Gandi Standard '
                       'SSL/CN=test4.domain.fr'},
           {'date_created': DateTime('20150409T00:00:00'),
            'date_expire': DateTime('20160409T00:00:00'),
            'id': 6,
            'state': u'created',
            'subject': u'/OU=Domain Control Validated/OU=Gandi Standard '
                       'Wildcard SSL/CN=*.domain.fr'}]

    options.pop('items_per_page', None)
    fqdns = options.pop('fqdns', None)

    if fqdns:
        if not isinstance(fqdns, (type_list, tuple)):
            fqdns = [fqdns]
        for fqdn in fqdns:
            options.setdefault('id', []).extend(fqdns_id.get(fqdn, []))

    def compare(hc, option):
        if isinstance(option, (type_list, tuple)):
            return hc in option
        return hc == option

    for fkey in options:
        ret = [hc for hc in ret if compare(hc[fkey], options[fkey])]

    return ret
Esempio n. 23
0
def image_list(options):

    ret = [
        {
            'author_id': 248842,
            'datacenter_id': 3,
            'date_created': DateTime('20130902T15:04:18'),
            'date_updated': DateTime('20130903T12:14:30'),
            'disk_id': 527489,
            'id': 131,
            'kernel_version': '3.2-i386',
            'label': 'Fedora 17 32 bits',
            'os_arch': 'x86-32',
            'size': 3072,
            'visibility': 'all'
        },
        {
            'author_id': 248842,
            'datacenter_id': 3,
            'date_created': DateTime('20130902T15:04:18'),
            'date_updated': DateTime('20130903T12:14:30'),
            'disk_id': 527490,
            'id': 132,
            'kernel_version': '3.2-x86_64',
            'label': 'Fedora 17 64 bits',
            'os_arch': 'x86-64',
            'size': 3072,
            'visibility': 'all'
        },
        {
            'author_id': 248842,
            'datacenter_id': 3,
            'date_created': DateTime('20130902T15:04:18'),
            'date_updated': DateTime('20130903T12:14:30'),
            'disk_id': 527491,
            'id': 133,
            'kernel_version': '3.2-i386',
            'label': 'OpenSUSE 12.2 32 bits',
            'os_arch': 'x86-32',
            'size': 3072,
            'visibility': 'all'
        },
        {
            'author_id': 248842,
            'datacenter_id': 3,
            'date_created': DateTime('20130902T15:04:18'),
            'date_updated': DateTime('20130903T12:14:30'),
            'disk_id': 527494,
            'id': 134,
            'kernel_version': '3.2-x86_64',
            'label': 'OpenSUSE 12.2 64 bits',
            'os_arch': 'x86-64',
            'size': 3072,
            'visibility': 'all'
        },
        {
            'author_id': 248842,
            'datacenter_id': 3,
            'date_created': DateTime('20130902T15:04:18'),
            'date_updated': DateTime('20130903T12:14:30'),
            'disk_id': 726224,
            'id': 149,
            'kernel_version': '2.6.32',
            'label': 'CentOS 5 32 bits',
            'os_arch': 'x86-32',
            'size': 3072,
            'visibility': 'all'
        },
        {
            'author_id': 248842,
            'datacenter_id': 3,
            'date_created': DateTime('20130902T15:04:18'),
            'date_updated': DateTime('20130903T12:14:30'),
            'disk_id': 726225,
            'id': 150,
            'kernel_version': '2.6.32-x86_64',
            'label': 'CentOS 5 64 bits',
            'os_arch': 'x86-64',
            'size': 3072,
            'visibility': 'all'
        },
        {
            'author_id': 248842,
            'datacenter_id': 3,
            'date_created': DateTime('20130902T15:04:18'),
            'date_updated': DateTime('20130903T12:14:30'),
            'disk_id': 726230,
            'id': 151,
            'kernel_version': '3.2-i386',
            'label': 'ArchLinux 32 bits',
            'os_arch': 'x86-32',
            'size': 3072,
            'visibility': 'all'
        },
        {
            'author_id': 248842,
            'datacenter_id': 3,
            'date_created': DateTime('20130902T15:04:18'),
            'date_updated': DateTime('20130903T12:14:30'),
            'disk_id': 726233,
            'id': 152,
            'kernel_version': '3.2-x86_64',
            'label': 'ArchLinux 64 bits',
            'os_arch': 'x86-64',
            'size': 3072,
            'visibility': 'all'
        },
        {
            'author_id': 248842,
            'datacenter_id': 2,
            'date_created': DateTime('20140417T18:38:53'),
            'date_updated': DateTime('20141030T10:38:45'),
            'disk_id': 1401491,
            'id': 161,
            'kernel_version': '3.12-x86_64 (hvm)',
            'label': 'Debian 7 64 bits (HVM)',
            'os_arch': 'x86-64',
            'size': 3072,
            'visibility': 'all'
        },
        {
            'author_id': 248842,
            'datacenter_id': 1,
            'date_created': DateTime('20140417T18:38:53'),
            'date_updated': DateTime('20141030T18:06:44'),
            'disk_id': 1349810,
            'id': 162,
            'kernel_version': '3.12-x86_64 (hvm)',
            'label': 'Debian 7 64 bits (HVM)',
            'os_arch': 'x86-64',
            'size': 3072,
            'visibility': 'all'
        },
        {
            'author_id': 248842,
            'datacenter_id': 3,
            'date_created': DateTime('20140417T18:38:53'),
            'date_updated': DateTime('20141030T10:38:45'),
            'disk_id': 1401327,
            'id': 167,
            'kernel_version': '3.12-x86_64 (hvm)',
            'label': 'Debian 7 64 bits (HVM)',
            'os_arch': 'x86-64',
            'size': 3072,
            'visibility': 'all'
        },
        {
            'author_id': 248842,
            'datacenter_id': 1,
            'date_created': DateTime('20141203T14:15:28'),
            'date_updated': DateTime('20150116T11:24:56'),
            'disk_id': 3315704,
            'id': 172,
            'kernel_version': '3.12-x86_64 (hvm)',
            'label': 'Debian 8 (testing) 64 bits (HVM)',
            'os_arch': 'x86-64',
            'size': 3072,
            'visibility': 'all'
        },
        {
            'author_id': 248842,
            'datacenter_id': 2,
            'date_created': DateTime('20141203T14:15:28'),
            'date_updated': DateTime('20150116T11:24:56'),
            'disk_id': 3315992,
            'id': 176,
            'kernel_version': '3.12-x86_64 (hvm)',
            'label': 'Debian 8 (testing) 64 bits (HVM)',
            'os_arch': 'x86-64',
            'size': 3072,
            'visibility': 'all'
        },
        {
            'author_id': 248842,
            'datacenter_id': 3,
            'date_created': DateTime('20141203T14:15:28'),
            'date_updated': DateTime('20150116T11:24:56'),
            'disk_id': 3316076,
            'id': 180,
            'kernel_version': '3.12-x86_64 (hvm)',
            'label': 'Debian 8 (testing) 64 bits (HVM)',
            'os_arch': 'x86-64',
            'size': 3072,
            'visibility': 'all'
        },
        {
            'author_id': 248842,
            'datacenter_id': 1,
            'date_created': DateTime('20141203T14:15:28'),
            'date_updated': DateTime('20150116T11:24:56'),
            'disk_id': 3315748,
            'id': 184,
            'kernel_version': '3.12-x86_64 (hvm)',
            'label': 'Ubuntu 14.04 64 bits LTS (HVM)',
            'os_arch': 'x86-64',
            'size': 3072,
            'visibility': 'all'
        },
        {
            'author_id': 248842,
            'datacenter_id': 2,
            'date_created': DateTime('20141203T14:15:28'),
            'date_updated': DateTime('20150116T11:24:56'),
            'disk_id': 3316144,
            'id': 188,
            'kernel_version': '3.12-x86_64 (hvm)',
            'label': 'Ubuntu 14.04 64 bits LTS (HVM)',
            'os_arch': 'x86-64',
            'size': 3072,
            'visibility': 'all'
        },
        {
            'author_id': 248842,
            'datacenter_id': 3,
            'date_created': DateTime('20141203T14:15:28'),
            'date_updated': DateTime('20150116T11:24:56'),
            'disk_id': 3316160,
            'id': 192,
            'kernel_version': '3.12-x86_64 (hvm)',
            'label': 'Ubuntu 14.04 64 bits LTS (HVM)',
            'os_arch': 'x86-64',
            'size': 3072,
            'visibility': 'all'
        },
        {
            'author_id': 248842,
            'datacenter_id': 1,
            'date_created': None,
            'date_updated': DateTime('20150116T11:24:56'),
            'disk_id': 2876292,
            'id': 196,
            'kernel_version': '3.12-x86_64 (hvm)',
            'label': 'CentOS 7 64 bits (HVM)',
            'os_arch': 'x86-64',
            'size': 3072,
            'visibility': 'all'
        },
        {
            'author_id': 248842,
            'datacenter_id': 2,
            'date_created': None,
            'date_updated': DateTime('20150116T11:24:56'),
            'disk_id': 4744388,
            'id': 200,
            'kernel_version': '3.12-x86_64 (hvm)',
            'label': 'CentOS 7 64 bits (HVM)',
            'os_arch': 'x86-64',
            'size': 3072,
            'visibility': 'all'
        },
        {
            'author_id': 248842,
            'datacenter_id': 3,
            'date_created': None,
            'date_updated': DateTime('20150116T11:24:56'),
            'disk_id': 4744392,
            'id': 204,
            'kernel_version': '3.12-x86_64 (hvm)',
            'label': 'CentOS 7 64 bits (HVM)',
            'os_arch': 'x86-64',
            'size': 3072,
            'visibility': 'all'
        },
        {
            'author_id': 248842,
            'datacenter_id': 4,
            'date_created': DateTime('20140417T18:38:53'),
            'date_updated': DateTime('20141030T10:38:45'),
            'disk_id': 1401492,
            'id': 163,
            'kernel_version': '3.12-x86_64 (hvm)',
            'label': 'Debian 7 64 bits (HVM)',
            'os_arch': 'x86-64',
            'size': 3072,
            'visibility': 'all'
        },
    ]

    for fkey in options:
        ret = [dc for dc in ret if dc[fkey] == options[fkey]]
    return ret
Esempio n. 24
0
def disk_list(options):
    disks = [{
        'can_snapshot': True,
        'type': 'data',
        'size': 10240,
        'label': None,
        'snapshot_profile_id': None,
        'date_created': DateTime('20120521T22:20:57'),
        'id': 4126,
        'name': 'data',
        'is_boot_disk': False,
        'datacenter_id': 1,
        'source': None,
        'vms_id': [80458],
        'state': 'created',
        'date_updated': DateTime('20140728T10:52:45'),
        'visibility': 'private',
        'kernel_version': None,
        'total_size': 10240,
        'snapshots_id': []
    }, {
        'can_snapshot': True,
        'type': 'data',
        'size': 10240,
        'label': 'ArchLinux 64 bits',
        'snapshot_profile_id': None,
        'date_created': DateTime('20130601T10:33:53'),
        'id': 4204,
        'name': 'arch64',
        'is_boot_disk': True,
        'datacenter_id': 1,
        'source': 136529,
        'vms_id': [80458],
        'state': 'created',
        'date_updated': DateTime('20140728T10:52:45'),
        'visibility': 'private',
        'kernel_version': '3.2-x86_64',
        'total_size': 6240,
        'snapshots_id': []
    }, {
        'visibility': 'private',
        'size': 3072,
        'kernel_version': '3.12-x86_64 (hvm)',
        'name': 'sys_docker',
        'datacenter_id': 3,
        'label': 'Ubuntu 14.04 64 bits LTS (HVM)',
        'id': 9184,
        'date_updated': DateTime('20150103T15:27:22'),
        'vms_id': [128620],
        'source': 3316160,
        'total_size': 3072,
        'snapshots_id': [],
        'type': 'data',
        'is_boot_disk': True,
        'state': 'created',
        'date_created': DateTime('20150103T15:26:52'),
        'snapshot_profile_id': None,
        'can_snapshot': True
    }]

    if 'name' in options:
        disks = dict([(disk['name'], disk) for disk in disks])
        return [disks[options['name']]]

    return disks
Esempio n. 25
0
def vm_info(id):

    ret = [{
        'ai_active':
        0,
        'console':
        0,
        'console_url':
        'console.gandi.net',
        'cores':
        1,
        'datacenter_id':
        3,
        'date_created':
        DateTime('20150319T11:10:34'),
        'date_updated':
        DateTime('20150319T11:11:31'),
        'description':
        None,
        'disks': [{
            'can_snapshot': True,
            'datacenter_id': 3,
            'date_created': DateTime('20150319T11:10:34'),
            'date_updated': DateTime('20150319T11:10:58'),
            'id': 4969232,
            'is_boot_disk': True,
            'kernel_cmdline': {
                'console': 'ttyS0',
                'nosep': True,
                'ro': True,
                'root': '/dev/sda'
            },
            'kernel_version': '3.12-x86_64 (hvm)',
            'label': 'Debian 7 64 bits (HVM)',
            'name': 'sys_1426759833',
            'size': 3072,
            'snapshot_profile': None,
            'snapshots_id': [],
            'source': 1401327,
            'state': 'created',
            'total_size': 3072,
            'type': 'data',
            'visibility': 'private',
            'vms_id': [152966]
        }],
        'disks_id': [4969232],
        'flex_shares':
        0,
        'graph_urls': {
            'vcpu': [''],
            'vdi': [''],
            'vif': ['']
        },
        'hostname':
        'vm1426759833',
        'id':
        152966,
        'ifaces': [{
            'bandwidth':
            102400.0,
            'datacenter_id':
            3,
            'date_created':
            DateTime('20150319T11:10:34'),
            'date_updated':
            DateTime('20150319T11:10:35'),
            'id':
            156572,
            'ips': [{
                'datacenter_id': 3,
                'date_created': DateTime('20150319T11:10:34'),
                'date_updated': DateTime('20150319T11:10:36'),
                'id': 204557,
                'iface_id': 156572,
                'ip': '2001:4b98:dc2:43:216:3eff:fece:e25f',
                'num': 0,
                'reverse': 'xvm6-dc2-fece-e25f.ghst.net',
                'state': 'created',
                'version': 6
            }],
            'ips_id': [204557],
            'num':
            0,
            'state':
            'used',
            'type':
            'public',
            'vlan':
            None,
            'vm_id':
            152966
        }],
        'ifaces_id': [156572],
        'memory':
        256,
        'probes': [],
        'state':
        'running',
        'triggers': [],
        'vm_max_memory':
        2048
    }, {
        'ai_active':
        0,
        'console':
        0,
        'console_url':
        'console.gandi.net',
        'cores':
        1,
        'datacenter_id':
        1,
        'date_created':
        DateTime('20150319T11:14:13'),
        'date_updated':
        DateTime('20150319T11:14:55'),
        'description':
        None,
        'disks': [{
            'can_snapshot': True,
            'datacenter_id': 1,
            'date_created': DateTime('20150319T11:14:13'),
            'date_updated': DateTime('20150319T11:14:29'),
            'id': 4969249,
            'is_boot_disk': True,
            'kernel_cmdline': {
                'console': 'ttyS0',
                'nosep': True,
                'ro': True,
                'root': '/dev/sda'
            },
            'kernel_version': '3.12-x86_64 (hvm)',
            'label': 'Debian 7 64 bits (HVM)',
            'name': 'sys_server01',
            'size': 3072,
            'snapshot_profile': None,
            'snapshots_id': [],
            'source': 1349810,
            'state': 'created',
            'total_size': 3072,
            'type': 'data',
            'visibility': 'private',
            'vms_id': [152967]
        }],
        'disks_id': [4969249],
        'flex_shares':
        0,
        'graph_urls': {
            'vcpu': [''],
            'vdi': [''],
            'vif': ['']
        },
        'hostname':
        'server01',
        'id':
        152967,
        'ifaces': [{
            'bandwidth':
            102400.0,
            'datacenter_id':
            1,
            'date_created':
            DateTime('20150319T11:14:13'),
            'date_updated':
            DateTime('20150319T11:14:16'),
            'id':
            156573,
            'ips': [{
                'datacenter_id': 1,
                'date_created': DateTime('20150317T16:20:10'),
                'date_updated': DateTime('20150319T11:14:13'),
                'id': 203968,
                'iface_id': 156573,
                'ip': '95.142.160.181',
                'num': 0,
                'reverse': 'xvm-160-181.dc0.ghst.net',
                'state': 'created',
                'version': 4
            }, {
                'datacenter_id': 1,
                'date_created': DateTime('20150319T11:14:16'),
                'date_updated': DateTime('20150319T11:14:16'),
                'id': 204558,
                'iface_id': 156573,
                'ip': '2001:4b98:dc0:47:216:3eff:feb2:3862',
                'num': 1,
                'reverse': 'xvm6-dc0-feb2-3862.ghst.net',
                'state': 'created',
                'version': 6
            }],
            'ips_id': [203968, 204558],
            'num':
            0,
            'state':
            'used',
            'type':
            'public',
            'vlan':
            None,
            'vm_id':
            152967
        }],
        'ifaces_id': [156573],
        'memory':
        256,
        'probes': [],
        'state':
        'running',
        'triggers': [],
        'vm_max_memory':
        2048
    }]

    vms = dict([(vm['id'], vm) for vm in ret])
    return vms[id]
Esempio n. 26
0
              
Check taskomatic logs in order to monitor the status of the build and promote tasks e.g. # tail -f /var/log/rhn/rhn_taskomatic_daemon.log. '''
                                ))
parser.add_argument(
    "--config",
    "-c",
    help="enter config file path that provides suma host user and password")
parser.add_argument("--profile", "-p", help="enter profile name")
parser.add_argument("--build_host", "-b", help="enter build host name")
parser.add_argument("--build_version", "-s", help="enter build image version")

args = parser.parse_args()

now = datetime.today()
#print(now)
earlierst_occurence = DateTime(now)
#print(earlierst_occourence)

if args.config:
    if os.path.exists(args.config):
        path = args.config
        login = get_login(path)
    else:
        print("The config file does not exist. %s" % args.config)
        sys.exit(1)
else:
    login = get_login()

MANAGER_URL = "https://" + login['suma_host'] + "/rpc/api"
MANAGER_LOGIN = login['suma_user']
MANAGER_PASSWORD = login['suma_password']
Esempio n. 27
0
def list(options):
    return [{'trustlogo': False,
             'assumed_name': None,
             'package': 'cert_std_1_0_0',
             'order_number': None,
             'altnames': [],
             'trustlogo_token': {'mydomain.name': 'adadadadad'},
             'date_incorporation': None,
             'card_pay_trustlogo': False,
             'contact': 'TEST1-GANDI',
             'date_start': None,
             'ida_email': None,
             'business_category': None,
             'cert': None,
             'date_end': None,
             'status': 'pending',
             'csr': '-----BEGIN CERTIFICATE REQUEST-----\n'
                    'MIICgzCCAWsCAQAwPjERMA8GA1UEAwwIZ2F1dnIuaX'
                    '...'
                    'K+I=\n-----END CERTIFICATE REQUEST-----',
             'date_updated': DateTime('20140904T14:06:26'),
             'software': 2,
             'id': 701,
             'joi_locality': None,
             'date_created': DateTime('20140904T14:06:26'),
             'cn': 'mydomain.name',
             'sha_version': 1,
             'middleman': '',
             'ida_tel': None,
             'ida_fax': None,
             'comodo_id': None,
             'joi_country': None,
             'joi_state': None},
            {'trustlogo': False,
             'assumed_name': None,
             'package': 'cert_bus_20_250_0',
             'order_number': None,
             'altnames': [],
             'trustlogo_token': {'inter.net': 'adadadadad'},
             'date_incorporation': None,
             'card_pay_trustlogo': False,
             'contact': 'TEST1-GANDI',
             'date_start': None,
             'ida_email': None,
             'business_category': None,
             'cert': None,
             'date_end': None,
             'status': 'valid',
             'csr': '-----BEGIN CERTIFICATE REQUEST-----\n'
                    'MIICgzCCAWsCAQAwPjERMA8GA1UEAwwIZ2F1dnIuaX'
                    '...'
                    'K+I=\n-----END CERTIFICATE REQUEST-----',
             'date_updated': DateTime('20140904T14:06:26'),
             'software': 2,
             'id': 706,
             'joi_locality': None,
             'date_created': DateTime('20140904T14:06:26'),
             'cn': 'inter.net',
             'sha_version': 1,
             'middleman': '',
             'ida_tel': None,
             'ida_fax': None,
             'comodo_id': None,
             'joi_country': None,
             'joi_state': None},
            {'altnames': [],
             'assumed_name': None,
             'business_category': None,
             'card_pay_trustlogo': False,
             'cert': 'MIIE5zCCA8+gAwIBAgIQAkC4TU9JG8wqhf4FCrsNGTANBgkqhkiG9'
                     'w0BAQsFADBfMQswCQYDVQQGEwJGUjEOMAwGA1UECBMFUGFyaXMxDj'
                     '...'
                     'tU6XzbS6/s2D1/N1wWOOCD/V3XAROtKr1a0mtJ8n7SZyzr0j3weRbN'
                     '7nV24RDQ6d4+GHy5zZstKyDrTknluyyZuDAAYAQJ+nrL5p1gxVNwj1'
                     'f5XKFk=',
             'cn': 'lol.cat',
             'comodo_id': 1777348256,
             'contact': 'DF2975-GANDI',
             'csr': '-----BEGIN CERTIFICATE REQUEST-----\n'
                    'MIICgzCCAWsCAQAwPjERMA8GA1UEAwwIZ2F1dnIuaX'
                    '...'
                    'K+I=\n-----END CERTIFICATE REQUEST-----',
             'date_created': DateTime('20150318T00:00:00'),
             'date_end': DateTime('20160318T00:00:00'),
             'date_incorporation': None,
             'date_start': DateTime('20150318T00:00:00'),
             'date_updated': DateTime('20150318T00:00:00'),
             'id': 710,
             'ida_email': None,
             'ida_fax': None,
             'ida_tel': None,
             'joi_country': None,
             'joi_locality': None,
             'joi_state': None,
             'middleman': '',
             'order_number': 12345678,
             'package': 'cert_std_1_0_0',
             'sha_version': 2,
             'software': 2,
             'status': 'valid',
             'trustlogo': False,
             'trustlogo_token': {'lol.cat': 'ababababa'}}
            ]
Esempio n. 28
0
def vhost_delete(name):
    return {'id': 200, 'step': 'WAIT', 'name': 'rproxy_update',
            'paas_id': 1177220,
            'date_creation': DateTime('20150728T17:50:56')}
Esempio n. 29
0
def nowtime():
    return DateTime(datetime.now())
Esempio n. 30
0
def info(paas_id):

    ret = [{'autorenew': None,
            'catalog_name': 'nodejsmongodb_s',
            'console': '*****@*****.**',
            'data_disk_additional_size': 0,
            'datacenter': {'country': 'Luxembourg',
                           'dc_code': 'LU-BI1',
                           'id': 3,
                           'iso': 'LU',
                           'name': 'Bissen'},
            'datadisk_total_size': 10.0,
            'date_end': DateTime('20161125T15:52:56'),
            'date_end_commitment': DateTime('20151118T00:00:00'),
            'date_start': DateTime('20141025T15:52:56'),
            'ftp_server': 'sftp.dc2.gpaas.net',
            'git_server': 'git.dc2.gpaas.net',
            'id': 163744,
            'name': 'paas_cozycloud',
            'need_upgrade': False,
            'owner': {'handle': 'PXP561-GANDI', 'id': 2920674},
            'servers': [{'graph_urls': {'vcpu': [''], 'vdi': [''],
                                        'vif': ['']},
                         'id': 163728,
                         'uuid': 19254}],
            'size': 's',
            'snapshot_profile': None,
            'state': 'running',
            'type': 'nodejsmongodb',
            'user': 185290,
            'vhosts': [{'date_creation': DateTime('20141025T15:50:54'),
                        'id': 1177216,
                        'name': '187832c2b34.testurl.ws',
                        'state': 'running'},
                       {'date_creation': DateTime('20141025T15:50:54'),
                        'id': 1177220,
                        'name': 'cloud.iheartcli.com',
                        'state': 'running'},
                       {'date_creation': DateTime('20150728T17:50:56'),
                        'id': 1365951,
                        'name': 'cli.sexy',
                        'state': 'running'}]},
           {'autorenew': None,
            'catalog_name': 'phpmysql_s',
            'console': '*****@*****.**',
            'data_disk_additional_size': 0,
            'datacenter': {'country': 'France',
                           'dc_code': 'FR-SD2',
                           'id': 1,
                           'iso': 'FR',
                           'name': 'Equinix Paris'},
            'datadisk_total_size': 10.0,
            'date_end': DateTime('20160408T00:00:00'),
            'date_end_commitment': None,
            'date_start': DateTime('20130903T22:14:13'),
            'ftp_server': 'sftp.dc0.gpaas.net',
            'git_server': 'git.dc0.gpaas.net',
            'id': 126276,
            'name': 'sap',
            'need_upgrade': False,
            'owner': {'handle': 'PXP561-GANDI', 'id': 2920674},
            'servers': [{'graph_urls': {'vcpu': [''], 'vdi': [''],
                                        'vif': ['']},
                         'id': 126273,
                         'uuid': 195339}],
            'size': 's',
            'snapshot_profile': None,
            'state': 'halted',
            'type': 'phpmysql',
            'user': 1656411,
            'vhosts': [{'date_creation': DateTime('20130903T22:11:54'),
                        'id': 160126,
                        'name': 'aa3e0e26f8.url-de-test.ws',
                        'state': 'running'},
                       {'date_creation': DateTime('20130903T22:24:06'),
                        'id': 160127,
                        'name': 'cloud.cat.lol',
                        'state': 'running'}]},
           {'autorenew': None,
            'catalog_name': 'pythonpgsql_s',
            'console': '*****@*****.**',
            'data_disk_additional_size': 0,
            'datacenter': {'country': 'Luxembourg',
                           'dc_code': 'LU-BI1',
                           'id': 3,
                           'iso': 'LU',
                           'name': 'Bissen'},
            'datadisk_total_size': 10.0,
            'date_end': DateTime('20161125T15:52:56'),
            'date_end_commitment': DateTime('20151118T00:00:00'),
            'date_start': DateTime('20141025T15:52:56'),
            'ftp_server': 'sftp.dc2.gpaas.net',
            'git_server': 'git.dc2.gpaas.net',
            'id': 123456,
            'name': '123456',
            'need_upgrade': False,
            'owner': {'handle': 'PXP561-GANDI', 'id': 2920674},
            'servers': [{'graph_urls': {'vcpu': [''], 'vdi': [''],
                                        'vif': ['']},
                         'id': 1123456,
                         'uuid': 119254}],
            'size': 's',
            'snapshot_profile': None,
            'state': 'running',
            'type': 'pythonpgsql',
            'user': 1185290,
            'vhosts': [{'date_creation': DateTime('20141025T15:50:54'),
                        'id': 2177216,
                        'name': '987832c2b34.testurl.ws',
                        'state': 'running'}]}]

    instances = dict([(paas['id'], paas) for paas in ret])
    return instances[paas_id]