Open-source News

New AMD Linux Patches Prepare Secure TSC Support For SEV-SNP Guests

Phoronix - Tue, 01/31/2023 - 19:20
A new patch series published this week by AMD engineers is preparing Linux kernel support for Secure TSC, a feature found with SEV-SNP enabled processors since the EPYC 7003 "Milan" series...

MSM DRM Driver Adds Support For Newer Qualcomm Platforms With Linux 6.3

Phoronix - Tue, 01/31/2023 - 18:59
The MSM Direct Rendering Manager (DRM) driver that was started originally as part of the Freedreno effort for open-source, reverse-engineered graphics driver support for Qualcomm Adreno graphics continues flourishing. A number of MSM driver additions -- including new Qualcomm platform support -- is ready to go with the upcoming Linux 6.3 kernel...

AMDVLK 2023.Q1.1 Brings New GPU Support, New Extensions

Phoronix - Tue, 01/31/2023 - 18:30
AMDVLK 2023.Q1.1 is out today as the first update to this official open-source AMD Vulkan Linux driver for 2023. Given the month and a half since the prior update, this AMDVLK update is rather significant with all of its changes...

Intel Timed I/O Driver Being Worked On For The Linux Kernel

Phoronix - Tue, 01/31/2023 - 17:00
As a new hardware feature for Intel IoT and server platforms not previously announced at large, Intel Timed I/O is being worked on in a new open-source Linux kernel driver...

Use Terraform to manage an OpenStack cluster

opensource.com - Tue, 01/31/2023 - 16:00
Use Terraform to manage an OpenStack cluster ajscanlas Tue, 01/31/2023 - 03:00

After having an OpenStack production and home lab for a while, I can definitively say that provisioning a workload and managing it from an Admin and Tenant perspective is important.

Terraform is an open source Infrastructure-as-Code (IaC) software tool used for provisioning networks, servers, cloud platforms, and more. Terraform is a declarative language that can act as a blueprint of the infrastructure you're working on. You can manage it with Git, and it has a strong GitOps use case.

This article covers the basics of managing an OpenStack cluster using Terraform. I recreate the OpenStack Demo project using Terraform.

Install Terraform

I use CentOS as a jump host, where I run Terraform. Based on the official documentation, the first step is to add the Hashicorp repository:

$ sudo dnf config-manager \ --add-repo https://rpm.releases.hashicorp.com/RHEL/hashicorp.repo

Next, install Terraform:

$ sudo dnf install terraform -y

Verify the installation:

$ terraform –version

If you see a version number in return, you have installed Terraform.

Explore the open source cloud Free online course: Developing cloud-native applications with microservices eBook: Modernize your IT with managed cloud services Try for 60 days: Red Hat OpenShift Dedicated Free online course: Containers, Kubernetes and Red Hat OpenShift What is Kubernetes? Understanding edge computing Latest articles for IT architects Create a Terraform script for the OpenStack provider

In Terraform, you need a provider. A provider is a converter that Terraform calls to convert your .tf into API calls to the platform you are orchestrating.

There are three types of providers: Official, Partner, and Community:

  • Official providers are Hashicorp maintained.
  • Partner providers are maintained by technology companies that partner with Hashicorp.
  • Community providers are maintained by open source community members.

There is a good Community provider for OpenStack in this link. To use this provider, create a .tf file and call it main.tf.

$ vi main.tf

Add the following content to main.tf:

terraform { required_version = ">= 0.14.0" required_providers { openstack = { source = "terraform-provider-openstack/openstack" version = "1.49.0" } } } provider "openstack" { user_name = “OS_USERNAME” tenant_name = “OS_TENANT” password = “OS_PASSWORD” auth_url = “OS_AUTH_URL” region = “OS_REGION” }

You need to change the OS_USERNAME, OS_TENANT, OS_PASSWORD, OS_AUTH_URL, and OS_REGION variables for it to work.

Create an Admin Terraform file

OpenStack Admin files focus on provisioning external networks, routers, users, images, tenant profiles, and quotas.

This example provisions flavors, a router connected to an external network, a test image, a tenant profile, and a user.

First, create an AdminTF directory for the provisioning resources:

$ mkdir AdminTF $ cd AdminTF

In the main.tf, add the following:

terraform { required_version = ">= 0.14.0" required_providers { openstack = { source = "terraform-provider-openstack/openstack" version = "1.49.0" } } } provider "openstack" { user_name = “OS_USERNAME” tenant_name = “admin” password = “OS_PASSWORD” auth_url = “OS_AUTH_URL” region = “OS_REGION” } resource "openstack_compute_flavor_v2" "small-flavor" { name = "small" ram = "4096" vcpus = "1" disk = "0" flavor_id = "1" is_public = "true" } resource "openstack_compute_flavor_v2" "medium-flavor" { name = "medium" ram = "8192" vcpus = "2" disk = "0" flavor_id = "2" is_public = "true" } resource "openstack_compute_flavor_v2" "large-flavor" { name = "large" ram = "16384" vcpus = "4" disk = "0" flavor_id = "3" is_public = "true" } resource "openstack_compute_flavor_v2" "xlarge-flavor" { name = "xlarge" ram = "32768" vcpus = "8" disk = "0" flavor_id = "4" is_public = "true" } resource "openstack_networking_network_v2" "external-network" { name = "external-network" admin_state_up = "true" external = "true" segments { network_type = "flat" physical_network = "physnet1" } } resource "openstack_networking_subnet_v2" "external-subnet" { name = "external-subnet" network_id = openstack_networking_network_v2.external-network.id cidr = "10.0.0.0/8" gateway_ip = "10.0.0.1" dns_nameservers = ["10.0.0.254", "10.0.0.253"] allocation_pool { start = "10.0.0.1" end = "10.0.254.254" } } resource "openstack_networking_router_v2" "external-router" { name = "external-router" admin_state_up = true external_network_id = openstack_networking_network_v2.external-network.id } resource "openstack_images_image_v2" "cirros" { name = "cirros" image_source_url = "https://download.cirros-cloud.net/0.6.1/cirros-0.6.1-x86_64-disk.img" container_format = "bare" disk_format = "qcow2" properties = { key = "value" } } resource "openstack_identity_project_v3" "demo-project" { name = "Demo" } resource "openstack_identity_user_v3" "demo-user" { name = "demo-user" default_project_id = openstack_identity_project_v3.demo-project.id password = "demo" }Create a Tenant Terraform file

As a Tenant, you usually create VMs. You also create network and security groups for the VMs.

This example uses the user created above by the Admin file.

First, create a TenantTF directory for Tenant-related provisioning:

$ mkdir TenantTF $ cd TenantTF

In the main.tf, add the following:

terraform { required_version = ">= 0.14.0" required_providers { openstack = { source = "terraform-provider-openstack/openstack" version = "1.49.0" } } } provider "openstack" { user_name = “demo-user” tenant_name = “demo” password = “demo” auth_url = “OS_AUTH_URL” region = “OS_REGION” } resource "openstack_compute_keypair_v2" "demo-keypair" { name = "demo-key" public_key = "ssh-rsa ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ" } resource "openstack_networking_network_v2" "demo-network" { name = "demo-network" admin_state_up = "true" } resource "openstack_networking_subnet_v2" "demo-subnet" { network_id = openstack_networking_network_v2.demo-network.id name = "demo-subnet" cidr = "192.168.26.0/24" } resource "openstack_networking_router_interface_v2" "demo-router-interface" { router_id = “XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX” subnet_id = openstack_networking_subnet_v2.demo-subnet.id } resource "openstack_compute_instance_v2" "demo-instance" { name = "demo" image_id = "YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY" flavor_id = "3" key_pair = "demo-key" security_groups = ["default"] metadata = { this = "that" } network { name = "demo-network" } }Initialize your Terraform

After creating the Terraform files, you need to initialize Terraform.

For Admin:

$ cd AdminTF $ terraform init $ terraform fmt

For Tenants:

$ cd TenantTF $ terraform init $ terraform fmt

Command explanation:

  • terraform init downloads the provider from the registry to use in provisioning this project.
  • terraform fmt formats the files for use in repositories.
Create a Terraform plan

Next, create a plan for you to see what resources will be created.

For Admin:

$ cd AdminTF $ terraform validate $ terraform plan

For Tenants:

$ cd TenantTF $ terraform validate $ terraform plan

Command explanation:

  • terraform validate validates whether the .tf syntax is correct.
  • terraform plan creates a plan file in the cache where all managed resources can be tracked in creation and destroy.
Apply your first TF

To deploy the resources, use the terraform apply command. This command applies all resource states in the plan file.

For Admin:

$ cd AdminTF $ terraform apply

For Tenants:

$ cd TenantTF $ terraform applyNext steps

Previously, I wrote an article on deploying a minimal OpenStack cluster on a Raspberry Pi. You can discover how to have more detailed Terraform and Ansible configurations and implement some CI/CD with GitLab.

Terraform is a declarative language that can act as a blueprint of the infrastructure you're working on.

Image by:

Opensource.com

Cloud OpenStack Automation CI/CD What to read next This work is licensed under a Creative Commons Attribution-Share Alike 4.0 International License. Register or Login to post a comment.

Automate Mastodon interactions with Python

opensource.com - Tue, 01/31/2023 - 16:00
Automate Mastodon interactions with Python Moshe Zadka Tue, 01/31/2023 - 03:00

The federated Mastodon social network has gotten very popular lately. It's fun to post on social media, but it's also fun to automate your interactions. There is some documentation of the client-facing API, but it's a bit light on examples. This article aims to help with that.

You should be fairly confident with Python before trying to follow along with this article. If you're not comfortable in Python yet, check out Seth Kenlon's Getting started with Python article and my Program a simple game article.

More Python resources What is an IDE? Cheat sheet: Python 3.7 for beginners Top Python GUI frameworks Download: 7 essential PyPI libraries Red Hat Developers Latest Python articles Create an application

The first step is to go to Preferences in Mastodon and select the Development category. In the Development panel, click on the New Applications button.

After creating an application, copy the access token. Be careful with it. This is your authorization to post to your Mastodon account.

There are a few Python modules that can help.

  • The httpx module is useful, given that it is a web API.
  • The getpass module allows you to paste the token into the session safely.
  • Mastodon uses HTML as its post content, so a nice way to display HTML inline is useful.
  • Communication is all about timing, and the dateutil and zoneinfo modules will help deal with that.

Here's what my typical import list looks like:

import httpx import getpass from IPython.core import display from dateutil import parser import zoneinfo

Paste in the token into the getpass input:

token=getpass.getpass()

Create the httpx.Client:

client = httpx.Client(headers=dict(Authorization=f"Bearer {token}"))

The verify_credentials method exists to verify that the token works. It's a good test, and it gives you useful metadata about your account:

res = client.get("https://mastodon.social/api/v1/accounts/verify_credentials")

You can query your Mastodon identity:

res.raise_for_status() result = res.json() result["id"], result["username"] >>> ('27639', 'moshez')

Your mileage will vary, but you get your internal ID and username in response. The ID can be useful later.

For now, abstract away the raise_for_status and parse the JSON output:

def parse(result):     result.raise_for_status()     return result.json()

Here's how this can be useful. Now you can check your account data by ID. This is a nice way to cross-check consistency:

result = parse(client.get("https://mastodon.social/api/v1/accounts/27639")) result["username"] >>> 'moshez'

But the interesting thing, of course, is to get your timeline. Luckily, there's an API for that:

statuses = parse(client.get("https://mastodon.social/api/v1/timelines/home")) len(statuses) >>> 20

It's just a count of posts, but that's enough for now. There's no need to deal with paging just yet. The question is, what can you do with a list of your posts? Well, you can query it for all kinds of interesting data. For instance, who posted the fourth status?

some_status = statuses[3] some_status["account"]["username"] >>> 'donwatkins'

Wonderful, a tweet from fellow Opensource.com correspondent Don Watkins! Always great content. I'll check it out:

display.HTML(some_status["content"])

Just finished installed @fedora #Silverblue 37 on @system76 #DarterPro

"Just" finished? Wait, when was this tweet posted? I live in California, so I want the time in my local zone:

california = zoneinfo.ZoneInfo("US/Pacific") when = parser.isoparse(some_status["created_at"]) print(when.astimezone(california)) >>> 2022-12-29 13:56:56-08:00

Today (at the time of this writing), a little before 2 PM. Talk about timeliness.

Do you want to see the post for yourself? Here's the URL:

some_status["url"] >>> 'https://fosstodon.org/@donwatkins/109599196234639478'

Enjoy tooting, now with 20% more API!

Follow along as I play with the Mastodon API to create a new application.

Image by:

kris krüg

Python Alternatives What to read next This work is licensed under a Creative Commons Attribution-Share Alike 4.0 International License. Register or Login to post a comment.

How to Install and Set Up Headless Linux Server

Tecmint - Tue, 01/31/2023 - 15:19
The post How to Install and Set Up Headless Linux Server first appeared on Tecmint: Linux Howtos, Tutorials & Guides .

A vast majority of Linux users are familiar with a Linux desktop PC which provides a graphical environment with which you can interact with the system. However, unlike a Linux desktop, a headless server

The post How to Install and Set Up Headless Linux Server first appeared on Tecmint: Linux Howtos, Tutorials & Guides.

Pages